void MohawkEngine_Riven::changeToStack(uint16 n) { // The endings are in reverse order because of the way the 1.02 patch works. // The only "Data3" file is j_Data3.mhk from that patch. Patch files have higher // priorities over the regular files and are therefore loaded and checked first. static const char *endings[] = { "_Data3.mhk", "_Data2.mhk", "_Data1.mhk", "_Data.mhk", "_Sounds.mhk" }; // Don't change stack to the current stack (if the files are loaded) if (_curStack == n && !_mhk.empty()) return; _curStack = n; // Stop any videos playing _video->stopVideos(); _video->clearMLST(); // Clear the graphics cache; images aren't used across stack boundaries _gfx->clearCache(); // Clear the old stack files out for (uint32 i = 0; i < _mhk.size(); i++) delete _mhk[i]; _mhk.clear(); // Get the prefix character for the destination stack char prefix = getStackName(_curStack)[0]; // Load any file that fits the patterns for (int i = 0; i < ARRAYSIZE(endings); i++) { Common::String filename = Common::String(prefix) + endings[i]; MohawkArchive *mhk = new MohawkArchive(); if (mhk->open(filename)) _mhk.push_back(mhk); else delete mhk; } // Make sure we have loaded files if (_mhk.empty()) error("Could not load stack %s", getStackName(_curStack).c_str()); // Stop any currently playing sounds _sound->stopAllSLST(); }
void MohawkEngine_CSTime::loadResourceFile(Common::String name) { MohawkArchive *archive = new MohawkArchive(); if (!archive->open(name + ".mhk")) error("failed to open %s.mhk", name.c_str()); _mhk.push_back(archive); }