[Scummvm-git-logs] scummvm master -> 8085aa455cf1320099e7867cedfe39e9ac6e980c

mduggan noreply at scummvm.org
Fri Mar 10 08:10:28 UTC 2023


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

Summary:
8085aa455c TETRAEDGE: Add versioning of savegames


Commit: 8085aa455cf1320099e7867cedfe39e9ac6e980c
    https://github.com/scummvm/scummvm/commit/8085aa455cf1320099e7867cedfe39e9ac6e980c
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2023-03-10T17:10:12+09:00

Commit Message:
TETRAEDGE: Add versioning of savegames

Changed paths:
    engines/tetraedge/game/game.cpp
    engines/tetraedge/game/inventory.cpp
    engines/tetraedge/game/inventory.h


diff --git a/engines/tetraedge/game/game.cpp b/engines/tetraedge/game/game.cpp
index ec9e9a6fdca..4dfb947e14f 100644
--- a/engines/tetraedge/game/game.cpp
+++ b/engines/tetraedge/game/game.cpp
@@ -1606,11 +1606,21 @@ void Game::stopSound(const Common::String &name) {
 Common::Error Game::syncGame(Common::Serializer &s) {
 	Application *app = g_engine->getApplication();
 
-	// TODO: should be an error before testing.
-	//if (!s.syncVersion(1))
-	//	error("Save game version too new: %d", s.getVersion());
+	//
+	// Note: Early versions of this code didn't sync a version number so it was
+	// the inventory item count.  We use a large version number which would never
+	// be the inventory count.
+	//
+	if (!s.syncVersion(1000))
+		error("Save game version too new: %d", s.getVersion());
+
+	if (s.getVersion() < 1000) {
+		warning("Loading as old un-versioned save data");
+		inventory().syncStateWithCount(s, s.getVersion());
+	} else {
+		inventory().syncState(s);
+	}
 
-	inventory().syncState(s);
 	inventory().cellphone()->syncState(s);
 	// dialog2().syncState(s); // game saves this here, but doesn't actually save anything
 	_luaContext.syncState(s);
diff --git a/engines/tetraedge/game/inventory.cpp b/engines/tetraedge/game/inventory.cpp
index 0286f101e53..0cd05e9633c 100644
--- a/engines/tetraedge/game/inventory.cpp
+++ b/engines/tetraedge/game/inventory.cpp
@@ -539,6 +539,10 @@ bool Inventory::updateLayout() {
 Common::Error Inventory::syncState(Common::Serializer &s) {
 	uint nitems = _invObjects.size();
 	s.syncAsUint32LE(nitems);
+	return syncStateWithCount(s, nitems);
+}
+
+Common::Error Inventory::syncStateWithCount(Common::Serializer &s, uint nitems) {
 	if (nitems > 1000)
 		error("Unexpected number of elems syncing inventory");
 
diff --git a/engines/tetraedge/game/inventory.h b/engines/tetraedge/game/inventory.h
index 7d92c7e987f..c004e59d361 100644
--- a/engines/tetraedge/game/inventory.h
+++ b/engines/tetraedge/game/inventory.h
@@ -80,6 +80,7 @@ public:
 	bool updateLayout();
 
 	Common::Error syncState(Common::Serializer &s);
+	Common::Error syncStateWithCount(Common::Serializer &s, uint nitems);
 
 	Cellphone *cellphone() { return _cellphone; }
 




More information about the Scummvm-git-logs mailing list