diff options
Diffstat (limited to 'engines/wintermute/base')
21 files changed, 164 insertions, 137 deletions
diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index d4b17a0a64..79b16e5c74 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -46,8 +46,8 @@ BaseEngine::BaseEngine() { _gameId = ""; } -void BaseEngine::init(Common::Language lang) { - _fileManager = new BaseFileManager(lang); +void BaseEngine::init() { + _fileManager = new BaseFileManager(_language); // Don't forget to register your random source _rnd = new Common::RandomSource("Wintermute"); _classReg = new SystemClassRegistry(); @@ -60,9 +60,11 @@ BaseEngine::~BaseEngine() { delete _classReg; } -void BaseEngine::createInstance(const Common::String &gameid, Common::Language lang) { - instance()._gameId = gameid; - instance().init(lang); +void BaseEngine::createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang) { + instance()._targetName = targetName; + instance()._gameId = gameId; + instance()._language = lang; + instance().init(); } void BaseEngine::LOG(bool res, const char *fmt, ...) { diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index d972e6ebbc..1b3b976bda 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -44,17 +44,19 @@ class BaseRenderer; class SystemClassRegistry; class Timer; class BaseEngine : public Common::Singleton<Wintermute::BaseEngine> { - void init(Common::Language lang); + void init(); BaseFileManager *_fileManager; Common::String _gameId; + Common::String _targetName; BaseGame *_gameRef; // We need random numbers Common::RandomSource *_rnd; SystemClassRegistry *_classReg; + Common::Language _language; public: BaseEngine(); ~BaseEngine(); - static void createInstance(const Common::String &gameid, Common::Language lang); + static void createInstance(const Common::String &targetName, const Common::String &gameId, Common::Language lang); void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; } Common::RandomSource *getRandomSource() { return _rnd; } @@ -68,7 +70,9 @@ public: static const Timer *getTimer(); static const Timer *getLiveTimer(); static void LOG(bool res, const char *fmt, ...); - const char *getGameId() { return _gameId.c_str(); } + const char *getGameTargetName() const { return _targetName.c_str(); } + Common::String getGameId() const { return _gameId; } + Common::Language getLanguage() const { return _language; } }; } // end of namespace Wintermute diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 7d59b03684..64bdbd1660 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -269,7 +269,7 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f bool BaseFileManager::hasFile(const Common::String &filename) { if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - BasePersistenceManager pm(BaseEngine::instance().getGameId()); + BasePersistenceManager pm(BaseEngine::instance().getGameTargetName()); if (filename.size() <= 9) { return false; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 4d8e79b5c2..0f0d928285 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -81,7 +81,7 @@ IMPLEMENT_PERSISTENT(BaseGame, true) ////////////////////////////////////////////////////////////////////// -BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gameId), _timerNormal(), _timerLive() { +BaseGame::BaseGame(const Common::String &targetName) : BaseObject(this), _targetName(targetName), _timerNormal(), _timerLive() { _shuttingDown = false; _state = GAME_RUNNING; @@ -212,7 +212,7 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam #else*/ _touchInterface = false; _constrainedMemory = false; - + _settings = new BaseGameSettings(this); //#endif @@ -1276,11 +1276,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); const char *initVal = stack->pop()->getString(); - Common::String privKey = "wme_" + StringUtil::encodeSetting(key); - Common::String result = initVal; - if (ConfMan.hasKey(privKey)) { - result = StringUtil::decodeSetting(ConfMan.get(key)); - } + Common::String result = readRegistryString(key, initVal); stack->pushString(result.c_str()); return STATUS_OK; } @@ -3734,7 +3730,7 @@ bool BaseGame::onWindowClose() { bool BaseGame::displayDebugInfo() { const uint32 strLength = 100; char str[strLength]; - + if (_debugShowFPS) { sprintf(str, "FPS: %d", _gameRef->_fps); _systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT); @@ -3902,4 +3898,26 @@ char *BaseGame::getKeyFromStringTable(const char *str) const { return _settings->getKeyFromStringTable(str); } +Common::String BaseGame::readRegistryString(const Common::String &key, const Common::String &initValue) const { + // Game specific hacks: + Common::String result = initValue; + // James Peris: + if (BaseEngine::instance().getGameId() == "jamesperis" && key == "Language") { + Common::Language language = BaseEngine::instance().getLanguage(); + if (language == Common::EN_ANY) { + result = "english"; + } else if (language == Common::ES_ESP) { + result = "spanish"; + } else { + error("Invalid language set for James Peris"); + } + } else { // Just fallback to using ConfMan for now + Common::String privKey = "wme_" + StringUtil::encodeSetting(key); + if (ConfMan.hasKey(privKey)) { + result = StringUtil::decodeSetting(ConfMan.get(key)); + } + } + return result; +} + } // end of namespace Wintermute diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index d51255d013..f635339286 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -137,7 +137,7 @@ public: bool initialize2(); bool initialize3(); BaseTransitionMgr *_transMgr; - + // String Table void expandStringByStringTable(char **str) const; char *getKeyFromStringTable(const char *str) const; @@ -150,7 +150,7 @@ public: BaseScriptable *_mathClass; BaseSurfaceStorage *_surfaceStorage; BaseFontStorage *_fontStorage; - BaseGame(const Common::String &gameId); + BaseGame(const Common::String &targetName); virtual ~BaseGame(); bool _debugDebugMode; @@ -173,8 +173,8 @@ public: // compatibility bits bool _compatKillMethodThreads; - const char* getGameId() const { return _gameId.c_str(); } - void setGameId(const Common::String& gameId) { _gameId = gameId; } + const char* getGameTargetName() const { return _targetName.c_str(); } + void setGameTargetName(const Common::String& targetName) { _targetName = targetName; } uint32 _surfaceGCCycleTime; bool _smartCache; // RO bool _subtitles; // RO @@ -275,7 +275,7 @@ private: bool _mouseRightDown; bool _mouseMidlleDown; - + BaseGameSettings *_settings; int32 _soundBufferSizeSec; @@ -295,7 +295,7 @@ private: uint32 _lastTime; uint32 _fpsTime; uint32 _framesRendered; - Common::String _gameId; + Common::String _targetName; void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = nullptr, void *data = nullptr); ENGINE_LOG_CALLBACK _engineLogCallback; @@ -343,6 +343,8 @@ private: bool isDoubleClick(int32 buttonIndex); uint32 _usedMem; +// TODO: This should be expanded into a proper class eventually: + Common::String readRegistryString(const Common::String &key, const Common::String &initValue) const; protected: diff --git a/engines/wintermute/base/base_game_music.cpp b/engines/wintermute/base/base_game_music.cpp index ac23801e4c..eff5d47210 100644 --- a/engines/wintermute/base/base_game_music.cpp +++ b/engines/wintermute/base/base_game_music.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -65,10 +65,10 @@ bool BaseGameMusic::playMusic(int channel, const char *filename, bool looping, u BaseEngine::LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; } - + delete _music[channel]; _music[channel] = nullptr; - + _music[channel] = new BaseSound(_gameRef); if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { if (_musicStartTime[channel]) { @@ -93,7 +93,7 @@ bool BaseGameMusic::stopMusic(int channel) { BaseEngine::LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; } - + if (_music[channel]) { _music[channel]->stop(); delete _music[channel]; @@ -111,7 +111,7 @@ bool BaseGameMusic::pauseMusic(int channel) { BaseEngine::LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; } - + if (_music[channel]) { return _music[channel]->pause(); } else { @@ -126,7 +126,7 @@ bool BaseGameMusic::resumeMusic(int channel) { BaseEngine::LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; } - + if (_music[channel]) { return _music[channel]->resume(); } else { @@ -141,7 +141,7 @@ bool BaseGameMusic::setMusicStartTime(int channel, uint32 time) { BaseEngine::LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; } - + _musicStartTime[channel] = time; if (_music[channel] && _music[channel]->isPlaying()) { return _music[channel]->setPositionTime(time); @@ -153,14 +153,14 @@ bool BaseGameMusic::setMusicStartTime(int channel, uint32 time) { ////////////////////////////////////////////////////////////////////////// bool BaseGameMusic::updateMusicCrossfade() { /* byte globMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ - + if (!_musicCrossfadeRunning) { return STATUS_OK; } if (_gameRef->_state == GAME_FROZEN) { return STATUS_OK; } - + if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { _musicCrossfadeRunning = false; return STATUS_OK; @@ -169,34 +169,34 @@ bool BaseGameMusic::updateMusicCrossfade() { _musicCrossfadeRunning = false; return STATUS_OK; } - + if (!_music[_musicCrossfadeChannel1]->isPlaying()) { _music[_musicCrossfadeChannel1]->play(); } if (!_music[_musicCrossfadeChannel2]->isPlaying()) { _music[_musicCrossfadeChannel2]->play(); } - + uint32 currentTime = _gameRef->getLiveTimer()->getTime() - _musicCrossfadeStartTime; - + if (currentTime >= _musicCrossfadeLength) { _musicCrossfadeRunning = false; //_music[_musicCrossfadeChannel2]->setVolume(GlobMusicVol); _music[_musicCrossfadeChannel2]->setVolumePercent(100); - + _music[_musicCrossfadeChannel1]->stop(); //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol); _music[_musicCrossfadeChannel1]->setVolumePercent(100); - - + + if (_musicCrossfadeSwap) { // swap channels BaseSound *dummy = _music[_musicCrossfadeChannel1]; int dummyInt = _musicStartTime[_musicCrossfadeChannel1]; - + _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; - + _music[_musicCrossfadeChannel2] = dummy; _musicStartTime[_musicCrossfadeChannel2] = dummyInt; } @@ -205,10 +205,10 @@ bool BaseGameMusic::updateMusicCrossfade() { //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); _music[_musicCrossfadeChannel1]->setVolumePercent((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); _music[_musicCrossfadeChannel2]->setVolumePercent((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); - + //_gameRef->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); } - + return STATUS_OK; } @@ -242,15 +242,15 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this stack->correctParams(4); channel = stack->pop()->getInt(); } - + const char *filename = stack->pop()->getString(); ScValue *valLooping = stack->pop(); bool looping = valLooping->isNULL() ? true : valLooping->getBool(); - + ScValue *valLoopStart = stack->pop(); uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); - - + + if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) { stack->pushBool(false); } else { @@ -258,20 +258,20 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this } return STATUS_OK; } - + ////////////////////////////////////////////////////////////////////////// // StopMusic / StopMusicChannel ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { int channel = 0; - + if (strcmp(name, "StopMusic") == 0) { stack->correctParams(0); } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - + if (DID_FAIL(stopMusic(channel))) { stack->pushBool(false); } else { @@ -279,20 +279,20 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this } return STATUS_OK; } - + ////////////////////////////////////////////////////////////////////////// // PauseMusic / PauseMusicChannel ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { int channel = 0; - + if (strcmp(name, "PauseMusic") == 0) { stack->correctParams(0); } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - + if (DID_FAIL(pauseMusic(channel))) { stack->pushBool(false); } else { @@ -300,7 +300,7 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this } return STATUS_OK; } - + ////////////////////////////////////////////////////////////////////////// // ResumeMusic / ResumeMusicChannel ////////////////////////////////////////////////////////////////////////// @@ -312,7 +312,7 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this stack->correctParams(1); channel = stack->pop()->getInt(); } - + if (DID_FAIL(resumeMusic(channel))) { stack->pushBool(false); } else { @@ -320,7 +320,7 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this } return STATUS_OK; } - + ////////////////////////////////////////////////////////////////////////// // GetMusic / GetMusicChannel ////////////////////////////////////////////////////////////////////////// @@ -343,7 +343,7 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this } return STATUS_OK; } - + ////////////////////////////////////////////////////////////////////////// // SetMusicPosition / SetMusicChannelPosition ////////////////////////////////////////////////////////////////////////// @@ -355,18 +355,18 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this stack->correctParams(2); channel = stack->pop()->getInt(); } - + uint32 time = stack->pop()->getInt(); - + if (DID_FAIL(setMusicStartTime(channel, time))) { stack->pushBool(false); } else { stack->pushBool(true); } - + return STATUS_OK; } - + ////////////////////////////////////////////////////////////////////////// // GetMusicPosition / GetMusicChannelPosition ////////////////////////////////////////////////////////////////////////// @@ -378,7 +378,7 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this stack->correctParams(1); channel = stack->pop()->getInt(); } - + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { stack->pushInt(0); } else { @@ -386,7 +386,7 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this } return STATUS_OK; } - + ////////////////////////////////////////////////////////////////////////// // IsMusicPlaying / IsMusicChannelPlaying ////////////////////////////////////////////////////////////////////////// @@ -398,7 +398,7 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this stack->correctParams(1); channel = stack->pop()->getInt(); } - + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { stack->pushBool(false); } else { @@ -406,7 +406,7 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this } return STATUS_OK; } - + ////////////////////////////////////////////////////////////////////////// // SetMusicVolume / SetMusicChannelVolume ////////////////////////////////////////////////////////////////////////// @@ -418,7 +418,7 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this stack->correctParams(2); channel = stack->pop()->getInt(); } - + int volume = stack->pop()->getInt(); if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { stack->pushBool(false); @@ -431,7 +431,7 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this } return STATUS_OK; } - + ////////////////////////////////////////////////////////////////////////// // GetMusicVolume / GetMusicChannelVolume ////////////////////////////////////////////////////////////////////////// @@ -443,16 +443,16 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this stack->correctParams(1); channel = stack->pop()->getInt(); } - + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { stack->pushInt(0); } else { stack->pushInt(_music[channel]->getVolumePercent()); } - + return STATUS_OK; } - + ////////////////////////////////////////////////////////////////////////// // MusicCrossfade ////////////////////////////////////////////////////////////////////////// @@ -462,34 +462,34 @@ bool BaseGameMusic::scCallMethod(ScScript *script, ScStack *stack, ScStack *this int channel2 = stack->pop()->getInt(0); uint32 fadeLength = (uint32)stack->pop()->getInt(0); bool swap = stack->pop()->getBool(true); - + if (_musicCrossfadeRunning) { script->runtimeError("Game.MusicCrossfade: Music crossfade is already in progress."); stack->pushBool(false); return STATUS_OK; } - + _musicCrossfadeStartTime = _gameRef->getLiveTimer()->getTime(); _musicCrossfadeChannel1 = channel1; _musicCrossfadeChannel2 = channel2; _musicCrossfadeLength = fadeLength; _musicCrossfadeSwap = swap; - + _musicCrossfadeRunning = true; - + stack->pushBool(true); return STATUS_OK; - } + } ////////////////////////////////////////////////////////////////////////// // GetSoundLength ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetSoundLength") == 0) { stack->correctParams(1); - + int length = 0; const char *filename = stack->pop()->getString(); - + BaseSound *sound = new BaseSound(_gameRef); if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { length = sound->getLength(); diff --git a/engines/wintermute/base/base_game_music.h b/engines/wintermute/base/base_game_music.h index 0ac904b8c1..150ea6200c 100644 --- a/engines/wintermute/base/base_game_music.h +++ b/engines/wintermute/base/base_game_music.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -53,7 +53,7 @@ public: bool stopMusic(int channel); bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); bool updateMusicCrossfade(); - + bool persistChannels(BasePersistenceManager *persistMgr); bool persistCrossfadeSettings(BasePersistenceManager *persistMgr); private: diff --git a/engines/wintermute/base/base_game_settings.cpp b/engines/wintermute/base/base_game_settings.cpp index 55fbe39fd2..9b5eb314bb 100644 --- a/engines/wintermute/base/base_game_settings.cpp +++ b/engines/wintermute/base/base_game_settings.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -47,7 +47,7 @@ BaseGameSettings::BaseGameSettings(BaseGame *gameRef) { _allowAccessTab = true; _allowAboutTab = true; _allowDesktopRes = false; - + _compressedSavegames = true; _richSavedGames = false; _savedGameExt = "dsv"; @@ -101,21 +101,21 @@ bool BaseGameSettings::loadSettings(const char *filename) { TOKEN_TABLE(SAVED_GAME_EXT) TOKEN_TABLE(GUID) TOKEN_TABLE_END - - + + byte *origBuffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (origBuffer == nullptr) { BaseEngine::LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename); return STATUS_FAILED; } - + bool ret = STATUS_OK; - + byte *buffer = origBuffer; byte *params; int cmd; BaseParser parser; - + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { BaseEngine::LOG(0, "'SETTINGS' keyword expected in game settings file."); return STATUS_FAILED; @@ -130,61 +130,61 @@ bool BaseGameSettings::loadSettings(const char *filename) { strcpy(_gameFile, (char *)params); } break; - + case TOKEN_STRING_TABLE: if (DID_FAIL(_stringTable->loadFile((char *)params))) { cmd = PARSERR_GENERIC; } break; - + case TOKEN_RESOLUTION: parser.scanStr((char *)params, "%d,%d", &_resWidth, &_resHeight); break; - + case TOKEN_REQUIRE_3D_ACCELERATION: parser.scanStr((char *)params, "%b", &_requireAcceleration); break; - + case TOKEN_REQUIRE_SOUND: parser.scanStr((char *)params, "%b", &_requireSound); break; - + case TOKEN_HWTL_MODE: parser.scanStr((char *)params, "%d", &_TLMode); break; - + case TOKEN_ALLOW_WINDOWED_MODE: parser.scanStr((char *)params, "%b", &_allowWindowed); break; - + case TOKEN_ALLOW_DESKTOP_RES: parser.scanStr((char *)params, "%b", &_allowDesktopRes); break; - + case TOKEN_ALLOW_ADVANCED: parser.scanStr((char *)params, "%b", &_allowAdvanced); break; - + case TOKEN_ALLOW_ACCESSIBILITY_TAB: parser.scanStr((char *)params, "%b", &_allowAccessTab); break; - + case TOKEN_ALLOW_ABOUT_TAB: parser.scanStr((char *)params, "%b", &_allowAboutTab); break; - + case TOKEN_REGISTRY_PATH: //BaseEngine::instance().getRegistry()->setBasePath((char *)params); break; - + case TOKEN_RICH_SAVED_GAMES: parser.scanStr((char *)params, "%b", &_richSavedGames); break; - + case TOKEN_SAVED_GAME_EXT: _savedGameExt = (char *)params; break; - + case TOKEN_GUID: break; } @@ -197,12 +197,12 @@ bool BaseGameSettings::loadSettings(const char *filename) { BaseEngine::LOG(0, "Error loading game settings '%s'", filename); ret = STATUS_FAILED; } - + _allowWindowed = true; // TODO: These two settings should probably be cleaned out altogether. _compressedSavegames = true; - + delete[] origBuffer; - + return ret; } diff --git a/engines/wintermute/base/base_game_settings.h b/engines/wintermute/base/base_game_settings.h index 1dfb0b50cc..92c00ab0c2 100644 --- a/engines/wintermute/base/base_game_settings.h +++ b/engines/wintermute/base/base_game_settings.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/wintermute/base/base_keyboard_state.h b/engines/wintermute/base/base_keyboard_state.h index b62ece02b7..e321dfee16 100644 --- a/engines/wintermute/base/base_keyboard_state.h +++ b/engines/wintermute/base/base_keyboard_state.h @@ -61,7 +61,7 @@ private: bool _currentPrintable; uint32 _currentKeyData; uint32 _currentCharCode; - + bool _currentShift; bool _currentAlt; bool _currentControl; diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 5dbacb157b..23290e1574 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -94,7 +94,7 @@ BasePersistenceManager::BasePersistenceManager(const char *savePrefix, bool dele if (savePrefix) { _savePrefix = savePrefix; } else if (_gameRef) { - _savePrefix = _gameRef->getGameId(); + _savePrefix = _gameRef->getGameTargetName(); } else { _savePrefix = "wmesav"; } @@ -282,7 +282,7 @@ bool BasePersistenceManager::initSave(const char *desc) { } else { _saveStream->writeUint32LE(0); } - + thumbnailOK = true; } } diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 3c1ecc7a73..5ffb06f854 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -66,12 +66,6 @@ static Common::FSNode getNodeForRelativePath(const Common::String &filename) { const Common::FSNode gameDataDir(ConfMan.get("path")); Common::FSNode curNode = gameDataDir; - Common::String fixedPath = ""; - while (!path.empty()) { - fixedPath += path.nextToken() + "/"; - } - fixedPath.deleteLastChar(); - // Parse all path-elements while (!path.empty()) { // Get the next path-component by slicing on '\\' diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index c20881e425..b3f05ce977 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -113,15 +113,21 @@ void BaseRenderer::setIndicatorVal(int value) { } void BaseRenderer::setLoadingScreen(const char *filename, int x, int y) { - // TODO: Handle NULL - _loadImageName = filename; + if (filename == nullptr) { + _saveImageName = ""; + } else { + _loadImageName = filename; + } _loadImageX = x; _loadImageY = y; } void BaseRenderer::setSaveImage(const char *filename, int x, int y) { - // TODO: Handle NULL - _saveImageName = filename; + if (filename == nullptr) { + _saveImageName = ""; + } else { + _saveImageName = filename; + } _saveImageX = x; _saveImageY = y; } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 866a8a1623..7905184190 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -534,7 +534,7 @@ void BaseRenderOSystem::drawTickets() { // Revert the colorMod-state. _colorMod = oldColorMod; - + it = _renderQueue.begin(); // Clean out the old tickets decrement = 0; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index e0b7aea5a3..b809318133 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -164,7 +164,7 @@ bool BaseSurfaceOSystem::finishLoad() { needsColorKey = true; } } - + if (needsColorKey) { TransparentSurface trans(*_surface); trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, replaceAlpha); diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.cpp b/engines/wintermute/base/gfx/osystem/render_ticket.cpp index 091bb6e58a..8d9d5325c4 100644 --- a/engines/wintermute/base/gfx/osystem/render_ticket.cpp +++ b/engines/wintermute/base/gfx/osystem/render_ticket.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/wintermute/base/gfx/osystem/render_ticket.h b/engines/wintermute/base/gfx/osystem/render_ticket.h index c294cb3082..ec1412b032 100644 --- a/engines/wintermute/base/gfx/osystem/render_ticket.h +++ b/engines/wintermute/base/gfx/osystem/render_ticket.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/wintermute/base/save_thumb_helper.cpp b/engines/wintermute/base/save_thumb_helper.cpp index bab29c5cf8..535648eddd 100644 --- a/engines/wintermute/base/save_thumb_helper.cpp +++ b/engines/wintermute/base/save_thumb_helper.cpp @@ -56,23 +56,23 @@ BaseImage *SaveThumbHelper::storeThumb(bool doFlip, int width, int height) { // works normally for direct3d _gameRef->displayContent(false); _gameRef->_renderer->flip(); - + _gameRef->displayContent(false); _gameRef->_renderer->flip(); } - + BaseImage *screenshot = _gameRef->_renderer->takeScreenshot(); if (!screenshot) { return nullptr; } - + // normal thumbnail if (_gameRef->getSaveThumbWidth() > 0 && _gameRef->getSaveThumbHeight() > 0) { thumbnail = new BaseImage(); thumbnail->copyFrom(screenshot, width, height); } - - + + delete screenshot; screenshot = nullptr; } @@ -99,7 +99,7 @@ bool SaveThumbHelper::storeThumbnail(bool doFlip) { bool SaveThumbHelper::storeScummVMThumbNail(bool doFlip) { delete _scummVMThumb; _scummVMThumb = nullptr; - + _scummVMThumb = storeThumb(doFlip, kThumbnailWidth, kThumbnailHeight2); if (!_scummVMThumb) { return STATUS_FAILED; diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 1b945c2e1c..0cffa94b50 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -461,6 +461,7 @@ void ScScript::cleanup() { _parentScript = nullptr; // ref only delete _scriptStream; + _scriptStream = nullptr; } diff --git a/engines/wintermute/base/timer.cpp b/engines/wintermute/base/timer.cpp index 5dfc117f48..96097c10d5 100644 --- a/engines/wintermute/base/timer.cpp +++ b/engines/wintermute/base/timer.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/wintermute/base/timer.h b/engines/wintermute/base/timer.h index ec5477ba2e..4099c6c825 100644 --- a/engines/wintermute/base/timer.h +++ b/engines/wintermute/base/timer.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -51,7 +51,7 @@ public: void persist(BasePersistenceManager *persistMgr); }; - + } // End of namespace Wintermute #endif |