WAVE 7 Phase A: wire the projectile/missile weapon SUBSYSTEMS byte-exact (un-mislabeled)

An 8-agent decomp-mapping workflow mapped every weapon-family ctor + fire/spawn path
(scratchpad/wave7_maps.txt).  KEY IDENTITY CORRECTION via VDATA.h enum (base 3000=0xBB8):
the factory ctor-address comments were right but the built CLASS names were stubs/base --
    0xBCD == ProjectileWeapon  (was building the base MechWeapon stub)
    0xBCE == GaussRifle         (NOT MissileLauncher -- was a MissileLauncher stub)
    0xBD0 == MissileLauncher    (NOT BallisticWeapon -- was a BallisticWeapon stub)
Un-mislabeled + wired via Create<Class>Subsystem bridges (mirroring CreateEmitterSubsystem),
each static_assert-locked byte-exact on the now-locked MechWeapon(0x3F0)/Emitter(0x478) bases:

  * ProjectileWeapon (0xBCD, @4bc3fc : MechWeapon, sizeof 0x448)
      FIX: AmmoBinConnection was an empty 1-byte struct -> retyped to the binary's 0xC
           SharedData::Connection (was making the object 8 bytes short, sliding
           MissileLauncher's missileCount off 0x448).
  * MissileLauncher (0xBD0, @4bcff0 : ProjectileWeapon, sizeof 0x44C)
      FIX: deleted muzzleVelocity (ALIAS of inherited ProjectileWeapon launchVelocity@0x410)
           and salvoCount (SHADOW of inherited MechWeapon damageData.burstCount@0x3d4),
           keeping the single own field missileCount@0x448.
  * GaussRifle (0xBCE, @4bdcb4 : Emitter, sizeof 0x484 = Emitter + Vector3D muzzleVelocity)
      DEDICATED bridge (not CreateEmitter): its FireWeapon is a no-op (mov [eax+0x414],0) --
      a non-functional weapon in this 1995 build.  Also fixed GAUSS.CPP's discharge write
      rechargeLevel -> currentLevel@0x414 (the binary writes this+0x414).

Phase A safe-stubs FireWeapon (consume round + recoil, NO spawn): the reconstructed
Projectile (@4be1bc, 0x340) + Missile (@4bf5b4, 0x368) ENTITY classes are NOT spawn-ready
(Entity-base phantom members overflow their New() alloc -> heap corruption; New() takes
(int)this instead of the 0xD4 descriptor; Entity base size unconfirmed 2007-vs-1995, the
Mech 0x638-vs-0x854 problem).  The workflow's adversarial verify flagged the live spawn as a
heap-overflow hazard and recommended exactly this phasing.  Phase B = the entity byte-exactness
+ descriptor build + New(MakeMessage*) so a fired shot becomes a flying entity that damages.

Factory now 18 of 20 cases wired to real ticking classes (remaining: SubsystemMessageManager
0xBD3 [WAVE 8], Gyroscope 0xBC4 [deferred]).  Verified: Mad Cat (LRM/ballistic) + BLH construct
the real weapon classes + tick authentic charge/ammo/heat/recoil, DESTROYED-in-8, 0 crashes,
heapcheck-clean through construction.  Energy weapons already damage via the mech4 beam path,
so combat is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
arcattack
2026-07-07 13:35:43 -05:00
co-authored by Claude Opus 4.8
parent 9d82be46a1
commit 2bcca26cea
8 changed files with 167 additions and 49 deletions
+31 -17
View File
@@ -112,10 +112,10 @@ MissileLauncher::MissileLauncher(
// vtable installed by the compiler (PTR_FUN_00512570)
missileCount = subsystem_resource->missileCount; // @0x448 resource +0x1d0
muzzleVelocity = subsystem_resource->muzzleVelocity; // @0x410 resource +0x1d4
launchVelocity = subsystem_resource->muzzleVelocity; // @0x410 (inherited ProjectileWeapon slot; was aliased "muzzleVelocity")
// per-salvo count copy + per-missile damage
this->salvoCount = missileCount; // @0x3d4 this[0xf5]
// per-salvo count copy + per-missile damage (write the inherited Damage fields)
this->damageData.burstCount = missileCount; // @0x3d4 this[0xf5] (was shadow "salvoCount")
this->damageData.damageAmount /= (Scalar)missileCount; // @0x3ac this[0xeb] /= missileCount
}
@@ -219,23 +219,21 @@ void MissileLauncher::FireWeapon()
// Begin the per-shot recharge cooldown (recoil bleeds to 0 before ReadyToFire).
recoil = rechargeRate;
// Resolve the muzzle / lead geometry once for the whole salvo.
// - muzzle transform MechWeapon::GetMuzzlePoint @004b9948
// - lead point leadPosition (ComputeTimeOfFlight, run by the sim)
// - per-missile Damage damageData (already /missileCount in the ctor)
// - muzzleVelocity this->muzzleVelocity (@0x410, resource +0x1d4)
// Resolve the muzzle / lead geometry (used to seed each missile's descriptor).
Point3D muzzle;
GetMuzzlePoint(muzzle); // @004b9948
damageData.burstCount = missileCount; // @0x3d4 (was shadow "salvoCount")
// Spawn `missileCount` guided Missile entities (streamed ClassID 0xBD0). Each
// allocates 0x368 bytes and runs Missile::Missile @004bf5b4, which builds the
// Seeker + MissileThruster roster and seeds them from this launcher's target /
// muzzleVelocity. FUN_004bf8bc == Missile::New.
salvoCount = missileCount; // @0x3d4
for (int i = 0; i < missileCount; ++i)
{
Missile::New((int)this); // @004bf8bc -> @004bf5b4
}
// ⚠ SPAWN DEFERRED (WAVE 7 Phase B): the shipped code loops missileCount times
// building a 0xD4-byte Missile MakeMessage (muzzle transform + lead + the 12-word
// Damage descriptor + launchVelocity + owner/target) and calls Missile::New
// (@004bf8bc -> ctor @004bf5b4, allocs 0x368). The Missile ENTITY class is not
// spawn-ready (Entity-base phantom members overflow the 0x368 alloc; New() takes
// (int)this instead of the descriptor) -> a live spawn would corrupt the heap. The
// launcher SUBSYSTEM ticks authentically (charge/ammo/heat/recoil, damage split
// across missileCount) but does NOT launch until the entity work lands. See
// scratchpad/wave7_maps.txt (Missile map) + docs/SUBSYS_PLAN.md.
// for (int i = 0; i < missileCount; ++i) Missile::New(&descriptor); // <-- Phase B
simulationFlags |= 0x1; // replication-dirty
Check_Fpu();
@@ -264,3 +262,19 @@ Logical MissileLauncher::TestInstance() const
{
return ProjectileWeapon::TestInstance();
}
//===========================================================================//
// WAVE 7 factory bridge -- MissileLauncher (factory case 0xBD0, "BallisticWeapon"
// mislabel). VDATA.h enum: 0xBD0 == MissileLauncherClassID. The real class
// (ctor @004bcff0) is MissileLauncher : ProjectileWeapon (sizeof 0x44C); the
// factory built a BallisticWeapon RECON_SUBSYS stub. alloc 0x44C. Ticks its
// real per-frame sim (charge/ammo/heat, damage split across missileCount);
// FireWeapon consumes a round + recoils but DEFERS the missile spawn (Phase B).
//===========================================================================//
Subsystem *CreateMissileLauncherSubsystem(Mech *owner, int id, void *seg)
{
Check(sizeof(MissileLauncher) <= 0x44C);
return (Subsystem *) new (Memory::Allocate(0x44C))
MissileLauncher(owner, id, (MissileLauncher::SubsystemResource *)seg, MissileLauncher::DefaultData);
}