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
fix(w3ddevice): -volsmoke a second nuke keeps the first one's cloud
Olcay Seygan875c5ab0e1a8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9011f7ef0..584d6cfcb 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -115,7 +115,7 @@ found and fixed, EA's own, not port damage.**- A tank goes up the way the footage of a real one does. Orange flame and black smoke burst out low along its own hull, long under an Overlord and short under a Crusader, and roll along the ground off both ends. A ragged fan of blown-out white fire with orange edges rises straight off the hull and opens wider as it climbs, tallest in the middle, on High about twice as tall as the fire is wide and on Low a shorter fan of the same shape, and in about a second it has cooled through orange to grey-brown smoke. Two round near-black blobs stand on each long side of the hull at its top, in front of the fire, apart from each other with flame showing between them and their rims glowing red, and slump away inside a second; the soot laid there before burned with the fire beside it and from the side read as a haze. White-hot sparks streak up out of the fire and out over the fan in long thin straight lines and fall back, where they were short orange beaded comets. The wreck's black column is gone about two seconds after the death, and a thin wisp over a glowing ember fades out by three and a half, a quarter as long as the game's own smoke with the setting Off, so a fast game is never fighting through last minute's smoke; it used to stand for half a minute, which in a fast game left a field of black pillars. A Crusader's fan no longer stands on a thin stem or grows horns at its edges. The glowing ball and the rays round it are gone, and so is the ring on the ground. Shells that hit a tank's armour no longer throw a fountain of dirt off it. The scrap flying off a dead tank keeps its own sparks but no longer drags thick grey arcs across the fire, and every gun but a tank's keeps the soft grey muzzle puff it always had, where it had turned into a flat tan disc on the ground.- 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 wave runs out through every smoke it reaches, the other blasts' clouds, the burning buildings' flames and the smoke hanging in the air, and moves it while it passes: a Scud Launcher's missile lands in the last one's smoke and shoves it aside, and a second nuke's wave tears into the first one's mushroom, which lets go of its shape, drifts off and thins out over a few seconds where it used to hang on untouched for over a minute. Before, a wave's push was mostly lost in the first frame, a nuke's cap pulled itself straight back into shape, and a Scud's warheads pushed nothing at all. Units you cannot see push nothing, and a blast in the shroud sends no wave, so the smoke never gives away a stealthed tank, an unscouted base or a strike out of sight.+- 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 wave runs out through every smoke it reaches, the other blasts' clouds, the burning buildings' flames and the smoke hanging in the air, and moves it while it passes: a Scud Launcher's missile lands in the last one's smoke and shoves it aside, and a second nuke's wave tears into the first one's mushroom, which lets go of its cauliflower shape and is shoved aside and upward as a soft tan cloud, still plain to see eleven seconds after the second hit, and thins away until it is gone 18 seconds after it was let go; it used to hang on untouched for over a minute. On Low the second nuke takes the first one's place in the air, so there the first cloud goes the moment the second lands. Before, a wave's push was mostly lost in the first frame, a nuke's cap pulled itself straight back into shape, and a Scud's warheads pushed nothing at all. Units you cannot see push nothing, and a blast in the shroud sends no wave, so the smoke never gives away a stealthed tank, an unscouted base or a strike out of sight.- 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.diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/VolumeShockCore.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/VolumeShockCore.hindex acc28679f..8166804d6 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/VolumeShockCore.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/VolumeShockCore.h@@ -30,7 +30,11 @@ const float CapRelease = 60.0f; // units another blast must move a nuclear capstruct ShockClass { float speed, push, r0, seconds, disperse; };// First numbers, tuned by eye on volshock; speeds and lifetimes are the ones addShock had.-const ShockClass Nuclear = { 420.0f, 300.0f, 150.0f, 2.5f, 0.6f };+// (push 300 and a 0.6 share took a first nuke's cloud off the screen inside 3 s of the second; a+// 0.4 share and the shell's stretch left a released cap's soot at a fifth to a third, a thin veil,+// and 0.2 still a tan veil with no cap body in it. The push stays: 250 is what lets volshock's third+// nuke, 434 units off, release the second's cap at all, about 58 units against the 57 it needs)+const ShockClass Nuclear = { 420.0f, 250.0f, 150.0f, 2.5f, 0.1f };const ShockClass NukeCannon = { 250.0f, 60.0f, 60.0f, 1.5f, 0.4f };const ShockClass Scud = { 260.0f, 60.0f, 50.0f, 1.2f, 0.3f };const ShockClass StructureFall = { 140.0f, 30.0f, 40.0f, 1.0f, 0.2f };diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cppindex bd7c28d55..39a99995c 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp@@ -179,8 +179,12 @@ const float ShortEndFade = 1.5f; // seconds a tank's, a building's, a launch'sconst float MuzzleHeatHalfLife = 0.07f, MuzzleLife = 1.6f, MuzzleEndFade = 0.6f;const unsigned MuzzleCap[3] = { 0, 3, 6 };// A nuclear cap another blast has let go of (VolumeShock::capHold) is free smoke, thinning out at this-// half-life, and its volume ends this long after.-const float NukeDisperseHalfLife = 4.0f, NukeDisperseLife = 8.0f;+// half-life, and its volume ends this long after. At 6 s the cap's body was gone two seconds after+// its release and only a veil stayed; 18 s ends it, end fade included, just before volshock's third+// nuke lands 19 s after the second. One only loosened spills what the front pushed off it at up to+// LoosenedSpillHalfLife, the 4 s it had before the released cloud was slowed: a cap that stays+// loosened keeps that spill for the rest of its 90 s.+const float NukeDisperseHalfLife = 10.0f, NukeDisperseLife = 18.0f, LoosenedSpillHalfLife = 4.0f;const float ShadeLight = 0.26f; // the light smoke keeps where the sun does not reach itconst float SunShare = 0.75f; // and what the sun adds where it doesconst float Extinction = 0.16f; // per world unit at density 1@@ -297,7 +301,7 @@ struct SimConstants {float ShockCount[4];float Shocks[MaxShocks * 2][4];// A nuclear cap's soot and stem dust kept this step once they leave its shape (MushroomPass):- // CapSpillHalfLife, stretched to NukeDisperseHalfLife as another blast loosens the cap.+ // CapSpillHalfLife, stretched to LoosenedSpillHalfLife as another blast loosens the cap.float Spill[MaxSlabs][4];};@@ -3024,9 +3028,19 @@ void schedule(const Volume &volume, unsigned slab, float t, DrawConstants *draw)if (volume.hold < 1.0f) {stem[3] *= volume.hold;cap[0] *= volume.hold;+ // As it is let go its hard cauliflower surface softens to half and its thin dust is spared,+ // as the young fireball's is. The front leaves a quarter to a half of the cap's soot (its+ // share mixed away, the shell's stretch), and with nothing laying it again that fell under+ // the surface's 0.3 to 0.55: the whole cloud was gone two seconds after the second nuke,+ // whatever its thinning. At none it lay over the view as one flat veil. A Scud's dent keeps it.+ const float freed = 1 - smoothstep01(volume.hold, 0.05f, 0.5f);+ billows *= 1 - 0.5f * freed;+ spared = (std::max)(spared, freed);if (volume.hold < 0.05f) {for (float *field : { cap, stem, shape, power, motion }) std::memset(field, 0, 16);- shape[2] = 1000.0f; // no ceiling: the freed smoke keeps its lift+ // its ceiling where the cap was: with none its last heat lifted it off the top of the+ // box in a few seconds, with 0 (the memset) it stopped dead+ shape[2] = capZ;collarOpacity = shellOpacity = 0; // drawn shapes, not smoke: they go with the cap}}@@ -3226,7 +3240,7 @@ void step(ID3D11DeviceContext *context, unsigned t, int now, float dt, float sec// a nuclear cap another blast let go of thins out as free smoke, and while it is only loosened what// the front pushed off it drifts aside instead of fading at the cap's own spill rateif (volume.kind == Nuclear && volume.hold < 0.05f) sim.Thin[slab][0] = std::pow(0.5f, dt / NukeDisperseHalfLife);- sim.Spill[slab][0] = std::pow(0.5f, dt / (CapSpillHalfLife + (NukeDisperseHalfLife - CapSpillHalfLife) * (1 - volume.hold)));+ sim.Spill[slab][0] = std::pow(0.5f, dt / (CapSpillHalfLife + (LoosenedSpillHalfLife - CapSpillHalfLife) * (1 - volume.hold)));const bool rolls = (volume.kind == Structure && !volume.standing) || volume.kind == Launch || volume.kind == Muzzle;// (not a bomb's: its small mushroom's stem would fall out of it)// (a tank's: its dark base masses slump slowly onto the ground, which eats them; the weight goes@@ -3491,19 +3505,25 @@ void holdCaps(int now)const float capZ = volume.blast[2] + 2.0f + 20.0f * (1 - std::exp(-t / 3.2f)); // schedule'sconst float middle[3] = { volume.origin[0] + (volume.blast[0] + 0.5f) * volume.cell,volume.origin[1] + (volume.blast[1] + 0.5f) * volume.cell, volume.origin[2] + (capZ + 0.5f) * volume.cell };+ const Shock *hardest = nullptr; // TEMPORARY (stage 1 retune): named in the log line below+ float hardestShift = 0;for (const Shock &shock : shocks) {const float age = float(now - shock.born) / LOGICFRAMES_PER_SECOND;if (!shock.checked || age < 0 || age > shock.c.seconds || spares(volume, (int)slot, shock)) continue;const float d[3] = { middle[0] - shock.at[0], middle[1] - shock.at[1], middle[2] - shock.at[2] };- volume.capPushed += VolumeShock::shiftAt(shock.c, age, std::sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]),+ const float shift = VolumeShock::shiftAt(shock.c, age, std::sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]),(float)frames / LOGICFRAMES_PER_SECOND);+ volume.capPushed += shift;+ if (shift > hardestShift) { hardest = &shock; hardestShift = shift; }}volume.hold = VolumeShock::capHold(volume.capPushed);if (volume.hold < 0.05f) {volume.life = (std::min)(volume.life, now - volume.born + int(NukeDisperseLife * LOGICFRAMES_PER_SECOND));static unsigned released = 0;if (released++ < 8)- DEBUG_LOG(("VOLSMOKE: frame %d, nuclear cap %u let go: other blasts moved it %.0f units\n", now, slot, volume.capPushed));+ DEBUG_LOG(("VOLSMOKE: frame %d, nuclear cap %u (born %d) let go: other blasts moved it %.0f units, the last by a push %.0f front born %d at (%.0f, %.0f, %.0f), owner %d\n",+ now, slot, volume.born, volume.capPushed, hardest ? hardest->c.push : 0.0f, hardest ? hardest->born : -1,+ hardest ? hardest->at[0] : 0.0f, hardest ? hardest->at[1] : 0.0f, hardest ? hardest->at[2] : 0.0f, hardest ? hardest->owner : -1));}}}@@ -4740,6 +4760,12 @@ bool Takes(ParticleSystem *system)Coord3D where;system->getPosition(&where);addShock(where, *known->second, (int)TheGameLogic->getFrame());+ // TEMPORARY (stage 1 retune): what starts each nuclear front, for the cap a nuke's own later+ // front lets go 3 to 4 s after it lands in the cost runs+ static unsigned nuclearFronts = 0;+ if (known->second->push >= VolumeShock::Nuclear.push && nuclearFronts++ < 16)+ DEBUG_LOG(("VOLSMOKE: frame %d, nuclear front from '%s' at (%.0f, %.0f, %.0f)\n", (int)TheGameLogic->getFrame(),+ tmplate->getName().str(), where.x, where.y, where.z));}}// a building's or a wreck's fire burns in a fire slab, or keeps its billboards; never the air's@@ -4893,9 +4919,14 @@ bool Takes(ParticleSystem *system)if (kind.trigger && !building && (kindNow == Structure || (kindNow == TankDeath && mammoth && !hullAt(where, false))))building = structureAt(where, INVALID_ID);if (kindNow == TankDeath && building && !onBuilding) kindNow = Structure;+ // A nuke's own mushroom systems are first seen when they come into view, not when they start: from+ // the play camera its NukeMushroomCloudRing, 2 s on, was first seen 3.5 s on, started a nuke of its+ // own, evicted the nuke before it and let go of its own nuke's cap. Its flare keeps 180 frames.+ const bool lateMushroom = kind.trigger && kindNow == Nuclear && std::strcmp(own, "NukeFlare") && std::strcmp(own, "NukeGLAFlare");for (const Volume &volume : volumes) {if (!volume.live || volume.kind == Fire || seen < volume.born - 10- || seen > volume.born + (volume.kind == Nuclear ? 180 : volume.kind == TankDeath || volume.kind == Structure ? 90 : 30)) continue; // a nuke's stem comes 2 s after its flare+ || seen > volume.born + (volume.kind == Nuclear ? (lateMushroom ? 600 : 180) // a nuke's stem comes 2 s after its flare+ : volume.kind == TankDeath || volume.kind == Structure ? 90 : 30)) continue;// a gun's shot takes its own FX only, and they join nothing else (a tank firing beside a dead// one keeps its shot)if ((volume.kind == Muzzle) != gun) continue;@@ -4972,6 +5003,10 @@ bool Takes(ParticleSystem *system)|| (rankOf(volumes[i]) == rankOf(volumes[slot]) && volumes[i].born < volumes[slot].born))slot = i;++droppedCount;+ // TEMPORARY (stage 1 retune): which blast a nuke's slab goes to+ if (volumes[slot].kind == Nuclear || type == Nuclear)+ DEBUG_LOG(("VOLSMOKE: frame %d, '%s' (kind %d) %s slab %u from a kind %d born at frame %d\n", now, own, (int)type,+ rankOf(volumes[slot]) > rank ? "dropped, not taking" : "takes", slot, (int)volumes[slot].kind, volumes[slot].born));if (rankOf(volumes[slot]) > rank) {if (type == Structure) DEBUG_LOG(("VOLSMOKE: frame %d, a structure's blast dropped: every slab held a higher rank\n", now));pruneSets();@@ -5093,7 +5128,7 @@ bool Takes(ParticleSystem *system)addShock(where, kind.scale >= 3.0f ? VolumeShock::NukeCannon : VolumeShock::shell(kind.scale), now, (int)slot);pruneSets();takenSystems.insert(id);- if (claimedCount++ < 8)+ if (claimedCount++ < 8 || type == Nuclear) // TEMPORARY (stage 1 retune): every nuclear oneDEBUG_LOG(("VOLSMOKE: frame %d, %s volume %u for '%s' at (%.0f, %.0f, %.0f), %.0f units wide\n", now,type == TankDeath ? "tank" : type == Shell ? "shell" : type == Airburst ? "airburst" : type == Structure ? "structure": type == Launch ? "launch" : "nuclear", slot,diff --git a/GeneralsMD/Code/Tests/test_volume_fire_policy.cpp b/GeneralsMD/Code/Tests/test_volume_fire_policy.cppindex bec60e25d..bef8bdb29 100644--- a/GeneralsMD/Code/Tests/test_volume_fire_policy.cpp+++ b/GeneralsMD/Code/Tests/test_volume_fire_policy.cpp@@ -190,9 +190,13 @@ TEST(volume_shock_passage_moves_a_point_by_the_fronts_displacement)// D falls as the front runs through the point, so the sum sits within a few per cent of D thereCHECK_NEAR((float)moved, displacement(one.c, meet), 0.05f * displacement(one.c, meet));}- // the second nuke moves the first's cap about half its 160-unit radius- CHECK(displacement(Nuclear, 390.0f / Nuclear.speed) > 70.0f);- CHECK(displacement(Nuclear, 390.0f / Nuclear.speed) < 100.0f);+ // holdCaps measures to the first nuke's cap middle, about 230 units over the ground. The second+ // 390 units off moves it about 40% of its 160-unit radius, enough to let it go (hold under 0.05,+ // 57 units); one 520 units off only loosens it+ const float capNear = std::hypot(390.0f, 230.0f), capFar = std::hypot(520.0f, 230.0f);+ CHECK(displacement(Nuclear, capNear / Nuclear.speed) > CapRelease);+ CHECK(displacement(Nuclear, capNear / Nuclear.speed) < 70.0f);+ CHECK(displacement(Nuclear, capFar / Nuclear.speed) < 0.95f * CapRelease);// past three widths the shell is cut: erfc(3), about two parts in a hundred thousandCHECK_EQ(profile(100.0f + 3.01f * 25.0f, 100.0f, 25.0f), 0.0f);CHECK(std::erfc(3.0) < 1e-4);@@ -211,9 +215,14 @@ TEST(volume_shock_passage_mixes_away_its_share)CHECK_NEAR(kept, 1.0f - dispersed(c, age), 1e-4f);CHECK(dispersed(c, age) <= c.disperse);}- // a Scud next to an earlier puff thins it by about a tenth, a nuke over the other's cap by half+ // a Scud next to an earlier puff thins it by about a tenth, and a nuke over the other's cap by its+ // whole tenth too (its push there would mix away 40%; that, and later a fifth, with the shell's+ // stretch left a released cap too thin to draw as more than a veil)CHECK_NEAR(dispersed(Scud, 100.0f / Scud.speed), 0.13f, 0.03f);- CHECK_NEAR(dispersed(Nuclear, 390.0f / Nuclear.speed), 0.55f, 0.06f);+ CHECK_NEAR(dispersed(Nuclear, std::hypot(390.0f, 230.0f) / Nuclear.speed), Nuclear.disperse, 1e-6f);+ CHECK_NEAR(Nuclear.disperse, 0.1f, 1e-6f);+ // volshock's nuke 3, 434 units from nuke 2, still lets nuke 2's cap go (about 230 units up)+ CHECK(displacement(Nuclear, std::hypot(434.0f, 230.0f) / Nuclear.speed) > 0.95f * CapRelease);// a cap lets go once moved CapRelease units, and holds while barely touchedCHECK_EQ(capHold(0.0f), 1.0f);CHECK_EQ(capHold(CapRelease), 0.0f);