Files
TeslaRel410/restoration/source410/BT_L4/BTL4GRND.CPP
T
CydandClaude Fable 5 64e208f121 BT410 Phase 5.3.26: THE COCKPIT GAUGE BLOCK -- the first rendered milestone
Six TUs born in one wave (4-agent re-hosting workflow from the BT411 donors
+ inline integration): BTL4GAUG (16 widget primitives + 5 connections, the
TU anchor @004c3f6c), BTL4GAU2 (13 composite panel clusters), BTL4GAU3
(PilotList/PlayerStatus/SectorDisplay/MessageBoard/mapping group), BTL4RDR
(the MapDisplay radar vs the authentic surviving header), BTL4GRND (the
real renderer: L4LampManager + L4Warehouse + BuildConfigurationFile with
the 19-entry BT registry chained onto the engine table).  btl4.lib grows
7 -> 11 members; all 50 game TUs compile; link clean.

VERIFIED LIVE: with L4GAUGE=640x480x16 the interpreter parses the full
authentic L4GAUGE.CFG, Bhk1Init runs, ColorMapperArmor binds the live
mech's damage zones by name (cross-chassis names take the authentic inert
path), and the complete mutual missile fight runs with the cockpit stack
updating from real combat -- 16/16 rounds, 138 zone hits, zero faults.
Gauges-off regressions untouched.

Engine bring-up deviation (documented): ParseAttribute normalizes
unpublished attribute names to a shared writable zero cell -- the 1995
GaugeConnectionDirectOf ctor hard-derefs its source (first boot crashed
there); widgets on unpublished names draw static zeros and light up
automatically as the attribute waves publish the 1995 CFG spellings the
bindings already carry.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 19:02:04 -05:00

216 lines
6.5 KiB
C++

//===========================================================================//
// File: btl4grnd.cpp //
// Project: BattleTech Brick: Gauge Renderer Manager //
// Contents: BTL4GaugeRenderer -- the BT cockpit gauge renderer //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
//
// RECONSTRUCTED against the authentic surviving BTL4GRND.HPP (5 members, no
// data -- all state inherited). Binary anchors: ctor @004cbea0 (vtable
// 0051cebc), dtor @004cbf40, TestInstance @004cbf90, NotifyOfNew @004cbfa0,
// NotifyOfBecoming @004cc028; the BT registration table @0051c910.
//
#include <btl4.hpp>
#pragma hdrstop
#if !defined(BTL4GRND_HPP)
# include <btl4grnd.hpp>
#endif
#if !defined(BTL4GAUG_HPP)
# include <btl4gaug.hpp>
#endif
#if !defined(BTL4GAU2_HPP)
# include <btl4gau2.hpp>
#endif
#if !defined(BTL4GAU3_HPP)
# include <btl4gau3.hpp>
#endif
#if !defined(BTL4RDR_HPP)
# include <btl4rdr.hpp>
#endif
#if !defined(L4WRHOUS_HPP)
# include <l4wrhous.hpp>
#endif
#if !defined(L4LAMP_HPP)
# include <l4lamp.hpp>
#endif
#if !defined(APP_HPP)
# include <app.hpp>
#endif
#if !defined(MOVER_HPP)
# include <mover.hpp>
#endif
#if !defined(TERRAIN_HPP)
# include <terrain.hpp>
#endif
#if !defined(RESOURCE_HPP)
# include <resource.hpp>
#endif
//
//#############################################################################
// The BT gauge primitive registry (.data @0051c910): every L4GAUGE.CFG
// keyword the BT cockpit adds, chained onto the engine L4MethodDescription
// table so unmatched keywords (bgPixelMap / numeric / rankAndScore / ...)
// fall through to the base widgets. The CHAIN entry MUST stay LAST, and
// every listed methodDescription's Make must be real code -- the
// interpreter assigns opcodes by flattened table index and calls Make at
// Interpret time.
//#############################################################################
//
extern MethodDescription *L4MethodDescription[];
static MethodDescription
BTL4ChainToPrevious = METHOD_DESCRIPTION_CHAIN(L4MethodDescription);
MethodDescription
*BTL4MethodDescription[] =
{
&ColorMapperHeat::methodDescription, // "cmHeat"
&HeadingPointer::methodDescription, // "headingPointer"
&ColorMapperArmor::methodDescription, // "cmArmor"
&ColorMapperMultiArmor::methodDescription, // "colorMapperMultiArmor"
&ColorMapperCritical::methodDescription, // "cmCrit"
&VertTwoPartBar::methodDescription, // "vertBar"
&SegmentArcRatio::methodDescription, // "segmentArcRatio"
&OneOfSeveralPixInt::methodDescription, // "oneOfSeveralPixInt"
&MapDisplay::methodDescription, // "map"
&PlayerStatus::methodDescription, // "PlayerStatus"
&VehicleSubSystems::methodDescription, // "vehicleSubSystems"
&BitMapInverseWipe::methodDescription, // "LeakGauge"
&VertNormalSlider::methodDescription, // "vertNormalSlider"
&PilotList::methodDescription, // "pilotList"
&GeneratorCluster::methodDescription, // "GeneratorCluster"
&SectorDisplay::methodDescription, // "sectorDisplay"
&PrepEngrScreen::methodDescription, // "prepEngr"
&MessageBoard::methodDescription, // "messageBoard"
&BTL4ChainToPrevious
};
//
//#############################################################################
// Construction (binary @004cbea0): the lamp manager, the warehouse, then
// the configuration build -- BuildConfigurationFile parses the ENTIRE
// gauge\l4gauge.cfg to bytecode against the registry and immediately runs
// the cfg's `Initialization` procedure (ports / global gauges, entity ==
// NULL). The per-mech gauges instantiate later via ConfigureForModel
// ("<GameModel>Init") from MakeViewpointEntity.
//#############################################################################
//
BTL4GaugeRenderer::BTL4GaugeRenderer():
L4GaugeRenderer()
{
Check(this);
lampManager = new L4LampManager(
(LBE4ControlsManager *)application->GetControlsManager());
Register_Object(lampManager);
warehousePointer = new L4Warehouse();
Register_Object(warehousePointer);
BuildConfigurationFile("gauge\\l4gauge.cfg", BTL4MethodDescription);
Check_Fpu();
}
//
//#############################################################################
// Destruction (binary @004cbf40): remove every gauge BEFORE the warehouse
// dies (gauge dtors release warehouse resources).
//#############################################################################
//
BTL4GaugeRenderer::~BTL4GaugeRenderer()
{
Check(this);
Remove(0);
if (warehousePointer != NULL)
{
Unregister_Object(warehousePointer);
delete warehousePointer;
warehousePointer = NULL;
}
}
Logical
BTL4GaugeRenderer::TestInstance() const
{
return True;
}
//
//#############################################################################
// The radar feed (binary @004cbfa0 / @004cc028): an interesting entity with
// a gauge-image (pip) resource joins the moving (Mover) or static (Terrain)
// list; everything ALWAYS chains to the base (the engine forwards the
// notification to every live gauge -- "all descendents MUST chain back").
//#############################################################################
//
void
BTL4GaugeRenderer::NotifyOfNewInterestingEntity(Entity *entity)
{
Check(this);
Check(entity);
ResourceDescription *pip =
application->GetResourceFile()->SearchList(
entity->GetResourceID(),
ResourceDescription::GaugeImageStreamResourceType
);
if (pip != NULL)
{
if (entity->IsDerivedFrom(Mover::ClassDerivations))
{
movingEntities.Add(entity);
}
else if (entity->IsDerivedFrom(Terrain::ClassDerivations))
{
staticEntities.Add(entity);
}
}
L4GaugeRenderer::NotifyOfNewInterestingEntity(entity);
}
void
BTL4GaugeRenderer::NotifyOfBecomingUninterestingEntity(Entity *entity)
{
Check(this);
Check(entity);
ResourceDescription *pip =
application->GetResourceFile()->SearchList(
entity->GetResourceID(),
ResourceDescription::GaugeImageStreamResourceType
);
if (pip != NULL)
{
if (entity->IsDerivedFrom(Mover::ClassDerivations))
{
movingEntities.Remove(entity);
}
else if (entity->IsDerivedFrom(Terrain::ClassDerivations))
{
staticEntities.Remove(entity);
}
}
L4GaugeRenderer::NotifyOfBecomingUninterestingEntity(entity);
}