How to make a bug-free Quick Save function? [Solved]

Started by Khristian Cammilleri, Sat 06/04/2013 03:44:24

Previous topic - Next topic

Khristian Cammilleri

Hi everyone!

I've coded a simple quicksave function:
Code: AGS
  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

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:
PizzaNostra!

Khristian Cammilleri

Any idea how to script a bug-free quicksave function?
PizzaNostra!

Phemar

#2
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.

Khristian Cammilleri

#3
The code works well in almost all the game
But sometimes the game crashes randomly...  That's why I won't include that feature

PizzaNostra!

Crimson Wizard

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 to compile and run it? That way we could use the crash dumps and check what happens.

Phemar

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 :/

Khristian Cammilleri

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
PizzaNostra!

Khris

Try removing the SayBackground.
Or try setting a variable like this:

Code: ags
// 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);
  }

Khristian Cammilleri

Quote from: Khris on Mon 13/05/2013 02:49:19
Try removing the SayBackground.
Or try setting a variable like this:

Code: ags
// 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!
PizzaNostra!

Khris

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.

Crimson Wizard

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 ;).

Khristian Cammilleri

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
PizzaNostra!

Crimson Wizard

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.

Khristian Cammilleri

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
PizzaNostra!

SMF spam blocked by CleanTalk