Audio: in-game TRIGGERING works -- real StateIndicator attrs + audio-watcher databinding (task #50)
Enabling audio unlocked L4AudioRenderer::CreateEntityAudioObjects, which binds AudioStateWatchers to entity/subsystem state attrs BY NAME (attribute-pointer databinding) and calls AddAudioWatcher on them. The reconstruction pointed the Mech's state attrs at the scalar read-pad `attrPad` (fine for gauges that READ a value, fatal for a state watcher that calls a METHOD) -> AV in SChainOf::Add on 0xCDCDCDCD. Root-caused via cdb + a BT_ATTRBIND_LOG trace in AttributeWatcher. Mech-level state audio now REAL + driven (verified: walking fires SetupPatch + PlayNote/alSourcePlay, patches 78/80/116): - AnimationState (0x1f) / ReplicantAnimationState (0x20): real StateIndicators (0x21 states covering MechAnimationState 0..0x20), driven from SetBodyAnimation so footstep/gait/transition sounds fire on animation change. - CollisionState (0x16): real 4-state StateIndicator driven from ProcessCollision via collisionTemporaryState (the deferred @4aa741 per-frame zero + the part_012.c:15406-15413 contact tail, InitialHit accumulation; the 1-vs-2 Slide split awaits the 0x240/0x244 floats still stubbed by fieldAt()). - @0x44c CORRECTED: "ammoState (0/1 leaking/2 dry)" was a mislabel -> it is collisionTemporaryState (never read as ammo). Bring-up guards [T3, temporary, self-clearing] so audio-on is STABLE while the subsystem state models are still stubs (Generators/Condensers/Myomers/Torso/ Avionics/Reservoir/ControlsMapper -- ~15 subsystems, ~40 attrs: GeneratorState, CondenserState, ReportLeak, ...): a NULL subsystem attr redirects to an inert pad (was a fatal Fail); an AudioStateWatcher on an unconstructed StateIndicator (null/ 0xCDCDCDCD) skips instead of AV. Both pass automatically once the subsystem is reconstructed. Those subsystem sounds stay silent until then (their audio wave). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
c75abca857
commit
7b1e469ffa
@@ -1,3 +1,4 @@
|
||||
#include <cstdlib>
|
||||
#include "munga.h"
|
||||
#pragma hdrstop
|
||||
|
||||
@@ -873,6 +874,26 @@ AudioStateWatcher::AudioStateWatcher(
|
||||
AudioWatcherOf<StateIndicator>(stream, entity)
|
||||
{
|
||||
Check_Pointer(attributePointer);
|
||||
// BRING-UP GUARD [T3, temporary]: an AudioStateWatcher binds to a StateIndicator
|
||||
// attribute BY NAME. The Mech's own state indicators (SimulationState, Animation/
|
||||
// ReplicantAnimationState, CollisionState) are real; but audio also binds state
|
||||
// attrs on subsystems that are not fully reconstructed yet (GeneratorState,
|
||||
// CondenserState, Torso MotionState, ...). Those resolve to an unconstructed
|
||||
// object -- a null/garbage vtable at +0 or a debug-fill (0xCDCDCDCD) watcher chain
|
||||
// at +0x18 -- and AddAudioWatcher would AV in SChainOf::Add. Skip the register
|
||||
// (that subsystem's state audio stays silent) until the subsystem is built; this
|
||||
// is SELF-CLEARING (a real StateIndicator passes). See docs: audio subsystem wave.
|
||||
{
|
||||
unsigned vt = *(unsigned*)attributePointer;
|
||||
unsigned chain = *(unsigned*)((char*)attributePointer + 0x18);
|
||||
if (vt == 0 || vt == 0xCDCDCDCD || chain == 0xCDCDCDCD)
|
||||
{
|
||||
if (getenv("BT_AUDIO_LOG"))
|
||||
DEBUG_STREAM << "[audiostate] skip watcher on unbuilt StateIndicator "
|
||||
<< attributePointer << " (vt=" << (void*)vt << ")\n" << std::flush;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Cast_Object(StateIndicator*, attributePointer)->AddAudioWatcher(this);
|
||||
}
|
||||
|
||||
|
||||
+26
-15
@@ -1,3 +1,4 @@
|
||||
#include <cstdlib>
|
||||
#include "munga.h"
|
||||
#pragma hdrstop
|
||||
|
||||
@@ -95,21 +96,31 @@ AttributeWatcher::AttributeWatcher(
|
||||
|
||||
attributePointer = simulation->GetAttributePointer(attribute_name);
|
||||
|
||||
#if DEBUG_LEVEL>0
|
||||
if (attributePointer == NULL)
|
||||
{
|
||||
Dump(attribute_name);
|
||||
}
|
||||
#else
|
||||
if (attributePointer == NULL)
|
||||
{
|
||||
DEBUG_STREAM <<
|
||||
"AttributeWatcher::AttributeWatcher - attribute " <<
|
||||
attribute_name <<
|
||||
"\n";
|
||||
Fail("AttributeWatcher::AttributeWatcher - attribute not found\n");
|
||||
}
|
||||
#endif
|
||||
if (getenv("BT_ATTRBIND_LOG"))
|
||||
{
|
||||
DEBUG_STREAM << "[attrbind] subsys=[" << subsystem_name
|
||||
<< "] attr=[" << attribute_name << "] -> ptr=" << attributePointer
|
||||
<< " vtbl=" << (attributePointer ? *(void**)attributePointer : (void*)0)
|
||||
<< "\n" << std::flush;
|
||||
}
|
||||
|
||||
// BRING-UP GUARD [T3, temporary]: audio references attributes on subsystems that
|
||||
// are not fully reconstructed yet (GeneratorState/On, CondenserState, ReportLeak,
|
||||
// Torso SpeedOfTorsoHorizontal/MotionState, Reservoir/Avionics/ControlsMapper ...).
|
||||
// GetAttributePointer returns NULL for those, and the original engine Fail()s
|
||||
// (fatal) -- which would abort every audio-enabled run. Redirect NULL to a shared
|
||||
// inert zero pad so scalar/vector watchers read 0 (that sound stays silent) instead
|
||||
// of crashing; state watchers on it are skipped by the AudioStateWatcher guard.
|
||||
// Self-clearing: a registered attribute resolves to its real member. Remove once
|
||||
// the subsystem attribute tables are reconstructed (the audio subsystem wave).
|
||||
if (attributePointer == NULL)
|
||||
{
|
||||
static char s_missingAttrPad[64] = {0};
|
||||
if (getenv("BT_AUDIO_LOG"))
|
||||
DEBUG_STREAM << "[attrnull] " << subsystem_name << "." << attribute_name
|
||||
<< " not reconstructed -> inert pad\n" << std::flush;
|
||||
attributePointer = s_missingAttrPad;
|
||||
}
|
||||
|
||||
Check_Pointer(attributePointer);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user