diff options
author | Willem Jan Palenstijn | 2011-12-17 21:30:54 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2011-12-17 21:30:54 +0100 |
commit | b0a42f115eb8333cb6f25eb713324ef778822bce (patch) | |
tree | 42e8333a61af2df8094475c9d35322d676156579 | |
parent | 5958d2d29af136a7adcbc4dc2abbb8ee5e0fcbba (diff) | |
download | scummvm-rg350-b0a42f115eb8333cb6f25eb713324ef778822bce.tar.gz scummvm-rg350-b0a42f115eb8333cb6f25eb713324ef778822bce.tar.bz2 scummvm-rg350-b0a42f115eb8333cb6f25eb713324ef778822bce.zip |
DREAMWEB: Use serializer for ReelRoutines
-rw-r--r-- | engines/dreamweb/saveload.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp index c77c419148..a47afdea63 100644 --- a/engines/dreamweb/saveload.cpp +++ b/engines/dreamweb/saveload.cpp @@ -25,12 +25,25 @@ #include "gui/saveload.h" #include "common/config-manager.h" #include "common/translation.h" +#include "common/serializer.h" namespace DreamGen { // Temporary storage for loading the room from a savegame Room g_madeUpRoomDat; + +void syncReelRoutine(Common::Serializer &s, ReelRoutine *reel) { + s.syncAsByte(reel->reallocation); + s.syncAsByte(reel->mapX); + s.syncAsByte(reel->mapY); + s.syncAsByte(reel->b3); + s.syncAsByte(reel->b4); + s.syncAsByte(reel->period); + s.syncAsByte(reel->counter); + s.syncAsByte(reel->b7); +} + void DreamGenContext::loadGame() { if (data.byte(kCommandtype) != 246) { data.byte(kCommandtype) = 246; @@ -405,6 +418,11 @@ void DreamGenContext::savePosition(unsigned int slot, const char *descbuf) { outSaveFile->write((const uint8 *)&madeUpRoom, sizeof(Room)); outSaveFile->write(data.ptr(kRoomscango, 16), 16); + // TODO: Convert more to serializer? + Common::Serializer s(0, outSaveFile); + for (unsigned int i = 0; 8*i < kLenofreelrouts; ++i) { + syncReelRoutine(s, (ReelRoutine*)data.ptr(kReelroutines + 8*i, 8)); + } outSaveFile->write(data.ptr(kReelroutines, len[5]), len[5]); outSaveFile->finalize(); @@ -454,7 +472,11 @@ void DreamGenContext::loadPosition(unsigned int slot) { inSaveFile->read((uint8 *)&g_madeUpRoomDat, sizeof(Room)); inSaveFile->read(data.ptr(kRoomscango, 16), 16); - inSaveFile->read(data.ptr(kReelroutines, len[5]), len[5]); + // TODO: Use serializer for more + Common::Serializer s(inSaveFile, 0); + for (unsigned int i = 0; 8*i < kLenofreelrouts; ++i) { + syncReelRoutine(s, (ReelRoutine*)data.ptr(kReelroutines + 8*i, 8)); + } delete inSaveFile; } |