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

svn-id: r44358
This commit is contained in:
Max Horn 2009-09-25 13:02:11 +00:00
parent 78d2ea9fcf
commit 2fe6b32968
6 changed files with 7 additions and 26 deletions

View File

@ -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]);
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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.

View File

@ -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;

View File

@ -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 */