diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/toltecs/detection.cpp | 39 | ||||
-rw-r--r-- | engines/toltecs/saveload.cpp | 31 | ||||
-rw-r--r-- | engines/toltecs/toltecs.cpp | 5 | ||||
-rw-r--r-- | engines/toltecs/toltecs.h | 3 |
4 files changed, 51 insertions, 27 deletions
diff --git a/engines/toltecs/detection.cpp b/engines/toltecs/detection.cpp index 3717d33950..8d685f8633 100644 --- a/engines/toltecs/detection.cpp +++ b/engines/toltecs/detection.cpp @@ -166,9 +166,11 @@ bool ToltecsMetaEngine::hasFeature(MetaEngineFeature f) const { return (f == kSupportsListSaves) || (f == kSupportsLoadingDuringStartup) || -// (f == kSupportsDeleteSave) || - (f == kSavesSupportMetaInfo) || - (f == kSavesSupportThumbnail); + (f == kSupportsDeleteSave) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportThumbnail) || + (f == kSavesSupportCreationDate) || + (f == kSavesSupportPlayTime); } bool Toltecs::ToltecsEngine::hasFeature(EngineFeature f) const { @@ -220,10 +222,6 @@ int ToltecsMetaEngine::getMaximumSaveSlot() const { } void ToltecsMetaEngine::removeSaveState(const char *target, int slot) const { - // Slot 0 can't be deleted, it's for restarting the game(s) - if (slot == 0) - return; - Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); Common::String filename = Toltecs::ToltecsEngine::getSavegameFilename(target, slot); @@ -240,19 +238,11 @@ void ToltecsMetaEngine::removeSaveState(const char *target, int slot) const { int slotNum = atoi(file->c_str() + file->size() - 3); // Rename every slot greater than the deleted slot, - // Also do not rename quicksaves. - if (slotNum > slot && slotNum < 990) { - // FIXME: Our savefile renaming done here is inconsitent with what we do in - // GUI_v2::deleteMenu. While here we rename every slot with a greater equal - // number of the deleted slot to deleted slot, deleted slot + 1 etc., - // we only rename the following slots in GUI_v2::deleteMenu until a slot - // is missing. + if (slotNum > slot) { saveFileMan->renameSavefile(file->c_str(), filename.c_str()); - filename = Toltecs::ToltecsEngine::getSavegameFilename(target, ++slot); } } - } SaveStateDescriptor ToltecsMetaEngine::querySaveMetaInfos(const char *target, int slot) const { @@ -269,10 +259,25 @@ SaveStateDescriptor ToltecsMetaEngine::querySaveMetaInfos(const char *target, in if (error == Toltecs::ToltecsEngine::kRSHENoError) { SaveStateDescriptor desc(slot, header.description); - desc.setDeletableFlag(false); + desc.setDeletableFlag(true); desc.setWriteProtectedFlag(false); desc.setThumbnail(header.thumbnail); + if (header.version > 0) { + int day = (header.saveDate >> 24) & 0xFF; + int month = (header.saveDate >> 16) & 0xFF; + int year = header.saveDate & 0xFFFF; + + desc.setSaveDate(year, month, day); + + int hour = (header.saveTime >> 16) & 0xFF; + int minutes = (header.saveTime >> 8) & 0xFF; + + desc.setSaveTime(hour, minutes); + + desc.setPlayTime(header.playTime * 1000); + } + return desc; } } diff --git a/engines/toltecs/saveload.cpp b/engines/toltecs/saveload.cpp index c421be4cd2..3e1be75a88 100644 --- a/engines/toltecs/saveload.cpp +++ b/engines/toltecs/saveload.cpp @@ -39,12 +39,12 @@ namespace Toltecs { - Maybe switch to SCUMM/Tinsel serialization approach? */ -#define TOLTECS_SAVEGAME_VERSION 0 // 0 is dev version until in official SVN +#define TOLTECS_SAVEGAME_VERSION 1 ToltecsEngine::kReadSaveHeaderError ToltecsEngine::readSaveHeader(Common::SeekableReadStream *in, bool loadThumbnail, SaveHeader &header) { header.version = in->readUint32LE(); - if (header.version != TOLTECS_SAVEGAME_VERSION) + if (header.version > TOLTECS_SAVEGAME_VERSION) return kRSHEInvalidVersion; byte descriptionLen = in->readByte(); @@ -62,17 +62,30 @@ ToltecsEngine::kReadSaveHeaderError ToltecsEngine::readSaveHeader(Common::Seekab header.gameID = in->readByte(); header.flags = in->readUint32LE(); + if (header.version > 0) { + header.saveDate = in->readUint32LE(); + header.saveTime = in->readUint32LE(); + header.playTime = in->readUint32LE(); + } else { + header.saveDate = 0; + header.saveTime = 0; + header.playTime = 0; + } + return ((in->eos() || in->err()) ? kRSHEIoError : kRSHENoError); } void ToltecsEngine::savegame(const char *filename, const char *description) { - Common::OutSaveFile *out; if (!(out = g_system->getSavefileManager()->openForSaving(filename))) { warning("Can't create file '%s', game not saved", filename); return; } + TimeDate curTime; + g_system->getTimeAndDate(curTime); + + // Header start out->writeUint32LE(TOLTECS_SAVEGAME_VERSION); byte descriptionLen = strlen(description); @@ -84,6 +97,13 @@ void ToltecsEngine::savegame(const char *filename, const char *description) { // Not used yet, reserved for future usage out->writeByte(0); out->writeUint32LE(0); + uint32 saveDate = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF); + uint32 saveTime = ((curTime.tm_hour & 0xFF) << 16) | (((curTime.tm_min) & 0xFF) << 8) | ((curTime.tm_sec) & 0xFF); + uint32 playTime = g_engine->getTotalPlayTime() / 1000; + out->writeUint32LE(saveDate); + out->writeUint32LE(saveTime); + out->writeUint32LE(playTime); + // Header end out->writeUint16LE(_cameraX); out->writeUint16LE(_cameraY); @@ -114,11 +134,9 @@ void ToltecsEngine::savegame(const char *filename, const char *description) { out->finalize(); delete out; - } void ToltecsEngine::loadgame(const char *filename) { - Common::InSaveFile *in; if (!(in = g_system->getSavefileManager()->openForLoading(filename))) { warning("Can't open file '%s', game not loaded", filename); @@ -135,6 +153,8 @@ void ToltecsEngine::loadgame(const char *filename) { return; } + g_engine->setTotalPlayTime(header.playTime * 1000); + _cameraX = in->readUint16LE(); _cameraY = in->readUint16LE(); _cameraHeight = in->readUint16LE(); @@ -171,7 +191,6 @@ void ToltecsEngine::loadgame(const char *filename) { _newCameraX = _cameraX; _newCameraY = _cameraY; - } Common::Error ToltecsEngine::loadGameState(int slot) { diff --git a/engines/toltecs/toltecs.cpp b/engines/toltecs/toltecs.cpp index 046578cffd..948c0c5ec3 100644 --- a/engines/toltecs/toltecs.cpp +++ b/engines/toltecs/toltecs.cpp @@ -166,6 +166,7 @@ Common::Error ToltecsEngine::run() { #endif // Start main game loop + setTotalPlayTime(0); _script->loadScript(0, 0); _script->setMainScript(0); if (ConfMan.hasKey("save_slot")) { @@ -297,7 +298,6 @@ void ToltecsEngine::updateScreen() { } void ToltecsEngine::drawScreen() { - // FIXME: Quick hack, sometimes cameraY was negative (the code in updateCamera was at fault) if (_cameraY < 0) _cameraY = 0; @@ -318,7 +318,6 @@ void ToltecsEngine::drawScreen() { _system->updateScreen(); updateCamera(); - } void ToltecsEngine::updateInput() { @@ -430,7 +429,6 @@ void ToltecsEngine::setGuiHeight(int16 guiHeight) { } void ToltecsEngine::setCamera(int16 x, int16 y) { - _screen->finishTalkTextItems(); _screen->clearSprites(); @@ -440,7 +438,6 @@ void ToltecsEngine::setCamera(int16 x, int16 y) { _cameraY = y; _newCameraY = y; - } bool ToltecsEngine::getCameraChanged() { diff --git a/engines/toltecs/toltecs.h b/engines/toltecs/toltecs.h index 279016cce8..3d49af6176 100644 --- a/engines/toltecs/toltecs.h +++ b/engines/toltecs/toltecs.h @@ -189,6 +189,9 @@ public: uint32 version; byte gameID; uint32 flags; + uint32 saveDate; + uint32 saveTime; + uint32 playTime; Graphics::Surface *thumbnail; }; |