diff options
Diffstat (limited to 'engines/fullpipe/utils.h')
-rw-r--r-- | engines/fullpipe/utils.h | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h index 2b97ab6480..8966ceb8ba 100644 --- a/engines/fullpipe/utils.h +++ b/engines/fullpipe/utils.h @@ -58,7 +58,17 @@ public: int readCount(); double readDouble(); CObject *parseClass(bool *isCopyReturned); - CObject *readClass(); + + template <typename T> + T *readClass() { + CObject *obj = readBaseClass(); + if (!obj) + return nullptr; + + T *res = dynamic_cast<T *>(obj); + assert(res); + return res; + } void writeObject(CObject *obj); @@ -76,6 +86,7 @@ public: private: void init(); + CObject *readBaseClass(); }; enum ObjType { @@ -106,9 +117,24 @@ public: bool loadFile(const Common::String &fname); }; -class ObList : public Common::List<CObject *>, public CObject { +template <class T> +class ObList : public Common::List<T *>, public CObject { public: - virtual bool load(MfcArchive &file); + virtual bool load(MfcArchive &file) { + debugC(5, kDebugLoading, "ObList::load()"); + int count = file.readCount(); + + debugC(9, kDebugLoading, "ObList::count: %d:", count); + + for (int i = 0; i < count; i++) { + debugC(9, kDebugLoading, "ObList::[%d]", i); + T *t = file.readClass<T>(); + + this->push_back(t); + } + + return true; + } }; class MemoryObject : CObject { |