reimplement: SHC_3BB0A8C1_0x00479F30 100%#82
Conversation
|
Took 1 minute on Claude using the repo's mcp tools! Essentially, the reference to ClaudeNow I can see the issue. The
The do-while loop starts So the clean version: loop Let me verify by checking the diff first, then write the fix:Now let me compile the cleaned-up version:Compiled successfully. Now let's check the assembly diff:The diff shows Here's a summary of what changed and why it works: Before (decompiler artifact pattern): int* piVar1 = this->sampleSoundIndex_0x20c + 1;
unsigned int iVar3 = 32;
do {
AIL_end_sample((HSAMPLE)piVar1[-0x20]); // negative index: -32 from piVar1[1] = sample_0x190[i]
*piVar1 = 0; // sampleSoundIndex_0x20c[i+1]
piVar1 = piVar1 + 1;
iVar3 = iVar3 + -1;
} while (iVar3 != 1); // runs 31 timesAfter (clean equivalent): for (int i = 0; i < 31; ++i) {
AIL_end_sample(this->sample_0x190[i]);
this->sampleSoundIndex_0x20c[i + 1] = 0;
}The key insight is that |
gynt
left a comment
There was a problem hiding this comment.
for (int i = 0; i < 31; ++i) {
AIL_end_sample(this->sample_0x190[i]);
this->sampleSoundIndex_0x20c[i + 1] = 0;
}|
Ha, stupid me ignoring that |
0159646 to
fd41d7b
Compare
I really hate this one. This part here:
Does not make much sense. It is actually something along these lines:
Something caues MSVC to anchor to
this->sampleSoundIndex_0x20c + 1in the original binary and I have no idea why. If someone has a stronger AI model available, be my guest.What is clear: No sane person would write code like what is currently fitting. So something is off: The function structure, the struct types, something else.
I really which to know what really can prompt the compiler to do this.
Should I prefer the more matching or the more readable version?