[Scummvm-git-logs] scummvm master -> 3475c01c62082b6df8838e9cd0a22c115de5d1e2

kelmer44 noreply at scummvm.org
Fri Jul 10 08:15:48 UTC 2026


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
3475c01c62 TOT: Fixes crash when trying to continue game when autosave isnt present yet


Commit: 3475c01c62082b6df8838e9cd0a22c115de5d1e2
    https://github.com/scummvm/scummvm/commit/3475c01c62082b6df8838e9cd0a22c115de5d1e2
Author: kelmer (kelmer at gmail.com)
Date: 2026-07-10T10:15:35+02:00

Commit Message:
TOT: Fixes crash when trying to continue game when autosave isnt present yet

Changed paths:
    engines/tot/tot.cpp
    engines/tot/tot.h


diff --git a/engines/tot/tot.cpp b/engines/tot/tot.cpp
index 0f455cf26e9..980e62037a8 100644
--- a/engines/tot/tot.cpp
+++ b/engines/tot/tot.cpp
@@ -22,6 +22,7 @@
 #include "common/config-manager.h"
 #include "common/debug-channels.h"
 #include "common/events.h"
+#include "common/savefile.h"
 #include "common/scummsys.h"
 #include "common/system.h"
 
@@ -163,13 +164,27 @@ int TotEngine::engineStart() {
 	if (_startNewGame && !shouldQuit()) {
 		newGame();
 	} else if (_continueGame && !shouldQuit()) {
+
 		resumeGame();
 	}
 	return startGame();
 }
 
+bool TotEngine::autosaveExists() {
+	int saveSlot = getAutosaveSlot();
+	if (saveSlot == -1)
+		return false;
+	Common::InSaveFile *f = getSaveFileManager()->openForLoading(getSaveStateName(saveSlot));
+	if (!f)
+		return false;
+	delete f;
+	return true;
+}
+
 void TotEngine::resumeGame() {
-	loadGameState(getMetaEngine()->getAutosaveSlot());
+	if (!autosaveExists())
+		return;
+	loadGameState(getAutosaveSlot());
 }
 
 void TotEngine::processEvents(bool &escapePressed) {
@@ -1252,9 +1267,11 @@ void TotEngine::mainMenu(bool fade) {
 				}
 			} else if (y > 174 && y < 190) {
 				if (x > 20 && x < 145) {
-					_startNewGame = false;
-					validOption = true;
-					_continueGame = true;
+					if (autosaveExists()) {
+						_startNewGame = false;
+						validOption = true;
+						_continueGame = true;
+					}
 				} else if (x > 173 && x < 288) {
 					exitToDOS();
 				}
diff --git a/engines/tot/tot.h b/engines/tot/tot.h
index bedb4f3a5e6..77b8fecd270 100644
--- a/engines/tot/tot.h
+++ b/engines/tot/tot.h
@@ -88,6 +88,7 @@ private:
 	SavedGame *saveGameToRegister();
 	void originalSaveLoadScreen();
 	void loadGame(SavedGame *game);
+	bool autosaveExists();
 
 	RoomFileRegister *readScreenDataFile(Common::SeekableReadStream *screenDataFile);
 	void lookAtObject(byte objectNumber);




More information about the Scummvm-git-logs mailing list