Author Topic: Save Game Crashes with #dispose dialog boxes  (Read 5131 times)

0 Members and 1 Guest are viewing this topic.

Offline Doan Sephim

Save Game Crashes with #dispose dialog boxes
« on: May 04, 2017, 10:37:57 PM »
Sometimes I use print commands that don't pause the game using the #dispose tag for dialog:
Code: [Select]
Print("Howdy there!" #dispose)This works perfectly fine so long as I remember to (send gPrintDlg:dispose) when it's time for the message to go away.

However, the problem I am running into is if a player attempts to save the game while this #dispose message is on the screen. After the save, the game crashes with the "Oops" message (and of course restoring the game from that point leads to crashing upon restoration).

I'm having trouble finding out how to sidestep this difficulty. Any tips?


Artificial Intelligence Competition

Offline MusicallyInspired

Re: Save Game Crashes with #dispose dialog boxes
« Reply #1 on: May 04, 2017, 10:56:59 PM »
Could you add (send gPrintDlg:dispose) to the beginning of the Save method or something?
Brass Lantern Prop Competition

Offline troflip

Re: Save Game Crashes with #dispose dialog boxes
« Reply #2 on: May 04, 2017, 11:09:52 PM »
The save method of Game already disposes of gPrintDlg (unless Doan changed it).
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline troflip

Re: Save Game Crashes with #dispose dialog boxes
« Reply #3 on: May 04, 2017, 11:21:32 PM »
I'm having trouble finding out how to sidestep this difficulty. Any tips?

Use the debug switch on the Sierra interpreter (-d). It should break into the debugger when it crashes, and you should at least be able to see the send stack to know roughly where it crashed.
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Doan Sephim

Re: Save Game Crashes with #dispose dialog boxes
« Reply #4 on: May 04, 2017, 11:25:04 PM »
The save method of Game already disposes of gPrintDlg (unless Doan changed it).
Unless I know what I'm doing (which isn't very often) I don't dare touch the original source code. I found what Troflip was referencing, and it appears to still be in the code:
Code: [Select]
(method (save)
(var strDescBuf[20], gameNum, oldCursor, hSound)
        Load(rsFONT gSaveRestoreFont)
Load(rsCURSOR gLoadingCursor)

= oldCursor (self:setCursor(gNormalCursor))
= hSound (Sound:pause(1))
(if(GetSaveDisk(TRUE))
(if(gPrintDlg)
(send gPrintDlg:dispose())
)
= gameNum (Save:doit(@strDescBuf))
(if(<> gameNum -1)
= oldCursor (self:setCursor(gLoadingCursor 1))
(if(not SaveGame(objectName gameNum @strDescBuf gVersion))
Print(
"Your save game disk is full. You must either "+
"use another disk or save over an existing saved game."
#font 0
#button "OK" 1
)
)
(self:setCursor(oldCursor HaveMouse()))
)
  GetSaveDisk(FALSE)
)
  (Sound:pause(hSound))
)

Offline Doan Sephim

Re: Save Game Crashes with #dispose dialog boxes
« Reply #5 on: May 04, 2017, 11:29:42 PM »
You know what? I bet I know what's going on.

when you (send gPrintDlg:dispose) without a dialog box the game crashes. So when the player Saves the game, the (send gPrintDlg:dispose) is called and the dialog box it removed.

Then, moments later when my changeState method is rolling on to the next Case, the game is calling (send gPrintDlg:dispose) with no box. I bet if I add the same if clause as is found in the Save method, this will fix the problem.

EDIT: My hypothesis was correct. I was calling (send gPrintDlg:dispose) after the save method already did thus crashing the game. Adding (if(gPrintDlg) as the condition for (send gPrintDlg:dispose) fixes it up nicely. Thanks for the help!
« Last Edit: May 04, 2017, 11:37:08 PM by Doan Sephim »
Artificial Intelligence Competition

Offline MusicallyInspired

Re: Save Game Crashes with #dispose dialog boxes
« Reply #6 on: May 05, 2017, 12:05:06 AM »
Good to know!
Brass Lantern Prop Competition

Offline troflip

Re: Save Game Crashes with #dispose dialog boxes
« Reply #7 on: May 05, 2017, 12:18:21 AM »
Yep, looks like Dialog:dispose nulls out gPrintDialog (if it's itself) so we can know that it's valid by checking for NULL:

Code: [Select]
(method (dispose)
(if (== self gPrintDlg)
(SetPort gOldPort)
(= gPrintDlg NULL)
(= gOldPort NULL)
)
(if window (window dispose:))
(= window NULL)
(= theItem NULL)
(super dispose:)
)

Check out my website: http://icefallgames.com
Groundhog Day Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.022 seconds with 17 queries.