From 9ea4bdaf503e2feea1dd12f86b0f16a7db64e3a5 Mon Sep 17 00:00:00 2001 From: arcattack Date: Mon, 6 Jul 2026 18:19:09 -0500 Subject: [PATCH] gauges: publish HeatSink attribute table (CoolantMass/CoolantCapacity/CurrentTemperature) The cockpit gauge config binds Subsystem/Attribute names (e.g. HeatSink/CurrentTemperature) resolved by ParseAttribute -> FindSubsystem -> GetAttributePointer -> the class's activeAttributeIndex. HeatSink wired GetAttributeIndex() into DefaultData but published an EMPTY table (only the inherited SimulationState id 1), so every HeatSink/* numeric read NULL -> guarded to 0. Add HeatSink::AttributePointers[] + GetAttributeIndex() publishing CoolantMass (coolantLevel @0x12C), CoolantCapacity (thermalCapacity @0x128), and CurrentTemperature (inherited currentTemperature @0x114), chained to the parent index so SimulationState is preserved and the built index stays dense (ids run contiguously from HeatableSubsystem::NextAttributeID -- a gap would make AttributeIndexSet::Find strcmp a garbage slot). Condenser and Reservoir derive from HeatSink with no override, so they inherit this table for free. Verified live (BT_DEV_GAUGES): the Heat surface heatsink-temperature readout (numeric HeatSink/CurrentTemperature, a base engine primitive that was already drawing NULL) now shows 77 (= startTemp) instead of 0. Combat un-regressed (TARGET DESTROYED after 8 hits), 0 crashes. The coolant attributes are ready for the vertBar widget (next increment). Co-Authored-By: Claude Opus 4.8 (1M context) --- game/reconstructed/heat.cpp | 28 ++++++++++++++++++++++++++++ game/reconstructed/heat.hpp | 22 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/game/reconstructed/heat.cpp b/game/reconstructed/heat.cpp index 9084809..13684e0 100644 --- a/game/reconstructed/heat.cpp +++ b/game/reconstructed/heat.cpp @@ -318,6 +318,34 @@ int //########################################################################### //########################################################################### +//############################################################################# +// Attribute Support +// +// The named attributes the cockpit gauges bind to (config content/GAUGE/L4GAUGE.CFG: +// HeatSink/CoolantMass, HeatSink/CoolantCapacity, HeatSink/CurrentTemperature). +// Chained to the parent index so SimulationState (id 1) is preserved; the ids run +// contiguously from HeatableSubsystem::NextAttributeID so the built index stays dense +// (AttributeIndexSet::Find strcmps every slot -- a gap would read a garbage name). +// +const HeatSink::IndexEntry + HeatSink::AttributePointers[]= +{ + ATTRIBUTE_ENTRY(HeatSink, CoolantMass, coolantLevel), // @0x12C (live: UpdateCoolant depletes it) + ATTRIBUTE_ENTRY(HeatSink, CoolantCapacity, thermalCapacity), // @0x128 + ATTRIBUTE_ENTRY(HeatSink, CurrentTemperature, currentTemperature) // @0x114 (inherited from HeatableSubsystem) +}; + +HeatSink::AttributeIndexSet& + HeatSink::GetAttributeIndex() +{ + static HeatSink::AttributeIndexSet attributeIndex( + ELEMENTS(HeatSink::AttributePointers), + HeatSink::AttributePointers, + HeatableSubsystem::GetAttributeIndex() + ); + return attributeIndex; +} + //############################################################################# // Shared Data Support // diff --git a/game/reconstructed/heat.hpp b/game/reconstructed/heat.hpp index c5dd7b0..3cb6c59 100644 --- a/game/reconstructed/heat.hpp +++ b/game/reconstructed/heat.hpp @@ -275,6 +275,28 @@ inline int static Derivation *GetClassDerivations(); static SharedData DefaultData; + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // Attribute Support -- the cockpit gauge bindings resolved by name through + // Simulation::GetAttributePointer (see engine GAUGREND.cpp ParseAttribute): + // HeatSink/CoolantMass -> coolantLevel (@0x12C, live) + // HeatSink/CoolantCapacity -> thermalCapacity (@0x128) + // HeatSink/CurrentTemperature -> currentTemperature (@0x114, inherited) + // Condenser and Reservoir derive from HeatSink and define no override, so + // their DefaultData resolves Condenser6/CoolantMass/... to this same table. + // (SimulationState id 1 is preserved by chaining to the parent index.) + // + public: + enum { + CoolantMassAttributeID = HeatableSubsystem::NextAttributeID, + CoolantCapacityAttributeID, + CurrentTemperatureAttributeID, + NextAttributeID + }; + private: + static const IndexEntry AttributePointers[]; + public: + static AttributeIndexSet& GetAttributeIndex(); + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Heat alarm state (this+0x138, reported by PrintState @004ae050) //