Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gameclient): smoke thickness never lowers the player's particle cap

Olcay Seyganbbf6f41d66cf
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
index 5ddf225b7..1da1be2d1 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
@@ -644,6 +644,11 @@ Int particleSmokeParticleCap( Int shippedCap, Real thickness )
if (shippedCap <= 0 || thickness <= 1.0f)
return shippedCap;
+ // the ceiling bounds what the switch adds, never what the player set: a cap already above it
+ // stays where the player put it
+ if (shippedCap >= CAP_CEILING)
+ return shippedCap;
+
Int raised = REAL_TO_INT( shippedCap * thickness );
return (raised > CAP_CEILING) ? CAP_CEILING : raised;
}
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index 8d8daf30b..ebae73972 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -4166,6 +4166,12 @@ TEST(smoke_cap_grows_with_the_thickness_and_stops_at_the_ceiling)
CHECK_EQ(particleSmokeParticleCap(2500, 2.0f), 5000);
CHECK(particleSmokeParticleCap(2500, 4.0f) > particleSmokeParticleCap(2500, 2.0f));
CHECK_EQ(particleSmokeParticleCap(20000, 8.0f), 20000);
+ CHECK_EQ(particleSmokeParticleCap(15000, 2.0f), 20000);
+}
+
+TEST(smoke_cap_never_lowers_a_cap_the_player_set_above_the_ceiling)
+{
+ CHECK_EQ(particleSmokeParticleCap(1000000, 2.0f), 1000000);
}
//////////////////////////////////////////////////////////////////////////////