AGS: Check msg is initialized and add mirrored getAutosaveSlot

This is required for the overwrite warning to work properly
This commit is contained in:
Walter Agazzi 2023-12-09 01:27:45 +01:00 committed by Thierry Crozat
parent 1978f4c9c8
commit 77cb444f6b
2 changed files with 28 additions and 10 deletions

View File

@ -297,24 +297,30 @@ Common::FSNode AGSEngine::getGameFolder() {
}
bool AGSEngine::canLoadGameStateCurrently(Common::U32String *msg) {
if (ConfMan.get("gameid") == "strangeland") {
*msg = _("This game does not support loading from the menu. Use in-game interface");
return false;
if (msg) {
if (ConfMan.get("gameid") == "strangeland") {
*msg = _("This game does not support loading from the menu. Use in-game interface");
return false;
}
if (_G(noScummSaveLoad))
*msg = _("To preserve the original experience, this game should be loaded using the in-game interface.\nYou can, however, override this setting in Game Options.");
}
if (_G(noScummSaveLoad))
*msg = _("To preserve the original experience, this game should be loaded using the in-game interface.\nYou can, however, override this setting in Game Options.");
return !_GP(thisroom).Options.SaveLoadDisabled &&
!_G(inside_script) && !_GP(play).fast_forward && !_G(no_blocking_functions) &&
!_G(noScummSaveLoad);
}
bool AGSEngine::canSaveGameStateCurrently(Common::U32String *msg) {
if (ConfMan.get("gameid") == "strangeland") {
*msg = _("This game does not support saving from the menu. Use in-game interface");
return false;
if (msg) {
if (ConfMan.get("gameid") == "strangeland") {
*msg = _("This game does not support saving from the menu. Use in-game interface");
return false;
}
if (_G(noScummSaveLoad))
*msg = _("To preserve the original experience, this game should be saved using the in-game interface.\nYou can, however, override this setting in Game Options.");
}
if (_G(noScummSaveLoad))
*msg = _("To preserve the original experience, this game should be saved using the in-game interface.\nYou can, however, override this setting in Game Options.");
return !_GP(thisroom).Options.SaveLoadDisabled &&
!_G(inside_script) && !_GP(play).fast_forward && !_G(no_blocking_functions) &&
!_G(noScummSaveLoad);
@ -330,6 +336,13 @@ Common::Error AGSEngine::saveGameState(int slot, const Common::String &desc, boo
return Common::kNoError;
}
int AGSEngine::getAutosaveSlot() const {
if (!g_engine || !_G(noScummAutosave))
return 0;
else
return -1;
}
void AGSEngine::GUIError(const Common::String &msg) {
GUIErrorMessage(msg);
}

View File

@ -162,6 +162,11 @@ public:
*/
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
/**
* Returns autosave slot (-1 if unavailable)
*/
int getAutosaveSlot() const override;
/**
* Synchronize user volume settings
*/