Input-audit cause #1: revive the Avionics power bank + add the unhandled-message trace

THE CLASS OF BUG.  A default-constructed Receiver::MessageHandlerSet is a total
blackhole: entryCount 0 and NO parent chain, so Find() returns NullHandler for
every id and Receiver::Receive dropped the message with no log, no counter,
nothing.  docs/INPUT_PATH_AUDIT.md ranked this systemic cause #1; running its own
lint finds SEVEN such sets (Sensor, Searchlight, ThermalSight, Gyroscope,
MechTech, SubsystemMessageManager, Torso).  It is also why generators cannot be
switched off (#53) -- same shape.

FIX 1 -- Sensor / Avionics (the big one).  The streamed mappings aim 108 records
across the 18 mechs at it: the MFD2 ENG1 power bank, 6 clickable buttons plus keys
F5-F9 (route Avionics power to generators A-D, gen mode, coolant cut).  All
silently swallowed.  Sensor needed NO handlers of its own -- ids 4-8 already live
on PoweredSubsystem, which chains HeatSink for id 3, covering the whole 3-8 range
those buttons send.  It only ever needed to CHAIN, which is exactly why the
byte-identical bank on ENG2 works (Myomers chains, myomers.cpp:88-100; Sensor did
not).  Added Sensor::GetMessageHandlers() with the same function-local-static
idiom and pointed DefaultData at it instead of the empty set.

VERIFIED LIVE (scratchpad/avionics.py -- pages MFD2 and presses the bank):
  [gensel] Avionics -> GeneratorA (tapped)   ... B, C, D
  [gensel] Avionics mode -> 2
i.e. Avionics now behaves exactly like Myomers.  24 handler hits, 0 unhandled.

FIX 2 -- the standing guard.  Receiver::Receive now logs once per (class,
message id) pair when no handler is found: '[msg] UNHANDLED: <class> has no
handler for message id N -- silently dropped (is its MessageHandlerSet chained?)'.
Once-per-pair on purpose, since some ids broadcast every frame.  This one line
would have printed Avionics, Searchlight, ThermalSight, crouch and all four
generator buttons on the first boot instead of costing us months of player
reports.  Uses SharedData::derivedClasses -> Derivation::className.

DEFERRED, with reasons (not guessed at): Searchlight's ToggleLamp body exists but
is unreachable -- it needs a correctly-typed forwarder (Receiver::Handler is
void(const Message*); ToggleLamp is Logical(Message&), so a cast would be UB that
happens to work on x86) AND an id check, because its id 3 collides with HeatSink's
ToggleCooling and I have not traced whether PowerWatcher's chain reaches HeatSink.
#53 needs more than chaining: ToggleGeneratorOnOff @004b1ed0 has no body at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0166KTsC7ADm7VXEi1HF1jNg
This commit is contained in:
arcattack
2026-07-25 10:05:57 -05:00
co-authored by Claude Opus 5
parent 5bbe070e9d
commit 33ca99eb69
4 changed files with 172 additions and 1 deletions
+28 -1
View File
@@ -100,6 +100,33 @@ Derivation
"Sensor"
);
//
// MESSAGE HANDLERS (Gitea #53 family / input-path audit systemic cause #1).
//
// This was a DEFAULT-CONSTRUCTED `MessageHandlerSet`, which is a total blackhole:
// it has `entryCount = 0` and **no parent chain**, so `Find()` returns
// `NullHandler` for every id (`engine/MUNGA/RECEIVER.h`), and `Receiver::Receive`
// drops the message with no log, no warning and no counter. The Sensor is the
// cockpit's **"Avionics"** subsystem, and the streamed control mappings aim
// **108 records across the 18 mechs** at it -- the MFD2 ENG1 page's power bank
// (6 clickable buttons, keys F5-F9): route Avionics power to generator A-D, gen
// mode, coolant cut. Every one of them was silently swallowed.
//
// Sensor needs NO handlers of its own -- those ids (4-8) already exist on
// `PoweredSubsystem`. It only ever needed to CHAIN, which is exactly why the
// byte-identical bank on ENG2 works: Myomers chains (myomers.cpp:88-100) and
// Sensor did not. Same idiom, function-local static so construction order is
// safe.
//
Receiver::MessageHandlerSet&
Sensor::GetMessageHandlers()
{
static Receiver::MessageHandlerSet messageHandlers(
0, 0, // no ids of its own
PoweredSubsystem::GetMessageHandlers()); // copy-inherit ids 4-8
return messageHandlers;
}
Receiver::MessageHandlerSet
Sensor::MessageHandlers;
@@ -130,7 +157,7 @@ Sensor::AttributeIndexSet
Sensor::SharedData
Sensor::DefaultData(
&Sensor::ClassDerivations,
Sensor::MessageHandlers,
Sensor::GetMessageHandlers(), // was the EMPTY MessageHandlers (blackhole)
Sensor::AttributeIndex,
Sensor::StateCount
);