Files
BT411/engine/MUNGA/SUBSYSTM.h
T
arcattackandClaude Opus 5 ef8e449a17 #55 steps 0/1/2/4: the 1995 DEATH pass restored, the arg gate made real, and 5 subsystems the respawn sweep never reached
THE HEADLINE: the port's death sweep was a total no-op, and fixing it required
fixing the arg gate in the same commit -- otherwise corpses refill their ammo.

STEP 2 -- the authentic dispatch shape:
  * engine/MUNGA/SUBSYSTM.h: Subsystem::DeathShutdown gains the binary's
    universal base body { DeathReset(c) } (@004ad10e).  It was empty, and NO
    port class overrode it, so everything the 1995 game does at death was
    skipped entirely.
  * mech4.cpp death sweep now passes 0, not 1 (the binary's @0049fe0c arg) --
    the wreck shape: alarms/state settle, nothing refills.
  * ARG PROPAGATION (mandatory once the sweep runs): AmmoBin::DeathReset is now
    arg-gated exactly as @004bd26c -- refill only when arg != 0, ammoAlarm
    unconditional.  Ignoring the arg was harmless only while the sweep was
    dead; with it restored, every corpse would have re-armed.  Also forwarded
    in PoweredSubsystem / HeatSink / Condenser / HeatableSubsystem / Generator
    (each binary body forwards it -- verified addresses in the plan).

STEP 4 -- coverage for 5 classes that had an authentic slot-10 body but no
DeathReset, so the respawn sweep fell through to the empty base:
  Torso (this is Gitea #70 -- "loosing torso twist function after a death"),
  Gyroscope, Myomers, HUD, Seeker.

STEPS 0/1 -- observability + the David chain:
  * Three unconditional matchlog rows: DEAD_NOTIFY (mech + resolved link),
    PLAYER_LINK (player <-> vehicle), RESPAWN (mode/alive/zones/subsys/pos).
    A respawn was previously INVISIBLE in the matchlog -- night 3's analysis
    had to infer them from ammo arithmetic.
  * Mech::PlayerLinkMessageHandler + the death dispatch site: when the engine's
    one-shot registry lookup misses (no null check, no retry -> the whole
    death/respawn cycle silently swallowed), recover the SAME object via the
    reverse link the binary's own respawn branch walks (player+0x1FC ==
    playerVehicle).  Complete-type TU, no raw offsets.
  * deathPending cleared in the first-spawn branch (a latch carried in would
    permanently kill every later respawn -- the #57 class).

VERIFIED on the 2-pod rig (madcat vs thor, forced kills, 5 death/respawn cycles
per pod): build clean, ZERO new /FORCE unresolved externs from the 5 new
overrides; refill lines appear ONLY immediately before a Mech::Reset and NEVER
between a death and the next respawn (the corpse-refill regression this commit
had to pre-empt); all three probe rows present in both pods' matchlogs; every
DEAD_NOTIFY carried a non-null link.

DELIBERATELY DEFERRED (documented, not forgotten): the mechsub.cpp rename pair
(ResetToInitialState -> GenerateFault, ClearStatus -> the root reset @004ac22c),
deleting HeatableSubsystem::ResetToInitialState, and deleting RespawnRepair.
Those need the HeatableSubsystem vtable-slot-10 pre-flight the plan calls for,
and we have no binary image here to dump the vtable from -- guessing at it
risks the vptr-alias trap.  Next session with the decomp shards open.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-27 08:09:31 -05:00

187 lines
3.8 KiB
C++

#pragma once
#include "simulate.h"
#include "resource.h"
#include "damage.h"
class Entity;
class NotationFile;
//##########################################################################
//#################### Subsystem::ModelResource ######################
//##########################################################################
struct Subsystem__SubsystemResource
{
char
subsystemName[32];
RegisteredClass::ClassID
classID;
size_t
subsystemModelSize;
int
segmentIndex;
LWord
subsystemFlags;
};
//##########################################################################
//######################## Subsystem #################################
//##########################################################################
class Subsystem:
public Simulation
{
//##########################################################################
// Shared Data Support
//
public:
static Derivation *GetClassDerivations();
static SharedData DefaultData;
//##########################################################################
// Construction and Destruction Support
//
public:
typedef Subsystem__SubsystemResource SubsystemResource;
~Subsystem();
static ResourceDescription::ResourceID
CreateStreamedSubsystem(
NotationFile *model_file,
const char* model_name,
const char* subsystem_name,
SubsystemResource *subsystem_resource,
NotationFile *subsystem_file,
const ResourceDirectories *directories
);
protected:
Subsystem(
Entity *entity,
int subsystem_id,
SubsystemResource *model,
SharedData &shared_data
);
Subsystem(
Entity *entity,
int subsystem_id,
const char *subsystem_name,
RegisteredClass::ClassID class_id,
SharedData &shared_data
);
//##########################################################################
// Flag Support
//
public:
enum {
DontReplicateBit = Simulation::NextBit,
NextBit
};
enum {
DontReplicateFlag = 1<<DontReplicateBit
};
//##########################################################################
// Model support
//
public:
typedef void
(Subsystem::*Performance)(Scalar time_slice);
void
SetPerformance(Performance performance)
{
Check(this);
activePerformance = (Simulation::Performance)performance;
}
Entity*
GetEntity()
{Check(this); return owningEntity;}
int
GetSegmentIndex()
{Check(this); return segmentIndex;}
const char*
GetName()
{Check(this); return subsystemName;}
void
WriteUpdateRecord(
UpdateRecord *message,
int update_model
);
protected:
Entity*
owningEntity;
char*
subsystemName;
int
subsystemID;
int
segmentIndex;
//##########################################################################
// Test support
//
public:
Logical
TestInstance() const;
enum
{
nextFaultIndex = 0
};
virtual Logical
GenerateFault(int fault_index);
//##########################################################################
// Damage support
//
virtual void
TakeDamage(Damage &damage)
{
Check(this); Check_Pointer(&damage); Check(damageZone);
damageZone->TakeDamage(damage);
}
DamageZone *damageZone;
virtual void
DeathReset(int /*reset_command*/)
{}
virtual void
DeathShutdown(int shutdown_command)
{
// #55: the binary's universal base @004ad10e forwards slot 11 to
// slot 10 -- { this->vtbl[0x28](this, arg); } -- so a death sweep
// with arg 0 runs every subsystem's DeathReset in its wreck shape
// (no refill). The empty body here made the whole 1995 death
// pass a no-op in the port.
DeathReset(shutdown_command);
}
};
//##########################################################################
// Tool support
//
int
Get_Segment_Index(
NotationFile *model_file,
const char* model_name,
const ResourceDirectories *directories,
const char *desired_page
);