aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen
diff options
context:
space:
mode:
authorBastien Bouclet2017-09-20 18:57:47 +0200
committerBastien Bouclet2017-09-22 07:05:58 +0200
commit48bf24b41e0222039e343dca175dcecd768c7e0c (patch)
tree7c23b3a6582f06b19025fb0d5d40ca6dd9bd2717 /engines/xeen
parent8547c89b86f0be02c4b3ef8e8adb4d5f96cf8432 (diff)
downloadscummvm-rg350-48bf24b41e0222039e343dca175dcecd768c7e0c.tar.gz
scummvm-rg350-48bf24b41e0222039e343dca175dcecd768c7e0c.tar.bz2
scummvm-rg350-48bf24b41e0222039e343dca175dcecd768c7e0c.zip
XEEN: Change SavesManager to use a map of pointers to MemoryWriteStreamDynamic
Our implementation of HashMap does not allow value types without a zero-argument constructor.
Diffstat (limited to 'engines/xeen')
-rw-r--r--engines/xeen/saves.cpp13
-rw-r--r--engines/xeen/saves.h2
2 files changed, 9 insertions, 6 deletions
diff --git a/engines/xeen/saves.cpp b/engines/xeen/saves.cpp
index 4df4b3727c..f7d93d1dc4 100644
--- a/engines/xeen/saves.cpp
+++ b/engines/xeen/saves.cpp
@@ -37,10 +37,10 @@ void OutFile::finalize() {
uint16 id = BaseCCArchive::convertNameToId(_filename);
if (!_vm->_saves->_newData.contains(id))
- _vm->_saves->_newData[id] = Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES);
+ _vm->_saves->_newData[id] = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES);
- Common::MemoryWriteStreamDynamic &out = _vm->_saves->_newData[id];
- out.write(getData(), size());
+ Common::MemoryWriteStreamDynamic *out = _vm->_saves->_newData[id];
+ out->write(getData(), size());
}
/*------------------------------------------------------------------------*/
@@ -54,6 +54,9 @@ SavesManager::SavesManager(XeenEngine *vm, Party &party) :
}
SavesManager::~SavesManager() {
+ for (Common::HashMap<uint16, Common::MemoryWriteStreamDynamic *>::iterator it = _newData.begin(); it != _newData.end(); it++) {
+ delete (*it)._value;
+ }
delete[] _data;
}
@@ -86,8 +89,8 @@ Common::SeekableReadStream *SavesManager::createReadStreamForMember(const Common
// save manager, then return that new resource
uint16 id = BaseCCArchive::convertNameToId(name);
if (_newData.contains(id)) {
- Common::MemoryWriteStreamDynamic stream = _newData[id];
- return new Common::MemoryReadStream(stream.getData(), stream.size());
+ Common::MemoryWriteStreamDynamic *stream = _newData[id];
+ return new Common::MemoryReadStream(stream->getData(), stream->size());
}
// Retrieve the resource from the loaded savefile
diff --git a/engines/xeen/saves.h b/engines/xeen/saves.h
index 2571c46600..404dee00a7 100644
--- a/engines/xeen/saves.h
+++ b/engines/xeen/saves.h
@@ -60,7 +60,7 @@ private:
XeenEngine *_vm;
Party &_party;
byte *_data;
- Common::HashMap<uint16, Common::MemoryWriteStreamDynamic > _newData;
+ Common::HashMap<uint16, Common::MemoryWriteStreamDynamic *> _newData;
void load(Common::SeekableReadStream *stream);
public: