From 48bf24b41e0222039e343dca175dcecd768c7e0c Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Wed, 20 Sep 2017 18:57:47 +0200 Subject: 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. --- engines/xeen/saves.cpp | 13 ++++++++----- engines/xeen/saves.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'engines/xeen') 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::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 _newData; + Common::HashMap _newData; void load(Common::SeekableReadStream *stream); public: -- cgit v1.2.3