From 359be0c0665d9fed898ad1c511614a76ee92e331 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 17 Jun 2010 23:14:34 +0000 Subject: SCI: Change SciEngine's 'char *getGameID()' to 'Common::String getGameId()' svn-id: r49968 --- engines/sci/console.cpp | 2 +- engines/sci/engine/kernel.cpp | 4 ++-- engines/sci/engine/kgraphics.cpp | 8 ++++---- engines/sci/engine/kmisc.cpp | 4 ++-- engines/sci/engine/kpathing.cpp | 4 ++-- engines/sci/graphics/palette.cpp | 6 +++--- engines/sci/graphics/picture.cpp | 4 ++-- engines/sci/graphics/ports.cpp | 2 +- engines/sci/graphics/screen.cpp | 4 ++-- engines/sci/sci.cpp | 20 +++++++------------- engines/sci/sci.h | 3 ++- 11 files changed, 28 insertions(+), 33 deletions(-) diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index d17b1facaa..b46e03830d 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -424,7 +424,7 @@ bool Console::cmdGetVersion(int argc, const char **argv) { bool hasVocab997 = g_sci->getResMan()->testResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_SELECTORS)) ? true : false; - DebugPrintf("Game ID: %s\n", _engine->getGameID()); + DebugPrintf("Game ID: %s\n", _engine->getGameId().c_str()); DebugPrintf("Emulated interpreter version: %s\n", getSciVersionDesc(getSciVersion())); DebugPrintf("\n"); DebugPrintf("Detected features:\n"); diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 7367e3f34a..6e02bbbb4e 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -747,7 +747,7 @@ void Kernel::setDefaultKernelNames() { // In SCI1.1, kSetSynonyms is an empty function _kernelNames[0x26] = "Empty"; - if (!strcmp(g_sci->getGameID(), "kq6")) { + if (g_sci->getGameId() == "kq6") { // In the Windows version of KQ6 CD, the empty kSetSynonyms // function has been replaced with kPortrait. In KQ6 Mac, // kPlayBack has been replaced by kShowMovie. @@ -755,7 +755,7 @@ void Kernel::setDefaultKernelNames() { _kernelNames[0x26] = "Portrait"; else if (g_sci->getPlatform() == Common::kPlatformMacintosh) _kernelNames[0x84] = "ShowMovie"; - } else if (!strcmp(g_sci->getGameID(), "qfg4") && g_sci->isDemo()) { + } else if (g_sci->getGameId() == "qfg4" && g_sci->isDemo()) { _kernelNames[0x7b] = "RemapColors"; // QFG4 Demo has this SCI2 function instead of StrSplit } diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 6241c22f88..0a334924ab 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -534,7 +534,7 @@ reg_t kBaseSetter(EngineState *s, int argc, reg_t *argv) { // WORKAROUND for a problem in LSL1VGA. This allows the casino door to be opened, // till the actual problem is found - if (!strcmp(g_sci->getGameID(), "lsl1sci") && s->currentRoomNumber() == 300) { + if (g_sci->getGameId() == "lsl1sci" && s->currentRoomNumber() == 300) { int top = readSelectorValue(s->_segMan, object, SELECTOR(brTop)); writeSelectorValue(s->_segMan, object, SELECTOR(brTop), top + 2); } @@ -807,7 +807,7 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) { // ALL other games use a hardcoded -1 (madness!) // We are detecting jones/talkie as "jones" as well, but the sierra interpreter of talkie doesnt have this // "hack". Hopefully it wont cause regressions (the code causes regressions if used against kq5/floppy) - if (!strcmp(g_sci->getGameID(), "jones")) + if (g_sci->getGameId() == "jones") priority = readSelectorValue(s->_segMan, controlObject, SELECTOR(priority)); else priority = -1; @@ -991,7 +991,7 @@ reg_t kDrawCel(EngineState *s, int argc, reg_t *argv) { bool hiresMode = (argc > 7) ? true : false; reg_t upscaledHiresHandle = (argc > 7) ? argv[7] : NULL_REG; - if (!strcmp(g_sci->getGameID(), "freddypharkas") || !strcmp(g_sci->getGameID(), "freddypharkas-demo")) { + if (g_sci->getGameId() == "freddypharkas" || g_sci->getGameId() == "freddypharkas-demo") { // WORKAROUND // Script 24 contains code that draws the game menu on screen. It uses a temp variable for setting priority that // is not set. in Sierra sci this happens to be 8250h. In our sci temporary variables are initialized thus we would @@ -1002,7 +1002,7 @@ reg_t kDrawCel(EngineState *s, int argc, reg_t *argv) { priority = 15; } - if (!strcmp(g_sci->getGameID(), "laurabow2")) { + if (g_sci->getGameId() == "laurabow2") { // WORKAROUND // see the one above if ((viewId == 995) && (priority == 0)) diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 99b268f774..525f9f5bf4 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -59,9 +59,9 @@ reg_t kGameIsRestarting(EngineState *s, int argc, reg_t *argv) { // LSL3 calculates a machinespeed variable during game startup (right after the filthy questions) // This one would go through w/o throttling resulting in having to do 1000 pushups or something // Another way of handling this would be delaying incrementing of "machineSpeed" selector - if (!strcmp(g_sci->getGameID(), "lsl3") && s->currentRoomNumber() == 290) + if (g_sci->getGameId() == "lsl3" && s->currentRoomNumber() == 290) s->_throttleTrigger = true; - if (!strcmp(g_sci->getGameID(), "iceman") && s->currentRoomNumber() == 27) { + if (g_sci->getGameId() == "iceman" && s->currentRoomNumber() == 27) { s->_throttleTrigger = true; neededSleep = 60; } diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index 857ccc2a08..09cec29a79 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -1056,7 +1056,7 @@ static Polygon *convert_polygon(EngineState *s, reg_t polygon) { // WORKAROUND: broken polygon in lsl1sci, room 350, after opening elevator // Polygon has 17 points but size is set to 19 - if ((size == 19) && !strcmp(g_sci->getGameID(), "lsl1sci")) { + if ((size == 19) && g_sci->getGameId() == "lsl1sci") { if ((s->currentRoomNumber() == 350) && (read_point(segMan, points, 18) == Common::Point(108, 137))) { debug(1, "Applying fix for broken polygon in lsl1sci, room 350"); @@ -1174,7 +1174,7 @@ static PathfindingState *convert_polygon_set(EngineState *s, reg_t poly_list, Co // WORKAROUND LSL5 room 660. Priority glitch due to us choosing a different path // than SSCI. Happens when Patti walks to the control room. - if (!strcmp(g_sci->getGameID(), "lsl5") && (s->currentRoomNumber() == 660) && (Common::Point(67, 131) == *new_start) && (Common::Point(229, 101) == *new_end)) { + if (g_sci->getGameId() == "lsl5" && (s->currentRoomNumber() == 660) && (Common::Point(67, 131) == *new_start) && (Common::Point(229, 101) == *new_end)) { debug(1, "[avoidpath] Applying fix for priority problem in LSL5, room 660"); pf_s->_prependPoint = new_start; new_start = new Common::Point(77, 107); diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp index 1b2e5f410e..35741dedf7 100644 --- a/engines/sci/graphics/palette.cpp +++ b/engines/sci/graphics/palette.cpp @@ -66,11 +66,11 @@ GfxPalette::GfxPalette(ResourceManager *resMan, GfxScreen *screen) // and those will overwrite the current palette in that case // Quest for Glory 3 demo and police quest 1 vga behave the same interpreter wise and all have glitches, if we don't // switch back - if (!strcmp(g_sci->getGameID(), "laurabow2") && (g_sci->isDemo())) + if (g_sci->getGameId() == "laurabow2" && (g_sci->isDemo())) _alwaysForceRealMerge = true; - if (!strcmp(g_sci->getGameID(), "qfg3") && (g_sci->isDemo())) + else if (g_sci->getGameId() == "qfg3" && (g_sci->isDemo())) _alwaysForceRealMerge = true; - if (!strcmp(g_sci->getGameID(), "pq1sci")) + else if (g_sci->getGameId() == "pq1sci") _alwaysForceRealMerge = true; } diff --git a/engines/sci/graphics/picture.cpp b/engines/sci/graphics/picture.cpp index a59153f116..0b62a558ca 100644 --- a/engines/sci/graphics/picture.cpp +++ b/engines/sci/graphics/picture.cpp @@ -437,7 +437,7 @@ void GfxPicture::drawVectorData(byte *data, int dataSize) { memcpy(&EGApalettes[i], &vector_defaultEGApalette, sizeof(vector_defaultEGApalette)); memcpy(&EGApriority, &vector_defaultEGApriority, sizeof(vector_defaultEGApriority)); - if (strcmp(g_sci->getGameID(), "iceman") == 0) { + if (g_sci->getGameId() == "iceman") { // WORKAROUND: we remove certain visual&priority lines in underwater rooms of iceman, when not dithering the // picture. Normally those lines aren't shown, because they share the same color as the dithered // fill color combination. When not dithering, those lines would appear and get distracting. @@ -532,7 +532,7 @@ void GfxPicture::drawVectorData(byte *data, int dataSize) { // inside picture data for such games case PIC_OP_SET_PATTERN: if (_resourceType >= SCI_PICTURE_TYPE_SCI11) { - if (strcmp(g_sci->getGameID(), "sq4") == 0) { + if (g_sci->getGameId() == "sq4") { // WORKAROUND: For SQ4 / for some pictures handle this like a terminator // This picture includes garbage data, first a set pattern w/o parameter and then short pattern // I guess that garbage is a left over from the sq4-floppy (sci1) to sq4-cd (sci1.1) conversion diff --git a/engines/sci/graphics/ports.cpp b/engines/sci/graphics/ports.cpp index c964ccd346..b762872357 100644 --- a/engines/sci/graphics/ports.cpp +++ b/engines/sci/graphics/ports.cpp @@ -87,7 +87,7 @@ void GfxPorts::init(bool usesOldGfxFunctions, GfxPaint16 *paint16, GfxText16 *te // Jones, Slater and Hoyle 3 were called with parameter -Nw 0 0 200 320. // Mother Goose (SCI1) uses -Nw 0 0 159 262. The game will later use SetPort so we don't need to set the other fields. // This actually meant not skipping the first 10 pixellines in windowMgrPort - Common::String gameId = g_sci->getGameID(); + Common::String gameId = g_sci->getGameId(); if (gameId == "jones" || gameId == "slater" || gameId == "hoyle3" || (gameId == "mothergoose" && getSciVersion() == SCI_VERSION_1_EARLY)) offTop = 0; diff --git a/engines/sci/graphics/screen.cpp b/engines/sci/graphics/screen.cpp index 0e054d5a76..82ff478da2 100644 --- a/engines/sci/graphics/screen.cpp +++ b/engines/sci/graphics/screen.cpp @@ -97,9 +97,9 @@ GfxScreen::GfxScreen(ResourceManager *resMan, int16 width, int16 height, int ups if (_resMan->isSci11Mac() && getSciVersion() == SCI_VERSION_1_1) { // For SCI1.1 Mac, we need to expand the screen to accommodate for // the icon bar. Of course, both KQ6 and QFG1 VGA differ in size. - if (!scumm_stricmp(g_sci->getGameID(), "kq6")) + if (g_sci->getGameId() == "kq6") initGraphics(_displayWidth, _displayHeight + 26, _displayWidth > 320); - else if (!scumm_stricmp(g_sci->getGameID(), "qfg1")) + else if (g_sci->getGameId() == "qfg1") initGraphics(_displayWidth, _displayHeight + 20, _displayWidth > 320); else error("Unknown SCI1.1 Mac game"); diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 00f832817b..265d5dc151 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -72,7 +72,7 @@ SciEngine *g_sci = 0; class GfxDriver; SciEngine::SciEngine(OSystem *syst, const ADGameDescription *desc) - : Engine(syst), _gameDescription(desc) { + : Engine(syst), _gameDescription(desc), _gameId(_gameDescription->gameid) { assert(g_sci == 0); g_sci = this; @@ -128,7 +128,7 @@ SciEngine::SciEngine(OSystem *syst, const ADGameDescription *desc) // Add the patches directory, except for KQ6CD; The patches folder in some versions of KQ6CD // is for the demo of Phantasmagoria, included in the disk - if (strcmp(getGameID(), "kq6")) + if (_gameId != "kq6") SearchMan.addSubDirectoryMatching(gameDataDir, "patches"); // resource patches } @@ -167,7 +167,7 @@ Common::Error SciEngine::run() { */ // Add the after market GM patches for the specified game, if they exist - _resMan->addNewGMPatch(getGameID()); + _resMan->addNewGMPatch(_gameId); _gameObj = _resMan->findGameObject(); SegManager *segMan = new SegManager(_resMan); @@ -179,10 +179,10 @@ Common::Error SciEngine::run() { // gk1/floppy does support upscaled hires scriptswise, but doesn't actually have the hires content we need to limit // it to platform windows. if (getPlatform() == Common::kPlatformWindows) { - if (!strcmp(getGameID(), "kq6")) + if (_gameId == "kq6") upscaledHires = GFX_SCREEN_UPSCALED_640x440; #ifdef ENABLE_SCI32 - if (!strcmp(getGameID(), "gk1")) + if (_gameId == "gk1") upscaledHires = GFX_SCREEN_UPSCALED_640x480; #endif } @@ -494,10 +494,6 @@ Console *SciEngine::getSciDebugger() { return _console; } -const char* SciEngine::getGameID() const { - return _gameDescription->gameid; -} - Common::Language SciEngine::getLanguage() const { return _gameDescription->language; } @@ -523,14 +519,12 @@ Common::String SciEngine::getSavegamePattern() const { } Common::String SciEngine::getFilePrefix() const { - const char* gameID = getGameID(); - if (!strcmp(gameID, "qfg2")) { + if (_gameId == "qfg2") { // Quest for Glory 2 wants to read files from Quest for Glory 1 (EGA/VGA) to import character data if (_gamestate->currentRoomNumber() == 805) return "qfg1"; // TODO: Include import-room for qfg1vga - } - if (!strcmp(gameID, "qfg3")) { + } else if (_gameId == "qfg3") { // Quest for Glory 3 wants to read files from Quest for Glory 2 to import character data if (_gamestate->currentRoomNumber() == 54) return "qfg2"; diff --git a/engines/sci/sci.h b/engines/sci/sci.h index 5ea5edc17b..ee51147a4e 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -151,7 +151,7 @@ public: bool canSaveGameStateCurrently(); void syncSoundSettings(); - const char* getGameID() const; + const Common::String &getGameId() const { return _gameId; } int getResourceVersion() const; Common::Language getLanguage() const; Common::Platform getPlatform() const; @@ -265,6 +265,7 @@ private: void initStackBaseWithSelector(Selector selector); const ADGameDescription *_gameDescription; + const Common::String _gameId; ResourceManager *_resMan; /**< The resource manager */ EngineState *_gamestate; Kernel *_kernel; -- cgit v1.2.3