Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Khristian Cammilleri on Sat 06/04/2013 03:44:24

Title: How to make a bug-free Quick Save function? [Solved]
Post by: Khristian Cammilleri on Sat 06/04/2013 03:44:24
Hi everyone!

I've coded a simple quicksave function:
Code (AGS) Select
  if (keycode == eKeyF5) {player.SayBackground("Quicksave");SaveGameSlot(19, "QuickSave");} // F5
  if (keycode == eKeyF7) { Game.StopAudio(eAudioTypeSound);RestoreGameSlot(19); } // F7



Sometimes, when I try to load the game crashes with this error:

CrashInfo.dmp
http://www.mediafire.com/?mugyit363l2gfj7 (http://www.mediafire.com/?mugyit363l2gfj7)

Before my head explodes trying to solve this (apparently unsolvable) bug, I would like to ask to the AGS community :

Do you have a better way of scripting the Quicksave or the Auto-save?

Someone else had the same problem?
Many thanks for reading :smiley:
Title: Re: How to make a good Quick Save function?
Post by: Khristian Cammilleri on Sun 12/05/2013 19:41:55
Any idea how to script a bug-free quicksave function?
Title: Re: How to make a bug-free Quick Save function?
Post by: Phemar on Sun 12/05/2013 23:39:09
I just tested your code out and it seems to work fine. I had no problems.

There's just a tiny glitch when you quick load, the "Quicksave" speech is still visible.
Title: Re: How to make a bug-free Quick Save function?
Post by: Khristian Cammilleri on Sun 12/05/2013 23:49:37
The code works well in almost all the game
But sometimes the game crashes randomly...  That's why I won't include that feature

Title: Re: How to make a bug-free Quick Save function?
Post by: Crimson Wizard on Sun 12/05/2013 23:55:57
If the game crashes with an exception, this means there's a bug in AGS, not your script.

Unfortunately we cannot use the crash dump if the game is compiled by any previous version of AGS, because... well, I explained it here, its purely technical: http://www.adventuregamestudio.co.uk/forums/index.php?topic=47162.0

How easy it is to reproduce this bug? I don't want to ask you to do this if it happens like once in a month.
Is it possible for you to make a backup copy of your game and try out the AGS 3.3.0 beta (http://www.adventuregamestudio.co.uk/forums/index.php?topic=47966.0) to compile and run it? That way we could use the crash dumps and check what happens.
Title: Re: How to make a bug-free Quick Save function?
Post by: Phemar on Sun 12/05/2013 23:56:36
Yea I dunno it might be an AGS thing. I had the same problem when scripting a click animation for the mouse a few days ago. Just gave up on the feature too :/
Title: Re: How to make a bug-free Quick Save function?
Post by: Khristian Cammilleri on Mon 13/05/2013 02:36:47
Well..
The bug isn't very common but I don't want it to happen in the released game anyway,
because it could put in risk the user's save games!

It isn't a crucial feature for my game, so I'm going to delete it once for all
I will just use de F5 key to show save dialog and the F7 key to show the load diag.
Let's hope that in AGS 3.3.0 this feature could be implemented
Thanks for the help Phemar and Crimson Wizard! ;D
Title: Re: How to make a bug-free Quick Save function? [Solved]
Post by: Khris on Mon 13/05/2013 02:49:19
Try removing the SayBackground.
Or try setting a variable like this:

Code (ags) Select
// above repeatedly_execute & on_key_press
int quick_save_load;

  // in on_key_press
  if (keycode == eKeyF5) quick_save_load = 1; // F5
  if (keycode == eKeyF7) quick_save_load = -1; // F7

  // in repeatedly_execute
  if (quick_save_load == 1) {
    quick_save_load = 0;
    SaveGameSlot(19, "QuickSave");
  }
  if (quick_save_load == -1) {
    Game.StopAudio(eAudioTypeSound);
    RestoreGameSlot(19);
  }
Title: Re: How to make a bug-free Quick Save function? [Solved]
Post by: Khristian Cammilleri on Mon 13/05/2013 19:32:07
Quote from: Khris on Mon 13/05/2013 02:49:19
Try removing the SayBackground.
Or try setting a variable like this:

Code (ags) Select
// above repeatedly_execute & on_key_press
int quick_save_load;

  // in on_key_press
  if (keycode == eKeyF5) quick_save_load = 1; // F5
  if (keycode == eKeyF7) quick_save_load = -1; // F7

  // in repeatedly_execute
  if (quick_save_load == 1) {
    quick_save_load = 0;
    SaveGameSlot(19, "QuickSave");
  }
  if (quick_save_load == -1) {
    Game.StopAudio(eAudioTypeSound);
    RestoreGameSlot(19);
  }

:grin:
I'm going to try it
Thanks (as always) Khris!
Title: Re: How to make a bug-free Quick Save function? [Solved]
Post by: Khris on Mon 13/05/2013 19:57:41
It's a shot in the dark, but worth a try I guess. Restore/SaveGameSlot aren't executed until the current function has finished, so what I suggested shouldn't make much of a difference, but maybe it'll help.
Title: Re: How to make a bug-free Quick Save function? [Solved]
Post by: Crimson Wizard on Mon 13/05/2013 21:11:38
Quote from: Khristian Cammilleri on Mon 13/05/2013 02:36:47
Let's hope that in AGS 3.3.0 this feature could be implemented

What feature?  :confused:

If there's a bug, it would really help to have more details on it, because the engine code is big and I doubt we will find the possible root of problem easily without known steps to reproduce it or a crash dump.
Well, ofc, I cannot force you on doing that ;).
Title: Re: How to make a bug-free Quick Save function? [Solved]
Post by: Khristian Cammilleri on Tue 14/05/2013 21:12:44
Quote from: Crimson Wizard on Mon 13/05/2013 21:11:38
Quote from: Khristian Cammilleri on Mon 13/05/2013 02:36:47
Let's hope that in AGS 3.3.0 this feature could be implemented

What feature?  :confused:

If there's a bug, it would really help to have more details on it, because the engine code is big and I doubt we will find the possible root of problem easily without known steps to reproduce it or a crash dump.
Well, ofc, I cannot force you on doing that ;).
Maybe "feature" wasn't the word I was looking for!
What I was trying to say (In my rather poor English) is that it could be nice to have an autosave function integrated in the 3.3.0 version
This, in theory, should make game experience more streamlined, but don't confuse with simple ;)

About the crash dump... I didn't know about how that thing works, that's why I included that just in case. Thanks for explaining it to me.

I think that's all. Case closed  (laugh)
Thank you all again
Title: Re: How to make a bug-free Quick Save function? [Solved]
Post by: Crimson Wizard on Tue 14/05/2013 21:59:56
Quote from: Khristian Cammilleri on Tue 14/05/2013 21:12:44
What I was trying to say (In my rather poor English) is that it could be nice to have an autosave function integrated in the 3.3.0 version
This, in theory, should make game experience more streamlined, but don't confuse with simple ;)
There's SetRestartPoint and RestartGame functions that allow to make self-overwriting autosave.
Title: Re: How to make a bug-free Quick Save function? [Solved]
Post by: Khristian Cammilleri on Tue 14/05/2013 22:08:33
Quote from: Crimson Wizard on Tue 14/05/2013 21:59:56
Quote from: Khristian Cammilleri on Tue 14/05/2013 21:12:44
What I was trying to say (In my rather poor English) is that it could be nice to have an autosave function integrated in the 3.3.0 version
This, in theory, should make game experience more streamlined, but don't confuse with simple ;)
There's SetRestartPoint and RestartGame functions that allow to make self-overwriting autosave.
Ups! I wasn't aware of that function