diff options
author | Willem Jan Palenstijn | 2011-12-03 16:00:55 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2011-12-03 16:07:48 +0100 |
commit | a64c89e7dd8ebfae94c4a5ee265e83324bae40a1 (patch) | |
tree | 62d7e493837afca41153478d98ccdb5e145c19b8 | |
parent | 15856843a49db4ca29c974ab071b3118528c93a7 (diff) | |
download | scummvm-rg350-a64c89e7dd8ebfae94c4a5ee265e83324bae40a1.tar.gz scummvm-rg350-a64c89e7dd8ebfae94c4a5ee265e83324bae40a1.tar.bz2 scummvm-rg350-a64c89e7dd8ebfae94c4a5ee265e83324bae40a1.zip |
DREAMWEB: Don't use Madeuproomdat as a global when not necessary
-rw-r--r-- | engines/dreamweb/saveload.cpp | 37 | ||||
-rw-r--r-- | engines/dreamweb/structs.h | 2 |
2 files changed, 25 insertions, 14 deletions
diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp index 79f6caeb31..b520150254 100644 --- a/engines/dreamweb/saveload.cpp +++ b/engines/dreamweb/saveload.cpp @@ -78,7 +78,7 @@ void DreamGenContext::doLoad() { }; checkCoords(loadlist); if (data.byte(kGetback) == 1) - break; + break; // This signalled that actualLoad loaded a game if (data.byte(kGetback) == 2) return; // "quitloaded" } @@ -106,6 +106,10 @@ void DreamGenContext::doLoad() { data.byte(kGetback) = 1; } + // If we reach this point, loadPosition() has just been called. + // Note: Among other things, it will have filled kMadeuproomdat. + + // kTempgraphics might not have been allocated if we bypassed all menus if (data.word(kTempgraphics) != 0xFFFF) getRidOfTemp(); @@ -307,17 +311,16 @@ void DreamGenContext::actualLoad() { void DreamGenContext::savePosition(unsigned int slot, const uint8 *descbuf) { - const Room *currentRoom = (const Room *)cs.ptr(kRoomdata + sizeof(Room)*data.byte(kLocation), sizeof(Room)); - Room *madeUpRoom = (Room *)cs.ptr(kMadeuproomdat, sizeof(Room)); + const Room ¤tRoom = g_roomData[data.byte(kLocation)]; - *madeUpRoom = *currentRoom; - madeUpRoom->roomsSample = data.byte(kRoomssample); - madeUpRoom->mapX = data.byte(kMapx); - madeUpRoom->mapY = data.byte(kMapy); - madeUpRoom->liftFlag = data.byte(kLiftflag); - madeUpRoom->b21 = data.byte(kManspath); - madeUpRoom->facing = data.byte(kFacing); - madeUpRoom->b27 = 255; + Room madeUpRoom = currentRoom; + madeUpRoom.roomsSample = data.byte(kRoomssample); + madeUpRoom.mapX = data.byte(kMapx); + madeUpRoom.mapY = data.byte(kMapy); + madeUpRoom.liftFlag = data.byte(kLiftflag); + madeUpRoom.b21 = data.byte(kManspath); + madeUpRoom.facing = data.byte(kFacing); + madeUpRoom.b27 = 255; openForSave(slot); @@ -342,7 +345,11 @@ void DreamGenContext::savePosition(unsigned int slot, const uint8 *descbuf) { engine->writeToSaveFile(data.ptr(kStartvars, len[1]), len[1]); engine->writeToSaveFile(getSegment(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]); engine->writeToSaveFile(getSegment(data.word(kBuffers)).ptr(kListofchanges, len[3]), len[3]); - engine->writeToSaveFile(data.ptr(kMadeuproomdat, len[4]), len[4]); + + // len[4] == 48, which is sizeof(Room) plus 16 for 'Roomscango' + engine->writeToSaveFile((const uint8 *)&madeUpRoom, sizeof(Room)); + engine->writeToSaveFile(data.ptr(kRoomscango, 16), 16); + engine->writeToSaveFile(data.ptr(kReelroutines, len[5]), len[5]); closeFile(); } @@ -374,7 +381,11 @@ void DreamGenContext::loadPosition(unsigned int slot) { engine->readFromSaveFile(data.ptr(kStartvars, len[1]), len[1]); engine->readFromSaveFile(getSegment(data.word(kExtras)).ptr(kExframedata, len[2]), len[2]); engine->readFromSaveFile(getSegment(data.word(kBuffers)).ptr(kListofchanges, len[3]), len[3]); - engine->readFromSaveFile(data.ptr(kMadeuproomdat, len[4]), len[4]); + + // len[4] == 48, which is sizeof(Room) plus 16 for 'Roomscango' + engine->readFromSaveFile(data.ptr(kMadeuproomdat, sizeof(Room)), sizeof(Room)); + engine->readFromSaveFile(data.ptr(kRoomscango, 16), 16); + engine->readFromSaveFile(cs.ptr(kReelroutines, len[5]), len[5]); closeFile(); diff --git a/engines/dreamweb/structs.h b/engines/dreamweb/structs.h index 106b27ea84..39bfeb7f4e 100644 --- a/engines/dreamweb/structs.h +++ b/engines/dreamweb/structs.h @@ -208,7 +208,7 @@ struct Room { uint8 b30; uint8 realLocation; }; -extern const Room g_RoomData[]; +extern const Room g_roomData[]; struct Rain { uint8 x; |