Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Maverick on Sat 14/04/2007 13:27:42

Title: Bug report on loading saved game
Post by: Maverick on Sat 14/04/2007 13:27:42
I made custom GUIs for the save and load functions and everything seems to work fine up to a point when the game kicks out with this error message:

Quote
Illegal exception
--
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x004615AC ;
program pointer is +2051, ACI version 2.72.920, gtags(1,5)

Did I assign a conflicting GUI name that gets mixed up with something that is already hardcoded?
GUIs I have at the moment:
gSave
gLoadGames
gYesNo

Thanks

Edit by strazer: Please post error messages in clear text so they show up in the forum search!
Title: Re: Bug report on loading saved game
Post by: Gilbert on Sat 14/04/2007 14:24:11
Can you post the portion of codes around the saving/loading part?
Title: Re: Bug report on loading saved game
Post by: Pumaman on Sat 14/04/2007 15:26:02
Is it one particular save game that has the problem, or can you not load any saved games?
Title: Re: Bug report on loading saved game
Post by: Maverick on Sat 14/04/2007 17:20:07
Quote from: Gilbot V7000a on Sat 14/04/2007 14:24:11
Can you post the portion of codes around the saving/loading part?

The save part works just fine

function SaveGame(){
  int index = lstSaved.ItemCount;
  if(index < 10){
    String GameReference = txtboxSaved.Text;
    SaveGameSlot(index+1, GameReference);
    mouse.Mode = eModeWalkto;
    gSave.Visible = false;


#sectionstart btnSaveGame_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnSaveGame_Click(GUIControl *control, MouseButton button) {

SaveGame();
 
}
#sectionend btnSaveGame_Click  // DO NOT EDIT OR REMOVE THIS LINE


The load part just kicks out of the game

#sectionstart btnLoadGame_Click  // DO NOT EDIT OR REMOVE THIS LINE
function btnLoadGame_Click(GUIControl *control, MouseButton button) {
  int loadgame = lstLoadGame.SelectedIndex;
Wait(5);
RestoreGameSlot(loadgame);
 
}

As for CJ's question,
It doesn't work for anything that I tried.
Title: Re: Bug report on loading saved game
Post by: Gilbert on Sat 14/04/2007 17:34:05
Note that the indices in a listbox starts from 0, while the same game slots starts from 1. Moreover, if no item is selected the SelectedIndex is -1.
These can cause problems if not handled properly.

So I think (not tested) the load game part could use some tweaking:

function btnLoadGame_Click(GUIControl *control, MouseButton button) {
  int loadgame = lstLoadGame.SelectedIndex;
  if (loadgame != -1) {
Wait(5);
RestoreGameSlot(loadgame+1);
  } 
}


I'm too lazy to check, but probably there is a similar problem with saving at incorrect slot index for the sabe game part as well.
Title: Re: Bug report on loading saved game
Post by: SupSuper on Sat 14/04/2007 17:57:51
Actually, savegames aren't stored the same way they're displayed in listboxes, so you have to use the SaveGameSlots property:

RestoreGameSlot(lstLoadGame.SaveGameSlots[loadgame]);

You still need the "nothing selected" check though, as Gilbot pointed out.
Title: Re: Bug report on loading saved game
Post by: Pumaman on Sat 14/04/2007 19:41:21
Even so, it shouldn't cause the engine to crash. Any chance you could upload the game for us to investigate, or is it too large to reasonably do that?
Title: Re: Bug report on loading saved game
Post by: Maverick on Sat 14/04/2007 22:19:13
Zipped the game is about 1meg. Just tell me where I can upload it to. I'm still battling with a some of the logic issues on the saveGUI so I'll just comment it out to send the file.
Title: Re: Bug report on loading saved game
Post by: Pumaman on Sun 15/04/2007 00:04:47
Try here: http://americangirlscouts.org/agsuploads/index.php
Title: Re: Bug report on loading saved game
Post by: Maverick on Mon 16/04/2007 19:02:12
CJ,

Tried it but couldn't get in with my username and password for AGS as mentioned. I don't think it will do much good now because I changed a lot of the code before I checked the forum again.

One possible issue is that my script was a mix of old and new (no boxes checked in general setting under the script option). Anyway I solved the problem with the advice from Gilbot and SupSuper.

Thanks