aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2011-12-17 21:30:54 +0100
committerWillem Jan Palenstijn2011-12-17 21:30:54 +0100
commitb0a42f115eb8333cb6f25eb713324ef778822bce (patch)
tree42e8333a61af2df8094475c9d35322d676156579
parent5958d2d29af136a7adcbc4dc2abbb8ee5e0fcbba (diff)
downloadscummvm-rg350-b0a42f115eb8333cb6f25eb713324ef778822bce.tar.gz
scummvm-rg350-b0a42f115eb8333cb6f25eb713324ef778822bce.tar.bz2
scummvm-rg350-b0a42f115eb8333cb6f25eb713324ef778822bce.zip
DREAMWEB: Use serializer for ReelRoutines
-rw-r--r--engines/dreamweb/saveload.cpp24
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;
}