Files
TeslaRel410/restoration/source410/BT/MISTHRST.CPP
T
CydandClaude Fable 5 fdf26d6e55 BT410 Phase 5.3.19: teardown SOLVED -- flying missiles are the DEFAULT
The death-row page fault was the THIRD strike of the uninitialized
zone-array trap: the staged spawn rides the mech family's resourceID, whose
DamageZoneStream makes the Entity base ctor allocate the 20-pointer
damageZones[] array with UNINITIALIZED slots -- the Missile never fills it,
and ~Entity's teardown deleted 20 garbage pointers through trash vtables
(the dtor-chain bisect showed every dtor completing, then EIP-in-heap).
Fix: the Projectile ctor NULLs every inherited zone slot.  RULE, now
three-crashes-proven: any entity subclass that does not FILL the allocated
zone array must NULL it -- the engine never initializes the slots, on
construction OR destruction.

Missiles are now the default SRM delivery (BT_MISSILE_INSTANT=1 = the
5.3.18a instant-hit as an A/B opt-out).  Verified: 20 launches -> 20
detonations -> 20 clean death-row teardowns over a 110s mutual fight, zero
faults; smoke + novice regressions green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 13:39:18 -05:00

136 lines
4.1 KiB
C++

//===========================================================================//
// File: misthrst.cpp //
// Project: BattleTech Brick: Mech weapons //
// Contents: MissileThruster -- the missile's propulsion subsystem //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
//
// The class interface is the AUTHENTIC surviving CODE/BT/BT/MISTHRST.HPP.
// Bodies reconstructed via the BT411 decomp (ctor @004be7c4). The Subsystem
// base chain is the NAME ctor with the shipped string "MissleThruster"
// @00512e25 (the 1995 misspelling is AUTHENTIC -- keep it). No streamed
// resource in the pod content: the flight envelope defaults below are
// STAGED until the missile GameModel record decode (see MISSILE.NOTES.md).
//
#include <bt.hpp>
#pragma hdrstop
#if !defined(MISTHRST_HPP)
# include <misthrst.hpp>
#endif
#if !defined(MISSILE_HPP)
# include <missile.hpp>
#endif
//
// STAGED-DEFAULT burn envelope (a believable SRM: short hard burn).
//
static const Scalar DefaultBurnTime = 2.0f;
static const Scalar DefaultThrusterAcceleration = 120.0f; // u/s^2
static const Scalar DefaultThrusterClimb = 0.0f;
Derivation
MissileThruster::ClassDerivations(
Subsystem::ClassDerivations,
"MissileThruster"
);
const MissileThruster::IndexEntry
MissileThruster::AttributePointers[] =
{
ATTRIBUTE_ENTRY(MissileThruster, BurnTimeRemaining, burnTimeRemaining),
ATTRIBUTE_ENTRY(MissileThruster, MaxThrusterRotationRate, maxThrusterRotationRate),
ATTRIBUTE_ENTRY(MissileThruster, ThrusterAcceleration, thrusterAcceleration)
};
MissileThruster::AttributeIndexSet
MissileThruster::AttributeIndex(
ELEMENTS(MissileThruster::AttributePointers),
MissileThruster::AttributePointers,
Subsystem::AttributeIndex
);
MissileThruster::SharedData
MissileThruster::DefaultData(
MissileThruster::ClassDerivations,
Subsystem::MessageHandlers,
MissileThruster::AttributeIndex,
MissileThruster::StateCount
);
//
//#############################################################################
// Construction (binary @004be7c4). The const burn/thrust envelope streams
// from the missile resource in the binary; staged defaults here.
//#############################################################################
//
MissileThruster::MissileThruster(
Missile *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource
):
Subsystem(
owner,
subsystem_ID,
"MissleThruster",
(RegisteredClass::ClassID)ThrusterClassID,
DefaultData
),
thrusterAcceleration(
(subsystem_resource != NULL)
? subsystem_resource->thrusterAcceleration
: DefaultThrusterAcceleration
),
thrusterClimb(
(subsystem_resource != NULL)
? subsystem_resource->thrusterClimb
: DefaultThrusterClimb
)
{
Check(owner);
burnTimeRemaining = (subsystem_resource != NULL)
? subsystem_resource->burnTime
: DefaultBurnTime;
maxThrusterRotationRate = 0.0f;
Check_Fpu();
}
MissileThruster::~MissileThruster()
{
}
Logical
MissileThruster::TestInstance() const
{
return IsDerivedFrom(ClassDerivations);
}
//
//#############################################################################
// MissileThrusterSimulation -- bleed the burn. (Driven from the Missile's
// MoveAndCollide integrator, not a roster Performance -- the binary folds
// the thruster work into the integrate pass.)
//#############################################################################
//
void
MissileThruster::MissileThrusterSimulation(Scalar time_slice)
{
Check(this);
if (burnTimeRemaining > 0.0f)
{
burnTimeRemaining -= time_slice;
if (burnTimeRemaining < 0.0f)
{
burnTimeRemaining = 0.0f;
}
}
}