AdmiralCurtiss / SenPatcher

Fixes and customizations for the Trails of Cold Steel games on Windows.
Other
88 stars 6 forks source link

Tokyo Xanadu: Audio resume bug #144

Open AdmiralCurtiss opened 1 month ago

AdmiralCurtiss commented 1 month ago

The PC version of Tokyo Xanadu has a very strange bug where it appears to remember the last position of an audio track and will resume it there when it next encounters a request to play that audio track, regardless of if the game intended to resume the track or restart it from the beginning. Figure out what causes this and make it behave like intended (ie, like Vita/PS4/Switch) instead.

AdmiralCurtiss commented 3 weeks ago

After tracing this for a bit, I'm pretty sure the culprit is 0x447037. The function gets the (correct) offset to play the track at in [ebp+0xc] and that branch here completely ignores it, and if you compare with the same function in CS2 (0x4229f0) that branch isn't there at all.

(which, yes, means that they seem to have managed to desync the offset the game thinks it's playing music at with the actual offset it's playing music at. fun)

The function call there leads to 0x409270, a method on prOggFile. So I think what's happening is that the game's file caching layer reuses the prOggFile objects without resetting them properly, or something along those lines?

AdmiralCurtiss commented 3 weeks ago

Okay yeah I think the 'right' solution, which is a pain in the ass really, is to add an extra parameter to 0x409270 (and since this is a virtual function, all other related methods, which I think is only 0x41be20 on prWavFile) with the expected offset to play (which the engine does properly keep track of as far as I can see), and then in that function compare the expected offset with the real offset and re-sync the playback if it doesn't match...