Exemple #1
0
bool SaveStateDescriptor::getBool(const Common::String &key) const {
	if (contains(key)) {
		Common::String value = getVal(key);
		if (value.equalsIgnoreCase("true") ||
			value.equalsIgnoreCase("yes") ||
			value.equals("1"))
			return true;
		if (value.equalsIgnoreCase("false") ||
			value.equalsIgnoreCase("no") ||
			value.equals("0"))
			return false;
		error("SaveStateDescriptor: %s '%s' has unknown value '%s' for boolean '%s'",
				save_slot().c_str(), description().c_str(), value.c_str(), key.c_str());
	}
	return false;
}
Exemple #2
0
bool parseBool(const Common::String &val, bool &valAsBool) {
	if (val.equalsIgnoreCase("true") ||
		val.equalsIgnoreCase("yes") ||
		val.equals("1")) {
		valAsBool = true;
		return true;
	}
	if (val.equalsIgnoreCase("false") ||
		val.equalsIgnoreCase("no") ||
		val.equals("0")) {
		valAsBool = false;
		return true;
	}

	return false;
}
ScriptAction ScriptChunk::parseScriptAction(const Common::String &action) {
	for (int i = 0; i < kScriptActionNone; i++)
		if (action.equalsIgnoreCase(scriptAction[i]))
			return (ScriptAction) i;

	return kScriptActionNone;
}
static void upgradeTargetIfNecessary(const ADParams &params) {
    if (params.obsoleteList == 0)
        return;

    Common::String gameid = ConfMan.get("gameid");

    for (const ADObsoleteGameID *o = params.obsoleteList; o->from; ++o) {
        if (gameid.equalsIgnoreCase(o->from)) {
            gameid = o->to;
            ConfMan.set("gameid", gameid);

            if (o->platform != Common::kPlatformUnknown)
                ConfMan.set("platform", Common::getPlatformCode(o->platform));

            warning("Target upgraded from %s to %s", o->from, o->to);

            // WORKAROUND: Fix for bug #1719463: "DETECTOR: Launching
            // undefined target adds launcher entry"
            if (ConfMan.hasKey("id_came_from_command_line")) {
                warning("Target came from command line. Skipping save");
            } else {
                ConfMan.flushToDisk();
            }
            break;
        }
    }
}
ObjectVerb Object::parseObjectVerb(const Common::String &verb) {
	for (int i = 0; i < kObjectVerbNone; i++)
		if (verb.equalsIgnoreCase(objectVerb[i]))
			return (ObjectVerb) i;

	return kObjectVerbNone;
}
Exemple #6
0
Config::DriverId Config::parse(const Common::String &name) {
	for (int i = 0; _drivers[i].name; ++i) {
		if (name.equalsIgnoreCase(_drivers[i].name))
			return _drivers[i].id;
	}

	return -1;
}
Exemple #7
0
ThemeEngine::GraphicsMode ThemeEngine::findMode(const Common::String &cfg) {
	for (uint i = 0; i < _rendererModesSize; ++i) {
		if (cfg.equalsIgnoreCase(_rendererModes[i].cfg))
			return _rendererModes[i].mode;
	}

	return kGfxDisabled;
}
Exemple #8
0
bool ScummSteamFile::open(const Common::String &filename) {
	if (filename.equalsIgnoreCase(_indexFile.indexFileName)) {
		return openWithSubRange(_indexFile.executableName, _indexFile.start, _indexFile.len);
	} else {
		// Regular non-bundled file
		return ScummFile::open(filename);
	}
}
Exemple #9
0
int Inventory::findInv(const Common::String &name) {
	for (int idx = 0; idx < (int)_names.size(); ++idx) {
		if (name.equalsIgnoreCase(_names[idx]))
			return idx;
	}

	// Couldn't find the desired item
	error("Couldn't find inventory item - %s", name.c_str());
}
Exemple #10
0
void Sound::cdPlay(const Common::String &trackName) {
	if (!_cdrom)
		return;
	debugC(1, kDebugSound, "CDROM: Playing track \"%s\"", trackName.c_str());

// WORKAROUND - In Fascination CD, in the storage room, a track has the wrong
// name in the scripts, and therefore doesn't play. This fixes the problem.
	if ((_vm->getGameType() == kGameTypeFascination) && trackName.equalsIgnoreCase("boscle"))
		_cdrom->startTrack("bosscle");
	else
		_cdrom->startTrack(trackName.c_str());
}
Exemple #11
0
void initCommonGFX(bool defaultTo1XScaler) {
	const Common::ConfigManager::Domain *transientDomain = ConfMan.getDomain(Common::ConfigManager::kTransientDomain);
	const Common::ConfigManager::Domain *gameDomain = ConfMan.getActiveDomain();

	assert(transientDomain);

	const bool useDefaultGraphicsMode =
		(!transientDomain->contains("gfx_mode") ||
		!scumm_stricmp(transientDomain->getVal("gfx_mode").c_str(), "normal") ||
		!scumm_stricmp(transientDomain->getVal("gfx_mode").c_str(), "default")
		)
		 &&
		(
		!gameDomain ||
		!gameDomain->contains("gfx_mode") ||
		!scumm_stricmp(gameDomain->getVal("gfx_mode").c_str(), "normal") ||
		!scumm_stricmp(gameDomain->getVal("gfx_mode").c_str(), "default")
		);

	// See if the game should default to 1x scaler
	if (useDefaultGraphicsMode && defaultTo1XScaler) {
		g_system->resetGraphicsScale();
	} else {
		// Override global scaler with any game-specific define
		if (ConfMan.hasKey("gfx_mode")) {
			Common::String gfxMode = ConfMan.get("gfx_mode");
			g_system->setGraphicsMode(gfxMode.c_str());

			// HACK: For OpenGL modes, we will still honor the graphics scale override
			if (defaultTo1XScaler && gfxMode.equalsIgnoreCase("opengl"))
				g_system->resetGraphicsScale();
		}
	}

	// Note: The following code deals with the fullscreen / ASR settings. This
	// is a bit tricky, because there are three ways the user can affect these
	// settings: Via the config file, via the command line, and via in-game
	// hotkeys.
	// Any global or command line settings already have been applied at the time
	// we get here. Hence we only do something

	// (De)activate aspect-ratio correction as determined by the config settings
	if (gameDomain && gameDomain->contains("aspect_ratio"))
		g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));

	// (De)activate fullscreen mode as determined by the config settings
	if (gameDomain && gameDomain->contains("fullscreen"))
		g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
	
	// (De)activate filtering mode as determined by the config settings
	if (gameDomain && gameDomain->contains("filtering"))
		g_system->setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering"));
}
Exemple #12
0
int Inventory::putNameInInventory(const Common::String &name) {
	Scene &scene = *_vm->_scene;
	int matches = 0;

	for (uint idx = 0; idx < scene._bgShapes.size(); ++idx) {
		Object &o = scene._bgShapes[idx];
		if (name.equalsIgnoreCase(o._name) && o._type != INVALID) {
			putItemInInventory(o);
			++matches;
		}
	}

	return matches;
}
Exemple #13
0
ResourceLoader::ResourceLoader() {
	int lab_counter = 0;
	_cacheDirty = false;
	_cacheMemorySize = 0;

	Lab *l;
	Common::ArchiveMemberList files;

	SearchMan.listMatchingMembers(files, "*.lab");
	SearchMan.listMatchingMembers(files, "*.m4b");

	if (files.empty())
		error("Cannot find game data - check configuration file");

	for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
		const Common::String filename = (*x)->getName();
		l = new Lab();

		if (l->open(filename)) {
			if (filename.equalsIgnoreCase("data005.lab"))
				_labs.push_front(l);
			else
				_labs.push_back(l);
			lab_counter++;
		} else {
			delete l;
		}
	}

	files.clear();

	if (g_grim->getGameFlags() & GF_DEMO) {
		SearchMan.listMatchingMembers(files, "*.mus");

		for (Common::ArchiveMemberList::const_iterator x = files.begin(); x != files.end(); ++x) {
			const Common::String filename = (*x)->getName();
			l = new Lab();

			if (l->open(filename)) {
				_labs.push_back(l);
				lab_counter++;
			} else {
				delete l;
			}
		}
	}
}
Exemple #14
0
int Inventory::deleteItemFromInventory(const Common::String &name) {
	int invNum = -1;

	for (int idx = 0; idx < (int)size() && invNum == -1; ++idx) {
		if (name.equalsIgnoreCase((*this)[idx]._name))
			invNum = idx;
	}

	if (invNum == -1)
		// Item not present
		return 0;

	// Item found, so delete it
	remove_at(invNum);
	--_holdings;

	return 1;
}
void IdCreateDirectoryRequest::start() {
	//cleanup
	_ignoreCallback = true;
	if (_workingRequest)
		_workingRequest->finish();
	_workingRequest = nullptr;
	_ignoreCallback = false;

	//the only exception when we create parent folder - is when it's ScummVM/ base folder
	Common::String prefix = _requestedParentPath;
	if (prefix.size() > 7)
		prefix.erase(7);
	if (prefix.equalsIgnoreCase("ScummVM")) {
		Storage::BoolCallback callback = new Common::Callback<IdCreateDirectoryRequest, Storage::BoolResponse>(this, &IdCreateDirectoryRequest::createdBaseDirectoryCallback);
		Networking::ErrorCallback failureCallback = new Common::Callback<IdCreateDirectoryRequest, Networking::ErrorResponse>(this, &IdCreateDirectoryRequest::createdBaseDirectoryErrorCallback);
		_workingRequest = _storage->createDirectory("ScummVM", callback, failureCallback);
		return;
	}

	resolveId();
}
Exemple #16
0
reg_t kShowMovie(EngineState *s, int argc, reg_t *argv) {
	// Hide the cursor if it's showing and then show it again if it was
	// previously visible.
	bool reshowCursor = g_sci->_gfxCursor->isVisible();
	if (reshowCursor)
		g_sci->_gfxCursor->kernelHide();

	uint16 screenWidth = g_system->getWidth();
	uint16 screenHeight = g_system->getHeight();

	Video::VideoDecoder *videoDecoder = 0;

	if (argv[0].getSegment() != 0) {
		Common::String filename = s->_segMan->getString(argv[0]);

		if (g_sci->getPlatform() == Common::kPlatformMacintosh) {
			// Mac QuickTime
			// The only argument is the string for the video

			// HACK: Switch to 16bpp graphics for Cinepak.
			initGraphics(screenWidth, screenHeight, screenWidth > 320, NULL);

			if (g_system->getScreenFormat().bytesPerPixel == 1) {
				warning("This video requires >8bpp color to be displayed, but could not switch to RGB color mode");
				return NULL_REG;
			}

			videoDecoder = new Video::QuickTimeDecoder();
			if (!videoDecoder->loadFile(filename))
				error("Could not open '%s'", filename.c_str());
		} else {
			// DOS SEQ
			// SEQ's are called with no subops, just the string and delay
			// Time is specified as ticks
			videoDecoder = new SEQDecoder(argv[1].toUint16());

			if (!videoDecoder->loadFile(filename)) {
				warning("Failed to open movie file %s", filename.c_str());
				delete videoDecoder;
				videoDecoder = 0;
			}
		}
	} else {
		// Windows AVI
		// TODO: This appears to be some sort of subop. case 0 contains the string
		// for the video, so we'll just play it from there for now.

#ifdef ENABLE_SCI32
		if (getSciVersion() >= SCI_VERSION_2_1) {
			// SCI2.1 always has argv[0] as 1, the rest of the arguments seem to
			// follow SCI1.1/2.
			if (argv[0].toUint16() != 1)
				error("SCI2.1 kShowMovie argv[0] not 1");
			argv++;
			argc--;
		}
#endif
		switch (argv[0].toUint16()) {
		case 0: {
			Common::String filename = s->_segMan->getString(argv[1]);
			videoDecoder = new Video::AVIDecoder();

			if (filename.equalsIgnoreCase("gk2a.avi")) {
				// HACK: Switch to 16bpp graphics for Indeo3.
				// The only known movie to do use this codec is the GK2 demo trailer
				// If another video turns up that uses Indeo, we may have to add a better
				// check.
				initGraphics(screenWidth, screenHeight, screenWidth > 320, NULL);

				if (g_system->getScreenFormat().bytesPerPixel == 1) {
					warning("This video requires >8bpp color to be displayed, but could not switch to RGB color mode");
					return NULL_REG;
				}
			}

			if (!videoDecoder->loadFile(filename.c_str())) {
				warning("Failed to open movie file %s", filename.c_str());
				delete videoDecoder;
				videoDecoder = 0;
			} else {
				s->_videoState.fileName = filename;
			}
			break;
		}
		default:
			warning("Unhandled SCI kShowMovie subop %d", argv[0].toUint16());
		}
	}

	if (videoDecoder) {
		playVideo(videoDecoder, s->_videoState);

		// HACK: Switch back to 8bpp if we played a true color video.
		// We also won't be copying the screen to the SCI screen...
		if (g_system->getScreenFormat().bytesPerPixel != 1)
			initGraphics(screenWidth, screenHeight, screenWidth > 320);
		else {
			g_sci->_gfxScreen->kernelSyncWithFramebuffer();
			g_sci->_gfxPalette->kernelSyncScreenPalette();
		}
	}

	if (reshowCursor)
		g_sci->_gfxCursor->kernelShow();

	return s->r_acc;
}
Exemple #17
0
// TODO: specify the possible return values here
static Common::Error runGame(const EnginePlugin *plugin, OSystem &system, const Common::String &edebuglevels) {
    // Determine the game data path, for validation and error messages
    Common::FSNode dir(ConfMan.get("path"));
    Common::Error err = Common::kNoError;
    Engine *engine = 0;

    // Verify that the game path refers to an actual directory
    if (!(dir.exists() && dir.isDirectory()))
        err = Common::kPathNotDirectory;

    // Create the game engine
    if (err.getCode() == Common::kNoError)
        err = (*plugin)->createInstance(&system, &engine);

    // Check for errors
    if (!engine || err.getCode() != Common::kNoError) {

        // Print a warning; note that scummvm_main will also
        // display an error dialog, so we don't have to do this here.
        warning("%s failed to instantiate engine: %s (target '%s', path '%s')",
                plugin->getName(),
                err.getDesc().c_str(),
                ConfMan.getActiveDomainName().c_str(),
                dir.getPath().c_str()
               );

        // Autoadded is set only when no path was provided and
        // the game is run from command line.
        //
        // Thus, we remove this garbage entry
        //
        // Fixes bug #1544799
        if (ConfMan.hasKey("autoadded")) {
            ConfMan.removeGameDomain(ConfMan.getActiveDomainName().c_str());
        }

        return err;
    }

    // Set the window caption to the game name
    Common::String caption(ConfMan.get("description"));

    if (caption.empty()) {
        caption = EngineMan.findGame(ConfMan.get("gameid")).description();
    }
    if (caption.empty())
        caption = ConfMan.getActiveDomainName();	// Use the domain (=target) name
    if (!caption.empty())	{
        system.setWindowCaption(caption.c_str());
    }

    //
    // Setup various paths in the SearchManager
    //

    // Add the game path to the directory search list
    engine->initializePath(dir);

    // Add extrapath (if any) to the directory search list
    if (ConfMan.hasKey("extrapath")) {
        dir = Common::FSNode(ConfMan.get("extrapath"));
        SearchMan.addDirectory(dir.getPath(), dir);
    }

    // If a second extrapath is specified on the app domain level, add that as well.
    // However, since the default hasKey() and get() check the app domain level,
    // verify that it's not already there before adding it. The search manager will
    // check for that too, so this check is mostly to avoid a warning message.
    if (ConfMan.hasKey("extrapath", Common::ConfigManager::kApplicationDomain)) {
        Common::String extraPath = ConfMan.get("extrapath", Common::ConfigManager::kApplicationDomain);
        if (!SearchMan.hasArchive(extraPath)) {
            dir = Common::FSNode(extraPath);
            SearchMan.addDirectory(dir.getPath(), dir);
        }
    }

    // On creation the engine should have set up all debug levels so we can use
    // the command line arguments here
    Common::StringTokenizer tokenizer(edebuglevels, " ,");
    while (!tokenizer.empty()) {
        Common::String token = tokenizer.nextToken();
        if (token.equalsIgnoreCase("all"))
            DebugMan.enableAllDebugChannels();
        else if (!DebugMan.enableDebugChannel(token))
            warning(_("Engine does not support debug level '%s'"), token.c_str());
    }

    // Initialize any game-specific keymaps
    engine->initKeymap();

    // Set default values for all of the custom engine options
    const ExtraGuiOptions engineOptions = (*plugin)->getExtraGuiOptions(Common::String());
    for (uint i = 0; i < engineOptions.size(); i++) {
        ConfMan.registerDefault(engineOptions[i].configOption, engineOptions[i].defaultState);
    }

    // Inform backend that the engine is about to be run
    system.engineInit();

    // Run the engine
    Common::Error result = engine->run();

    // Inform backend that the engine finished
    system.engineDone();

    // Clean up any game-specific keymaps
    engine->deinitKeymap();

    // Free up memory
    delete engine;

    // We clear all debug levels again even though the engine should do it
    DebugMan.clearAllDebugChannels();

    // Reset the file/directory mappings
    SearchMan.clear();

    // Return result (== 0 means no error)
    return result;
}
Exemple #18
0
void Inter_v6::o6_playVmdOrMusic() {
	Common::String file = _vm->_game->_script->evalString();

	VideoPlayer::Properties props;

	props.x          = _vm->_game->_script->readValExpr();
	props.y          = _vm->_game->_script->readValExpr();
	props.startFrame = _vm->_game->_script->readValExpr();
	props.lastFrame  = _vm->_game->_script->readValExpr();
	props.breakKey   = _vm->_game->_script->readValExpr();
	props.flags      = _vm->_game->_script->readValExpr();
	props.palStart   = _vm->_game->_script->readValExpr();
	props.palEnd     = _vm->_game->_script->readValExpr();
	props.palCmd     = 1 << (props.flags & 0x3F);
	props.forceSeek  = true;

	debugC(1, kDebugVideo, "Playing video \"%s\" @ %d+%d, frames %d - %d, "
			"paletteCmd %d (%d - %d), flags %X", file.c_str(),
			props.x, props.y, props.startFrame, props.lastFrame,
			props.palCmd, props.palStart, props.palEnd, props.flags);

	// WORKAROUND: When taking the music sheet from Dr. Dramish's car,
	//             the video that lets the sheet vanish is missing. We'll
	//             play the one where the sheet is already gone instead.
	if (_vm->isCurrentTot("avt005.tot") && file.equalsIgnoreCase("MXRAMPART"))
		file = "PLCOFDR2";

	if (file == "RIEN") {
		_vm->_vidPlayer->closeAll();
		return;
	}

	bool close = false;
	if (props.lastFrame == -1) {
		close = true;
	} else if (props.lastFrame == -5) {
//		warning("Urban/Playtoons Stub: Stop without delay");
		_vm->_sound->bgStop();
		return;
	} else if (props.lastFrame == -6) {
//		warning("Urban/Playtoons Stub: Video/Music command -6 (cache video)");
		return;
	} else if (props.lastFrame == -7) {
//		warning("Urban/Playtoons Stub: Video/Music command -6 (flush cache)");
		return;
	} else if ((props.lastFrame == -8) || (props.lastFrame == -9)) {
		if (!file.contains('.'))
			file += ".WA8";

		probe16bitMusic(file);

		if (props.lastFrame == -9)
			debugC(0, kDebugVideo, "Urban/Playtoons Stub: Delayed music stop?");

		_vm->_sound->bgStop();
		_vm->_sound->bgPlay(file.c_str(), SOUND_WAV);
		return;
	} else if (props.lastFrame <= -10) {
		_vm->_vidPlayer->closeVideo();

		if (!(props.flags & VideoPlayer::kFlagNoVideo))
			props.loop = true;

	} else if (props.lastFrame < 0) {
		warning("Urban/Playtoons Stub: Unknown Video/Music command: %d, %s", props.lastFrame, file.c_str());
		return;
	}

	if (props.startFrame == -2) {
		props.startFrame = 0;
		props.lastFrame  = -1;
		props.noBlock    = true;
	}

	_vm->_vidPlayer->evaluateFlags(props);

	bool primary = true;
	if (props.noBlock && (props.flags & VideoPlayer::kFlagNoVideo))
		primary = false;

	int slot = 0;
	if (!file.empty() && ((slot = _vm->_vidPlayer->openVideo(primary, file, props)) < 0)) {
		WRITE_VAR(11, (uint32) -1);
		return;
	}

	if (props.hasSound)
		_vm->_vidPlayer->closeLiveSound();

	if (props.startFrame >= 0)
		_vm->_vidPlayer->play(slot, props);

	if (close && !props.noBlock) {
		if (!props.canceled)
			_vm->_vidPlayer->waitSoundEnd(slot);
		_vm->_vidPlayer->closeVideo(slot);
	}

}
Exemple #19
0
bool ResLoaderPak::checkFilename(Common::String filename) const {
	filename.toUppercase();
	return (filename.hasSuffix(".PAK") || filename.hasSuffix(".APK") || filename.hasSuffix(".VRM") || filename.hasSuffix(".CMP") || filename.hasSuffix(".TLK") || filename.equalsIgnoreCase(StaticResource::staticDataFilename()));
}