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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(w3ddevice): -volsmoke infantry rockets, straight grey trail
Olcay Seygan591aea0f73bd
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 690f6bfa1..7e6b57a07 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -116,7 +116,7 @@ found and fixed, EA's own, not port damage.**- A tank gun fires the way footage of a real one does. A cone of flame comes straight out of the muzzle along the barrel's own aim, white-hot at the tip and orange-red at its fringe, widening forward, and is gone in about a sixth of a second; the first version blew a round ball a gun's length ahead of the barrel with a gap behind it. It leaves a little grey smoke in front of the gun over the dust the blast blows off the ground round the tank's front, and both are gone in a second and a half. A Battlemaster's or a Scorpion's smaller gun throws a smaller flame, an Overlord's a bigger one. A shell striking armour throws one dense burst of thin white-yellow streaks out of the point it struck, over a hot white core, back towards the tank that fired it. The game's own sparks used to burst over the turret whichever side was struck, and stacked on the new ones they read as fireworks all over the tank: for those hits they are gone, and the white oval that used to flash over the whole tank is a small flash now. In a fight of fifteen tanks the shots and hits cost about 0.2 ms of GPU time a frame on High and next to nothing on Low, on an RTX 2060. Six shots at a time draw this way on High and three on Low; past that a shot keeps the game's own flash, and a shot whose slab a bigger blast takes gets its own flash back.- A nuke builds a mushroom you can read. The flash is light: the ground, the buildings and the missile's own smoke trail go white for a third of a second, where a flat white disc used to cover half the screen for most of a second. From the first frame a lumpy ball of fire sits on the ground, yellow-white inside an orange-red rim, with a thin white dome running out round it, and the orange disc that lay on the ground under it is gone. The ball rises and slows, and by five seconds is an orange cap on a thin grey-brown stem. A white collar rings the stem for a few seconds. The cap cools to cream and lumpy cauliflower, three to four times as wide as the stem, and it stays up for over a minute; the old one was a dark brown disc that had thinned away inside twelve seconds. The dark dust that used to bury the whole base under the cloud is gone, and a low wall of dust runs out along the ground between the buildings instead. The missile's own trail is smoke in the same air now, a thick pale column behind it on the way up from the silo and on the way down, drifting with the wind and spreading as it thins, where it used to stay a column of flat sprites.- Every other smoke goes the same way while it is on: missile and rocket trails, the dust behind a tank, a burning building's column, muzzle smoke. They are fed into one body of air round the camera instead of being drawn as sprites, and a unit moving through it pushes it. A tank's hull shoves the smoke aside and leaves a turning wake, a jet drags a sheet of it down between two wingtip vortices, and a helicopter hovering low flattens a burning column into a dark ring on the ground and lifts a band of dust round itself. A blast's front pushes the smoke already hanging round it outwards. Units you cannot see push nothing, so the smoke never gives away a stealthed tank or an unscouted base.-- Missile and rocket trails are thin ribbons of real smoke. A Tomahawk's, a Rocket Buggy's and a Scud Launcher's lay a pale line that breaks into puffs, widens towards its old end, stirs and drifts off with the wind, and fades out along its length as it goes, the oldest end first, so a Rocket Buggy salvo no longer leaves a tan haze over the field: a Tomahawk's arc over Heartland Shield is gone about 2 s after the launch, where it hung on for 5 to 6 and the game's own lasts about 3. A trail that climbs high, a Scud's arc or the nine columns a Scud Storm puts up, goes into a second, taller body of air over the battlefield, a thousand units high, where it thins just as fast. The trails are lit by the sun like any smoke: the Scud Storm's columns had stood as straight glowing pillars of one width that read as beams of light, and at night on Dark Night the trails stood out pale blue as if lit from inside. Now a big missile, a Scud's, a Tomahawk's or the nuclear missile's, leaves a white plume that billows out wider as it ages, lumpy and shaded on its far side, while a Rocket Buggy's, a Stinger's or a Comanche's rocket leaves a thin grey trail. Every one burns at the nozzle, a short white-yellow flame that is gone a few frames behind the missile. A launch throws a cloud: a Scud Storm, a Scud Launcher, a Tomahawk launcher and the nuclear silo blow a white cloud out sideways over the pad and the ground round it, under a flash at the nozzle, and it is gone in about four seconds. A rocket's backblast leaves a white puff at the launcher, where before it was gone before it showed. Before, a fast missile's trail broke into a dotted line of brown blobs, and once a missile climbed past about 200 units over the ground the top of its trail simply vanished.+- Missile and rocket trails are thin ribbons of real smoke. A Tomahawk's, a Rocket Buggy's and a Scud Launcher's lay a pale line that breaks into puffs, widens towards its old end, stirs and drifts off with the wind, and fades out along its length as it goes, the oldest end first, so a Rocket Buggy salvo no longer leaves a tan haze over the field: a Tomahawk's arc over Heartland Shield is gone about 2 s after the launch, where it hung on for 5 to 6 and the game's own lasts about 3. A trail that climbs high, a Scud's arc or the nine columns a Scud Storm puts up, goes into a second, taller body of air over the battlefield, a thousand units high, where it thins just as fast. The trails are lit by the sun like any smoke: the Scud Storm's columns had stood as straight glowing pillars of one width that read as beams of light, and at night on Dark Night the trails stood out pale blue as if lit from inside. Now a big missile, a Scud's, a Tomahawk's or the nuclear missile's, leaves a white plume that billows out wider as it ages, lumpy and shaded on its far side, while a Rocket Buggy's, a Stinger's or a Comanche's rocket leaves a thin grey trail. The infantry rockets follow the RPG-7 photo: a Tunnel Defender's, a Tank Hunter's or a Missile Defender's rocket carries a small bright flame right at its tail and draws a thin grey wisp straight along its path, where the game's own trail was a bright white rope with a regular wiggle (the rocket flies within a unit of a straight line; the game threw each point of its line sideways) and its glow burned as two orange dots a rocket's length behind it. The launcher puffs a white backblast behind the soldier instead of a yellow-white flash as big as he is. Every one burns at the nozzle, a short white-yellow flame that is gone a few frames behind the missile. A launch throws a cloud: a Scud Storm, a Scud Launcher, a Tomahawk launcher and the nuclear silo blow a white cloud out sideways over the pad and the ground round it, under a flash at the nozzle, and it is gone in about four seconds. A rocket's backblast leaves a white puff at the launcher, where before it was gone before it showed. Before, a fast missile's trail broke into a dotted line of brown blobs, and once a missile climbed past about 200 units over the ground the top of its trail simply vanished.- Buildings come down in their own shape. The smoke reads the building's model: the moment one dies, a white-yellow fireball bursts out of each of its parts, a War Factory's hall and its two stacks, a Speaker Tower's mast, bigger than the part it came from and pushed out through its walls, cools to orange under a sooty edge and is gone in well under a second, while a ragged plume climbs out of the tops and cools to smoke. Before, the parts filled with dull dust that slumped and only three small fires came off the roof. The chunks the building throws trail thin pale dust as they fly, gone before the column is, where they used to fly bare, and the white shower of shards that burst over the fall like a firework is gone while the smoke draws it; with the smoke Off both stay as they were. The collapse throws a pale dust cloud that rolls out along the ground on every side, heavier than the air and hugging the terrain, two to three times the building's width out before it thins, and runs round the buildings beside it, between their real walls and stacks rather than over one box. Before, the dust had nowhere to go but up, and a fall was only a column. The ruin burns under a thick black-grey column with the fire still glowing in its foot, where it used to be a thin pale wisp, for two seconds, so a fall's own smoke and dust are off the screen 3 to 4 s after it and only the game's own column is left in the air until about 6, sooner than the game's own at 7 to 8 (it stayed for fourteen at first, and in a fast game that hid the next fight); a damaged building's own smoke and the dust round it thin within a couple of seconds of their puffs. The size follows the building: an American Power Plant's is about half the width of a War Factory's or a Particle Cannon's. Each damaged stage on the way down blows fire out of the top of the standing building with a little smoke, where it used to leave a big black cloud over the roof, and the shells landing on it in that moment no longer leave their fireballs floating over the cloud. A Rocket Buggy's rockets hitting the rubble throw their dirt for a second and it falls back, where their brown fountains stood beside a fallen War Factory as tan fingers for six seconds after everything else had gone. The fall's smoke is lit on its sunny side: on Winter Wolf's snow it had stood as one block of pure black across the middle of the screen. The game's own fireball sprites, flare and flat shock ring for that moment are gone while the smoke is on; flying debris keeps its sparks.- Burning buildings burn. A damaged building's fires are flames in that same air now, where they were flat sprites: each burning spot gives off fuel off the building's own roof and wall tops, read from its model, at the heat the game's own flame there stands for, so the flames stand on the building instead of hanging over it; the fuel comes off in patches and lights, burns hottest on its outside where the air reaches it, rises on its own heat and leans with the wind. The flame glows the colour hot soot glows, yellow-white at its foot where it burns hottest and orange to dull red higher up, where it breaks into licks with clear air between them, and it puffs the way a real fire puffs, a wide one slower than a small one. The fuel a flame carries past its tips is too cool to burn by then and turns into near-black smoke, which climbs off the building and thins away in about three seconds; while it does, the game's own smoke on that building stands aside. The building's own floors and roofs are what the flames stand on, so a GLA barracks, whose outline is one big box over its tents, no longer smothers all but one of its fires. Units push it like any smoke: a helicopter hovering over a burning factory fans its flames down and out. It goes out within two seconds of the game's own fire, so a repaired building stops burning and a fire never outlasts the building's damage. Fires on the move, a burning tank driving off or a running soldier, keep the game's own flames, and so do sparks, embers and a burning car wreck, whose flame the first version had put out altogether. Eight burning buildings on Twilight Flame's plateau cost 0.4 ms of GPU time a frame on Low and 1.0 on High over the smoke alone, on an RTX 2060.- It costs the graphics card. Three armies and three superweapons on Twilight Flame at 1920x1080, on an RTX 2060: 5.2 ms of GPU time a frame with it Off, 8.6 on Low and 10.0 to 10.2 on High; the frame itself took 5.3, 5.6 and 6.9 to 7.2 ms. Low runs half as many blasts at once in a coarser body of air, so a weak card should leave it Off or take Low. A nuke on an American base on the same map costs 2.4 ms of GPU time a frame Off, 4.1 to 4.7 on Low and 6.9 to 7.1 on High. A rocket fight with Scud Launchers, then a Scud Storm and a nuke, seen from over the rockets: 2.2 ms Off, 3.1 on Low, 4.1 to 4.2 on High. Five buildings brought down one after another on that base: 1.3 ms Off, 1.9 to 2.0 on Low, 2.2 on High.diff --git a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.iniindex 5f3d69452..db449e086 100644--- a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini+++ b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini@@ -7051,3 +7051,183 @@ ParticleSystem ReforgedStructureDebrisDustWindPingPongEndAngleMin = 5.497787WindPingPongEndAngleMax = 6.283185End++; A small rocket's trail and tail flame while the smoke simulation is on, after the RPG-7 photo: a thin+; grey wisp laid straight along the rocket's own path and a short bright flame at it, both hung on the+; rocket by DX11VolumeSmoke.cpp (gatherNozzles), which then hides EA's additive fire line, its white+; ribbon and its lens flare. EA's line threw each point sideways (VelOrtho 0.2 a frame), which drew a+; sine wiggle a few units wide where the rocket flies within a unit of a straight line, and its flare+; burned two orange dots fifty pixels behind the rocket. No sideways velocity here, so the wisp is the+; path. With the smoke Off, EA's look stays.++ParticleSystem ReforgedRocketTrail+ Priority = WEAPON_TRAIL+ IsOneShot = No+ Shader = ALPHA+ Type = STREAK+ ParticleName = EXContrail.tga+ AngleZ = 0.00 0.00+ AngularRateZ = 0.00 0.00+ AngularDamping = 1.00 1.00+ VelocityDamping = 0.95 0.95+ Gravity = 0.00+ Lifetime = 20.00 20.00+ SystemLifetime = 0+ Size = 0.80 0.80+ StartSizeRate = 0.00 0.00+ SizeRate = 0.10 0.10+ SizeRateDamping = 0.95 0.95+ Alpha1 = 0.00 0.00 0+ Alpha2 = 0.50 0.50 2+ Alpha3 = 0.22 0.22 9+ Alpha4 = 0.00 0.00 20+ Alpha5 = 0.00 0.00 0+ Alpha6 = 0.00 0.00 0+ Alpha7 = 0.00 0.00 0+ Alpha8 = 0.00 0.00 0+ Color1 = R:170 G:168 B:164 0+ Color2 = R:195 G:193 B:190 12+ Color3 = R:0 G:0 B:0 0+ Color4 = R:0 G:0 B:0 0+ Color5 = R:0 G:0 B:0 0+ Color6 = R:0 G:0 B:0 0+ Color7 = R:0 G:0 B:0 0+ Color8 = R:0 G:0 B:0 0+ ColorScale = 0.00 0.00+ BurstDelay = 0.00 0.00+ BurstCount = 1.00 1.00+ InitialDelay = 0.00 0.00+ DriftVelocity = X:0.00 Y:0.00 Z:0.03+ VelocityType = ORTHO+ VelOrthoX = 0.00 0.00+ VelOrthoY = 0.00 0.00+ VelOrthoZ = 0.00 0.00+ VolumeType = POINT+ IsHollow = No+ IsGroundAligned = No+ IsEmitAboveGroundOnly = No+ IsParticleUpTowardsEmitter = No+ WindMotion = Unused+ WindAngleChangeMin = 0.149924+ WindAngleChangeMax = 0.449946+ WindPingPongStartAngleMin = 0.000000+ WindPingPongStartAngleMax = 0.785398+ WindPingPongEndAngleMin = 5.497787+ WindPingPongEndAngleMax = 6.283185+End++ParticleSystem ReforgedRocketFlame+ Priority = WEAPON_TRAIL+ IsOneShot = No+ Shader = ADDITIVE+ Type = PARTICLE+ ParticleName = EXLnzFlar2.tga+ AngleZ = 0.00 6.28+ AngularRateZ = 0.00 0.00+ AngularDamping = 1.00 1.00+ VelocityDamping = 1.00 1.00+ Gravity = 0.00+ Lifetime = 2.00 2.00+ SystemLifetime = 1+ Size = 2.40 3.00+ StartSizeRate = 0.00 0.00+ SizeRate = 0.00 0.00+ SizeRateDamping = 1.00 1.00+ Alpha1 = 1.00 1.00 0+ Alpha2 = 0.00 0.00 0+ Alpha3 = 0.00 0.00 0+ Alpha4 = 0.00 0.00 0+ Alpha5 = 0.00 0.00 0+ Alpha6 = 0.00 0.00 0+ Alpha7 = 0.00 0.00 0+ Alpha8 = 0.00 0.00 0+ Color1 = R:255 G:245 B:215 0+ Color2 = R:255 G:170 B:80 2+ Color3 = R:0 G:0 B:0 0+ Color4 = R:0 G:0 B:0 0+ Color5 = R:0 G:0 B:0 0+ Color6 = R:0 G:0 B:0 0+ Color7 = R:0 G:0 B:0 0+ Color8 = R:0 G:0 B:0 0+ ColorScale = 0.00 0.00+ BurstDelay = 0.00 0.00+ BurstCount = 1.00 1.00+ InitialDelay = 0.00 0.00+ DriftVelocity = X:0.00 Y:0.00 Z:0.00+ VelocityType = ORTHO+ VelOrthoX = 0.00 0.00+ VelOrthoY = 0.00 0.00+ VelOrthoZ = 0.00 0.00+ VolumeType = POINT+ IsHollow = No+ IsGroundAligned = No+ IsEmitAboveGroundOnly = No+ IsParticleUpTowardsEmitter = No+ WindMotion = Unused+ WindAngleChangeMin = 0.149924+ WindAngleChangeMax = 0.449946+ WindPingPongStartAngleMin = 0.000000+ WindPingPongStartAngleMax = 0.785398+ WindPingPongEndAngleMin = 5.497787+ WindPingPongEndAngleMax = 6.283185+End++; The white backblast puff behind a rocket soldier's or a rocket truck's launcher, as in the RPG-7+; photo, where the game had none for the Tunnel Defender and a yellow-white flash for the rest. Put+; behind the launcher by the smoke simulation (DX11VolumeSmoke.cpp, gatherNozzles) on the rocket's+; second frame, only while that setting is on, which draws it as white smoke in its air ("Backblast"+; in the name). A few puffs a little bigger than a soldier, gone in under a second.++ParticleSystem ReforgedRocketBackblastPuff+ Priority = WEAPON_EXPLOSION+ IsOneShot = No+ Shader = ALPHA+ Type = PARTICLE+ ParticleName = EXCloud01.tga+ AngleZ = 0.00 6.28+ AngularRateZ = -0.02 0.02+ AngularDamping = 0.98 0.98+ VelocityDamping = 0.85 0.85+ Gravity = 0.00+ Lifetime = 18.00 24.00+ SystemLifetime = 2+ Size = 3.00 4.00+ StartSizeRate = 0.00 0.00+ SizeRate = 0.30 0.40+ SizeRateDamping = 0.92 0.92+ Alpha1 = 0.00 0.00 0+ Alpha2 = 0.70 0.70 2+ Alpha3 = 0.35 0.35 10+ Alpha4 = 0.00 0.00 24+ Alpha5 = 0.00 0.00 0+ Alpha6 = 0.00 0.00 0+ Alpha7 = 0.00 0.00 0+ Alpha8 = 0.00 0.00 0+ Color1 = R:235 G:235 B:232 0+ Color2 = R:225 G:225 B:222 12+ Color3 = R:0 G:0 B:0 0+ Color4 = R:0 G:0 B:0 0+ Color5 = R:0 G:0 B:0 0+ Color6 = R:0 G:0 B:0 0+ Color7 = R:0 G:0 B:0 0+ Color8 = R:0 G:0 B:0 0+ ColorScale = 0.00 0.00+ BurstDelay = 1.00 1.00+ BurstCount = 3.00 4.00+ InitialDelay = 0.00 0.00+ DriftVelocity = X:0.00 Y:0.00 Z:0.05+ VelocityType = SPHERICAL+ VelSpherical = 0.60 1.20+ VolumeType = POINT+ IsHollow = No+ IsGroundAligned = No+ IsEmitAboveGroundOnly = No+ IsParticleUpTowardsEmitter = No+ WindMotion = Unused+ WindAngleChangeMin = 0.149924+ WindAngleChangeMax = 0.449946+ WindPingPongStartAngleMin = 0.000000+ WindPingPongStartAngleMax = 0.785398+ WindPingPongEndAngleMin = 5.497787+ WindPingPongEndAngleMax = 6.283185+Enddiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cppindex 0835032a3..8424202f6 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp@@ -1443,15 +1443,21 @@ const float StreakGain[2] = { 0.45f, 0.75f };// pillars that read as beams of light; the photos' plumes are white where the sun is on them and grey// on their shadow side.const float TrailTag = 1.25f, TrailTagSpan = 0.5f;-const float RocketGrey = 0.8f; // a rocket's trail is grey: its particle's own colour times this+// A rocket's trail is grey and wispy, after the RPG-7 photo: its particle's own colour times this, and+// a little thicker than its ribbon's opacity asks, since a ribbon a unit wide spreads over cells seven+// units across (at 0.55 with EA's additive fire line hidden the trail was gone)+const float RocketGrey = 0.55f, RocketGain = 1.6f;+const int RibbonSmoothPoints = 4; // a rocket ribbon's points averaged either side (stepAir)+const float RocketFlameLead = 0.5f; // a rocket's flame laid this many frames' travel ahead of its logic position, at the drawn tail// A ballistic or cruise missile's plume (the Scud's, the nuclear missile's, the Tomahawk's) opens out// wider with age than a rocket's trail, and is thicker, so it shades itself and its edge billows.const float PlumeSpread = 3.0f, PlumeGain = 1.6f;-// The flame at the nozzle: a trail's puffs younger than NozzleAge of their life are hot, and a trail-// cell's heat dies within a few hundredths of a second (AdvectPass), so only the nozzle glows, short-// and bright (fireColour is orange at 1.2 and white-yellow at 1.8).-const float NozzleAge = 0.05f;-const float NozzleHeat[2] = { 1.2f, 1.8f }; // a rocket's, a missile's+// The flame at the nozzle: a small hot ball at each rocket's tail, read off its drawable+// (gatherNozzles), and a trail cell's heat dies within a few hundredths of a second (AdvectPass), so+// only the nozzle glows, short and bright (fireColour is orange at 1.2 and white-yellow at 1.8). Laid+// on the ribbon's newest points it burned where the ribbon starts, a rocket's length behind it.+const float NozzleHeat[2] = { 1.6f, 1.8f }; // a rocket's, a missile's+const float NozzleSoot = 6.0f; // the smoke that glows there (at 2 it did not show)const float NozzleGlow = 2.0f; // the air's flame against the scene's white (a blast's soot[3])// A trail's smoke half-life in the air and the tall air (the brightness tells its cells): a Rocket// Buggy salvo's goes in a couple of seconds, a Scud Storm's columns hang on as rocket smoke does.@@ -1584,6 +1590,8 @@ std::vector<Hull> hulls, lastHulls;// in ParticleSystemReforged.ini). A system cannot be made in Takes, which runs inside the particle// manager's own loop, so Gather makes them next frame, outside the logic window.std::vector<Coord3D> pendingSparks;+struct Nozzle { float x, y, z; bool big; int frames; }; // a rocket's tail in flight (gatherNozzles)+std::vector<Nozzle> nozzles;// The same for a shell striking armour (TankStruckSmoke, which FX_DamageTankStruck turns away from// the attacker: `along` is the shot's heading).struct PendingHit { Coord3D at; float along[2]; };@@ -3197,7 +3205,8 @@ AirLook airLookOf(const ParticleSystemTemplate *tmplate, ParticleSystem *system)// as a sphere into cells seven units across lay on the ground in front of the gun as a flat// tan disc, where the game's own puff is soft grey and drifts.look.scrap = system->getPriority() == DEBRIS_TRAIL || std::strstr(name, "Debris") || std::strstr(name, "Shrapnel")- || std::strstr(name, "Shard") || std::strstr(name, "Muzzle");+ || std::strstr(name, "Shard") || std::strstr(name, "Muzzle")+ || !std::strncmp(name, "ReforgedRocket", 14); // gatherNozzles' billboards (as smoke in the air the backblast puff did not show)airLooks[tmplate] = look;return look;}@@ -3686,25 +3695,47 @@ void stepAir(ID3D11DeviceContext *context, unsigned g, int now, float dt, float// a ballistic or cruise missile's exhaust is a white billowing plume; a rocket's, a thin grey trailconst bool plume = trail && (std::strstr(named, "Scud") || std::strstr(named, "Neutron") || std::strstr(named, "Tomahawk"));bool chained = false;- for (Particle *p = system->getFirstParticle(); p; p = p->m_systemNext) {+ // A rocket's ribbon is laid straight: its points scatter off the fire line (EA's MissileExhaust,+ // which feeds it, throws each point sideways at up to 0.2 a frame), so the ribbon drew a regular+ // sine wiggle a few units wide where the rocket itself flies within a unit of a straight line+ // (logged off the drawables). Each point is taken as the mean of its neighbours along the+ // ribbon, fewer towards its ends, so the head stays on the rocket.+ static std::vector<Coord3D> straight;+ straight.clear();+ const bool straighten = trail && streak && !plume;+ if (straighten) {+ static std::vector<Coord3D> raw;+ raw.clear();+ for (Particle *p = system->getFirstParticle(); p; p = p->m_systemNext) raw.push_back(*p->getPosition());+ const int count = (int)raw.size();+ for (int i = 0; i < count; ++i) {+ const int reach = (std::min)((std::min)(i, count - 1 - i), RibbonSmoothPoints);+ Coord3D mean = { 0, 0, 0 };+ for (int k = i - reach; k <= i + reach; ++k) { mean.x += raw[k].x; mean.y += raw[k].y; mean.z += raw[k].z; }+ const float n = 2.0f * reach + 1.0f;+ straight.push_back({ mean.x / n, mean.y / n, mean.z / n });+ }+ }+ unsigned index = 0;+ for (Particle *p = system->getFirstParticle(); p; p = p->m_systemNext, ++index) {const float alpha = (std::min)(p->getAlpha() * fade * AirCoverage, 0.95f);if (alpha < 0.02f) { chained = false; continue; }- const Coord3D *at = p->getPosition();+ const Coord3D *at = straighten ? &straight[index] : p->getPosition();// at most 8 cells, so a sphere reaches 27 bricks at most (AirTileEntries)// (a ribbon's spheres are laid along its links too, so it may go thinner without breaking up).// A trail's particle is a puff of its own size, hashed from the particle, wider the older it// is: a Scud Storm's columns stood as straight pillars of one width all the way up.- float puff = 1.0f, thick = 1.0f, heat = 0.0f;+ float puff = 1.0f, thick = 1.0f;if (trail) {// the particle's address is the same for its whole life (a client-side look, nothing to replay)const unsigned h = (p->getPersonality() ^ unsigned(reinterpret_cast<uintptr_t>(p) >> 4)) * 2654435761u;const float age = p->m_lifetime ? (std::min)((std::max)(1.0f - (float)p->getLifetimeLeft() / (float)p->m_lifetime, 0.0f), 1.0f) : 0.0f;puff = (0.65f + 0.8f * ((h >> 8) & 255) / 255.0f) * (1.0f + (plume ? PlumeSpread : TrailSpread) * age);- thick = (0.55f + 0.9f * ((h >> 16) & 255) / 255.0f) * std::pow(1.0f - age, TrailAgeFade) * (plume ? PlumeGain : 1.0f);- // the flame at the nozzle: the newest puff burns, the rest of the trail is cold smoke- if (p->m_lifetime && age < NozzleAge) heat = plume ? NozzleHeat[1] : NozzleHeat[0];+ thick = (0.55f + 0.9f * ((h >> 16) & 255) / 255.0f) * std::pow(1.0f - age, TrailAgeFade) * (plume ? PlumeGain : RocketGain);}- const float radius = (std::min)((std::max)(p->getSize() * 0.6f, cell * (streak ? 0.6f : 0.8f)) * puff, cell * 8.0f);+ // (a straightened rocket ribbon at 0.6 of a cell passed between the cells' middles and laid+ // next to nothing)+ const float radius = (std::min)((std::max)(p->getSize() * 0.6f, cell * (straighten ? 0.9f : streak ? 0.6f : 0.8f)) * puff, cell * 8.0f);// inside the box less its faded rimconst float rim = 4.0f * cell;if (at->x < low[0] + rim || at->x > high[0] - rim || at->y < low[1] + rim || at->y > high[1] - rim@@ -3727,7 +3758,7 @@ void stepAir(ID3D11DeviceContext *context, unsigned g, int now, float dt, floatconst float grey = launchPuff ? TrailTag + TrailTagSpan : trail ? TrailTag + TrailTagSpan * (plume ? 1.0f : luma * RocketGrey) : luma;const float dx = at->x - look.x, dy = at->y - look.y;const Source here = { (at->x - low[0]) / cell - 0.5f, (at->y - low[1]) / cell - 0.5f, (at->z - low[2]) / cell - 0.5f,- radius / cell, dusty ? 0.0f : density, dusty ? density * 0.6f : 0.0f, grey, dx * dx + dy * dy, heat };+ radius / cell, dusty ? 0.0f : density, dusty ? density * 0.6f : 0.0f, grey, dx * dx + dy * dy, 0.0f };if (chained) {const Source &last = found.back();const float gap = std::sqrt((here.x - last.x) * (here.x - last.x) + (here.y - last.y) * (here.y - last.y)@@ -3765,6 +3796,19 @@ void stepAir(ID3D11DeviceContext *context, unsigned g, int now, float dt, float} else if (outside && !inside) airOutside.insert(id);else airOutside.erase(id);}+ // The nozzle flames, at the tail of each rocket in the box (gatherNozzles): a small hot ball of+ // trail smoke, so its heat dies with the trail's in a few frames once the rocket has moved on and+ // it glows only where the rocket is. A rocket's first frames burn bigger, the launch flash.+ for (const Nozzle &nozzle : nozzles) {+ if (nozzle.x < low[0] + 4 * cell || nozzle.x > high[0] - 4 * cell || nozzle.y < low[1] + 4 * cell || nozzle.y > high[1] - 4 * cell+ || nozzle.z < low[2] || nozzle.z > high[2] - 4 * cell)+ continue;+ const bool launch = nozzle.frames < 3;+ const float dx = nozzle.x - look.x, dy = nozzle.y - look.y;+ found.push_back({ (nozzle.x - low[0]) / cell - 0.5f, (nozzle.y - low[1]) / cell - 0.5f, (nozzle.z - low[2]) / cell - 0.5f,+ (nozzle.big ? 1.5f : 1.1f) * (launch ? 1.4f : 1.0f), NozzleSoot, 0.0f, TrailTag + TrailTagSpan, dx * dx + dy * dy,+ NozzleHeat[nozzle.big ? 1 : 0] + (launch ? 0.5f : 0.0f) });+ }const size_t cap = air.particles;if (found.size() > cap) {airLeftOut += unsigned(found.size() - cap);@@ -4464,6 +4508,28 @@ bool Takes(ParticleSystem *system)}}if (takenSystems.count(id)) return !airOutside.count(id);+ // A rocket's glow and its launch flash are the air's nozzle flame now (gatherNozzles): the lens+ // flare on its exhaust (MissileLenzflare and the rest) burned as two orange dots fifty pixels+ // behind the rocket, and the launch flash (MissileBackblast, the Stinger's and the TOW's) as a+ // yellow-white blob as big as the soldier.+ {+ const char *name = system->getTemplate()->getName().str();+ const bool flare = std::strstr(name, "MissileLenzflare") || std::strstr(name, "MissileExhaustLenzflare");+ const bool flash = std::strstr(name, "MissileBackblast") && !std::strstr(name, "Clouds");+ // and EA's fire line, the additive streak behind a rocket (MissileExhaust and its kin): with+ // its points thrown sideways each frame it was the bright white rope with the sine wiggle; the+ // air's grey ribbon, fed from it and laid straight, is the trail now+ const bool fireLine = system->isUsingStreak() && system->getShaderType() == ParticleSystemInfo::ADDITIVE+ && std::strstr(name, "MissileExhaust") && !std::strstr(name, "Scud") && !std::strstr(name, "Tomahawk") && !std::strstr(name, "Neutron");+ // and the white ribbon fed from it, whose points it throws off the line (ReforgedRocketTrail+ // rides the rocket in its place)+ const bool ribbon = !std::strcmp(name, "MissileExhaustTrail");+ if ((flare || flash || fireLine || ribbon) && usable()) {+ pruneSets();+ takenSystems.insert(id);+ return true;+ }+ }// A blast is told from loose billboard systems; trails, streaks, a building's smoke and every// other smoke or dust go to the air.// A loose ground-aligned system is let as far as a tank's blast: the stock ring a tank's death@@ -4799,6 +4865,64 @@ void attachDebrisDust(int now)}}+// The rockets and missiles in flight, read off their drawables once a logic frame: where the tail+// is and which way it points, for the air's nozzle flame (stepAir), which the stock lens flare drew+// fifty pixels behind the rocket where its exhaust ribbon starts. A small rocket fired near the+// ground also gets a white backblast puff behind its launcher on its second frame, when its heading+// is known (the Tunnel Defender's has no launch FX at all, and the Tank Hunter's and the Missile+// Defender's is a yellow-white flash). Client particles only; nothing goes back to the logic.+void gatherNozzles(int now)+{+ if (!TheGameClient) return;+ static std::unordered_map<DrawableID, std::pair<Coord3D, int>> last, next;+ next.clear();+ nozzles.clear();+ if (!TheParticleSystemManager) return;+ const ParticleSystemTemplate *puff = TheParticleSystemManager->findTemplate("ReforgedRocketBackblastPuff");+ const ParticleSystemTemplate *trail = TheParticleSystemManager->findTemplate("ReforgedRocketTrail");+ const ParticleSystemTemplate *flame = TheParticleSystemManager->findTemplate("ReforgedRocketFlame");+ for (Drawable *drawable = TheGameClient->firstDrawable(); drawable; drawable = drawable->getNextDrawable()) {+ if (!drawable->isKindOf(KINDOF_PROJECTILE) || !drawable->getTemplate()) continue;+ const char *name = drawable->getTemplate()->getName().str();+ if (!std::strstr(name, "Missile") && !std::strstr(name, "Missle") && !std::strstr(name, "Rocket")) continue;+ if (drawable->isDrawableEffectivelyHidden() || drawable->getFullyObscuredByShroud()) continue;+ const Coord3D at = *drawable->getPosition();+ auto seen = last.find(drawable->getID());+ const int frames = seen == last.end() ? 0 : seen->second.second + 1;+ next[drawable->getID()] = { at, frames };+ const bool big = std::strstr(name, "Scud") || std::strstr(name, "Neutron") || std::strstr(name, "Tomahawk") || std::strstr(name, "Nuke");+ // A small rocket's trail and flame are client billboards riding the rocket itself, after the+ // RPG-7 photo: a short bright flame at the tail and a thin grey wisp laid straight along its+ // path. The air's cells, seven units across, could draw neither: a ribbon a unit wide laid+ // next to nothing, and the flame came out as an orange ball a rocket's length behind.+ if (seen == last.end()) {+ if (!big && trail)+ if (ParticleSystem *system = TheParticleSystemManager->createParticleSystem(trail)) system->attachToDrawable(drawable);+ continue;+ }+ const float dx = at.x - seen->second.first.x, dy = at.y - seen->second.first.y, dz = at.z - seen->second.first.z;+ const float length = std::sqrt(dx * dx + dy * dy + dz * dz);+ if (length < 0.5f) continue;+ const float ux = dx / length, uy = dy / length, uz = dz / length;+ if (big) nozzles.push_back({ at.x - ux * 8.0f, at.y - uy * 8.0f, at.z - uz * 8.0f, big, frames });+ // The flame is laid afresh each frame where the rocket is drawn: a system hung on the rocket+ // emits where the rocket stood when the particles last moved, a frame and a half behind the+ // drawn model, the gap EA's flare showed too.+ else if (flame) {+ const Coord3D where = { at.x + dx * RocketFlameLead, at.y + dy * RocketFlameLead, at.z + dz * RocketFlameLead };+ if (ParticleSystem *system = TheParticleSystemManager->createParticleSystem(flame)) system->setPosition(&where);+ }+ const float ground = TheTerrainRenderObject ? TheTerrainRenderObject->getHeightMapHeight(at.x, at.y, NULL) : at.z;+ if (frames == 1 && !big && puff && at.z - ground < 40.0f)+ if (ParticleSystem *system = TheParticleSystemManager->createParticleSystem(puff)) {+ // behind the launcher, which is where the rocket was a frame ago less its tube+ const Coord3D where = { seen->second.first.x - ux * 10.0f, seen->second.first.y - uy * 10.0f, seen->second.first.z - uz * 10.0f };+ system->setPosition(&where);+ }+ }+ last.swap(next);+}+void Gather(){if (!requested() || !TheGameLogic || TheGlobalData->m_classicGraphics || LogicThread::isInsideWindow()) return;@@ -4824,6 +4948,7 @@ void Gather()pendingSparks.clear();}attachDebrisDust(now);+ gatherNozzles(now);ownedHits.erase(std::remove_if(ownedHits.begin(), ownedHits.end(), [now](const OwnedHit &hit) { return hit.frame < now - 8; }),ownedHits.end());// A shell striking armour: one dense burst of sparks out of the point where it struck, in a cone@@ -5121,6 +5246,7 @@ void Render(const HazardCloud::Camera &camera)void Reset(){pendingSparks.clear(); // before the early return: a burst queued as the setting went Off+ nozzles.clear();pendingHits.clear();ownedHits.clear();gunSystems.clear();