From 72d25455e050223b4dbd8fa5a5fa4e5326c7c055 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 6 Jun 2009 17:44:46 +0000 Subject: Implement scummvm.ini flag features for AGI engine svn-id: r41252 --- engines/agi/agi.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ engines/agi/agi.h | 7 ++++++- engines/agi/detection.cpp | 10 +++++++++- 3 files changed, 60 insertions(+), 2 deletions(-) (limited to 'engines/agi') diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index dc4764ba23..26e51f334f 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -627,6 +627,8 @@ AgiButtonStyle::AgiButtonStyle(Common::RenderMode renderMode) { AgiBase::AgiBase(OSystem *syst, const AGIGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { _noSaveLoadAllowed = false; + + initFeatures(); } AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) { @@ -642,6 +644,8 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas if (!scumm_stricmp(g->gameid, gameid)) _gameId = g->id; + parseFeatures(); + _rnd = new Common::RandomSource(); syst->getEventManager()->registerRandomSource(*_rnd, "agi"); @@ -838,4 +842,45 @@ void AgiEngine::syncSoundSettings() { _mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, soundVolumeSpeech); } +void AgiEngine::parseFeatures(void) { + if (!ConfMan.hasKey("features")) + return; + + char *features = strdup(ConfMan.get("features").c_str()); + const char *feature[100]; + int numFeatures = 0; + + char *tok = strtok(features, " "); + if (tok) { + do { + feature[numFeatures++] = tok; + } while ((tok = strtok(NULL, " ")) != NULL); + } else { + feature[numFeatures++] = features; + } + + const struct Flags { + const char *name; + uint32 flag; + } flags[] = { + { "agimouse", GF_AGIMOUSE }, + { "agds", GF_AGDS }, + { "agi256", GF_AGI256 }, + { "agi256-2", GF_AGI256_2 }, + { "agipal", GF_AGIPAL }, + { 0, 0 } + }; + + for (int i = 0; i < numFeatures; i++) { + for (const Flags *flag = flags; flag->name; flag++) { + if (!scumm_stricmp(feature[i], flag->name)) { + debug(0, "Added feature: %s", flag->name); + + setFeature(flag->flag); + break; + } + } + } +} + } // End of namespace Agi diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 255733ede8..962c75431e 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -750,6 +750,9 @@ public: void flipflag(int); const AGIGameDescription *_gameDescription; + + uint32 _gameFeatures; + uint32 getGameID() const; uint32 getFeatures() const; uint16 getVersion() const; @@ -757,6 +760,8 @@ public: Common::Language getLanguage() const; Common::Platform getPlatform() const; const char *getGameMD5() const; + void initFeatures(void); + void setFeature(uint32 feature); Common::Error loadGameState(int slot); Common::Error saveGameState(int slot, const char *desc); @@ -796,7 +801,7 @@ private: int checkCollision(VtEntry *v); int checkPosition(VtEntry *v); - uint32 matchVersion(uint32 crc); + void parseFeatures(void); int _firstSlot; diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index 63557712b0..b730b825f6 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -51,7 +51,7 @@ uint32 AgiBase::getGameID() const { } uint32 AgiBase::getFeatures() const { - return _gameDescription->features; + return _gameFeatures; } Common::Platform AgiBase::getPlatform() const { @@ -74,6 +74,14 @@ const char *AgiBase::getGameMD5() const { return _gameDescription->desc.filesDescriptions[0].md5; } +void AgiBase::initFeatures(void) { + _gameFeatures = _gameDescription->features; +} + +void AgiBase::setFeature(uint32 feature) { + _gameFeatures |= feature; +} + } static const PlainGameDescriptor agiGames[] = { -- cgit v1.2.3