diff options
author | Paul Gilbert | 2019-06-16 13:29:15 -0700 |
---|---|---|
committer | Paul Gilbert | 2019-06-16 14:59:26 -0700 |
commit | 553bb74f8c380ee31fb771c6619dad8e83fed8ce (patch) | |
tree | bf99be6554e96d66d2700837d7c08dc0d48ad127 /engines/glk/scott | |
parent | 3876fb67108284063b4d133cf087a04dae6993e4 (diff) | |
download | scummvm-rg350-553bb74f8c380ee31fb771c6619dad8e83fed8ce.tar.gz scummvm-rg350-553bb74f8c380ee31fb771c6619dad8e83fed8ce.tar.bz2 scummvm-rg350-553bb74f8c380ee31fb771c6619dad8e83fed8ce.zip |
GLK: Further changeover of sub-engines to use new savegame code
Diffstat (limited to 'engines/glk/scott')
-rw-r--r-- | engines/glk/scott/scott.cpp | 28 | ||||
-rw-r--r-- | engines/glk/scott/scott.h | 9 |
2 files changed, 21 insertions, 16 deletions
diff --git a/engines/glk/scott/scott.cpp b/engines/glk/scott/scott.cpp index b918f8cda2..11b01c9e7e 100644 --- a/engines/glk/scott/scott.cpp +++ b/engines/glk/scott/scott.cpp @@ -21,6 +21,7 @@ */ #include "glk/scott/scott.h" +#include "glk/quetzal.h" #include "common/config-manager.h" #include "common/translation.h" @@ -508,41 +509,44 @@ void Scott::lineInput(char *buf, size_t n) { buf[ev.val1] = 0; } -Common::Error Scott::saveGameData(strid_t file, const Common::String &desc) { +Common::Error Scott::writeGameData(Common::WriteStream *ws) { Common::String msg; for (int ct = 0; ct < 16; ct++) { msg = Common::String::format("%d %d\n", _counters[ct], _roomSaved[ct]); - glk_put_string_stream(file, msg.c_str()); + ws->write(msg.c_str(), msg.size()); + ws->writeByte(0); } msg = Common::String::format("%u %d %d %d %d %d\n", _bitFlags, (_bitFlags & (1 << DARKBIT)) ? 1 : 0, MY_LOC, _currentCounter, _savedRoom, _gameHeader._lightTime); - glk_put_string_stream(file, msg.c_str()); + ws->write(msg.c_str(), msg.size()); + ws->writeByte(0); for (int ct = 0; ct <= _gameHeader._numItems; ct++) { msg = Common::String::format("%hd\n", (short)_items[ct]._location); - glk_put_string_stream(file, msg.c_str()); + ws->write(msg.c_str(), msg.size()); + ws->writeByte(0); } output(_("Saved.\n")); return Common::kNoError; } -Common::Error Scott::loadGameData(strid_t file) { - char buf[128]; +Common::Error Scott::readSaveData(Common::SeekableReadStream *rs) { + Common::String line; int ct = 0; short lo; short darkFlag; for (ct = 0; ct < 16; ct++) { - glk_get_line_stream(file, buf, sizeof buf); - sscanf(buf, "%d %d", &_counters[ct], &_roomSaved[ct]); + line = QuetzalReader::readString(rs); + sscanf(line.c_str(), "%d %d", &_counters[ct], &_roomSaved[ct]); } - glk_get_line_stream(file, buf, sizeof buf); - sscanf(buf, "%u %hd %d %d %d %d\n", + line = QuetzalReader::readString(rs); + sscanf(line.c_str(), "%u %hd %d %d %d %d\n", &_bitFlags, &darkFlag, &MY_LOC, &_currentCounter, &_savedRoom, &_gameHeader._lightTime); @@ -550,8 +554,8 @@ Common::Error Scott::loadGameData(strid_t file) { if (darkFlag) _bitFlags |= (1 << 15); for (ct = 0; ct <= _gameHeader._numItems; ct++) { - glk_get_line_stream(file, buf, sizeof buf); - sscanf(buf, "%hd\n", &lo); + line = QuetzalReader::readString(rs); + sscanf(line.c_str(), "%hd\n", &lo); _items[ct]._location = (unsigned char)lo; } diff --git a/engines/glk/scott/scott.h b/engines/glk/scott/scott.h index 4739e9470a..b7527fe6fc 100644 --- a/engines/glk/scott/scott.h +++ b/engines/glk/scott/scott.h @@ -177,14 +177,15 @@ public: virtual void runGame() override; /** - * Load a savegame from the passed stream + * Load a savegame from the passed Quetzal file chunk stream */ - virtual Common::Error loadGameData(strid_t file) override; + virtual Common::Error readSaveData(Common::SeekableReadStream *rs) override; /** - * Save the game to the passed stream + * Save the game. The passed write stream represents access to the UMem chunk + * in the Quetzal save file that will be created */ - virtual Common::Error saveGameData(strid_t file, const Common::String &desc) override; + virtual Common::Error writeGameData(Common::WriteStream *ws) override; }; } // End of namespace Scott |