From 16bbc100ddf15da2c321bf54cf1f66f580dcdc93 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 27 Apr 2014 21:15:46 +0300 Subject: MADS: Handle the missing sections in Phantom and Dragonsphere --- engines/mads/resources.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'engines') diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp index aef22d3734..b6caed7b0c 100644 --- a/engines/mads/resources.cpp +++ b/engines/mads/resources.cpp @@ -60,7 +60,7 @@ private: /** * Load the index of all the game's HAG files */ - void loadIndex(); + void loadIndex(MADSEngine *vm); /** * Given a resource name, opens up the correct HAG file and returns whether @@ -78,7 +78,7 @@ private: */ ResourceType getResourceType(const Common::String &resourceName) const; public: - HagArchive(); + HagArchive(MADSEngine *vm); virtual ~HagArchive(); // Archive implementation @@ -90,8 +90,8 @@ public: const char *const MADSCONCAT_STRING = "MADSCONCAT"; -HagArchive::HagArchive() { - loadIndex(); +HagArchive::HagArchive(MADSEngine *vm) { + loadIndex(vm); } HagArchive::~HagArchive() { @@ -146,13 +146,25 @@ Common::SeekableReadStream *HagArchive::createReadStreamForMember(const Common:: return nullptr; } -void HagArchive::loadIndex() { +void HagArchive::loadIndex(MADSEngine *vm) { Common::File hagFile; for (int sectionIndex = -1; sectionIndex < 10; ++sectionIndex) { if (sectionIndex == 0) continue; + // Dragonsphere does not have some sections - skip them + if (vm->getGameID() == GType_Dragonsphere) { + if (sectionIndex == 7 || sectionIndex == 8) + continue; + } + + // Phantom does not have some sections - skip them + if (vm->getGameID() == GType_Phantom) { + if (sectionIndex == 6 || sectionIndex == 7 || sectionIndex == 8) + continue; + } + Common::String filename = (sectionIndex == -1) ? "GLOBAL.HAG" : Common::String::format("SECTION%d.HAG", sectionIndex); if (!hagFile.open(filename)) @@ -275,7 +287,7 @@ ResourceType HagArchive::getResourceType(const Common::String &resourceName) con /*------------------------------------------------------------------------*/ void Resources::init(MADSEngine *vm) { - SearchMan.add("HAG", new HagArchive()); + SearchMan.add("HAG", new HagArchive(vm)); } Common::String Resources::formatName(RESPREFIX resType, int id, const Common::String &ext) { -- cgit v1.2.3