aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2009-09-25 13:02:11 +0000
committerMax Horn2009-09-25 13:02:11 +0000
commit2fe6b329686cea10765ec87584455637ce656b47 (patch)
tree2e53113e54e861d71d89cebd6110a52294acd433
parent78d2ea9fcf863db4ba5f7bf92a7a4fecc4da6fc2 (diff)
downloadscummvm-rg350-2fe6b329686cea10765ec87584455637ce656b47.tar.gz
scummvm-rg350-2fe6b329686cea10765ec87584455637ce656b47.tar.bz2
scummvm-rg350-2fe6b329686cea10765ec87584455637ce656b47.zip
SCI: Remove EngineState::game_version, it was only used for saving anyway. Also remove syncCStr()
svn-id: r44358
-rw-r--r--engines/sci/console.cpp2
-rw-r--r--engines/sci/engine/kfile.cpp5
-rw-r--r--engines/sci/engine/savegame.cpp21
-rw-r--r--engines/sci/engine/savegame.h2
-rw-r--r--engines/sci/engine/state.cpp2
-rw-r--r--engines/sci/engine/state.h1
6 files changed, 7 insertions, 26 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index b8b3d2b9a5..2b3570daf5 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -831,7 +831,7 @@ bool Console::cmdSaveGame(int argc, const char **argv) {
}
// 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]);
}
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index ea16773a4d..2a1d997da4 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -579,7 +579,6 @@ reg_t kSaveGame(EngineState *s, int, int argc, reg_t *argv) {
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 @@ reg_t kSaveGame(EngineState *s, int, int argc, reg_t *argv) {
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 @@ reg_t kSaveGame(EngineState *s, int, int argc, reg_t *argv) {
s->r_acc = make_reg(0, 1);
}
}
- free(s->game_version);
- s->game_version = NULL;
return s->r_acc;
}
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index d1ce2885bb..cf54a61ebd 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -65,20 +65,6 @@ static void sync_reg_t(Common::Serializer &s, reg_t &obj) {
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 @@ static void sync_SavegameMetadata(Common::Serializer &s, SavegameMetadata &obj)
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 @@ static void sync_songlib_t(Common::Serializer &s, SongLibrary &obj) {
#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);
diff --git a/engines/sci/engine/savegame.h b/engines/sci/engine/savegame.h
index 8de6c236f2..5da5486da3 100644
--- a/engines/sci/engine/savegame.h
+++ b/engines/sci/engine/savegame.h
@@ -57,7 +57,7 @@ struct SavegameMetadata {
* @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.
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index 4248c68c63..dc66c033dd 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -33,8 +33,6 @@ namespace Sci {
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;
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index 10957737c3..9aa19b3dd4 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -171,7 +171,6 @@ public:
const uint32 _flags; /**< Specific game flags */
Common::String _gameName; /**< Designation of the primary object (which inherits from Game) */
- char *game_version;
/* Non-VM information */