Weapons dump firing heat into their own sinks, sinks conduct through the Condenser bank into the central HeatSink, temperatures drive the degradation/ failure alarms, and every powered subsystem tracks its generator through the electrical state machine. Verified: the authentic fire-discipline game -- a PPC spikes 77->709K per shot, relaxes to 441K across its 5s reload, and sustained fire climbs 441->674->838->960K, brushing the authored 1000K degradation threshold. All calibration values match the BT411 audit exactly (central bank 1.39e6, PPC sink 174000, thresholds 77/1000/2000). - HEAT: HeatSinkSimulation (@004ad924 absorb->T->load->conduct->alarm), ConductHeat/ComputeHeatFlow (@004ad8ac/@004ad9ec two-body equilibrium relaxation; flow==0 exactly at uniform T), UpdateHeatLoad (15-sample filter); heat-state enum + accessors; installed by the HeatSink ctor. - WIRE-VERIFIED: HeatSink resource gains linkedSinkIndex -- THE missing ancestry int that shifted every descendant block +1 (voltageSourceIndex had been reading the linked-sink index: "power sources" appeared to be Condensers). Conduction topology wired from it at construction: weapons->Condensers1-6->central; Generators->Condensers; Reservoir->central. - MECHWEAP resource: authentic pip tail (pipPosition int + pipColor 3 floats + pipExtendedRange int) per the BT411 verified overlay; with linkedSinkIndex this closes the whole +3 alignment mystery (ProjectileWeapon pad deleted). True bhk1 reads: PPC recharge 5.0s (not 1.0), discharge 0.99s, range 900. - POWERSUB: ctor resolves voltageSourceIndex -> GeneratorA-D (wire-verified), taps via Generator::TapVoltageSource (-1 when full); PoweredSubsystemSimulation (@004b0bd0) electrical FSM (Starting/NoVoltage/Shorted/GeneratorOff/Ready); GeneratorSimulation partial (start/short-recovery timers). - Weapons: power step at sim head; Loading recharge gated on electrical Ready (authentic @4bbdf5); FireWeapon dumps firing heat. HEAT UNITS: the chain is 1e7-native with TWO authoring conventions -- energy weapons store small (PPC=11, x1e7 from the energy algebra), ballistics store native (SRM6=5.06e7, dumped raw; double-scaling it was the bring-up runaway-temperature bug). - SENSOR: authentic gating (@004b1c4c) -- power step, electrical-Ready gate, heat-state switch (Degradation x0.5 / Failure 0). Verified Ready + 100%. Deferred: coolant depletion/venting, the novice HeatModelOff gate, the charge model (TrackSeekVoltage/voltage sag/I2R), weapon gate 1 + jam roll, the central sink's forward-linked drain. Zero Fail across fire + neutral runs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
350 lines
10 KiB
C++
350 lines
10 KiB
C++
//===========================================================================//
|
|
// File: heat.hpp //
|
|
// Project: BattleTech //
|
|
// Contents: Implementation details for heatable subsystems //
|
|
//---------------------------------------------------------------------------//
|
|
// Date Who Modification //
|
|
// -------- --- ---------------------------------------------------------- //
|
|
// //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
|
|
// All Rights reserved worldwide //
|
|
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#if !defined(HEAT_HPP)
|
|
# define HEAT_HPP
|
|
|
|
# if !defined(MECHSUB_HPP)
|
|
# include <mechsub.hpp>
|
|
# endif
|
|
|
|
# if !defined(AVERAGE_HPP)
|
|
# include <average.hpp>
|
|
# endif
|
|
|
|
//##################### Forward Class Declarations #######################
|
|
class Mech;
|
|
|
|
//###########################################################################
|
|
//################## HeatableSubsystem Model Resource ###################
|
|
//###########################################################################
|
|
|
|
struct HeatableSubsystem__SubsystemResource:
|
|
public MechSubsystem::SubsystemResource
|
|
{
|
|
Scalar startingTemperature;
|
|
Scalar degradationTemperature;
|
|
Scalar failureTemperature;
|
|
Scalar thermalConductance;
|
|
Scalar thermalMass;
|
|
};
|
|
|
|
//###########################################################################
|
|
//######################## HeatableSubsystem ############################
|
|
//###########################################################################
|
|
|
|
class HeatableSubsystem:
|
|
public MechSubsystem
|
|
{
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Shared Data Support
|
|
//
|
|
public:
|
|
static Derivation ClassDerivations;
|
|
static SharedData DefaultData;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Test Class Support
|
|
//
|
|
public:
|
|
static Logical
|
|
TestClass(Mech &);
|
|
Logical
|
|
TestInstance() const;
|
|
void
|
|
ResetToInitialState();
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Construction and Destruction
|
|
//
|
|
public:
|
|
typedef HeatableSubsystem__SubsystemResource SubsystemResource;
|
|
|
|
HeatableSubsystem(
|
|
Mech *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource,
|
|
SharedData &shared_data = DefaultData
|
|
);
|
|
|
|
~HeatableSubsystem();
|
|
|
|
static int
|
|
CreateStreamedSubsystem(
|
|
NotationFile *model_file,
|
|
const char *model_name,
|
|
const char *subsystem_name,
|
|
SubsystemResource *subsystem_resource,
|
|
NotationFile *subsystem_file,
|
|
const ResourceDirectories *directories,
|
|
int passes = 1
|
|
);
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Local Data
|
|
//
|
|
protected:
|
|
Scalar currentTemperature;
|
|
Scalar heatLoad;
|
|
Scalar degradationTemperature;
|
|
Scalar failureTemperature;
|
|
};
|
|
|
|
//###########################################################################
|
|
//########################## SubsystemConnection ########################
|
|
//###########################################################################
|
|
//
|
|
// A slot linking a heat sink to its master / linked heat sink.
|
|
//
|
|
class SubsystemConnection
|
|
{
|
|
public:
|
|
SubsystemConnection() { linked = NULL; }
|
|
void Add(Subsystem *s) { linked = s; }
|
|
Subsystem* Resolve() const { return linked; }
|
|
void Clear() { linked = NULL; }
|
|
protected:
|
|
Subsystem *linked;
|
|
int reserved[2];
|
|
};
|
|
|
|
//###########################################################################
|
|
//####################### HeatSink Model Resource #######################
|
|
//###########################################################################
|
|
|
|
struct HeatSink__SubsystemResource:
|
|
public HeatableSubsystem__SubsystemResource
|
|
{
|
|
//
|
|
// WIRE-VERIFIED (raw-stream dump): the roster index of the sink this
|
|
// one conducts its heat into -- the weapons/equipment link to the
|
|
// Condenser bank (slots 4-9), the Condensers to the central HeatSink.
|
|
// This was THE missing ancestry int that shifted every descendant
|
|
// resource block +1 (PoweredSubsystem voltageSourceIndex, the MechWeapon
|
|
// block, ...).
|
|
//
|
|
int linkedSinkIndex;
|
|
};
|
|
|
|
//###########################################################################
|
|
//############################## HeatSink ###############################
|
|
//###########################################################################
|
|
|
|
//###########################################################################
|
|
//################### HeatWatcher Model Resource #######################
|
|
//###########################################################################
|
|
|
|
struct HeatWatcher__SubsystemResource:
|
|
public MechSubsystem__SubsystemResource
|
|
{
|
|
int watchedSubsystem;
|
|
Scalar degradationTemperature;
|
|
Scalar failureTemperature;
|
|
};
|
|
|
|
//###########################################################################
|
|
//############################# HeatWatcher #############################
|
|
//###########################################################################
|
|
//
|
|
// Watches another subsystem's temperature and drives a 3-level alarm. A
|
|
// sibling branch to HeatableSubsystem (derives straight from MechSubsystem);
|
|
// PowerWatcher and the Torso/HUD/Gyroscope leaves descend from it.
|
|
//
|
|
class HeatWatcher:
|
|
public MechSubsystem
|
|
{
|
|
public:
|
|
static Derivation ClassDerivations;
|
|
static SharedData DefaultData;
|
|
|
|
static Logical
|
|
TestClass(Mech &);
|
|
Logical
|
|
TestInstance() const;
|
|
void
|
|
ResetToInitialState(Logical powered);
|
|
void
|
|
WatchSimulation(Scalar time_slice);
|
|
|
|
public:
|
|
typedef HeatWatcher__SubsystemResource SubsystemResource;
|
|
|
|
HeatWatcher(
|
|
Mech *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource,
|
|
SharedData &shared_data = DefaultData
|
|
);
|
|
~HeatWatcher();
|
|
|
|
protected:
|
|
SubsystemConnection watchedLink;
|
|
int watchedSubsystem;
|
|
Scalar degradationTemperature;
|
|
Scalar failureTemperature;
|
|
AlarmIndicator heatAlarm;
|
|
};
|
|
|
|
class HeatSink:
|
|
public HeatableSubsystem
|
|
{
|
|
friend class Condenser;
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Shared Data Support
|
|
//
|
|
public:
|
|
static Derivation ClassDerivations;
|
|
static SharedData DefaultData;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Test Class Support
|
|
//
|
|
public:
|
|
static Logical
|
|
TestClass(Mech &);
|
|
Logical
|
|
TestInstance() const;
|
|
void
|
|
ResetToInitialState(Logical powered);
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Heat state (carried in heatAlarm, 3 levels). The thresholds are the
|
|
// authored degradation/failure temperatures.
|
|
//
|
|
public:
|
|
enum {
|
|
NormalHeat = 0,
|
|
DegradationHeat,
|
|
FailureHeat,
|
|
HeatStateCount
|
|
};
|
|
|
|
unsigned
|
|
GetHeatState() { Check(this); return heatAlarm.GetLevel(); }
|
|
Scalar
|
|
CurrentTemperatureOf() { Check(this); return currentTemperature; }
|
|
void
|
|
AddPendingHeat(Scalar heat)
|
|
{ Check(this); pendingHeat += heat; }
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Simulation Support
|
|
//
|
|
public:
|
|
typedef void
|
|
(HeatSink::*Performance)(Scalar time_slice);
|
|
void
|
|
SetPerformance(Performance performance)
|
|
{
|
|
Check(this);
|
|
activePerformance = (Simulation::Performance)performance;
|
|
}
|
|
|
|
void
|
|
HeatSinkSimulation(Scalar time_slice);
|
|
void
|
|
UpdateHeatLoad();
|
|
void
|
|
ConductHeat(Scalar time_slice);
|
|
Scalar
|
|
ComputeHeatFlow(HeatSink *other, Scalar time_slice);
|
|
virtual Scalar
|
|
DrawCoolant(Scalar requested);
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Construction and Destruction
|
|
//
|
|
public:
|
|
typedef HeatSink__SubsystemResource SubsystemResource;
|
|
|
|
HeatSink(
|
|
Mech *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource,
|
|
SharedData &shared_data = DefaultData
|
|
);
|
|
|
|
~HeatSink();
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Local Data
|
|
//
|
|
protected:
|
|
Scalar coolantEfficiency;
|
|
Scalar thermalCapacity;
|
|
Scalar coolantLevel;
|
|
Scalar coolantDraw;
|
|
int coolantAvailable;
|
|
int coolantActive;
|
|
Scalar startingTemperature;
|
|
Scalar thermalConductance;
|
|
Scalar filterDecay;
|
|
Scalar thermalMass;
|
|
Scalar heatEnergy;
|
|
Scalar coolantFlowScale;
|
|
Scalar massScale;
|
|
Scalar pendingHeat;
|
|
Scalar radiatedHeat;
|
|
SubsystemConnection linkedSinks;
|
|
AlarmIndicator heatAlarm;
|
|
AverageOf<Scalar> heatFilter;
|
|
};
|
|
|
|
//###########################################################################
|
|
//#################### Condenser Model Resource ########################
|
|
//###########################################################################
|
|
|
|
struct Condenser__SubsystemResource:
|
|
public HeatSink__SubsystemResource
|
|
{
|
|
Scalar refrigerationFactor;
|
|
};
|
|
|
|
//###########################################################################
|
|
//############################## Condenser #############################
|
|
//###########################################################################
|
|
//
|
|
// A HeatSink with active refrigeration (a coolant loop's condenser).
|
|
//
|
|
class Condenser:
|
|
public HeatSink
|
|
{
|
|
public:
|
|
static Derivation ClassDerivations;
|
|
static SharedData DefaultData;
|
|
|
|
static Logical
|
|
TestClass(Mech &);
|
|
Logical
|
|
TestInstance() const;
|
|
|
|
public:
|
|
typedef Condenser__SubsystemResource SubsystemResource;
|
|
|
|
Condenser(
|
|
Mech *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource,
|
|
SharedData &shared_data = DefaultData
|
|
);
|
|
~Condenser();
|
|
|
|
protected:
|
|
int valveState;
|
|
int condenserNumber;
|
|
Scalar refrigerationFactor;
|
|
};
|
|
|
|
#endif
|