Skip to content

Commit f5c60e7

Browse files
marthofdoomclaude
andcommitted
DIAG v14 (EQSND): unconditional [diag-init] log at Init+0x113 + [diag-mark] handle dump
v13 muted 0x. Discriminate A (site never fires for the hum) vs B (fires but gate false): log EVERY BuildSound call from ShaderReferenceEffect::Init+0x113 with the ambient SNDR FormID (a_desc-0x20), the EFSH FormID, worn base FormID, target handle, and whether the mute gate would trip. Dump stamped actor handles at MarkReequippedRef to compare against the target handles the thunk sees. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent e65603b commit f5c60e7

1 file changed

Lines changed: 45 additions & 3 deletions

File tree

native/plugin.cpp

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,16 @@ static void MarkReequippedRef(RE::Actor* a_actor) {
257257
if (h == 0) {
258258
return;
259259
}
260+
// DIAG v14: dump the stamped handle so we can compare it against the
261+
// fx->target handle the Init+0x113 thunk sees (age-bit / wrong-ref mismatch?).
262+
{
263+
static std::atomic<int> dm{ 0 };
264+
const int n = dm.fetch_add(1, std::memory_order_relaxed) + 1;
265+
if (n <= 40) {
266+
spdlog::info("[diag-mark #{}] actor={:08X} handle={:08X}",
267+
n, a_actor->GetFormID(), h);
268+
}
269+
}
260270
const std::uint64_t now = NowMs();
261271
const std::uint64_t until = now + kMuteWindowMs;
262272
MutedRef* slot = nullptr;
@@ -5804,6 +5814,7 @@ namespace sndhook {
58045814
RE::BSISoundDescriptor*, std::uint32_t);
58055815
static inline REL::Relocation<BuildSoundFn> g_buildSound;
58065816
static std::atomic<int> g_muted{ 0 }; // count for the log
5817+
static std::atomic<int> g_diag{ 0 }; // DIAG v14: unconditional call log
58075818

58085819
// ShaderReferenceEffect::soundHandle offset (RE/S/ShaderReferenceEffect.h: "0C0").
58095820
// Hardcoded rather than offsetof() — the type is polymorphic (non-standard-layout).
@@ -5814,11 +5825,42 @@ namespace sndhook {
58145825
// rdx points at effect->soundHandle (member 0xC0); recover the effect.
58155826
auto* fx = reinterpret_cast<RE::ShaderReferenceEffect*>(
58165827
reinterpret_cast<std::uintptr_t>(a_handle) - kSoundHandleOffset);
5817-
if (fx && fx->wornObject && IsRefMuted(fx->target.native_handle())) {
5828+
5829+
// ── DIAG v14: log EVERY call to this exact site, unconditionally. ──
5830+
// This is the discriminator: if the enchanted-weapon hum passes through
5831+
// ShaderReferenceEffect::Init+0x113 we WILL see its ambient SNDR / EFSH
5832+
// FormID here (path B — a gate bug); if the hum plays and NOTHING with an
5833+
// enchant SNDR ever appears in this log, the hum uses a different emitter
5834+
// (path A — widen next build). We log the descriptor's owning SNDR form
5835+
// (the engine passed r8 = &BGSSoundDescriptorForm::BSISoundDescriptor, i.e.
5836+
// form+0x20, so form = a_desc - 0x20), the effect's EFSH FormID, the worn
5837+
// base object, the target handle, and whether the gate would fire.
5838+
const std::uint32_t tgtHandle = fx ? fx->target.native_handle() : 0;
5839+
const bool muted = fx && fx->wornObject && IsRefMuted(tgtHandle);
5840+
{
5841+
const int n = g_diag.fetch_add(1, std::memory_order_relaxed) + 1;
5842+
if (n <= 60) { // bounded
5843+
RE::FormID sndrID = 0;
5844+
if (a_desc) {
5845+
auto* form = reinterpret_cast<RE::BGSSoundDescriptorForm*>(
5846+
reinterpret_cast<std::uintptr_t>(a_desc) - 0x20);
5847+
sndrID = form->GetFormID();
5848+
}
5849+
const RE::FormID efshID = (fx && fx->effectData) ? fx->effectData->GetFormID() : 0;
5850+
const RE::FormID wornID = (fx && fx->wornObject) ? fx->wornObject->GetFormID() : 0;
5851+
spdlog::info(
5852+
"[diag-init #{}] fx={} SNDR={:08X} EFSH={:08X} worn={:08X} "
5853+
"target={:08X} refMuted={}",
5854+
n, static_cast<void*>(fx), sndrID, efshID, wornID, tgtHandle,
5855+
muted ? 1 : 0);
5856+
}
5857+
}
5858+
5859+
if (muted) {
58185860
const int n = g_muted.fetch_add(1, std::memory_order_relaxed) + 1;
58195861
if (n <= 24) { // bounded confirmation log
58205862
spdlog::info("[snd] enchant-shader hum muted (ref#{:08X}) — MEO re-equip",
5821-
fx->target.native_handle());
5863+
tgtHandle);
58225864
}
58235865
return false; // engine's own no-ambient-sound path; glow still attaches
58245866
}
@@ -5848,7 +5890,7 @@ namespace sndhook {
58485890
return;
58495891
}
58505892
g_buildSound = SKSE::GetTrampoline().write_call<5>(site, BuildSoundThunk);
5851-
spdlog::info("[snd] enchant-shader hum gate installed (ShaderReferenceEffect::Init->BuildSound)");
5893+
spdlog::info("[snd] DIAG v14 enchant-shader hum probe installed (ShaderReferenceEffect::Init->BuildSound) — unconditional [diag-init] logging");
58525894
}
58535895
} // namespace sndhook
58545896

0 commit comments

Comments
 (0)