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.

feat(gameclient): explosion debris trails as a player option

Olcay Seygan99f8c9580858
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0cf42b331..dd555fc83 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1456,7 +1456,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same
- A bright cloud no longer shows what is behind it as a line drawing. Inside a nuke's white cloud, or a falling War Factory's fireball, every tree and wreck under it used to come out as a thin grey outline, and the picture's sharpening ringed each dark piece in white. Both stop where the frame is bright.
- Smoke and fire no longer end on a straight line where they meet the ground or a building. A puff that sinks into a hillside or drifts against a wall thins out over its last few metres, softly enough that a nuke's haze and a Scud's grey smoke no longer come out as stacked, stair-stepped terraces, and a toxin cloud lying low over the ground keeps its body instead of breaking into hard-edged green islands. A China mine field blinks where you can see it again: its lights hang just off the ground, and the fade had eaten all but a thirtieth of their bright middle. No effect fades over more than its own size now, so a small spark close to the ground keeps its light. This is the default renderer; Classic and the old renderer keep the hard edge they had in 2003.
- Gunfire shows at the zoom you play at. A rifle's tracer was a third of a unit wide, about one pixel from the default camera, and a bullet hit nothing you could see. Tracers from rifles, Gattlings, Humvees, Technicals and Quad Cannons are now twice as wide and half again as long, the muzzle flash is half as big again, and every hit kicks up sparks and a puff of dirt where it lands. A tank shell burns a short hot streak behind it all the way to the target, where it used to be a grey sliver you could not pick out between the flash and the blast. A Crusader's, Battlemaster's, Scorpion's, Paladin's or Overlord's shot used to be a soft white glow drifting out in front of the gun, wider than the tank; it is now a short orange blast at the barrel tip, with a bigger flame and smoke puff behind it. A shell landing throws dirt and sparks around its blast. The colours are the ones the game always used, and no weapon does anything different.
-- Blasts throw fragments that smoke. Every explosion flings hot sparks into the air, each drawing a white line of smoke that arcs over and curves down. Where a shell, rocket or missile lands the spray opens back up the line it came in on, towards the gun that fired it, low for a tank shell and steeper for a diving rocket, so you can read where the fire came from. The bigger the blast, the higher and longer the fan: a Stinger or a rocket pod throws three short ones, a tank shell or a rocket four, a bomb, a heavy shell, a Scud or a building eight that climb several times a tank's length, and a nuke, a MOAB, a Daisy Cutter or a large building fourteen that arc over its own fireball and hang for nearly five seconds. A vehicle that blows up throws burning pieces that drag near-black smoke and bounce where they land, and the turret, wheels and plates it throws off trail smoke and flame too, then smoulder a moment on the ground. In a fight of seventeen tanks the screen held about 1400 particles where it held 890, peaking at 2159 of the 2500 limit; the fragments and their smoke are the first effects that limit and a lower detail setting drop, so a bigger fight keeps its explosions and loses some lines. What a weapon does is unchanged.
+- Blasts throw fragments that smoke. Every explosion flings hot sparks into the air, each drawing a white line of smoke that arcs over and curves down. Where a shell, rocket or missile lands the spray opens back up the line it came in on, towards the gun that fired it, low for a tank shell and steeper for a diving rocket, so you can read where the fire came from. The bigger the blast, the higher and longer the fan: a Stinger or a rocket pod throws three short ones, a tank shell or a rocket four, a bomb, a heavy shell, a Scud or a building eight that climb several times a tank's length, and a nuke, a MOAB, a Daisy Cutter or a large building fourteen that arc over its own fireball and hang for nearly five seconds. A vehicle that blows up throws burning pieces that drag near-black smoke and bounce where they land, and the turret, wheels and plates it throws off trail smoke and flame too, then smoulder a moment on the ground. In a fight of seventeen tanks the screen held about 1400 particles where it held 890, peaking at 2159 of the 2500 limit; the fragments and their smoke are the first effects that limit and a lower detail setting drop, so a bigger fight keeps its explosions and loses some lines. What a weapon does is unchanged. Rather have the explosions as they always were? Explosion Debris Trails in the launcher's Options turns all of it off, for you alone: the other players in your match keep whatever they picked, and nobody's game falls out of step over it.
- A China mine field tells you what kind it is. EA's field had no model at all, only a soft white glint swelling and fading on each of its eight spots, so your own minefield looked like a patch of fireflies. Each mine is now marked by a small arming light that snaps on for a quarter of a second every second and a half, red on standard and cluster mines and blue on EMP mines, with a white-hot point and a dark rim that keep it readable on grass, sand or snow. No mine body is drawn on the ground, only the light. The enemy still sees nothing until he detects the field. A mine going off under a tank now throws a column of dark earth twice the tank's height, scatters clods round it and leaves a low black smoke and a scorch, with a short jolt of the screen; it used to puff a pale spray of specks that looked like dust kicked up. An EMP mine throws no earth, so you can tell which kind went off: it lights a blue ring across the ground, a crackle of blue sparks and a short blue flash at the spot; EA's flash grew until it washed the whole screen white for a fifth of a second. What a mine does is unchanged.
- A base out of power looks out of power. A building that switches off when your power runs short, or one a hacker shut down, drains to a cold grey and sags darker, and its windows and lamps go out. Every few seconds it blinks dark for an instant or its lights catch again for a moment, and blue sparks jump on its walls where something shorts. A tank or building hit by an EMP crawls with thin blue arcs for as long as it stays dead, where it used to just turn dark grey.
- Your own stealthed units look like glass, not like ice. In 3.0 a camouflaged Rebel, a Pathfinder or Colonel Burton came out under a blue skin with bands running up it, which players rightly called ugly. The blue is gone: the ground behind him shows through his body in its own colours and bends, a slow lens that ripples along him and pulls harder at his outline, with only a hint of his own paint left in it. The bend is what you find him by: each face of him tips the ground behind it its own way, so his shape shows even on plain sand, and the bend never drops below a few pixels, and a faint cool haze that thickens at his outline keeps a cloaked soldier or building findable at the zoom you play at, without turning him white. Up close a building's flat wall bends across its face. It moves slowly and never fizzes. He never turns solid, and the 2003 breathing of the fade is still there. His shadow fades with him, to between a quarter and a half of its strength as he breathes, where it used to lie on the ground at full strength and give him away before his body did; on Classic and the old renderer the shadow stays whole. When an enemy detector has found him, his whole body beats amber along with his edge, so a spotted building reads as spotted and does not just turn tan. On every renderer, a stealthed unit of yours no longer comes out solid whenever no building is on the screen: the game drew it a second time without its see-through. An enemy stealth unit your detector finds used to turn into a flat orange shape with no paint; now it shows as heat, its own shading run from dark red through orange to a warm yellow that stops short of white, so you can still tell a tank from a soldier and bright GLA paint keeps its detail, with a burning outline and a slow glow climbing it that flares on every sweep of the detector. The fine scan lines of 3.0 are gone, since zoomed out they broke into stripes. This is the default renderer; Classic and the old renderer keep the 2003 look for all of these.
diff --git a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini
index 1ad3711ad..0d2dd3e73 100644
--- a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini
+++ b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini
@@ -5092,6 +5092,7 @@ End
; ----------------------------------------------------------------------------------------------
ParticleSystem ReforgedBlastShards
+ ExplosionDebrisTrail = Yes
Priority = WEAPON_EXPLOSION
IsOneShot = No
Shader = ADDITIVE
@@ -5206,6 +5207,7 @@ ParticleSystem ReforgedBlastShardPuff
End
ParticleSystem ReforgedBlastShardsSmall
+ ExplosionDebrisTrail = Yes
Priority = WEAPON_EXPLOSION
IsOneShot = No
Shader = ADDITIVE
@@ -5320,6 +5322,7 @@ ParticleSystem ReforgedBlastShardPuffSmall
End
ParticleSystem ReforgedBlastShardsLarge
+ ExplosionDebrisTrail = Yes
Priority = WEAPON_EXPLOSION
IsOneShot = No
Shader = ADDITIVE
@@ -5434,6 +5437,7 @@ ParticleSystem ReforgedBlastShardPuffLarge
End
ParticleSystem ReforgedBlastShardsHuge
+ ExplosionDebrisTrail = Yes
Priority = WEAPON_EXPLOSION
IsOneShot = No
Shader = ADDITIVE
@@ -5560,6 +5564,7 @@ End
; first the cap or detail setting drops.
ParticleSystem ReforgedVehicleShrapnel
+ ExplosionDebrisTrail = Yes
Priority = DEATH_EXPLOSION
IsOneShot = No
Shader = ADDITIVE
@@ -5740,6 +5745,7 @@ End
; scrap bits.
ParticleSystem ReforgedDebrisTrail
+ ExplosionDebrisTrail = Yes
Priority = WEAPON_EXPLOSION
IsOneShot = No
Shader = ALPHA
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
index 870ed329e..892c8fcf3 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
@@ -208,6 +208,7 @@ public:
Bool m_shadowsForParticles; // "ShadowsForParticles": big alpha-blended particle clouds drop a soft blob on the ground
Bool m_volumetricSmokeShadows; // "VolumetricSmokeShadows": smoke and dust shade the world and themselves through the sun's map (Direct3D 11)
Bool m_smokeFireLighting; // "SmokeFireLighting": smoke takes light from the fire beside it
+ Bool m_explosionDebrisTrails; // "DebrisTrails": blasts throw smoke-trailing fragments and burning shrapnel
Int m_shadowQuality; // "ShadowQuality": the sun's depth map at 1024, 2048 or 4096 texels a side (Direct3D 11)
Bool m_classicGraphics; // "ClassicGraphics": the game's own art, tile, shadows and picture; read at startup
Int m_lightingStyle; // "LightingStyle": LightingStyleType; the map's lights are rebalanced as each map loads
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
index ae1ce6c3f..811785455 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
@@ -612,6 +612,12 @@ public:
AsciiString getName( void ) const { return m_name; }
+ /** "ExplosionDebrisTrail = Yes": one of the fork's smoke-trailing blast fragments, which the
+ * player's DebrisTrails option turns off. A system built from it while the option is off is
+ * destroyed before it emits, so every FXList and object creation list stays the same for everyone. */
+ Bool isExplosionDebrisTrail( void ) const { return m_explosionDebrisTrail; }
+ void setExplosionDebrisTrail( Bool on ) { m_explosionDebrisTrail = on; }
+
// This function was made const because of update modules' module data being all const.
ParticleSystem *createSlaveSystem( Bool createSlaves = TRUE ) const ; ///< if returns non-NULL, it is a slave system for use
@@ -635,6 +641,7 @@ protected:
protected:
AsciiString m_name; ///< the name of this template
+ Bool m_explosionDebrisTrail; ///< switched off with the DebrisTrails option (client only)
// This has to be mutable because of the delayed initialization thing in createSlaveSystem
mutable const ParticleSystemTemplate *m_slaveTemplate; ///< if non-NULL, use this to create a slave system
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
index 7c20d0d0d..085a1b0fa 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
@@ -695,6 +695,7 @@ GlobalData::GlobalData()
m_shadowsForParticles = TRUE; //on by default: the shipped INI has no entry for it
m_volumetricSmokeShadows = TRUE;
m_smokeFireLighting = TRUE;
+ m_explosionDebrisTrails = TRUE;
m_shadowQuality = 1; //medium, the 2048 map the shadows always had
m_classicGraphics = FALSE;
m_lightingStyle = LIGHTING_STYLE_REFORGED;
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
index ce9d2fe0d..2a873c5f6 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
@@ -112,6 +112,7 @@ OPTION_BOOL_ACCESSORS( m_particleGroundBounce )
OPTION_BOOL_ACCESSORS( m_volumetricSmokeShadows )
OPTION_BOOL_ACCESSORS( m_useCloudMap )
OPTION_BOOL_ACCESSORS( m_smokeFireLighting )
+OPTION_BOOL_ACCESSORS( m_explosionDebrisTrails )
OPTION_INT_ACCESSORS( m_shadowQuality )
//-----------------------------------------------------------------------------
@@ -494,6 +495,12 @@ const OptionDef TheOptionCatalog[] =
OPTION_BOOL, APPLY_LIVE, 0, 1,
get_m_smokeFireLighting, set_m_smokeFireLighting },
+ // The fork's smoke-trailing blast fragments. Off, every system marked ExplosionDebrisTrail in
+ // ParticleSystemReforged.ini is destroyed as it is made, which leaves the retail explosions.
+ { "DebrisTrails", "", "",
+ OPTION_BOOL, APPLY_LIVE, 0, 1,
+ get_m_explosionDebrisTrails, set_m_explosionDebrisTrails },
+
// The size of the sun's depth map. The shadow pass asks for it every frame and the backend makes
// the map again when the size changes, so a new level shows on the next frame. No control in the
// game's own menu; the launcher writes it. Classic graphics and -d3d9 draw no map at all.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
index b1c21f1f9..7d3120c2a 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
@@ -1560,6 +1560,12 @@ ParticleSystem::ParticleSystem( const ParticleSystemTemplate *sysTemplate,
if (m_systemID != INVALID_PARTICLE_SYSTEM_ID)
TheParticleSystemManager->friend_addParticleSystem(this);
+ // DebrisTrails off: the fork's blast fragments never emit, so nothing of them, their trails or
+ // their slaves is drawn. Destroyed rather than never built, so the FXList, the object creation
+ // list and every caller holding the pointer go on exactly as they do with the option on.
+ if (sysTemplate->m_explosionDebrisTrail && !TheGlobalData->m_explosionDebrisTrails)
+ destroy();
+
//DEBUG_ASSERTLOG(!(m_totalParticleSystemCount % 10 == 0), ( "TotalParticleSystemCount = %d\n", m_totalParticleSystemCount ));
}
@@ -3311,6 +3317,7 @@ const FieldParse ParticleSystemTemplate::m_fieldParseTable[] =
{ "SlaveSystem", INI::parseAsciiString, NULL, offsetof( ParticleSystemTemplate, m_slaveSystemName ) },
{ "SlavePosOffset", INI::parseCoord3D, NULL, offsetof( ParticleSystemTemplate, m_slavePosOffset ) },
{ "PerParticleAttachedSystem", INI::parseAsciiString, NULL, offsetof( ParticleSystemTemplate, m_attachedSystemName ) },
+ { "ExplosionDebrisTrail", INI::parseBool, NULL, offsetof( ParticleSystemTemplate, m_explosionDebrisTrail ) },
{ "Lifetime", parseRetailFramesRandom, NULL, offsetof( ParticleSystemTemplate, m_lifetime ) },
{ "SystemLifetime", INI::parseRetailFramesUnsignedInt, NULL, offsetof( ParticleSystemTemplate, m_systemLifetime ) },
@@ -3483,6 +3490,7 @@ ParticleSystemTemplate::ParticleSystemTemplate( const AsciiString &name ) :
//Initializations inserted
m_slaveTemplate = NULL;
//
+ m_explosionDebrisTrail = FALSE;
}
// ------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index 2dc60d546..843542754 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -5328,6 +5328,60 @@ TEST(particlesys_find_answers_by_id_and_forgets_a_dead_system)
TheGameClient = savedClient;
}
+/* The DebrisTrails option, on by default, round-trips through Options.ini. Off, a system built from a
+ template marked ExplosionDebrisTrail comes back already destroyed, so it never emits and the manager
+ drops it, while every other system is untouched. On, the marked one lives like any other. */
+TEST(particlesys_debris_trails_option_destroys_only_marked_systems)
+{
+ const OptionDef *def = findOptionDef( "DebrisTrails" );
+ CHECK( def != NULL );
+ CHECK_EQ( (Int)def->kind, (Int)OPTION_BOOL );
+ CHECK_EQ( (Int)def->apply, (Int)APPLY_LIVE );
+
+ GlobalData *savedData = TheWritableGlobalData;
+ TheWritableGlobalData = NEW GlobalData;
+ CHECK( TheGlobalData->m_explosionDebrisTrails );
+
+ UserPreferences pref;
+ TheWritableGlobalData->m_explosionDebrisTrails = FALSE;
+ saveOptionsToPreferences( pref );
+ CHECK_STR( pref[ AsciiString( "DebrisTrails" ) ].str(), "no" );
+ TheWritableGlobalData->m_explosionDebrisTrails = TRUE;
+ loadOptionsFromPreferences( pref );
+ CHECK( !TheGlobalData->m_explosionDebrisTrails );
+
+ GameClient *savedClient = TheGameClient;
+ TheGameClient = getTestGameClient();
+ ParticleSystemManager *savedManager = TheParticleSystemManager;
+
+ {
+ TestParticleSystemManager mgr;
+ TheParticleSystemManager = &mgr;
+
+ ParticleSystemTemplate *plain = mgr.newTemplate( AsciiString( "TestPlainSystem" ) );
+ ParticleSystemTemplate *debris = mgr.newTemplate( AsciiString( "TestDebrisSystem" ) );
+ debris->setExplosionDebrisTrail( TRUE );
+
+ ParticleSystem *plainOff = mgr.createParticleSystem( plain, FALSE );
+ ParticleSystem *debrisOff = mgr.createParticleSystem( debris, FALSE );
+ CHECK( !plainOff->isDestroyed() );
+ CHECK( debrisOff->isDestroyed() );
+
+ TheWritableGlobalData->m_explosionDebrisTrails = TRUE;
+ ParticleSystem *debrisOn = mgr.createParticleSystem( debris, FALSE );
+ CHECK( !debrisOn->isDestroyed() );
+
+ plainOff->deleteInstance();
+ debrisOff->deleteInstance();
+ debrisOn->deleteInstance();
+ }
+
+ TheParticleSystemManager = savedManager;
+ TheGameClient = savedClient;
+ delete TheWritableGlobalData;
+ TheWritableGlobalData = savedData;
+}
+
/* Loading a save has to put each system back under the id it was saved with. It used to build the
system through createParticleSystem, which hands out the next id in sequence and files the system
under it, and only then read the saved id over the top - so the manager's index pointed at the