Forcing A Save-Game To Load From A Custom Location

Started by Mandle, Tue 30/08/2016 16:42:34

Previous topic - Next topic

Mandle

This is about my MAGS entry "Predators Prey For Plants"

There were issues for some users where the game crashed on initial loading...

I'm assuming that this is because the game forces the load of a save game file as its interactive title screen on startup...

Here is the code where the game defines where the save game goes:

Code: ags

function game_start() 
{
  Game.SetSaveGameDirectory("Saved Maps");


Here is the code for loading the save game:

Code: ags

function room_Load()
{
 if (Game.GetSaveSlotDescription(998) != null){RestoreGameSlot(998);}
 aTo_love_again.Play(eAudioPriorityVeryHigh, eRepeat);
}


The only other thing I changed was the options in "Saved Games" in "General Settings":

Quote
Enhanced save games: False
Save game file extension:
Save games folder name:
Save screenshots in save games: False

The game saves the save game in a folder called "Saved Maps" in the actual game folder instead of in a folder in "My Documents" or whatever...

This seems to work fine for most users but there is the odd case where it crashes on initial loading...

Does anyone more tech-savvy than myself know why this might be happening? (Khris?)

Do I need to perhaps enter "Saved Maps" in the General Settings field of: Save games folder name? (This is the name of the folder in the game folder that holds the saved games)

Or do I need a complete file extension (no idea how to type that)

I also remember reading something about a "." being possibly needed in the Game Start function above to make the path "generic" or something, but in that thread the issue was never resolved so I stayed away from that...

It's very difficult to change the code and test it myself, as every computer I have run the game on: It works fine!

So...I'm turning on the big "K" spotlight on the clouds:

KHRRIIIIIIISSSSSSS!!!!

Crimson Wizard

#1
Which version of AGS is this?
Where did user install the game (was not that C:/Program Files" for instance, or read-only device)?
What kind of crash? were there error messages, crash dumps?


EDIT: Ok.... I searched in your game thread; are you talking about this crash?
http://www.adventuregamestudio.co.uk/forums/index.php?topic=53759.msg636540123#msg636540123

This error message means that savegame was made when running different EXE. An older versions of AGS had this check in them and wanted to launch a game with original name if the exe name in save was different. I think it is somehow related to minigame support in AGS.

I am not quite sure why this error is triggered with one installation path and does not with the other though... this might need investigation.
Anyway, I believe we fixed this check back in 3.3.0, so I suggest to at least upgrade to that.

Also, I must point out that it is not a good idea to forcedly save something to the game directory at runtime. User may have game installed in read-only location. This is why since version 3.3.5 AGS does not let developers to save anything to game folder anymore, except when players themselves enable this in advanced setup tab.

Mandle

Thanks so much CW! Of course I should have been screaming for your help, being the dude developing the engine and all...silly me...

And sorry for the confusing thread title. It's been fixed: The game doesn't force a gave save, it forces a game load, so there should be none of the issues that you mentioned. But it's valuable information for the future in any case.

If anyone else has further insight, or think they do, please post as well. I cannot yet conclusively say that the problem is fixed until I try a fix later today and get someone who crashed previously to test it out.

Crimson Wizard

#3
Quote from: Mandle on Wed 31/08/2016 00:19:43
And sorry for the confusing thread title. It's been fixed: The game doesn't force a gave save, it forces a game load, so there should be none of the issues that you mentioned.

Ok, we have a misunderstanding here, I guess...

Thread title has nothing to do with this, I did not even notice anything in there. I was checking out the description of the problem in the post.

The error message that user mentioned is displayed only in two cases:
1. You use RunAGSGame function in your script and the game you asked to run is not found.
2. If the game loads a save that was saved earlier when running a game with different exe name (or at least AGS believes that it is), and that exe is not present in the game folder (at least AGS believes that it is not).
This issue was fixed in AGS 3.3.0 (fixed in the way that AGS continues without crashing even if this exe name check fails, only putting a warning to the log).

PS. I can try some tests later, but I suspect this may has something to do with spaces in name and/or length of exe name.

Mandle

I've updated AGS to 3.3 and tried to work out how to fix the issue...

But the new build of the game cannot load the "Title Screen" save game from the older version...

The game does not crash, but instead just starts with a blank map...

I do not want to redraw the Title Screen all over again...Or recreate all the save games for the other maps...

Is there any way I can hack the old save game files to make them acceptable to the new build?

Crimson Wizard

#5
Quote from: Mandle on Wed 31/08/2016 07:56:44
The game does not crash, but instead just starts with a blank map...
Now, this is a bug which has to be fixed, unless it was fixed in later updates.

Regarding using your existing game, have the player tried to rename executable to name that was mentioned in error? (PREDAT~1.EXE)

Crimson Wizard

Alright, I found out that AGS 3.3.5 causes the main map not to load. 3.3.4 works fine.
I suppose that is because of the changes to how savegame paths are restricted now. However, the engine is supposed to deal with backward compatibility cases, so that still need a fix.

Mandle

I tried out 3.3.4 and it now works...

Except now the game is 2x larger and overflows off of my screen...

I don't know how to control the resolution of the game so that it fits the screen automatically...

I know this is a very basic thing to do, but I don't know how to do it...I have searched for it but haven't found...

Crimson Wizard

Quote from: Mandle on Wed 31/08/2016 17:35:46
Except now the game is 2x larger and overflows off of my screen...

I don't know how to control the resolution of the game so that it fits the screen automatically...

I know this is a very basic thing to do, but I don't know how to do it...I have searched for it but haven't found...

Oh right, we have a maximized window by default since 3.3.
You run winsetup and set a suitable scaling filter (x1, x2?) instead of "max nearest-neighbour".

Mandle

Quote from: Crimson Wizard on Wed 31/08/2016 17:50:30
Oh right, we have a maximized window by default since 3.3.
You run winsetup and set a suitable scaling filter (x1, x2?) instead of "max nearest-neighbour".

I was trying to mean how to set it from within AGS so the player doesn't have to.

Crimson Wizard

Quote from: Mandle on Wed 31/08/2016 23:31:52
I was trying to mean how to set it from within AGS so the player doesn't have to.
You cannot lock this option for the game entirely, but if you run setup from the editor menu, then the options you set there will be saved as defaults when player downloads your game (assuming you copy acsetup.cfg from Compiled folder along with rest of game files).

Crimson Wizard

#11
Mandle, in the last two days I was trying to create an automatic workaround in AGS 3.3.5 for the case when the precreated saves have to exist in game's folder, while primarily supporting saves in safe writeable folder in user documents, but I found that I am unable to do this. That could work in certain cases, but there are cases when it won't, not without overly complicated solution, and that bugged me too much.
One notable case (that is also easy to understand for regular user) is DeleteSaveSlot script command. By no common means I could make it work with the saves in game folder, since it is assumed (by concept) that this folder is read-only.


I realize that AGS developers have a long standing tradition of having saves in their game folders, and it will cause trouble when migrating to new versions of AGS, so I believe we will have to adress this problem again taking all aspects in consideration at some point in nearly future, and find a good solution that will work for everyone.


Regarding current situation, here are possible ways for you to upgrade your game, if whenever you decide to use AGS 3.3.5, 3.4.0 or higher:
1. Instead of using precreated savegames as map templates, have only dynamic sprite saved in a file, which could be loaded into game. Have a separate command in game to load such template (as opposed to savegame). You may use ListBox.FillDirList function to populate listbox with names of those template files. This will let you still have pre-created maps in the game folder, as read-only game data.
2. Make a "install.bat" file that would copy your precreated saves into the supported location ("%USERPROFILE%\Saved Games\Predators Prey For Plants\").

cat

Mandle, please consider that the second option (install) probably will not work for Linux users and most AGS players hate installers.

Crimson Wizard

Quote from: cat on Fri 02/09/2016 20:03:10
...and most AGS players hate installers.
I wonder why... is not it good when there is a program that automatically installs and deletes all game files for you?
Also by "AGS players", do you mean people from forums, or all the players of AGS games, including people who gets AGS games on steam, and such?

Mandle

I've compiled a new version of the game and sent it off to the biggest crasher: The dude that could never even get the game running no matter how many solutions came down the line from others about shifting to alternative forders etc...

I'm waiting with held breath on how it goes for him...

If it works for him then I'm just going to say the game works...

Thanks so much again to Crimson Wizard for your help!

cat

Quote from: Crimson Wizard on Fri 02/09/2016 22:06:28
Quote from: cat on Fri 02/09/2016 20:03:10
...and most AGS players hate installers.
I wonder why... is not it good when there is a program that automatically installs and deletes all game files for you?
Also by "AGS players", do you mean people from forums, or all the players of AGS games, including people who gets AGS games on steam, and such?
AFAIK an installer will NOT automatically delete all files - stuff that is created in application or user data (i.e. save games) will not be removed. Also, an msi installer makes things difficult for people using Linux.
With players I mean people from the AGS forum, which are probably the main audience of MAGS games. For Steam, of course, this is something completely differnt.

Crimson Wizard

Quote from: cat on Sun 04/09/2016 09:30:10
AFAIK an installer will NOT automatically delete all files - stuff that is created in application or user data (i.e. save games) will not be removed. Also, an msi installer makes things difficult for people using Linux.
Well, this means it is not made properly.
Deleting saves and temp files is potentially possible, but you need to know the name of the folder that game creates, which may or may not be equal to exe name (for example, if game author has changed the name of the save folder in general settings) but still should be known to game developer. I do not think this is harder to implement than saves deletion suggested by many non-AGS games (which ask "would you like to delete your saved games" when uninstalling).
Linux versions should of course be distributed and (un)installed with regards to their system.

Perhaps the things may be improved by making some kind of installer template to come along with AGS. And/or teach the engine to delete/copy/move user/temporary files by command.

SMF spam blocked by CleanTalk