Fix 2 (Gitea #12): gauge tree survives the in-session mech re-stream

The pre-launch host drop/rejoin re-stream re-creates every mech at mission
launch; the LOBBY-built gauge tree kept attribute pointers into the freed
first-stream mechs, every widget Execute AV'd, and the BT_DEV_GAUGES SEH
guard (Gauge::GuardedExecute, GAUGE.cpp:618) disabled each one PERMANENTLY
(rate=0, no rebind) -- the frozen dev-gauges window of incident #12.  The
authentic engine flow only tears the tree down at mission transitions
(Application::Shutdown -> gaugeRenderer->Shutdown() -> ShutdownImplementation
-> Remove(0), APP.cpp:787 / GAUGREND.cpp:3264); the re-stream bypassed it.

Fix: BTL4GaugeRenderer::TearDownForViewpointRestream() performs the
ENTITY-BOUND half of that same ShutdownImplementation sequence, in order
(gaugeAlarmManager->RemoveAllAlarms() -> Remove(0) -> moving/static entity
grid Clear), keeping the mission-scoped state (warehouse, graphics ports,
interpreter, controls-owned L4Lamps -- RemoveAllLamps would delete them
behind the buttonGroup's &lamp->automaticValue registrations).  Called from
BTL4Application::MakeViewpointEntity before ConfigureForModel("Init") on any
viewpoint RE-make -- that handler runs once per stream (the incident log's
[ctrlmap] installing x2) -- so the tree rebuilds bound to the NEW mech via
the renderer's existing lazy build.  Sentinel: "[gauge] viewpoint re-stream:
tearing the gauge tree down for rebuild".

Verified with the 2-instance relay harness (port 15600, MP_RELAY.EGG,
the incident sequence): join A (dev gauges) + B, kill B by exact PID at
WAITING FOR OPERATOR LAUNCH, rejoin B, operator launch.  Pod A re-streamed
(2x ctrlmap install, 4x zonebuild), logged the sentinel, and post-launch the
docked composite is fully live (mission clock/heading/radar advancing between
BT_SHOT frames) with ZERO [gauge-fault] DISABLED lines (the incident had 11).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
arcattack
2026-07-19 23:30:43 -05:00
co-authored by Claude Fable 5
parent 2edde29671
commit 0d032029a0
5 changed files with 124 additions and 23 deletions
+25
View File
@@ -697,6 +697,31 @@ BTL4Application::SharedData
<< (int)(gauge_renderer != NULL) << " -> ConfigureForModel(Init)\n" << std::flush;
if (gauge_renderer != NULL)
{
//
// GAUGE-TREE SURVIVAL ACROSS THE IN-SESSION RE-STREAM (Gitea #12 fix):
// when the mechs are RE-CREATED pre-launch (host drop/rejoin re-stream),
// this handler runs AGAIN for the new viewpoint mech -- but the
// lobby-built gauge tree still holds attribute pointers into the FREED
// first-stream mech; every widget then faults and the BT_DEV_GAUGES SEH
// guard disables it permanently (GAUGE.cpp:618) = the frozen dev-gauges
// window. The engine's own transition path is the Shutdown teardown
// (Application::Shutdown -> gaugeRenderer->Shutdown() -> Remove(0),
// APP.cpp:787 / GAUGREND.cpp:3264) followed by a lazy rebuild; the
// re-stream bypasses it. So: tear the entity-bound tree down HERE
// (alarms + gauges + entity grids -- see TearDownForViewpointRestream)
// and let the ConfigureForModel below rebuild it against THIS mech.
// A no-op on the first (lobby) build.
//
static int s_gaugeTreeBuilt = 0;
if (s_gaugeTreeBuilt)
{
DEBUG_STREAM << "[gauge] viewpoint re-stream: tearing the gauge tree "
"down for rebuild on entity " << (void *)viewing_entity
<< "\n" << std::flush;
gauge_renderer->TearDownForViewpointRestream();
}
s_gaugeTreeBuilt = 1;
gauge_renderer->ConfigureForModel("Init", viewing_entity); // FUN_0046ff64
}
+44
View File
@@ -73,6 +73,7 @@
#if !defined(L4LAMP_HPP)
# include <l4lamp.hpp>
#endif
#include <GAUGALRM.hpp> // GaugeAlarmManager (TearDownForViewpointRestream, Gitea #12)
#if !defined(L4WARE_HPP)
# include <l4ware.hpp>
#endif
@@ -269,6 +270,49 @@ Logical
return GaugeRenderer::TestInstance(); // FUN_00447b60
}
//
//#############################################################################
// TearDownForViewpointRestream (PORT FIX -- Gitea #12)
//#############################################################################
//
// The in-session mech RE-STREAM (a pre-launch host drop/rejoin re-creates all
// mechs at mission launch) frees the mech the LOBBY-built gauge tree was bound
// to; every gauge Execute then AVs on its dangling attribute pointers and the
// BT_DEV_GAUGES SEH guard (Gauge::GuardedExecute, GAUGE.cpp:618) disables each
// one PERMANENTLY (rate=0, nothing rebinds) -- the frozen dev-gauges window of
// incident #12. The AUTHENTIC engine flow only tears the tree down at mission
// transitions (Application::Shutdown -> gaugeRenderer->Shutdown() ->
// ShutdownImplementation -> Remove(0), APP.cpp:787 / GAUGREND.cpp:3264); the
// re-stream path bypasses it. This method performs the ENTITY-BOUND half of
// that same ShutdownImplementation sequence, in the same order:
// gaugeAlarmManager->RemoveAllAlarms() (alarms hold entity/subsystem ptrs)
// Remove(0) (delete every gauge, active+inactive)
// movingEntities/staticEntities.Clear() (raw Entity* grids for radar/map)
// and deliberately SKIPS the mission-scoped steps -- warehouse purge, graphics
// port destruction, lampManager->RemoveAllLamps() (the L4Lamps are owned by the
// CONTROLS layer, which registers &lamp->automaticValue into its buttonGroup --
// deleting them mid-session would dangle the button mappings; the mech-state
// "lamps" like AnimatedSubsystemLamp are Gauges and go with Remove(0)). The
// caller (MakeViewpointEntity) immediately re-runs ConfigureForModel("Init",
// <new mech>) against the still-initialized interpreter/warehouse, so the tree
// rebuilds bound to the NEW mech -- the gauge renderer builds lazily by design.
//
void
BTL4GaugeRenderer::TearDownForViewpointRestream()
{
Check(this);
if (gaugeAlarmManager != NULL)
{
Check(gaugeAlarmManager);
gaugeAlarmManager->RemoveAllAlarms();
}
Remove(0); // FUN_00447fc0(this, 0) -- all gauges
movingEntities.Clear();
staticEntities.Clear();
Check_Fpu();
}
//
//#############################################################################
// NotifyOfNewInterestingEntity
+17
View File
@@ -54,6 +54,23 @@
NotifyOfNewInterestingEntity(Entity *entity);
void
NotifyOfBecomingUninterestingEntity(Entity *entity);
//
// PORT FIX (Gitea #12 -- NOT in the surviving 1995 header): tear the
// built gauge tree down when the viewpoint mech is RE-STREAMED
// in-session (pre-launch host drop/rejoin re-creates every mech; the
// lobby-built tree's attribute pointers dangle and each widget is
// permanently DISABLED by the BT_DEV_GAUGES SEH guard, GAUGE.cpp:618).
// Performs the entity-bound half of the engine's mission-transition
// teardown (GaugeRenderer::ShutdownImplementation, GAUGREND.cpp:3264):
// alarms + all gauges + the entity grids. Warehouse / graphics ports /
// interpreter / controls lamps stay -- entity-independent, reused by
// the immediate ConfigureForModel rebuild. Called from
// BTL4Application::MakeViewpointEntity before ConfigureForModel;
// a no-op on the first (lobby) build.
//
void
TearDownForViewpointRestream();
};