[Scummvm-cvs-logs] SF.net SVN: scummvm:[44358] scummvm/trunk/engines/sci

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Sep 25 15:02:11 CEST 2009


Revision: 44358
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44358&view=rev
Author:   fingolfin
Date:     2009-09-25 13:02:11 +0000 (Fri, 25 Sep 2009)

Log Message:
-----------
SCI: Remove EngineState::game_version, it was only used for saving anyway. Also remove syncCStr()

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/engine/kfile.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/savegame.h
    scummvm/trunk/engines/sci/engine/state.cpp
    scummvm/trunk/engines/sci/engine/state.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-09-25 13:01:50 UTC (rev 44357)
+++ scummvm/trunk/engines/sci/console.cpp	2009-09-25 13:02:11 UTC (rev 44358)
@@ -831,7 +831,7 @@
 	}
 
 	// TODO: enable custom descriptions? force filename into a specific format?
-	if (gamestate_save(_vm->_gamestate, out, "debugging")) {
+	if (gamestate_save(_vm->_gamestate, out, "debugging", 0)) {
 		DebugPrintf("Saving the game state to '%s' failed\n", argv[1]);
 	}
 

Modified: scummvm/trunk/engines/sci/engine/kfile.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kfile.cpp	2009-09-25 13:01:50 UTC (rev 44357)
+++ scummvm/trunk/engines/sci/engine/kfile.cpp	2009-09-25 13:02:11 UTC (rev 44358)
@@ -579,7 +579,6 @@
 	char *version = argc > 3 ? strdup(s->segMan->derefString(argv[3])) : NULL;
 
 	debug(3, "kSaveGame(%s,%d,%s,%s)", game_id, savedir_nr, game_description, version);
-	s->game_version = version;
 
 	Common::Array<SavegameDesc> saves;
 	listSavegames(saves);
@@ -624,7 +623,7 @@
 		return NULL_REG;
 	}
 
-	if (gamestate_save(s, out, game_description)) {
+	if (gamestate_save(s, out, game_description, version)) {
 		warning("Saving the game failed.");
 		s->r_acc = NULL_REG;
 	} else {
@@ -638,8 +637,6 @@
 			s->r_acc = make_reg(0, 1);
 		}
 	}
-	free(s->game_version);
-	s->game_version = NULL;
 
 	return s->r_acc;
 }

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-09-25 13:01:50 UTC (rev 44357)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-09-25 13:02:11 UTC (rev 44358)
@@ -65,20 +65,6 @@
 	s.syncAsUint16LE(obj.offset);
 }
 
-// FIXME: Sync a C string, using malloc/free storage.
-// Much better to replace all of these by Common::String
-static void syncCStr(Common::Serializer &s, char **str) {
-	Common::String tmp;
-	if (s.isSaving() && *str)
-		tmp = *str;
-	s.syncString(tmp);
-	if (s.isLoading()) {
-		//free(*str);
-		*str = strdup(tmp.c_str());
-	}
-}
-
-
 static void sync_song_t(Common::Serializer &s, Song &obj) {
 	s.syncAsSint32LE(obj._handle);
 	s.syncAsSint32LE(obj._resourceNum);
@@ -295,7 +281,8 @@
 void EngineState::saveLoadWithSerializer(Common::Serializer &s) {
 	s.skip(4, VER(9), VER(9));	// OBSOLETE: Used to be savegame_version
 
-	syncCStr(s, &game_version);
+	Common::String tmp;
+	s.syncString(tmp);			// OBSOLETE: Used to be game_version
 	s.skip(4, VER(9), VER(9));	// OBSOLETE: Used to be version
 
 	// FIXME: Do in-place loading at some point, instead of creating a new EngineState instance from scratch.
@@ -508,14 +495,14 @@
 #pragma mark -
 
 
-int gamestate_save(EngineState *s, Common::WriteStream *fh, const char* savename) {
+int gamestate_save(EngineState *s, Common::WriteStream *fh, const char* savename, const char *version) {
 	tm curTime;
 	g_system->getTimeAndDate(curTime);
 
 	SavegameMetadata meta;
 	meta.savegame_version = CURRENT_SAVEGAME_VERSION;
 	meta.savegame_name = savename;
-	meta.game_version = s->game_version;
+	meta.game_version = version;
 	meta.savegame_date = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
 	meta.savegame_time = ((curTime.tm_hour & 0xFF) << 16) | (((curTime.tm_min) & 0xFF) << 8) | ((curTime.tm_sec) & 0xFF);
 

Modified: scummvm/trunk/engines/sci/engine/savegame.h
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.h	2009-09-25 13:01:50 UTC (rev 44357)
+++ scummvm/trunk/engines/sci/engine/savegame.h	2009-09-25 13:02:11 UTC (rev 44358)
@@ -57,7 +57,7 @@
  * @param savename	The description of the savegame
  * @return 0 on success, 1 otherwise
  */
-int gamestate_save(EngineState *s, Common::WriteStream *save, const char *savename);
+int gamestate_save(EngineState *s, Common::WriteStream *save, const char *savename, const char *version);
 
 /**
  * Restores a game state from a directory.

Modified: scummvm/trunk/engines/sci/engine/state.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/state.cpp	2009-09-25 13:01:50 UTC (rev 44357)
+++ scummvm/trunk/engines/sci/engine/state.cpp	2009-09-25 13:02:11 UTC (rev 44358)
@@ -33,8 +33,6 @@
 EngineState::EngineState(ResourceManager *res, Kernel *kernel, uint32 flags)
 : resMan(res), _kernel(kernel), _flags(flags), _dirseeker(this) {
 
-	game_version = 0;
-
 	gfx_state = 0;
 	old_screen = 0;
 

Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h	2009-09-25 13:01:50 UTC (rev 44357)
+++ scummvm/trunk/engines/sci/engine/state.h	2009-09-25 13:02:11 UTC (rev 44358)
@@ -171,7 +171,6 @@
 	const uint32 _flags;			/**< Specific game flags */
 
 	Common::String _gameName; /**< Designation of the primary object (which inherits from Game) */
-	char *game_version;
 
 	/* Non-VM information */
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list