Restore game/sound crash observation + a fix

I’m testing post-comp Six. Last night I saved my game. This morning I restored it (in the latest Gargoyle) and it immediately crashed like this:

[i] [Saved file successfully restored.]

*** fatal error: Reference to nonexistent Glk object. ***[/i]

I had restored it from the game’s front-end menu, so I tried again by typing RESTORE at the parser after starting a new game, and got the same error.

I then took the game to a terp with no sound enabled (Zoom), and found I was able to restore the save.

Then I took it to an old terp with sound support (Spatterlight), and tried to restore, and got the error again.

So I’d learned it was sound-related and not just Gargoyle. I never saw this happen before, and a lot of people have played the game, and none have reported this happening. That suggested it might be something in the new glk spec, but it could equally have been luck.

Then I tried an experiment. I started playing and saved the game while a sound was playing. Then I tried to restore that game. It crashed. I restarted, walked to the same room, let the sound finish playing and saved. I was able to restore from that position.

So it seems if you save while a sound’s playing, when you restore, something akin to the absence of that sound makes it crash. I was able to fix this by adding a rule before any SAVE attempt that stops all audio.

I just put this observation and fix here for anyone using sound (again, next to nobody. Sound remains unpopular :wink:)

This happens if a game has a sound channel open at save (or restore) time, and doesn’t do the appropriate work in GGRecoverObjects() or IdentifyGlkObject() to determine its identity.

The game says it’s using the “Multiple Sounds” extension… I haven’t looked at that to see if it’s doing it right.

Multiple Sounds doesn’t have anything in it to do with save or restore. It just creates channels, plays sounds and changes volumes. My contribution to the extension was the part which adds more channels than the default 2. I’m still pretty proud of that part given that I don’t know any C or i6, hehe.

Mm. Well, your fix is correct in that case – you can’t have a sound playing when you save or restore.

You’ll probably run into the same problem with undo, I’m afraid. (If you undo across an event that starts or stops a sound.)

Thanks for the info.

That’s interesting about Undo - it has always worked fine, and with no extra programming from me. I observed that it immediately cuts any sounds playing when you do it, but I was okay with that. And it’s never caused a crash.

Edit - For safety, I hooked into Undo and added manual sound stopping before all Undos.

You should probably add a record-scratching sound for good measure. :slight_smile:

Hehehe!