Files
BT412/game/reconstructed/sensor.hpp
T
arcattackandClaude Opus 4.8 7b7d465e5e Initial commit: bt411 -- standalone Windows BattleTech (Tesla 4.10 port)
Clean, self-contained extraction of the BattleTech-specific work from the
reverse-engineering workspace -- engine + game + content + build, with nothing
from Red Planet or the raw archive dumps. Builds green (Win32) and runs the
single-player drive->animate->target->fire->damage->destroy loop out of the box.

Layout:
  engine/   MUNGA + MUNGA_L4 shared 2007 engine, carrying our BT render/loader
            work (bgfload/L4D3D/L4VIDEO: BSL bit-slice decode, LOD/ground/shadow
            models) + image codec; the minimal rp/ headers the audio HAL needs
  game/     reconstructed BT logic + surviving-original BT source + fwd shims
            + WinMain launcher
  content/  full runtime tree (BTL4.RES, VIDEO/, GAUGE/, AUDIO/, eggs, BTDPL.INI)
  docs/     format specs + reconstruction ledgers
  reference/ raw Ghidra pseudocode (recon source-of-truth) + decomp exporter
  tools/    MP console emulator + map/resource scanners

One top-level CMake builds munga_engine lib + bt410_l4 game lib + btl4.exe.
All paths relativized (186 fwd shims + ~437 CMake abs paths -> repo-relative);
DXSDK is the one external, overridable via -DDXSDK. Verified: builds to a
byte-identical 2.27MB exe and runs combat (TARGET DESTROYED, 0 crashes) against
the bundled content.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-05 21:03:40 -05:00

228 lines
8.0 KiB
C++

//===========================================================================//
// File: sensor.hpp //
// Project: BattleTech //
// Contents: Sensor subsystem //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 8/10/95 GDU Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. All Rights reserved //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
//
// This declaration is the SURVIVING SENSOR.HPP
// (410SRC/.../CODE/BT/BT/SENSOR.HPP) reproduced verbatim, with reconstruction
// annotations added in comments only. The class body below is GROUND TRUTH;
// the @ADDR / @offset notes were recovered from the shipped binary and tie
// each declaration to the evidence used in sensor.cpp.
//
// Recovered binary facts (see sensor.cpp for per-method @ADDR evidence):
// - Sensor IS-A PoweredSubsystem (powersub.hpp), object size 0x328.
// - vtable @0050fb0c ctor @004b1d18 dtor @004b1d90
// - DefaultData @0050fa1c ClassDerivations @0050fa2c
// - AttributePointers @0050fa50 (three IndexEntry records, see below)
// - RegisteredClass::SensorClassID == 0x0BC3 (resource +0x20),
// streamed model size 0x190 (resource +0x24 -- same record as
// PoweredSubsystem; the Sensor resource adds no fields).
//
// IMPORTANT CONFLICT NOTE: the prior powersub.cpp/CLASSMAP reconstruction
// labelled the class at vtable @0050fb0c / ctor @004b1d18 "Myomers" with
// inferred members outputVoltage/powered/voltageAvailable. That was a
// misidentification. The shipped attribute string pool (@0050fae0:
// "Sensor", "RadarPercent", "SelfTest", "BadVoltage") and the surviving
// SENSOR.HPP prove the class is Sensor. classID 0xBC3 is Sensor, not
// Myomers. See CLASSMAP.md "Resolved conflict".
//
#if !defined(SENSOR_HPP)
# define SENSOR_HPP
#if !defined(POWERSUB_HPP)
#include "powersub.hpp"
#endif
//##########################################################################
//################# SensorSubsystemResource #######################
//##########################################################################
//
// Empty extension of the PoweredSubsystem resource. Confirmed by
// CreateStreamedSubsystem @004b1dcc, which only chains to
// PoweredSubsystem::CreateStreamedSubsystem (@004b13ac) and stamps the
// classID/model-size -- it parses NO sensor-specific fields, and the streamed
// model size is 0x190 (identical to the PoweredSubsystem record).
//
struct Sensor__SubsystemResource:
public PoweredSubsystem::SubsystemResource
{
};
//##########################################################################
//########################## Sensor ###############################
//##########################################################################
class Sensor:
public PoweredSubsystem
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Death and Damage Support
//
// NOTE: the Sensor vtable @0050fb0c carries the inherited (PoweredSubsystem
// / HeatSink) addresses in the damage/death slots -- no Sensor-specific
// bodies were captured in the decomp. The definitions in sensor.cpp are
// BEST-EFFORT (chain to base) and flagged accordingly.
//
public:
void
TakeDamage(Damage &damage);
void
DeathReset(Logical full_recovery);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Shared Data Support
//
// DefaultData @0050fa1c, ClassDerivations @0050fa2c.
//
public:
static Derivation ClassDerivations;
static SharedData DefaultData;
static Receiver::MessageHandlerSet MessageHandlers;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// BT segment / base-state compatibility shims.
//
// CROSS-FAMILY: these accessors and segment-flag constants logically belong
// on the shared bases (Mech::GetSegmentFlags, HeatSink::HeatStateLevel /
// HeatModelOff / heatEnergy, PoweredSubsystem::ElectricalStateLevel) plus a
// real multi-level AlarmIndicator. Until the heat/powersub/mech families
// expose them, they are backed locally here so this module compiles; the
// backing fields are written by the (cross-family) base simulation once the
// real accessors land. See report "CROSS-FAMILY NEEDS".
//
#if !defined(BT_SEGMENT_FLAG_CONSTS)
# define BT_SEGMENT_FLAG_CONSTS
enum {
SegmentCopyMask = 0x0C, // (flags & 0xC): 0 == primary, 4 == damaged copy
SegmentLiveFlag = 0x01,
MasterHeatSinkFlag = 0x0100
};
#endif
public:
Word
GetSegmentFlags() const { return segmentFlags; }
HeatSink::HeatState
HeatStateLevel() const { return heatStateLevel; }
Logical
HeatModelOff() const { return heatModelOff; }
Scalar
HeatMasterEnergy() const { return heatEnergy; } // own inherited sink
PoweredSubsystem::ElectricalState
ElectricalStateLevel() const { return electricalState; }
void
SetHasPerformanceFlag() { hasActivePerformance = True; }
protected:
Word segmentFlags; // @this[0x28]/segment flags (Mech-supplied)
Logical hasActivePerformance;
HeatSink::HeatState heatStateLevel; // heatAlarm level (cross-family base)
Logical heatModelOff; // thermal model disabled flag
PoweredSubsystem::ElectricalState electricalState; // electricalStateAlarm level
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Attribute Support
//
// Recovered IndexEntry table @0050fa50 (one {nameptr, attribID, offset+1}
// record each). The offset field is encoded as (byte_offset | 1):
// RadarPercent -> id 0x12, 0x31d => radarPercent @0x31C
// SelfTest -> id 0x13, 0x321 => selfTest @0x320
// BadVoltage -> id 0x14, 0x325 => badVoltage @0x324
// (PoweredSubsystem::NextAttributeID == 0x12, so the enum below resolves to
// RadarPercent=0x12, SelfTest=0x13, BadVoltage=0x14, NextAttributeID=0x15.)
//
public:
enum {
RadarPercentAttributeID = PoweredSubsystem::NextAttributeID,
SelfTestAttributeID,
BadVoltageAttributeID,
NextAttributeID
};
private:
static const IndexEntry AttributePointers[];
protected:
static AttributeIndexSet AttributeIndex;
public:
Scalar
radarPercent; // @0x31C ctor init 1.0f
Logical
selfTest, // @0x320 ctor init 0
badVoltage; // @0x324 ctor init 0
//##########################################################################
// Simulation Support
//
public:
typedef void
(Sensor::*Performance)(Scalar time_slice);
void
SetPerformance(Performance performance)
{
Check(this);
activePerformance = (Simulation::Performance)performance;
}
void
SensorSimulation(Scalar time_slice); // @004b1c4c (Performance, PTR @0050fa94)
//##########################################################################
// Test Class Support
//
public:
static Logical
TestClass(Mech&);
void
ResetToInitialState(); // slot 10, @004b1c18
//##########################################################################
// Construction and Destruction
//
public:
typedef Sensor__SubsystemResource SubsystemResource;
Sensor(
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource
); // @004b1d18
~Sensor(); // @004b1d90
Logical
TestInstance() const; // @004b1e18
static int
CreateStreamedSubsystem( // @004b1dcc
NotationFile *model_file,
const char *model_name,
const char *subsystem_name,
SubsystemResource *subsystem_resource,
NotationFile *subsystem_file,
const ResourceDirectories *directories,
int passes = 1
);
};
#endif