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
+48
View File
@@ -102,6 +102,54 @@ void
{
(this->*handler)(what);
}
else
{
//
// UNHANDLED-MESSAGE TRACE (input-path audit, systemic cause #1).
//
// A message with no handler was dropped here in complete silence -- no log,
// no counter -- and a DEFAULT-CONSTRUCTED `MessageHandlerSet` has
// entryCount 0 and no parent chain, so it swallows EVERY id. That is how
// the Avionics power bank (108 streamed records: 6 cockpit buttons + keys
// F5-F9), the searchlight toggle, the thermal sight, the crouch button and
// all four generator ON/OFF buttons were dead for months while looking
// perfectly wired. This trace is the standing guard for the whole class:
// one line per (class, message id) pair, first occurrence only, so a newly
// dead control announces itself on the first boot instead of waiting for a
// player report.
//
// Deliberately once-per-pair: some ids are broadcast every frame, and this
// must never become a per-frame log.
//
static const int kMaxSeen = 64;
static struct { const char *name; int id; } seen[kMaxSeen];
static int seenCount = 0;
Derivation *derivation = sharedData->derivedClasses;
const char *class_name = (derivation != 0 && derivation->className != 0)
? derivation->className : "<unnamed receiver>";
const int id = (int)what->messageID;
int known = 0;
for (int i = 0; i < seenCount; ++i)
{
if (seen[i].id == id && seen[i].name == class_name)
{
known = 1;
break;
}
}
if (!known && seenCount < kMaxSeen)
{
seen[seenCount].name = class_name;
seen[seenCount].id = id;
++seenCount;
DEBUG_STREAM << "[msg] UNHANDLED: " << class_name
<< " has no handler for message id " << id
<< " -- silently dropped (is its MessageHandlerSet chained?)"
<< std::endl;
}
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~