diff options
author | Einar Johan Trøan Sømåen | 2012-07-18 19:25:27 +0200 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2012-07-18 19:25:27 +0200 |
commit | 28794036edb5a1441ff9ba88a455205859416b43 (patch) | |
tree | 28f624a1577cee754da66b2b5a28c4aa0fbc3f7e /engines | |
parent | b42dae6a30db145fd0254e2badbfcd1a445521f6 (diff) | |
download | scummvm-rg350-28794036edb5a1441ff9ba88a455205859416b43.tar.gz scummvm-rg350-28794036edb5a1441ff9ba88a455205859416b43.tar.bz2 scummvm-rg350-28794036edb5a1441ff9ba88a455205859416b43.zip |
WINTERMUTE: Make savegames use targetName as prefix.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wintermute/Base/BGame.cpp | 5 | ||||
-rw-r--r-- | engines/wintermute/Base/BGame.h | 4 | ||||
-rw-r--r-- | engines/wintermute/Base/BPersistMgr.cpp | 18 | ||||
-rw-r--r-- | engines/wintermute/Base/BPersistMgr.h | 5 | ||||
-rw-r--r-- | engines/wintermute/detection.cpp | 9 | ||||
-rw-r--r-- | engines/wintermute/wintermute.cpp | 2 | ||||
-rw-r--r-- | engines/wintermute/wintermute.h | 1 |
7 files changed, 30 insertions, 14 deletions
diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp index 6e70bb6540..32242a5313 100644 --- a/engines/wintermute/Base/BGame.cpp +++ b/engines/wintermute/Base/BGame.cpp @@ -3814,7 +3814,10 @@ void CBGame::setWindowTitle() { bool CBGame::getSaveSlotFilename(int slot, char *buffer) {
AnsiString dataDir = getDataDir();
//sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt);
- sprintf(buffer, "save%03d.%s", slot, _savedGameExt);
+ CBPersistMgr *pm = new CBPersistMgr(_gameRef);
+ Common::String filename = pm->getFilenameForSlot(slot);
+ delete pm;
+ strcpy(buffer, filename.c_str());
warning("Saving %s - we really should prefix these things to avoid collisions.", buffer);
return STATUS_OK;
}
diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h index 09251aedf1..4bf053dac8 100644 --- a/engines/wintermute/Base/BGame.h +++ b/engines/wintermute/Base/BGame.h @@ -233,8 +233,10 @@ private: uint32 _lastTime;
uint32 _fpsTime;
uint32 _framesRendered;
-
+ Common::String _gameId;
public:
+ const char* getGameId() { return _gameId.c_str(); }
+ void setGameId(const Common::String& gameId) { _gameId = gameId; }
uint32 _surfaceGCCycleTime;
bool _smartCache;
bool _videoSubtitles;
diff --git a/engines/wintermute/Base/BPersistMgr.cpp b/engines/wintermute/Base/BPersistMgr.cpp index 700b63479a..46c2048ac7 100644 --- a/engines/wintermute/Base/BPersistMgr.cpp +++ b/engines/wintermute/Base/BPersistMgr.cpp @@ -51,7 +51,7 @@ namespace WinterMute { #define SAVE_MAGIC_2 0x32564153
//////////////////////////////////////////////////////////////////////////
-CBPersistMgr::CBPersistMgr(CBGame *inGame): CBBase(inGame) {
+CBPersistMgr::CBPersistMgr(CBGame *inGame, const char *savePrefix): CBBase(inGame) {
_saving = false;
// _buffer = NULL;
// _bufferSize = 0;
@@ -69,6 +69,13 @@ CBPersistMgr::CBPersistMgr(CBGame *inGame): CBBase(inGame) { _thumbnailDataSize = 0;
_thumbnailData = NULL;
+ if (savePrefix) {
+ _savePrefix = savePrefix;
+ } else if (_gameRef) {
+ _savePrefix = _gameRef->getGameId();
+ } else {
+ _savePrefix = "wmesav";
+ }
}
@@ -111,9 +118,9 @@ void CBPersistMgr::cleanup() { _saveStream = NULL;
}
-Common::String CBPersistMgr::getFilenameForSlot(int slot) {
- // TODO: Temporary solution until I have the namespacing sorted out
- return Common::String::format("save%03d.DirtySplitSav", slot);
+Common::String CBPersistMgr::getFilenameForSlot(int slot) const {
+ // 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise)
+ return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot);
}
void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) {
@@ -149,7 +156,8 @@ void CBPersistMgr::deleteSaveSlot(int slot) { }
uint32 CBPersistMgr::getMaxUsedSlot() {
- Common::StringArray saves = g_system->getSavefileManager()->listSavefiles("save???.DirtySplitSav");
+ Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str());
+ Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask);
Common::StringArray::iterator it = saves.begin();
int ret = -1;
for (; it != saves.end(); it++) {
diff --git a/engines/wintermute/Base/BPersistMgr.h b/engines/wintermute/Base/BPersistMgr.h index ee834c005e..656cdf975a 100644 --- a/engines/wintermute/Base/BPersistMgr.h +++ b/engines/wintermute/Base/BPersistMgr.h @@ -52,6 +52,7 @@ public: byte _savedVerBuild;
byte _savedExtMajor;
byte _savedExtMinor;
+ Common::String _savePrefix;
Common::String _savedName;
bool saveFile(const char *filename);
uint32 getDWORD();
@@ -93,14 +94,14 @@ public: bool transfer(const char *name, Common::String *val);
bool transfer(const char *name, Vector2 *val);
bool transfer(const char *name, AnsiStringArray &Val);
- CBPersistMgr(CBGame *inGame = NULL);
+ CBPersistMgr(CBGame *inGame = NULL, const char *savePrefix = NULL);
virtual ~CBPersistMgr();
bool checkVersion(byte verMajor, byte verMinor, byte verBuild);
uint32 _thumbnailDataSize;
byte *_thumbnailData;
+ Common::String getFilenameForSlot(int slot) const;
private:
- Common::String getFilenameForSlot(int slot);
bool readHeader(const Common::String &filename);
TimeDate getTimeDate();
bool putTimeDate(const TimeDate &t);
diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index ef28fedd2b..0112bce137 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -304,7 +304,7 @@ public: SaveStateList listSaves(const char *target) const { SaveStateList saves; - WinterMute::CBPersistMgr pm; + WinterMute::CBPersistMgr pm(NULL, target); for (int i = 0; i < getMaximumSaveSlot(); i++) { if (pm.getSaveExists(i)) { SaveStateDescriptor desc; @@ -316,17 +316,16 @@ public: } int getMaximumSaveSlot() const { - WinterMute::CBPersistMgr pm; - return pm.getMaxUsedSlot() + 1; // TODO: Since we use slot 0, this misses a bit. + return 100; } void removeSaveState(const char *target, int slot) const { - WinterMute::CBPersistMgr pm; + WinterMute::CBPersistMgr pm(NULL, target); pm.deleteSaveSlot(slot); } virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const { - WinterMute::CBPersistMgr pm; + WinterMute::CBPersistMgr pm(NULL, target); SaveStateDescriptor retVal; retVal.setDescription("Invalid savegame"); pm.getSaveStateDesc(slot, retVal); diff --git a/engines/wintermute/wintermute.cpp b/engines/wintermute/wintermute.cpp index ce66e197b3..835aa74e88 100644 --- a/engines/wintermute/wintermute.cpp +++ b/engines/wintermute/wintermute.cpp @@ -188,6 +188,8 @@ int WinterMuteEngine::init() { // load general game settings _game->initialize1(); + // set gameId, for savegame-naming: + _game->setGameId(_targetName); if (DID_FAIL(_game->loadSettings("startup.settings"))) { _game->LOG(0, "Error loading game settings."); diff --git a/engines/wintermute/wintermute.h b/engines/wintermute/wintermute.h index bfa4c73125..189f879eea 100644 --- a/engines/wintermute/wintermute.h +++ b/engines/wintermute/wintermute.h @@ -70,6 +70,7 @@ public: virtual ~Console(void) {} }; +// Mainly used for randInt() extern WinterMuteEngine *g_wintermute; } // End of namespace Wintermute |