diff options
-rw-r--r-- | engines/xeen/saves.cpp | 13 | ||||
-rw-r--r-- | engines/xeen/saves.h | 2 |
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: |