mirror of
https://github.com/scummvm/scummvm.git
synced 2025-04-02 10:52:32 -04:00
DREAMWEB: Use serializer for ReelRoutines
This commit is contained in:
parent
5958d2d29a
commit
b0a42f115e
1 changed files with 23 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue