Exemplo n.º 1
0
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->openFile(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();
}
Exemplo n.º 2
0
void MohawkEngine_Riven::changeToStack(uint16 stackId) {
	// Don't change stack to the current stack (if the files are loaded)
	if (_stack && _stack->getId() == stackId && !_mhk.empty())
		return;

	// Free resources that may rely on the current stack data being loaded
	if (_card) {
		_card->leave();
		delete _card;
		_card = nullptr;
	}
	_video->removeVideos();
	_sound->stopAllSLST();

	// 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 = RivenStacks::getName(stackId)[0];

	// Load files that start with the prefix
	const char **datafiles = listExpectedDatafiles();
	for (int i = 0; datafiles[i] != nullptr; i++) {
		if (datafiles[i][0] == prefix) {
			MohawkArchive *mhk = new MohawkArchive();
			if (mhk->openFile(datafiles[i]))
				_mhk.push_back(mhk);
			else
				delete mhk;
		}
	}

	// Make sure we have loaded files
	if (_mhk.empty())
		error("Could not load stack %s", RivenStacks::getName(stackId));

	delete _stack;
	_stack = constructStackById(stackId);
}
Exemplo n.º 3
0
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);
}