Mech milestone phase 2: reconstruct MechSubsystem base class (the roster foundation)

The base all ~30 mech subsystems derive from. Reconstructed against the 4.10
structure per the MECHSUB.NOTES analysis (NOT backdated from BT411's divergent
version):

- Header: expanded with the real mech-specific member set (statusAlarm =
  AlarmIndicator, vitalSubsystem, alarmModel, criticalReference,
  collisionCriticalHitWeight, printSimulationState, configureActivePress,
  resource). Dropped the speculative MessageHandlers static -- MechSubsystem
  reuses the base Subsystem sets (inherited Simulation handlers/attrs/statecount).
- CPP: statics (ClassDerivations/DefaultData), both ctors (light name+classID and
  resource), dtor, TestClass/TestInstance, and the damage API on the 4.10
  per-type model -- GetSubsystemDamageLevel/SetSubsystemDamageLevel read/write the
  real DamageZone::damageLevel [0,1]; ForceCriticalFailure; TakeDamage delegates
  to the zone. Both ctors build the damage zone the base leaves NULL.

Deferred (documented): the Mech__DamageZone per-type armour STREAM wiring (ctors
use a trivial armour-free base DamageZone placeholder for now) and
CreateStreamedSubsystem (model-load stream format). These are refinements above
the ctor frontier, not boot blockers.

Compile-verified (BT: 24 ok); full tree still links clean. Next: the subsystem
roster (GAUSS/PPC/SENSOR source + .TCP partials + decomp).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-19 23:10:11 -05:00
co-authored by Claude Fable 5
parent 02a6355f0e
commit 0e274d3dde
2 changed files with 247 additions and 2 deletions
+218
View File
@@ -0,0 +1,218 @@
//===========================================================================//
// File: mechsub.cpp //
// Project: BattleTech Brick: Mech subsystems //
// Contents: Implementation details for the MechSubsystem base //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#include <bt.hpp>
#pragma hdrstop
#if !defined(MECHSUB_HPP)
# include <mechsub.hpp>
#endif
#if !defined(MECH_HPP)
# include <mech.hpp>
#endif
#if !defined(DAMAGE_HPP)
# include <damage.hpp>
#endif
//
//#############################################################################
// Shared data support -- MechSubsystem adds no message handlers or attributes
// that are boot-critical, so it reuses the base Subsystem sets (which are the
// inherited Simulation sets).
//#############################################################################
//
Derivation
MechSubsystem::ClassDerivations(
Subsystem::ClassDerivations,
"MechSubsystem"
);
MechSubsystem::SharedData
MechSubsystem::DefaultData(
MechSubsystem::ClassDerivations,
Subsystem::MessageHandlers,
Subsystem::AttributeIndex,
Subsystem::StateCount
);
//
//#############################################################################
// Light constructor (name + classID). For a subsystem created without a
// streamed resource; builds a trivial (armour-free) damage zone named by the
// base.
//#############################################################################
//
MechSubsystem::MechSubsystem(
Mech *owner,
int subsystem_ID,
const char *subsystem_name,
RegisteredClass::ClassID class_id,
SharedData &shared_data
):
Subsystem(owner, subsystem_ID, subsystem_name, class_id, shared_data)
{
this->owner = owner;
vitalSubsystem = False;
alarmModel = ResourceDescription::NullResourceID;
criticalReference = 0.0f;
collisionCriticalHitWeight = 0.0f;
printSimulationState = False;
configureActivePress = -1;
resource = NULL;
statusAlarm.SetLevel(0);
//
// The base Subsystem ctor leaves damageZone NULL; give this subsystem a
// trivial (armour-free) zone.
//
damageZone = new DamageZone(owner, 0);
Register_Object(damageZone);
}
//
//#############################################################################
// Resource constructor. Chains the base Subsystem resource ctor and seeds the
// mech-specific fields from the subsystem resource.
//
// The 4.10 damage model is per-damage-TYPE: the damage zone owns
// defaultArmorPoints + damageScale[5] and streams them itself (a
// Mech__DamageZone built from the model's damage-zone stream). Wiring that
// stream through from the resource is deferred (see MECHSUB.NOTES.md); until
// then the subsystem gets a trivial armour-free zone so it constructs and takes
// damage with default (unscaled) behaviour.
//#############################################################################
//
MechSubsystem::MechSubsystem(
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
SharedData &shared_data
):
Subsystem(owner, subsystem_ID, subsystem_resource, shared_data)
{
Check_Pointer(subsystem_resource);
this->owner = owner;
resource = subsystem_resource;
vitalSubsystem = (subsystem_resource->vitalSubsystemIndex == 1);
alarmModel = subsystem_resource->alarmModel;
printSimulationState = subsystem_resource->printSimulationState;
criticalReference = subsystem_resource->criticalReference;
collisionCriticalHitWeight = subsystem_resource->collisionCriticalHitWeight;
configureActivePress = -1;
statusAlarm.SetLevel(0);
damageZone = new DamageZone(owner, GetSegmentIndex());
Register_Object(damageZone);
}
//
//#############################################################################
//#############################################################################
//
MechSubsystem::~MechSubsystem()
{
if (damageZone)
{
Unregister_Object(damageZone);
delete damageZone;
damageZone = NULL;
}
}
//
//#############################################################################
//#############################################################################
//
Logical
MechSubsystem::TestClass(Mech &)
{
return True;
}
Logical
MechSubsystem::TestInstance() const
{
return IsDerivedFrom(ClassDerivations);
}
//
//#############################################################################
// Damage support -- the 4.10 damage zone tracks damageLevel in [0,1]
// (0 = intact, 1 = destroyed).
//#############################################################################
//
Scalar
MechSubsystem::GetSubsystemDamageLevel() const
{
Check(this);
return damageZone ? damageZone->damageLevel : 0.0f;
}
void
MechSubsystem::SetSubsystemDamageLevel(Scalar level)
{
Check(this);
if (damageZone)
{
damageZone->damageLevel = level;
}
}
void
MechSubsystem::ForceCriticalFailure()
{
Check(this);
statusAlarm.SetLevel(MechSubsystem::Destroyed);
if (damageZone)
{
damageZone->SetDamageZoneState(DamageZone::BurningState);
}
}
//
//#############################################################################
// TakeDamage Forward to the damage zone (per-type scaling happens there).
//#############################################################################
//
void
MechSubsystem::TakeDamage(Damage &damage)
{
Check(this);
Check_Pointer(&damage);
if (damageZone)
{
damageZone->TakeDamage(damage);
}
}
//
//#############################################################################
// CreateStreamedSubsystem Model-load-time construction of the subsystem
// resource + its damage-zone stream. Not yet reconstructed (see
// MECHSUB.NOTES.md -- the 4.10 per-type damage-zone stream format).
//#############################################################################
//
int
MechSubsystem::CreateStreamedSubsystem(
NotationFile *,
const char *,
const char *,
SubsystemResource *,
NotationFile *,
const ResourceDirectories *,
int
)
{
Fail("MechSubsystem::CreateStreamedSubsystem -- mechsub.cpp not yet reconstructed");
return 0;
}
+29 -2
View File
@@ -19,6 +19,10 @@
# include <subsystm.hpp>
# endif
# if !defined(ALARM_HPP)
# include <alarm.hpp>
# endif
//##################### Forward Class Declarations #######################
class Mech;
class Damage;
@@ -55,7 +59,6 @@
public:
static Derivation ClassDerivations;
static SharedData DefaultData;
static MessageHandlerSet MessageHandlers;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Status model
@@ -122,11 +125,35 @@
virtual void
TakeDamage(Damage &damage);
Scalar
GetSubsystemDamageLevel() const;
void
SetSubsystemDamageLevel(Scalar level);
void
ForceCriticalFailure();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Local Data
//
protected:
Mech *owner;
Mech
*owner;
AlarmIndicator
statusAlarm;
Logical
vitalSubsystem;
ResourceDescription::ResourceID
alarmModel;
Scalar
criticalReference;
Scalar
collisionCriticalHitWeight;
Logical
printSimulationState;
int
configureActivePress;
SubsystemResource
*resource;
};
#endif