Example #1
0
bool ScScript::finishThreads() {
	for (uint32 i = 0; i < _engine->_scripts.size(); i++) {
		ScScript *scr = _engine->_scripts[i];
		if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) {
			scr->finish(true);
		}
	}
	return STATUS_OK;
}
Example #2
0
int Inventory::getIndex(char* name) {
	uint i = 0;

	for (i = 0; i < _inventory.size(); i++) {
		if (!scumm_stricmp(_inventory[i]->name, name))
			return i;
	}
	return UNKNOWN_OBJECT;
}
Example #3
0
const PlainGameDescriptor *findPlainGameDescriptor(const char *gameid, const PlainGameDescriptor *list) {
	const PlainGameDescriptor *g = list;
	while (g->gameid) {
		if (0 == scumm_stricmp(gameid, g->gameid))
			return g;
		g++;
	}
	return 0;
}
Example #4
0
bool SaveLoad_ns::saveGame() {
	// NOTE: shouldn't this check be done before, so that the
	// user can't even select 'save'?
	if (!scumm_stricmp(_vm->_location._name, "caveau")) {
		return false;
	}

	return SaveLoad::saveGame();
}
Example #5
0
bool ResourceManager::exist(const char *name) {
	debugC(1, kCGEDebugFile, "ResourceManager::exist(%s)", name);

	BtKeypack* result = find(name);
	if (!result)
		return false;

	return scumm_stricmp(result->_key, name) == 0;
}
Example #6
0
// Search for a node with the given "name", inside fslist. Ignores case
// when performing the matching. The first match is returned, so if you
// search for "resource" and two nodes "RESOURE and "resource" are present,
// the first match is used.
static bool searchFSNode(const Common::FSList &fslist, const Common::String &name, Common::FSNode &result) {
	for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
		if (!scumm_stricmp(file->getName().c_str(), name.c_str())) {
			result = *file;
			return true;
		}
	}
	return false;
}
Example #7
0
GameDescriptor Sword2MetaEngine::findGame(const char *gameid) const {
	const Sword2::GameSettings *g = Sword2::sword2_settings;
	while (g->gameid) {
		if (0 == scumm_stricmp(gameid, g->gameid))
			break;
		g++;
	}
	return GameDescriptor(g->gameid, g->description);
}
Example #8
0
SaveLoad_v4::SaveFile *SaveLoad_v4::getSaveFile(const char *fileName) {
	fileName = stripPath(fileName);

	for (int i = 0; i < ARRAYSIZE(_saveFiles); i++)
		if (!scumm_stricmp(fileName, _saveFiles[i].sourceName))
			return &_saveFiles[i];

	return 0;
}
Example #9
0
/*
   Compare two filename (fileName1,fileName2).
   If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
   If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
                                                                or strcasecmp)
   If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
        (like 1 on Unix, 2 on Windows)

*/
int unzStringFileNameCompare(const char* fileName1, const char* fileName2, int iCaseSensitivity) {
	if (iCaseSensitivity==0)
		iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;

	if (iCaseSensitivity==1)
		return strcmp(fileName1,fileName2);

	return scumm_stricmp(fileName1,fileName2);
}
void ConfigFile::removeSection(const String &section) {
	assert(isValidName(section));
	for (List<Section>::iterator i = _sections.begin(); i != _sections.end(); ++i) {
		if (!scumm_stricmp(section.c_str(), i->name.c_str())) {
			_sections.erase(i);
			return;
		}
	}
}
Example #11
0
static void computeGameSettingsFromMD5(const Common::FSList &fslist, const GameFilenamePattern *gfp, const MD5Table *md5Entry, DetectorResult &dr) {
	dr.language = md5Entry->language;
	dr.extra = md5Entry->extra;

	// Compute the precise game settings using gameVariantsTable.
	for (const GameSettings *g = gameVariantsTable; g->gameid; ++g) {
		if (g->gameid[0] == 0 || !scumm_stricmp(md5Entry->gameid, g->gameid)) {
			// The gameid either matches, or is empty. The latter indicates
			// a generic entry, currently used for some generic HE settings.
			if (g->variant == 0 || !scumm_stricmp(md5Entry->variant, g->variant)) {
				// Perfect match found, use it and stop the loop
				dr.game = *g;
				dr.game.gameid = md5Entry->gameid;

				// Set the platform value. The value from the MD5 record has
				// highest priority; if missing (i.e. set to unknown) we try
				// to use that from the filename pattern record instead.
				if (md5Entry->platform != Common::kPlatformUnknown) {
					dr.game.platform = md5Entry->platform;
				} else if (gfp->platform != Common::kPlatformUnknown) {
					dr.game.platform = gfp->platform;
				}

				// HACK: Special case to distinguish the V1 demo from the full version
				// (since they have identical MD5):
				if (dr.game.id == GID_MANIAC && !strcmp(gfp->pattern, "%02d.MAN")) {
					dr.extra = "V1 Demo";
				}

				// HACK: If 'Demo' occurs in the extra string, set the GF_DEMO flag,
				// required by some game demos (e.g. Dig, FT and COMI).
				if (dr.extra && strstr(dr.extra, "Demo")) {
					dr.game.features |= GF_DEMO;
				}

				// HACK: Try to detect languages for translated games
				if (dr.language == UNK_LANG) {
					dr.language = detectLanguage(fslist, dr.game.id);
				}
				break;
			}
		}
	}
}
Example #12
0
bool ScummFile::openSubFile(const Common::String &filename) {
	assert(isOpen());

	// Disable the XOR encryption and reset any current subfile range
	setEnc(0);
	resetSubfile();

	// Read in the filename table and look for the specified file

	unsigned long file_off, file_len;
	char file_name[0x20+1];
	unsigned long i;

	// Get the length of the data file to use for consistency checks
	const uint32 data_file_len = size();

	// Read offset and length to the file records */
	const uint32 file_record_off = readUint32BE();
	const uint32 file_record_len = readUint32BE();

	// Do a quick check to make sure the offset and length are good
	if (file_record_off + file_record_len > data_file_len) {
		return false;
	}

	// Do a little consistancy check on file_record_length
	if (file_record_len % 0x28) {
		return false;
	}

	// Scan through the files
	for (i = 0; i < file_record_len; i += 0x28) {
		// read a file record
		seek(file_record_off + i, SEEK_SET);
		file_off = readUint32BE();
		file_len = readUint32BE();
		read(file_name, 0x20);
		file_name[0x20] = 0;

		assert(file_name[0]);
		//debug(7, "  extracting \'%s\'", file_name);

		// Consistency check. make sure the file data is in the file
		if (file_off + file_len > data_file_len) {
			return false;
		}

		if (scumm_stricmp(file_name, filename.c_str()) == 0) {
			// We got a match!
			setSubfileRange(file_off, file_len);
			return true;
		}
	}

	return false;
}
Example #13
0
GameVar *GameVar::getSubVarByName(const char *name) {
	GameVar *sv = 0;

	if (_subVars != 0) {
		sv = _subVars;
		for (;sv && scumm_stricmp(sv->_varName, name); sv = sv->_nextVarObj)
			;
	}
	return sv;
}
Example #14
0
HRESULT CPartEmitter::RemoveForce(char *Name) {
	for (int i = 0; i < m_Forces.GetSize(); i++) {
		if (scumm_stricmp(Name, m_Forces[i]->m_Name) == 0) {
			delete m_Forces[i];
			m_Forces.RemoveAt(i);
			return S_OK;
		}
	}
	return E_FAIL;
}
Example #15
0
HRESULT CPartEmitter::RemoveSprite(char *Filename) {
	for (int i = 0; i < m_Sprites.GetSize(); i++) {
		if (scumm_stricmp(Filename, m_Sprites[i]) == 0) {
			delete [] m_Sprites[i];
			m_Sprites.RemoveAt(i);
			return S_OK;
		}
	}
	return E_FAIL;
}
Example #16
0
bool PartEmitter::removeForce(const Common::String &name) {
	for (uint32 i = 0; i < _forces.size(); i++) {
		if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) {
			delete _forces[i];
			_forces.remove_at(i);
			return STATUS_OK;
		}
	}
	return STATUS_FAILED;
}
Example #17
0
bool PartEmitter::removeSprite(const char *filename) {
	for (uint32 i = 0; i < _sprites.size(); i++) {
		if (scumm_stricmp(filename, _sprites[i]) == 0) {
			delete[] _sprites[i];
			_sprites.remove_at(i);
			return STATUS_OK;
		}
	}
	return STATUS_FAILED;
}
Example #18
0
GameVar *GameVar::getSubVarByName(const Common::String &name) {
	GameVar *sv = 0;

	if (_subVars != 0) {
		sv = _subVars;
		for (;sv && scumm_stricmp(sv->_varName.c_str(), name.c_str()); sv = sv->_nextVarObj)
			;
	}
	return sv;
}
Example #19
0
Sword2Engine::Sword2Engine(OSystem *syst) : Engine(syst) {
	// Add default file directories
	const Common::FSNode gameDataDir(ConfMan.get("path"));
	SearchMan.addSubDirectoryMatching(gameDataDir, "clusters");
	SearchMan.addSubDirectoryMatching(gameDataDir, "sword2");
	SearchMan.addSubDirectoryMatching(gameDataDir, "video");
	SearchMan.addSubDirectoryMatching(gameDataDir, "smacks");

	if (!scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2demo") || !scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2psxdemo"))
		_features = GF_DEMO;
	else
		_features = 0;

	// Check if we are running PC or PSX version.
	if (!scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2psx") || !scumm_stricmp(ConfMan.get("gameid").c_str(), "sword2psxdemo"))
		Sword2Engine::_platform = Common::kPlatformPSX;
	else
		Sword2Engine::_platform = Common::kPlatformPC;

	_bootParam = ConfMan.getInt("boot_param");
	_saveSlot = ConfMan.getInt("save_slot");

	_memory = NULL;
	_resman = NULL;
	_sound = NULL;
	_screen = NULL;
	_mouse = NULL;
	_logic = NULL;
	_fontRenderer = NULL;
	_debugger = NULL;

	_keyboardEvent.pending = false;
	_mouseEvent.pending = false;

	_wantSfxDebug = false;

	_gameCycle = 0;
	_gameSpeed = 1;

	_gmmLoadSlot = -1; // Used to manage GMM Loading

	g_eventRec.registerRandomSource(_rnd, "sword2");
}
Example #20
0
uint32 Database::getRoomId(const char *name) {
	for (uint i = 0; i < _ages.size(); i++)
		for (uint j = 0; j < _ages[i].rooms.size(); j++) {
			if (!scumm_stricmp(_ages[i].rooms[j].name, name)) {
				return _ages[i].rooms[j].id;
			}
		}

	return 0;
}
Example #21
0
const Font *FontManager::getFontByName(const Common::String &name) const {
	for (int i = 0; builtinFontNames[i].name; i++)
		if (!scumm_stricmp(name.c_str(), builtinFontNames[i].name))
			return getFontByUsage(builtinFontNames[i].id);

	Common::String lowercaseName = name;
	lowercaseName.toLowercase();
	if (!_fontMap.contains(lowercaseName))
		return 0;
	return _fontMap[lowercaseName];
}
Example #22
0
bool OSystem::setGraphicsMode(const char *name) {
	if (!name)
		return false;

	// Special case for the 'default' filter
	if (!scumm_stricmp(name, "normal") || !scumm_stricmp(name, "default")) {
		return setGraphicsMode(getDefaultGraphicsMode());
	}

	const GraphicsMode *gm = getSupportedGraphicsModes();

	while (gm->name) {
		if (!scumm_stricmp(gm->name, name)) {
			return setGraphicsMode(gm->id);
		}
		gm++;
	}

	return false;
}
Example #23
0
TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) :
		Engine(syst), _gameDescription(gameDesc) {
	_vm = this;

	// Register debug flags
	Common::addDebugChannel(kTinselDebugAnimations, "animations", "Animations debugging");
	Common::addDebugChannel(kTinselDebugActions, "actions", "Actions debugging");
	Common::addDebugChannel(kTinselDebugSound, "sound", "Sound debugging");
	Common::addDebugChannel(kTinselDebugMusic, "music", "Music debugging");

	// Setup mixer
	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, ConfMan.getInt("sfx_volume"));
	_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, ConfMan.getInt("music_volume"));

	// Add DW2 subfolder to search path in case user is running directly from the CDs
	Common::File::addDefaultDirectory(_gameDataDir.getChild("dw2"));

	// Add subfolders needed for psx versions of Discworld 1	
	if (TinselV1PSX)
		SearchMan.addDirectory(_gameDataDir.getPath(), _gameDataDir, 0, 3, true);

	const GameSettings *g;

	const char *gameid = ConfMan.get("gameid").c_str();
	for (g = tinselSettings; g->gameid; ++g)
		if (!scumm_stricmp(g->gameid, gameid))
			_gameId = g->id;

	int cd_num = ConfMan.getInt("cdrom");
	if (cd_num >= 0)
		_system->openCD(cd_num);

	int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI);
	bool native_mt32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32"));
	//bool adlib = (midiDriver == MD_ADLIB);

	_driver = MidiDriver::createMidi(midiDriver);
	if (native_mt32)
		_driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);

	_midiMusic = new MidiMusicPlayer(_driver);
	_pcmMusic = new PCMMusicPlayer();
	//_midiMusic->setNativeMT32(native_mt32);
	//_midiMusic->setAdlib(adlib);

	_musicVolume = ConfMan.getInt("music_volume");

	_sound = new SoundManager(this);

	_mousePos.x = 0;
	_mousePos.y = 0;
	_keyHandler = NULL;
	_dosPlayerDir = 0;
}
Example #24
0
int CGEEngine::takeEnum(const char **tab, const char *text) {
	const char **e;
	if (text) {
		for (e = tab; *e; e++) {
			if (scumm_stricmp(text, *e) == 0) {
				return e - tab;
			}
		}
	}
	return -1;
}
Example #25
0
bool OSystem::setStretchMode(const char *name) {
	if (!name)
		return false;

	// Special case for the 'default' filter
	if (!scumm_stricmp(name, "default")) {
		return setStretchMode(getDefaultStretchMode());
	}

	const GraphicsMode *sm = getSupportedStretchModes();

	while (sm->name) {
		if (!scumm_stricmp(sm->name, name)) {
			return setStretchMode(sm->id);
		}
		sm++;
	}

	return false;
}
Example #26
0
void LocationParser_br::parseGetData(ZonePtr z) {
	TypeData *data = &z->u;
	if (!scumm_stricmp(_tokens[0], "file")) {
		GfxObj *obj = _vm->_gfx->loadGet(_tokens[1]);
		obj->frame = 0;
		obj->x = z->getX();
		obj->y = z->getY();
		obj->_prog = _zoneProg;
		data->_gfxobj = obj;
	} else
	if (!scumm_stricmp(_tokens[0], "mask")) {
		_out->_info->loadGfxObjMask(_tokens[1], data->_gfxobj);
	} else
	if (!scumm_stricmp(_tokens[0], "path")) {
		_out->_info->loadGfxObjPath(_tokens[1], data->_gfxobj);
	} else
	if (!scumm_stricmp(_tokens[0], "icon")) {
		data->_getIcon = 4 + _vm->_objectsNames->lookup(_tokens[1]);
	}
}
Example #27
0
Material *Model::findMaterial(const char *name, CMap *cmap) const {
	for (int i = 0; i < _numMaterials; ++i) {
		if (scumm_stricmp(name, _materialNames[i]) == 0) {
			if (cmap->getFilename() != _cmap->getFilename())
				_materials[i]->reload(cmap);
			return _materials[i];
		}
	}

	return NULL;
}
Example #28
0
Common::String VideoPlayer::findFile(const Common::String &file, Properties &properties) {

	bool hasExtension = false;

	Common::String base     = file;
	Common::String fileName = file;

	const char *posDot = strrchr(base.c_str(), '.');
	if (posDot) {
		hasExtension = true;
		base = Common::String(base.c_str(), posDot);
		posDot++;
	}

	if (hasExtension) {
		int i;
		for (i = 0; i < ARRAYSIZE(_extensions); i++) {
			if (!scumm_stricmp(posDot, _extensions[i])) {
				if ((properties.type != kVideoTypeTry) && (properties.type == ((Type) i))) {
					warning("Attempted to open video \"%s\", but requested a different type", fileName.c_str());
					return "";
				}
				properties.type = (Type) i;
				break;
			}
		}
		if (i >= ARRAYSIZE(_extensions))
			hasExtension = false;
	}

	if (!hasExtension) {
		// No or unrecognized extension. Probing.

		int i;
		for (i = 0; i < ARRAYSIZE(_extensions); i++) {
			if ((properties.type == kVideoTypeTry) || (properties.type == ((Type) i))) {
				fileName = base + "." + _extensions[i];

				if (_vm->_dataIO->hasFile(fileName)) {
					properties.type = (Type) i;
					break;
				}
			}
		}
		if ((i >= ARRAYSIZE(_extensions)) || (properties.type == kVideoTypeTry)) {
			warning("Couldn't open video \"%s\"", file.c_str());
			return "";
		}

	}

	return fileName;
}
Example #29
0
Dialogue *LocationParser_ns::parseDialogue() {
	debugC(7, kDebugParser, "parseDialogue()");

	Dialogue *dialogue = new Dialogue;
	assert(dialogue);

	_script->readLineToken(true);

	while (scumm_stricmp(_tokens[0], "enddialogue")) {
		if (!scumm_stricmp(_tokens[0], "question")) {
			Question *q = new Question(_tokens[1]);
			assert(q);
			parseQuestion(q);
			dialogue->addQuestion(q);
		}
		_script->readLineToken(true);
	}

	debugC(7, kDebugParser, "parseDialogue() done");

	return dialogue;
}
Example #30
0
void LocationParser_ns::parseCommandFlags() {

	int _si = ctxt.nextToken;
	CommandPtr cmd = ctxt.cmd;

	if (!scumm_stricmp(_tokens[_si], "flags")) {
		do {
			_si++;
			parseCommandFlag(cmd, _tokens[_si], _vm->_localFlagNames);
			_si++;
		} while (!scumm_stricmp(_tokens[_si], "|"));
	}

	if (!scumm_stricmp(_tokens[_si], "gflags")) {
		do {
			_si++;
			parseCommandFlag(cmd, _tokens[_si], _vm->_globalFlagsNames);
			_si++;
		} while (!scumm_stricmp(_tokens[_si], "|"));
		cmd->_flagsOn |= kFlagsGlobal;
	}
}