From 830c39a6871ce6cae5d22bdf0f326fa063582ea7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 23 Nov 2010 22:27:40 +0000 Subject: SWORD2: Reduce dependencies on common/memstream.h svn-id: r54442 --- engines/sword2/header.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++ engines/sword2/mouse.cpp | 1 + engines/sword2/object.h | 73 +++------------------------------------------ engines/sword2/router.cpp | 2 +- engines/sword2/saveload.cpp | 1 + 5 files changed, 78 insertions(+), 70 deletions(-) (limited to 'engines/sword2') diff --git a/engines/sword2/header.cpp b/engines/sword2/header.cpp index c930b0c8e7..6ab88d159d 100644 --- a/engines/sword2/header.cpp +++ b/engines/sword2/header.cpp @@ -24,6 +24,7 @@ */ #include "sword2/header.h" +#include "sword2/object.h" #include "sword2/screen.h" #include "sword2/sword2.h" @@ -290,4 +291,74 @@ void Parallax::write(byte *addr) { writeS.writeUint16LE(h); } +void ObjectMouse::read(byte *addr) { + Common::MemoryReadStream readS(addr, size()); + + x1 = readS.readSint32LE(); + y1 = readS.readSint32LE(); + x2 = readS.readSint32LE(); + y2 = readS.readSint32LE(); + priority = readS.readSint32LE(); + pointer = readS.readSint32LE(); +} + +void ObjectMouse::write(byte *addr) { + Common::MemoryWriteStream writeS(addr, size()); + + writeS.writeSint32LE(x1); + writeS.writeSint32LE(y1); + writeS.writeSint32LE(x2); + writeS.writeSint32LE(y2); + writeS.writeSint32LE(priority); + writeS.writeSint32LE(pointer); +} + +void ObjectWalkdata::read(byte *addr) { + Common::MemoryReadStream readS(addr, size()); + + nWalkFrames = readS.readUint32LE(); + usingStandingTurnFrames = readS.readUint32LE(); + usingWalkingTurnFrames = readS.readUint32LE(); + usingSlowInFrames = readS.readUint32LE(); + usingSlowOutFrames = readS.readUint32LE(); + + int i; + + for (i = 0; i < ARRAYSIZE(nSlowInFrames); i++) + nSlowInFrames[i] = readS.readUint32LE(); + + for (i = 0; i < ARRAYSIZE(leadingLeg); i++) + leadingLeg[i] = readS.readUint32LE(); + + for (i = 0; i < ARRAYSIZE(dx); i++) + dx[i] = readS.readUint32LE(); + + for (i = 0; i < ARRAYSIZE(dy); i++) + dy[i] = readS.readUint32LE(); +} + +void ObjectWalkdata::write(byte *addr) { + Common::MemoryWriteStream writeS(addr, size()); + + writeS.writeUint32LE(nWalkFrames); + writeS.writeUint32LE(usingStandingTurnFrames); + writeS.writeUint32LE(usingWalkingTurnFrames); + writeS.writeUint32LE(usingSlowInFrames); + writeS.writeUint32LE(usingSlowOutFrames); + + int i; + + for (i = 0; i < ARRAYSIZE(nSlowInFrames); i++) + writeS.writeUint32LE(nSlowInFrames[i]); + + for (i = 0; i < ARRAYSIZE(leadingLeg); i++) + writeS.writeUint32LE(leadingLeg[i]); + + for (i = 0; i < ARRAYSIZE(dx); i++) + writeS.writeUint32LE(dx[i]); + + for (i = 0; i < ARRAYSIZE(dy); i++) + writeS.writeUint32LE(dy[i]); +} + } // End of namespace Sword2 diff --git a/engines/sword2/mouse.cpp b/engines/sword2/mouse.cpp index 4dbb38eaca..7998079944 100644 --- a/engines/sword2/mouse.cpp +++ b/engines/sword2/mouse.cpp @@ -28,6 +28,7 @@ #include "common/system.h" #include "common/events.h" +#include "common/memstream.h" #include "graphics/cursorman.h" diff --git a/engines/sword2/object.h b/engines/sword2/object.h index 98c9f6863b..53819c08cc 100644 --- a/engines/sword2/object.h +++ b/engines/sword2/object.h @@ -28,7 +28,6 @@ #ifndef SWORD2_OBJECT_H #define SWORD2_OBJECT_H -#include "common/memstream.h" #include "common/endian.h" namespace Sword2 { @@ -52,27 +51,8 @@ struct ObjectMouse { return 24; } - void read(byte *addr) { - Common::MemoryReadStream readS(addr, size()); - - x1 = readS.readSint32LE(); - y1 = readS.readSint32LE(); - x2 = readS.readSint32LE(); - y2 = readS.readSint32LE(); - priority = readS.readSint32LE(); - pointer = readS.readSint32LE(); - } - - void write(byte *addr) { - Common::MemoryWriteStream writeS(addr, size()); - - writeS.writeSint32LE(x1); - writeS.writeSint32LE(y1); - writeS.writeSint32LE(x2); - writeS.writeSint32LE(y2); - writeS.writeSint32LE(priority); - writeS.writeSint32LE(pointer); - } + void read(byte *addr); + void write(byte *addr); }; // logic structure - contains fields used in logic script processing @@ -295,53 +275,8 @@ struct ObjectWalkdata { return 916; } - void read(byte *addr) { - Common::MemoryReadStream readS(addr, size()); - - nWalkFrames = readS.readUint32LE(); - usingStandingTurnFrames = readS.readUint32LE(); - usingWalkingTurnFrames = readS.readUint32LE(); - usingSlowInFrames = readS.readUint32LE(); - usingSlowOutFrames = readS.readUint32LE(); - - int i; - - for (i = 0; i < ARRAYSIZE(nSlowInFrames); i++) - nSlowInFrames[i] = readS.readUint32LE(); - - for (i = 0; i < ARRAYSIZE(leadingLeg); i++) - leadingLeg[i] = readS.readUint32LE(); - - for (i = 0; i < ARRAYSIZE(dx); i++) - dx[i] = readS.readUint32LE(); - - for (i = 0; i < ARRAYSIZE(dy); i++) - dy[i] = readS.readUint32LE(); - } - - void write(byte *addr) { - Common::MemoryWriteStream writeS(addr, size()); - - writeS.writeUint32LE(nWalkFrames); - writeS.writeUint32LE(usingStandingTurnFrames); - writeS.writeUint32LE(usingWalkingTurnFrames); - writeS.writeUint32LE(usingSlowInFrames); - writeS.writeUint32LE(usingSlowOutFrames); - - int i; - - for (i = 0; i < ARRAYSIZE(nSlowInFrames); i++) - writeS.writeUint32LE(nSlowInFrames[i]); - - for (i = 0; i < ARRAYSIZE(leadingLeg); i++) - writeS.writeUint32LE(leadingLeg[i]); - - for (i = 0; i < ARRAYSIZE(dx); i++) - writeS.writeUint32LE(dx[i]); - - for (i = 0; i < ARRAYSIZE(dy); i++) - writeS.writeUint32LE(dy[i]); - } + void read(byte *addr); + void write(byte *addr); }; } // End of namespace Sword2 diff --git a/engines/sword2/router.cpp b/engines/sword2/router.cpp index 9c79f1f9cb..1548536ccb 100644 --- a/engines/sword2/router.cpp +++ b/engines/sword2/router.cpp @@ -26,7 +26,7 @@ */ -#include "common/stream.h" +#include "common/memstream.h" #include "sword2/sword2.h" #include "sword2/defs.h" diff --git a/engines/sword2/saveload.cpp b/engines/sword2/saveload.cpp index 9258d37fe3..fab360a8ac 100644 --- a/engines/sword2/saveload.cpp +++ b/engines/sword2/saveload.cpp @@ -35,6 +35,7 @@ // --------------------------------------------------------------------------- +#include "common/memstream.h" #include "common/savefile.h" #include "sword2/sword2.h" -- cgit v1.2.3