WINTERMUTE: Save the names of any language files that are loaded. (Fix bug #6651)

This way, they will be reloaded in the same order when loading a save game. Old save games will
continue to show the bug, but new savegames will be consistent. A quick fix for old save games in
the white chamber, is to launch the game with the correct language BEFORE loading the save game.

This increases the save-game-version to 1.3.1ScummVM
This commit is contained in:
Einar Johan Trøan Sømåen 2014-09-03 17:47:49 +02:00
parent 20d363c785
commit 55c8b7a11a
6 changed files with 42 additions and 2 deletions

View File

@ -3110,6 +3110,10 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) {
persistMgr->transferUint32(TMEMBER(_autoSaveSlot));
persistMgr->transferBool(TMEMBER(_cursorHidden));
if (persistMgr->checkVersion(1, 3, 1)) {
_settings->persist(persistMgr);
}
if (!persistMgr->getIsSaving()) {
_quitting = false;
}

View File

@ -219,4 +219,8 @@ char *BaseGameSettings::getKeyFromStringTable(const char *str) const {
return _stringTable->getKey(str);
}
bool BaseGameSettings::persist(BasePersistenceManager *persistMgr) {
return _stringTable->persist(persistMgr);
}
} // End of namespace Wintermute

View File

@ -34,6 +34,7 @@
namespace Wintermute {
class BaseStringTable;
class BaseGame;
class BasePersistenceManager;
class BaseGameSettings {
public:
const char *getGameFile() const { return (_gameFile ? _gameFile : "default.game"); }
@ -46,6 +47,8 @@ public:
bool loadStringTable(const char *filename, bool clearOld);
void expandStringByStringTable(char **str) const;
char *getKeyFromStringTable(const char *str) const;
bool persist(BasePersistenceManager *persistMgr);
private:
char *_gameFile;
int _resWidth;

View File

@ -189,8 +189,10 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) {
BaseEngine::LOG(0, "Loading string table...");
if (clearOld) {
_filenames.clear();
_strings.clear();
}
_filenames.push_back(Common::String(filename));
uint32 size;
byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &size);
@ -253,4 +255,27 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) {
return STATUS_OK;
}
bool BaseStringTable::persist(BasePersistenceManager *persistMgr) {
// Do nothing if the save game is too old.
if (!persistMgr->checkVersion(1, 3, 1)) {
return true;
}
uint32 numFiles = _filenames.size();
persistMgr->transferUint32("NumFiles", &numFiles);
if (persistMgr->getIsSaving()) {
for (int i = 0; i < numFiles; i++) {
persistMgr->transferString("Filename", &_filenames[i]);
}
} else {
_strings.clear();
_filenames.clear();
for (int i = 0; i < numFiles; i++) {
Common::String filename = "";
persistMgr->transferString("Filename", &filename);
loadFile(filename.c_str(), false);
}
}
return true;
}
} // End of namespace Wintermute

View File

@ -35,6 +35,8 @@
namespace Wintermute {
class BasePersistenceManager;
class BaseStringTable : public BaseClass {
public:
bool loadFile(const char *filename, bool deleteAll = true);
@ -44,8 +46,10 @@ public:
BaseStringTable(BaseGame *inGame);
virtual ~BaseStringTable();
char *getKey(const char *str) const;
bool persist(BasePersistenceManager *persistMgr);
private:
Common::HashMap<Common::String, Common::String> _strings;
Common::Array<Common::String> _filenames;
typedef Common::HashMap<Common::String, Common::String>::const_iterator StringsIter;
};

View File

@ -32,8 +32,8 @@
//////////////////////////////////////////////////////////////////////////
#define DCGF_VER_MAJOR 1
#define DCGF_VER_MINOR 2
#define DCGF_VER_BUILD 2
#define DCGF_VER_MINOR 3
#define DCGF_VER_BUILD 1
#define DCGF_VER_SUFFIX "ScummVM"
#define DCGF_VER_BETA true