From 23576c8f155833614f5207b14005f9a69f1c8d4f Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sat, 3 Dec 2011 16:30:51 +0100 Subject: DREAMWEB: Clean up --- engines/dreamweb/saveload.cpp | 20 +++++++------------- engines/dreamweb/stubs.cpp | 4 ++-- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp index b520150254..6af4071248 100644 --- a/engines/dreamweb/saveload.cpp +++ b/engines/dreamweb/saveload.cpp @@ -60,7 +60,7 @@ void DreamGenContext::doLoad() { namesToOld(); data.byte(kGetback) = 0; - while (true) { + while (data.byte(kGetback) == 0) { if (quitRequested()) return; delPointer(); @@ -77,8 +77,6 @@ void DreamGenContext::doLoad() { { 0xFFFF,0,0,0,0 } }; checkCoords(loadlist); - if (data.byte(kGetback) == 1) - break; // This signalled that actualLoad loaded a game if (data.byte(kGetback) == 2) return; // "quitloaded" } @@ -114,8 +112,6 @@ void DreamGenContext::doLoad() { if (data.word(kTempgraphics) != 0xFFFF) getRidOfTemp(); - dx = data; - es = dx; const Room *room = (const Room *)cs.ptr(kMadeuproomdat, sizeof(Room)); startLoading(*room); loadRoomsSample(); @@ -160,7 +156,7 @@ void DreamGenContext::saveGame() { data.word(kBufferout) = 0; data.byte(kGetback) = 0; - while (true) { + while (data.byte(kGetback) == 0) { if (quitRequested()) return; delPointer(); @@ -179,10 +175,6 @@ void DreamGenContext::saveGame() { { 0xFFFF,0,0,0,0 } }; checkCoords(savelist); - _cmp(data.byte(kGetback), 0); - if (flags.z()) - continue; - break; } return; } else { @@ -340,7 +332,7 @@ void DreamGenContext::savePosition(unsigned int slot, const uint8 *descbuf) { for (int i = 0; i < 6; ++i) header.setLen(i, len[i]); - engine->writeToSaveFile((const uint8 *)&header, kHeaderlen); + engine->writeToSaveFile((const uint8 *)&header, sizeof(FileHeader)); engine->writeToSaveFile(descbuf, len[0]); engine->writeToSaveFile(data.ptr(kStartvars, len[1]), len[1]); engine->writeToSaveFile(getSegment(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]); @@ -362,7 +354,7 @@ void DreamGenContext::loadPosition(unsigned int slot) { FileHeader header; - engine->readFromSaveFile((uint8 *)&header, kHeaderlen); + engine->readFromSaveFile((uint8 *)&header, sizeof(FileHeader)); // read segment lengths from savegame file header int len[6]; @@ -383,6 +375,8 @@ void DreamGenContext::loadPosition(unsigned int slot) { engine->readFromSaveFile(getSegment(data.word(kBuffers)).ptr(kListofchanges, len[3]), len[3]); // len[4] == 48, which is sizeof(Room) plus 16 for 'Roomscango' + // Note: the values read into Madeuproomdat are only used in actualLoad, + // which is (almost) immediately called after this function engine->readFromSaveFile(data.ptr(kMadeuproomdat, sizeof(Room)), sizeof(Room)); engine->readFromSaveFile(data.ptr(kRoomscango, 16), 16); @@ -403,7 +397,7 @@ unsigned int DreamGenContext::scanForNames() { ++count; - engine->readFromSaveFile((uint8 *)&header, kHeaderlen); + engine->readFromSaveFile((uint8 *)&header, sizeof(FileHeader)); if (header.len(0) != 17) { ::warning("Error loading save: description buffer isn't 17 bytes"); diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp index 4b3428e47d..2db75ee3e5 100644 --- a/engines/dreamweb/stubs.cpp +++ b/engines/dreamweb/stubs.cpp @@ -583,7 +583,7 @@ uint16 DreamGenContext::standardLoad(const char *fileName) { FileHeader header; engine->openFile(fileName); - engine->readFromFile((uint8 *)&header, kHeaderlen); + engine->readFromFile((uint8 *)&header, sizeof(FileHeader)); uint16 sizeInBytes = header.len(0); uint16 result = allocateMem((sizeInBytes + 15) / 16); engine->readFromFile(getSegment(result).ptr(0, 0), sizeInBytes); @@ -2425,7 +2425,7 @@ void DreamGenContext::loadRoomData(const Room &room, bool skipDat) { flags._c = false; FileHeader header; - engine->readFromFile((uint8 *)&header, kHeaderlen); + engine->readFromFile((uint8 *)&header, sizeof(FileHeader)); // read segment lengths from room file header int len[15]; -- cgit v1.2.3