"Two newroom requests" crash when savegame reloaded [SOLVED]

Started by paolo, Wed 26/06/2013 20:10:24

Previous topic - Next topic

paolo

I've got a bug in my code that I'm not sure how to fix.

At various critical places in the game I automatically save the game to give the user a "safe point" to reload if they mess up so that they can try again. One of these automatic saves is in a block of code in dialog_request(), and works more or less like this:

function dialog_request(int index)
{
    [...]
    else if (index == 17)
    {
        //check whether all dialog options have been used
   if (dialogComplete)
   {
            StopDialog();
            [...]    //conversation between characters
            warnOfDanger();    <--- safe point is set here
            [...]    //conversation between characters
   }
    }
}

The crash happens when the following takes place:

* Player completes dialog and the above code is executed
* Player messes up and gets killed
* Room changes to another playing an ending
* Room changes to a blank room that displays a "Try again/Restart/Quit" GUI
* Player clicks "Try again"
* The safe point is restored
* Player plays on
* Room changes eventually (either because they get killed again or are successful)
Crash at this point

Note that I test whether the dialog is complete and stop it myself so that the last dialog option can be displayed by itself in the dialog.

I'm aware that StopDialog() is executed at the end of the request, but I'm puzzled why the crash is happening because it doesn't happen when the room changes after the player was successful first time round. The safe point is saved using SaveGameSlot(100, "#SAFE POINT#"); and restored with RestoreGameSlot(100); Surely the game should continue from where it left off?

Crimson Wizard

Hi paolo.
What version of AGS do you use?
Is there any window displayed with an error message when the crash occurs?

paolo

Thanks for replying, Crimson Wizard. Yes, I get an error dialog with the error I mention. I'm using v2.71. I'll edit this post later with more details.

EDIT: further details after Khris's post below.

Khris

Here's a careful guess:

SetRestartPoint() gets queued, and is only executed after a RoomChange got queued, but not executed.
A game with a pending room change is saved, but the queue state isn't saved with it.
When the game is restored, and another room change gets queued, the queue is activated, and at this point there are now two room changes in the queue -> crash.

Plausible?

Also: 2.71...!?

paolo

Actually, I checked - it's 2.72. My game's been in development for a long time, so shoot me :)

Here's the full error message, for what it's worth:

----
An error has occured. Please contact the game author for support, as this is likely to be a scripting error and not a bug in AGS. (ACI version 2.72.920)

in Global script (line 10748)

Error: NewRoom: two NewRoom/RunDialog/StopDialog requests within dialog
----

Line 10748 is the line with the call to ChangeRoom().

Khris, that makes sense. I thought it might be something like that. I thought the entire state of the game was saved in the save game. Note however that while the saving of the game is done in dialog_request(), the room change is not. Any subsequent room change, however, causes the crash (whether to the room that plays out the epilogue when the player dies, or the next room in the game if the player is successful).

So is there a way round this? Can I remove one of the room changes from the queue manually, or prevent the first from being added? Or is the fact that the queue is not saved an AGS bug, possibly?

And a secondary question (which maybe belongs in a separate post) - I also have AGS v3.0 installed. I know there is a lot to gain in using 3.0, but what are the risks in updating my game from 2.72 to 3.0? Is anything likely to break?

PS: An answer to Kimberley's question: Yes, Kimberley, you can do this. First print your image. Then, while the ink is still wet, use chromatography to separate the ink into its component colours. Then, with a tissue, mop up the colours you don't need. This will be tricky, but it should work if you're careful enough. Good luck!

Crimson Wizard

Quote from: paolo on Fri 28/06/2013 07:52:19
And a secondary question (which maybe belongs in a separate post) - I also have AGS v3.0 installed. I know there is a lot to gain in using 3.0, but what are the risks in updating my game from 2.72 to 3.0? Is anything likely to break?
There's a whole section of manual dedicated to upgrading from 2.7 to 3.+:
http://www.adventuregamestudio.co.uk/wiki/Upgrading_to_AGS_3.0
http://www.adventuregamestudio.co.uk/wiki/Upgrading_to_AGS_3.1
also one about upgrading to 3.2 (but it is not present in website wiki, so check the manual that comes with AGS 3.2)
However, there are project settings that enable backwards compatible mode (related to script mainly) and make things easier. You probably won't have to change much.

paolo

Thanks for the links. I knew they were around somewhere but wasn't sure where. It's good to see that hardly anything has changed scripting-wise. Time to take the plunge, I think.

I've found a solution to the problem. There is a further problem, namely that when I restore the saved game, it doesn't go back to the point where it was saved, but rather to the point after that where control of the game is returned to the user, so what I was trying to do wouldn't have worked anyway. Now I have moved the save points to earlier points in the game, each point being where control is about to be returned to the user (ie, at the end of a cutscene) and, importantly, not in dialog_request (). This fixes both problems, and is probably a better solution as it makes it less obvious to the user what they did wrong.

Khris

Yes, all SetRestartPoint() does is save the game, and it doesn't until the next regular game loop.

SMF spam blocked by CleanTalk