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
This commit is contained in:
johndoe123 2015-12-04 23:20:22 +01:00 committed by Eugene Sandulenko
parent 6b36b750c2
commit aed3852701
15 changed files with 511 additions and 67 deletions

View file

@ -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) {