adventuregamestudio / ags

AGS editor and engine source code
Other
697 stars 160 forks source link

MAGICNUMBER not found before Audio Clips. #2182

Closed Crystal-Shard closed 1 year ago

Crystal-Shard commented 1 year ago

Describe the bug I'm in the process of upgrading A Tale of Two Kingdoms from AGS 3.3 to 3.6. In the new build, I get the following error when restoring a saved game. I'm not sure what this even means. Error: Unable to restore the saved game. Inconsistent format, or file is corrupted. MAGICNUMBER not found before Audio Clips.

AGS Version 3.6.0.52 legacysave_assume_dataver=43 and legacysave_let_gui_diff=1 are set.

Game A Tale of Two Kingdoms (I'll send you my current build over PM)

To Reproduce Steps to reproduce the behavior:

  1. Restore this saved game: agssave.043.atotk.zip
  2. See error

Expected behavior The saved game is restored.

Desktop (please complete the following information): Windows 11

ivan-mogilko commented 1 year ago

The last check before the GUI's "magic number" is the number of Views. This check passes, which means that number of views in saves and game matches, but also that format mismatch happens somewhere in between.

This could only be during reading views. Unfortunately the save does not make any checks for loop and frame counts. Have you by any chance change a number of loops or frames in this game?

I think i had the old version of this game somewhere, but I cannot remember what version it was, and whether this save will work there to make a test.

Crystal-Shard commented 1 year ago

The old version is on Steam, I'm pretty sure I've given you a key years ago.

Let me check what I did with views.

Crystal-Shard commented 1 year ago

Yes that's actually it. There was a rarely-used walk view used for goblin disguise, and the standard walk view has a few animations (e.g. pick up item) in it. So picking up things while disguised would crash, and I fixed that by adding a few loops with existing sprites.

...I can undo that easily, and add code to play animation unless in goblin view.

ivan-mogilko commented 1 year ago

I will adjust the error message to something easier to understand.

Crystal-Shard commented 1 year ago

Ok, here's a weird one...

It turns out that the AGS3.3 version had a reference to Music42.ogg which did not exist, and wasn't played anywhere either. Importing this to AGS3.6 will quietly remove this reference from the list of audio clips (this probably shouldn't happen). Loading a saved game will fail if the number of audio clips doesn't match (I'm not sure why this check is imporant). So after fixing the above issue, I ran into this one. I have fixed this by creating a Music42.ogg file and manually re-inserting it in game.agf and that seems to work.

ivan-mogilko commented 1 year ago

Loading a saved game will fail if the number of audio clips doesn't match (I'm not sure why this check is imporant).

This is a mistake on engine's side. I just noticed and fixed it too. The temp build is available here: https://cirrus-ci.com/task/5304763974156288

The only issue is to keep clip IDs in a correct order.

Importing this to AGS3.6 will quietly remove this reference from the list of audio clips (this probably shouldn't happen).

I also do not think that this is supposed to happen...

Crystal-Shard commented 1 year ago

This is a mistake on engine's side. I just noticed and fixed it too. The temp build is available here: https://cirrus-ci.com/task/5304763974156288

That doesn't help; I now get

Error: Unable to restore the saved game.
Game object initialization failed after save restoration.
Invalid audio clip index.
ivan-mogilko commented 1 year ago

Sigh, I should add a clip index information to let diagnose this.

But of course, if the clip was removed from the middle, or added into the middle, then the IDs could shift, and some of the current playback would reference mismatching ID.

Crystal-Shard commented 1 year ago

It's weird. With the previous build (which is the one from #2161 ) restoring does work if I manually put the audio clip in game.agf. With the build you just posted here, it appears to work neither with nor without the audio clip in game.agf.

ivan-mogilko commented 1 year ago

I made a mistake and broken the save format.

Is it possible to have a build which does not have extra view frames, so I could test the working saves on it?

Crystal-Shard commented 1 year ago

Sure, check your inbox. This build has the audio clip added and it seems to work fine.

ivan-mogilko commented 1 year ago

The new build is here: https://cirrus-ci.com/task/5949274081460224

Crystal-Shard commented 1 year ago

Yes, that works (with the music file NOT added to game.agf)