diff options
author | Sven Hesse | 2011-01-24 10:31:19 +0000 |
---|---|---|
committer | Sven Hesse | 2011-01-24 10:31:19 +0000 |
commit | d706ab3ee8acaab4244c3baada96974fba349294 (patch) | |
tree | 5280a48d9dbab38dfea38839648b2c6cf4d3858c /engines | |
parent | 5564926e06d3ed6538f7413816d500f173e45e22 (diff) | |
download | scummvm-rg350-d706ab3ee8acaab4244c3baada96974fba349294.tar.gz scummvm-rg350-d706ab3ee8acaab4244c3baada96974fba349294.tar.bz2 scummvm-rg350-d706ab3ee8acaab4244c3baada96974fba349294.zip |
GOB: Urban: Write intro.0xx to file too
This fixes retrying after dying in the Secret Room.
svn-id: r55496
Diffstat (limited to 'engines')
-rw-r--r-- | engines/gob/save/saveload.h | 31 | ||||
-rw-r--r-- | engines/gob/save/saveload_v6.cpp | 79 |
2 files changed, 101 insertions, 9 deletions
diff --git a/engines/gob/save/saveload.h b/engines/gob/save/saveload.h index 62daedccb6..569ca831f9 100644 --- a/engines/gob/save/saveload.h +++ b/engines/gob/save/saveload.h @@ -680,6 +680,26 @@ protected: File _file; }; + /** Handles the autosave temp sprite. */ + class AutoSpriteHandler : public TempSpriteHandler { + public: + AutoSpriteHandler(GobEngine *vm, const Common::String &target); + ~AutoSpriteHandler(); + + int32 getSize(); + bool load(int16 dataVar, int32 size, int32 offset); + bool save(int16 dataVar, int32 size, int32 offset); + + private: + class File : public SlotFileStatic { + public: + File(GobEngine *vm, const Common::String &base); + ~File(); + }; + + File _file; + }; + /** Handles the temporary saves. */ class TempHandler : public SaveHandler { public: @@ -717,11 +737,12 @@ protected: static SaveFile _saveFiles[]; - SpriteHandler *_spriteHandler; - GameHandler *_gameHandler; - AutoHandler *_autoHandler; - TempHandler *_tmpHandler[2]; - ExtraHandler *_extraHandler[120]; + SpriteHandler *_spriteHandler; + GameHandler *_gameHandler; + AutoHandler *_autoHandler; + AutoSpriteHandler *_autoSpriteHandler; + TempHandler *_tmpHandler[2]; + ExtraHandler *_extraHandler[120]; SaveHandler *getHandler(const char *fileName) const; const char *getDescription(const char *fileName) const; diff --git a/engines/gob/save/saveload_v6.cpp b/engines/gob/save/saveload_v6.cpp index a499e34f3f..37ac08ebea 100644 --- a/engines/gob/save/saveload_v6.cpp +++ b/engines/gob/save/saveload_v6.cpp @@ -160,7 +160,7 @@ SaveLoad_v6::SaveFile SaveLoad_v6::_saveFiles[] = { { "cata3.057", kSaveModeSave, 0, "extra save" }, // Slot 57 { "cata3.058", kSaveModeSave, 0, "extra save" }, // Slot 58 { "cata3.059", kSaveModeSave, 0, "extra save" }, // Slot 59 - { "intro.0xx", kSaveModeIgnore, 0, 0 }, + { "intro.0xx", kSaveModeSave, 0, "temp sprite"}, // Autosave sprite { "intro.000", kSaveModeSave, 0, "temp sprite"}, // Slot 00 { "intro.001", kSaveModeSave, 0, "temp sprite"}, // Slot 01 { "intro.002", kSaveModeSave, 0, "temp sprite"}, // Slot 02 @@ -696,6 +696,73 @@ bool SaveLoad_v6::AutoHandler::save(int16 dataVar, int32 size, int32 offset) { } +SaveLoad_v6::AutoSpriteHandler::File::File(GobEngine *vm, const Common::String &base) : + SlotFileStatic(vm, base, "asp") { +} + +SaveLoad_v6::AutoSpriteHandler::File::~File() { +} + + +SaveLoad_v6::AutoSpriteHandler::AutoSpriteHandler(GobEngine *vm, + const Common::String &target) : TempSpriteHandler(vm), _file(vm, target) { + +} + +SaveLoad_v6::AutoSpriteHandler::~AutoSpriteHandler() { +} + +int32 SaveLoad_v6::AutoSpriteHandler::getSize() { + Common::InSaveFile *file = _file.openRead(); + if (!file) + return -1; + + delete file; + return 1; +} + +bool SaveLoad_v6::AutoSpriteHandler::load(int16 dataVar, int32 size, int32 offset) { + if (offset != 0) { + warning("Invalid autosprite saving procedure (%d, %d, %d)", dataVar, size, offset); + return false; + } + + if (!TempSpriteHandler::create(624, 272, true)) + return false; + + Common::String fileName = _file.build(); + if (fileName.empty()) + return false; + + SaveReader reader(1, 0, fileName); + if (!reader.load()) + return false; + + if (!reader.readPart(0, _sprite)) + return false; + + return TempSpriteHandler::load(dataVar, size, offset); +} + +bool SaveLoad_v6::AutoSpriteHandler::save(int16 dataVar, int32 size, int32 offset) { + if (!TempSpriteHandler::save(dataVar, size, offset)) + return false; + + if (offset != 0) { + warning("Invalid autosprite saving procedure (%d, %d, %d)", dataVar, size, offset); + return false; + } + + Common::String fileName = _file.build(); + if (fileName.empty()) + return false; + + SaveWriter writer(1, 0, fileName); + + return writer.writePart(0, _sprite); +} + + SaveLoad_v6::TempHandler::TempHandler(GobEngine *vm) : SaveHandler(vm), _empty(true), _size(0), _data(0) { } @@ -781,9 +848,10 @@ bool SaveLoad_v6::ExtraHandler::save(int16 dataVar, int32 size, int32 offset) { SaveLoad_v6::SaveLoad_v6(GobEngine *vm, const char *targetName) : SaveLoad(vm) { - _spriteHandler = new SpriteHandler(vm); - _gameHandler = new GameHandler(vm, targetName, *_spriteHandler); - _autoHandler = new AutoHandler(vm, targetName); + _spriteHandler = new SpriteHandler(vm); + _gameHandler = new GameHandler(vm, targetName, *_spriteHandler); + _autoHandler = new AutoHandler(vm, targetName); + _autoSpriteHandler = new AutoSpriteHandler(vm, targetName); _tmpHandler[0] = new TempHandler(vm); _tmpHandler[1] = new TempHandler(vm); @@ -801,6 +869,8 @@ SaveLoad_v6::SaveLoad_v6(GobEngine *vm, const char *targetName) : _saveFiles[69 + i].handler = _extraHandler[60 + i] = new ExtraHandler(_vm, *_gameHandler, 3, i); + _saveFiles[129].handler = _autoSpriteHandler; + for (int i = 0; i < 60; i++) _saveFiles[130 + i].handler = _spriteHandler; } @@ -811,6 +881,7 @@ SaveLoad_v6::~SaveLoad_v6() { delete _tmpHandler[0]; delete _tmpHandler[1]; + delete _autoSpriteHandler; delete _autoHandler; delete _gameHandler; delete _spriteHandler; |