diff options
author | Alyssa Milburn | 2011-07-18 15:05:38 +0200 |
---|---|---|
committer | Alyssa Milburn | 2011-07-18 15:05:38 +0200 |
commit | f5bac8464927ed3624186629a25c698ce4b313d8 (patch) | |
tree | 46617c784a548c0dde99a375ce576dab766d643f /engines/composer | |
parent | 7f2f38e5da88aba6cc2377ea05ee4bef3d4f0445 (diff) | |
download | scummvm-rg350-f5bac8464927ed3624186629a25c698ce4b313d8.tar.gz scummvm-rg350-f5bac8464927ed3624186629a25c698ce4b313d8.tar.bz2 scummvm-rg350-f5bac8464927ed3624186629a25c698ce4b313d8.zip |
COMPOSER: Implement saving/loading.
Diffstat (limited to 'engines/composer')
-rw-r--r-- | engines/composer/composer.cpp | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp index 1d5706142d..343b5d2bd2 100644 --- a/engines/composer/composer.cpp +++ b/engines/composer/composer.cpp @@ -32,6 +32,7 @@ #include "common/keyboard.h" #include "common/substream.h" #include "common/memstream.h" +#include "common/savefile.h" #include "graphics/cursorman.h" #include "graphics/surface.h" @@ -1546,12 +1547,44 @@ int16 ComposerEngine::scriptFuncCall(uint16 id, int16 param1, int16 param2, int1 // TODO: incomplete? return 1; case kFuncSaveVars: - // TODO - warning("ignoring kFuncSaveVars(%d)", param1); + debug(3, "kFuncSaveVars(%d)", param1); + { + Common::String filename = _targetName + Common::String::format(".%03d", param1); + Common::WriteStream *stream = _saveFileMan->openForSaving(filename); + for (uint i = 0; i < 1000; i++) { + stream->writeUint16LE(_vars[i]); + } + delete stream; + } return 1; case kFuncLoadVars: - // TODO - warning("ignoring kFuncLoadVars(%d, %d, %d)", param1, param2, param3); + debug(3, "kFuncLoadVars(%d, %d, %d)", param1, param2, param3); + { + Common::String filename = _targetName + Common::String::format(".%03d", param1); + Common::SeekableReadStream *stream = _saveFileMan->openForLoading(filename); + if (!stream) { + if (!_bookIni.hasKey(Common::String::format("%d", param1), "Data")) + return 0; + filename = getFilename("Data", param1); + Common::File *file = new Common::File(); + if (!file->open(filename)) + error("couldn't open '%s' to get vars id '%d'", filename.c_str(), param1); + stream = file; + } + if (param3 == 0) + param3 = 1000; + else + param3 = param3; + if (param2 < 0 || param3 < 0 || param2 + param3 > 1000) + error("can't read %d entries into %d from file '%s' for vars id '%d'", param3, param2, filename.c_str(), param1); + stream->skip(param2 * 2); + for (uint i = 0; i < (uint)param3; i++) { + if (stream->pos() + 1 > stream->size()) + break; + _vars[param2 + i] = stream->readUint16LE(); + } + delete stream; + } return 1; case kFuncQueueScriptOnce: debug(3, "kFuncQueueScriptOnce(%d, %d, %d)", param1, param2, param3); @@ -1598,7 +1631,7 @@ int16 ComposerEngine::scriptFuncCall(uint16 id, int16 param1, int16 param2, int1 warning("ignoring kFuncSaveData(%d, %d, %d)", param1, param2, param3); return 1; case kFuncLoadData: - debug(3, "ignoring kFuncLoadData(%d, %d, %d)", param1, param2, param3); + debug(3, "kFuncLoadData(%d, %d, %d)", param1, param2, param3); { Common::String filename = getFilename("Data", param1); Common::File *file = new Common::File(); @@ -1607,7 +1640,7 @@ int16 ComposerEngine::scriptFuncCall(uint16 id, int16 param1, int16 param2, int1 if (param3 == 0) param3 = 1000; else - param3 = param3 / 2; + param3 = param3; if (param2 < 0 || param3 < 0 || param2 + param3 > 1000) error("can't read %d entries into %d from file '%s' for data id '%d'", param3, param2, filename.c_str(), param1); for (uint i = 0; i < (uint)param3; i++) { |