aboutsummaryrefslogtreecommitdiff
path: root/engines/illusions/resources
diff options
context:
space:
mode:
authorjohndoe1232015-12-04 23:20:22 +0100
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commitaed38527010e7b155af469d0521aa07e7fd7d12e (patch)
tree95a5ce5eb4ce90fe1500a6265090a5292c5faf17 /engines/illusions/resources
parent6b36b750c2567c32d20f8f7868a8b664baac5cde (diff)
downloadscummvm-rg350-aed38527010e7b155af469d0521aa07e7fd7d12e.tar.gz
scummvm-rg350-aed38527010e7b155af469d0521aa07e7fd7d12e.tar.bz2
scummvm-rg350-aed38527010e7b155af469d0521aa07e7fd7d12e.zip
ILLUSIONS: Implement save/load functionality
- Only works in Duckman at the moment - Only via the ScummVM main menu for now, save/load via the game's menu to be implemented
Diffstat (limited to 'engines/illusions/resources')
-rw-r--r--engines/illusions/resources/scriptresource.cpp40
-rw-r--r--engines/illusions/resources/scriptresource.h7
2 files changed, 45 insertions, 2 deletions
diff --git a/engines/illusions/resources/scriptresource.cpp b/engines/illusions/resources/scriptresource.cpp
index 3038a8694d..5472d28658 100644
--- a/engines/illusions/resources/scriptresource.cpp
+++ b/engines/illusions/resources/scriptresource.cpp
@@ -50,8 +50,8 @@ void Properties::init(uint count, byte *properties) {
}
void Properties::clear() {
- uint size = (_count >> 3) + 1;
- for (uint i = 0; i < size; ++i)
+ uint32 size = getSize();
+ for (uint32 i = 0; i < size; ++i)
_properties[i] = 0;
}
@@ -72,6 +72,24 @@ void Properties::set(uint32 propertyId, bool value) {
_properties[index] &= ~mask;
}
+uint32 Properties::getSize() {
+ return (_count >> 3) + 1;
+}
+
+void Properties::writeToStream(Common::WriteStream *out) {
+ const uint32 size = getSize();
+ out->writeUint32LE(size);
+ out->write(_properties, size);
+}
+
+bool Properties::readFromStream(Common::ReadStream *in) {
+ uint32 size = in->readUint32LE();
+ if (size != getSize())
+ return false;
+ in->read(_properties, size);
+ return true;
+}
+
void Properties::getProperyPos(uint32 propertyId, uint &index, byte &mask) {
propertyId &= 0xFFFF;
index = propertyId >> 3;
@@ -113,6 +131,24 @@ void BlockCounters::setC0(uint index, byte value) {
_blockCounters[index - 1] = oldValue | (value & 0xC0);
}
+uint32 BlockCounters::getSize() {
+ return _count;
+}
+
+void BlockCounters::writeToStream(Common::WriteStream *out) {
+ const uint32 size = getSize();
+ out->writeUint32LE(size);
+ out->write(_blockCounters, size);
+}
+
+bool BlockCounters::readFromStream(Common::ReadStream *in) {
+ uint32 size = in->readUint32LE();
+ if (size != getSize())
+ return false;
+ in->read(_blockCounters, size);
+ return true;
+}
+
// TriggerCause
void TriggerCause::load(Common::SeekableReadStream &stream) {
diff --git a/engines/illusions/resources/scriptresource.h b/engines/illusions/resources/scriptresource.h
index 6debcb2efb..f185319f67 100644
--- a/engines/illusions/resources/scriptresource.h
+++ b/engines/illusions/resources/scriptresource.h
@@ -24,6 +24,7 @@
#define ILLUSIONS_SCRIPTRESOURCE_H
#include "illusions/resourcesystem.h"
+#include "common/file.h"
namespace Illusions {
@@ -46,6 +47,9 @@ public:
void clear();
bool get(uint32 propertyId);
void set(uint32 propertyId, bool value);
+ uint32 getSize();
+ void writeToStream(Common::WriteStream *out);
+ bool readFromStream(Common::ReadStream *in);
public:
uint _count;
byte *_properties;
@@ -61,6 +65,9 @@ public:
void set(uint index, byte value);
byte getC0(uint index);
void setC0(uint index, byte value);
+ uint32 getSize();
+ void writeToStream(Common::WriteStream *out);
+ bool readFromStream(Common::ReadStream *in);
public:
uint _count;
byte *_blockCounters;