diff options
author | Max Horn | 2010-11-23 22:32:39 +0000 |
---|---|---|
committer | Max Horn | 2010-11-23 22:32:39 +0000 |
commit | 121056c12f5a624898c28a3a9a2b8b9389a97f6f (patch) | |
tree | 553ba3bbc35db9de4845e87613ec53e7ae4f1d4e | |
parent | 830c39a6871ce6cae5d22bdf0f326fa063582ea7 (diff) | |
download | scummvm-rg350-121056c12f5a624898c28a3a9a2b8b9389a97f6f.tar.gz scummvm-rg350-121056c12f5a624898c28a3a9a2b8b9389a97f6f.tar.bz2 scummvm-rg350-121056c12f5a624898c28a3a9a2b8b9389a97f6f.zip |
MOHAWK: Pass objs by const ref not by value
svn-id: r54443
-rw-r--r-- | engines/mohawk/dialogs.cpp | 6 | ||||
-rw-r--r-- | engines/mohawk/dialogs.h | 6 | ||||
-rw-r--r-- | engines/mohawk/livingbooks.cpp | 23 | ||||
-rw-r--r-- | engines/mohawk/livingbooks.h | 14 | ||||
-rw-r--r-- | engines/mohawk/myst.cpp | 4 | ||||
-rw-r--r-- | engines/mohawk/myst.h | 4 | ||||
-rw-r--r-- | engines/mohawk/myst_saveload.cpp | 7 | ||||
-rw-r--r-- | engines/mohawk/myst_saveload.h | 6 | ||||
-rw-r--r-- | engines/mohawk/resource.cpp | 2 | ||||
-rw-r--r-- | engines/mohawk/resource.h | 2 | ||||
-rw-r--r-- | engines/mohawk/riven_scripts.cpp | 4 | ||||
-rw-r--r-- | engines/mohawk/riven_scripts.h | 4 | ||||
-rw-r--r-- | engines/mohawk/video.cpp | 8 | ||||
-rw-r--r-- | engines/mohawk/video.h | 8 |
14 files changed, 50 insertions, 48 deletions
diff --git a/engines/mohawk/dialogs.cpp b/engines/mohawk/dialogs.cpp index a4645b4e77..a4ac2da66c 100644 --- a/engines/mohawk/dialogs.cpp +++ b/engines/mohawk/dialogs.cpp @@ -35,13 +35,13 @@ namespace Mohawk { // This used to have GUI::Dialog("MohawkDummyDialog"), but that doesn't work with the gui branch merge :P (Sorry, Tanoku!) -InfoDialog::InfoDialog(MohawkEngine *vm, Common::String message) : _vm(vm), GUI::Dialog(0, 0, 1, 1), _message(message) { +InfoDialog::InfoDialog(MohawkEngine *vm, const Common::String &message) : _vm(vm), GUI::Dialog(0, 0, 1, 1), _message(message) { _backgroundType = GUI::ThemeEngine::kDialogBackgroundSpecial; _text = new GUI::StaticTextWidget(this, 4, 4, 10, 10, _message, Graphics::kTextAlignCenter); } -void InfoDialog::setInfoText(Common::String message) { +void InfoDialog::setInfoText(const Common::String &message) { _message = message; _text->setLabel(_message); } @@ -61,7 +61,7 @@ void InfoDialog::reflowLayout() { _text->setSize(_w - 8, _h); } -PauseDialog::PauseDialog(MohawkEngine *vm, Common::String message) : InfoDialog(vm, message) { +PauseDialog::PauseDialog(MohawkEngine *vm, const Common::String &message) : InfoDialog(vm, message) { } void PauseDialog::handleKeyDown(Common::KeyState state) { diff --git a/engines/mohawk/dialogs.h b/engines/mohawk/dialogs.h index 04a9566fed..d4e3a3331b 100644 --- a/engines/mohawk/dialogs.h +++ b/engines/mohawk/dialogs.h @@ -48,9 +48,9 @@ protected: GUI::StaticTextWidget *_text; public: - InfoDialog(MohawkEngine *vm, Common::String message); + InfoDialog(MohawkEngine *vm, const Common::String &message); - void setInfoText(Common::String message); + void setInfoText(const Common::String &message); virtual void handleMouseDown(int x, int y, int button, int clickCount) { setResult(0); @@ -67,7 +67,7 @@ public: class PauseDialog : public InfoDialog { public: - PauseDialog(MohawkEngine* vm, Common::String message); + PauseDialog(MohawkEngine* vm, const Common::String &message); virtual void handleKeyDown(Common::KeyState state); }; diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp index 1c562a96a0..19af37439d 100644 --- a/engines/mohawk/livingbooks.cpp +++ b/engines/mohawk/livingbooks.cpp @@ -119,7 +119,7 @@ Common::Error MohawkEngine_LivingBooks::run() { return Common::kNoError; } -void MohawkEngine_LivingBooks::loadBookInfo(Common::String filename) { +void MohawkEngine_LivingBooks::loadBookInfo(const Common::String &filename) { if (!_bookInfoFile.loadFromFile(filename)) error("Could not open %s as a config file", filename.c_str()); @@ -272,38 +272,39 @@ Common::SeekableSubReadStreamEndian *MohawkEngine_LivingBooks::wrapStreamEndian( return new Common::SeekableSubReadStreamEndian(dataStream, 0, dataStream->size(), isBigEndian(), DisposeAfterUse::YES); } -Common::String MohawkEngine_LivingBooks::getStringFromConfig(Common::String section, Common::String key) { +Common::String MohawkEngine_LivingBooks::getStringFromConfig(const Common::String §ion, const Common::String &key) { Common::String x; _bookInfoFile.getKey(key, section, x); return removeQuotesFromString(x); } -int MohawkEngine_LivingBooks::getIntFromConfig(Common::String section, Common::String key) { +int MohawkEngine_LivingBooks::getIntFromConfig(const Common::String §ion, const Common::String &key) { return atoi(getStringFromConfig(section, key).c_str()); } -Common::String MohawkEngine_LivingBooks::getFileNameFromConfig(Common::String section, Common::String key) { +Common::String MohawkEngine_LivingBooks::getFileNameFromConfig(const Common::String §ion, const Common::String &key) { Common::String x = getStringFromConfig(section, key); return (getPlatform() == Common::kPlatformMacintosh) ? convertMacFileName(x) : convertWinFileName(x); } -Common::String MohawkEngine_LivingBooks::removeQuotesFromString(Common::String string) { +Common::String MohawkEngine_LivingBooks::removeQuotesFromString(const Common::String &string) { // The last char isn't necessarily a quote, the line could have "fade" in it, // most likely representing to fade to that page. Hopefully it really is that // obvious :P // Some versions wrap in quotations, some don't... - for (uint32 i = 0; i < string.size(); i++) { - if (string[i] == '\"') { - string.deleteChar(i); + Common::String tmp = string; + for (uint32 i = 0; i < tmp.size(); i++) { + if (tmp[i] == '\"') { + tmp.deleteChar(i); i--; } } - return string; + return tmp; } -Common::String MohawkEngine_LivingBooks::convertMacFileName(Common::String string) { +Common::String MohawkEngine_LivingBooks::convertMacFileName(const Common::String &string) { Common::String filename; for (uint32 i = 1; i < string.size(); i++) { // First character should be ignored (another colon) @@ -316,7 +317,7 @@ Common::String MohawkEngine_LivingBooks::convertMacFileName(Common::String strin return filename; } -Common::String MohawkEngine_LivingBooks::convertWinFileName(Common::String string) { +Common::String MohawkEngine_LivingBooks::convertWinFileName(const Common::String &string) { Common::String filename; for (uint32 i = 0; i < string.size(); i++) { diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h index 82f6f97adb..0305c92c6a 100644 --- a/engines/mohawk/livingbooks.h +++ b/engines/mohawk/livingbooks.h @@ -61,7 +61,7 @@ private: uint16 _curPage; Common::String getBookInfoFileName() const; - void loadBookInfo(Common::String filename); + void loadBookInfo(const Common::String &filename); void loadIntro(); uint16 getResourceVersion(); @@ -76,14 +76,14 @@ private: Common::String _copyright; // String Manipulation Functions - Common::String removeQuotesFromString(Common::String string); - Common::String convertMacFileName(Common::String string); - Common::String convertWinFileName(Common::String string); + Common::String removeQuotesFromString(const Common::String &string); + Common::String convertMacFileName(const Common::String &string); + Common::String convertWinFileName(const Common::String &string); // Configuration File Functions - Common::String getStringFromConfig(Common::String section, Common::String key); - int getIntFromConfig(Common::String section, Common::String key); - Common::String getFileNameFromConfig(Common::String section, Common::String key); + Common::String getStringFromConfig(const Common::String §ion, const Common::String &key); + int getIntFromConfig(const Common::String §ion, const Common::String &key); + Common::String getFileNameFromConfig(const Common::String §ion, const Common::String &key); // Platform/Version functions bool isBigEndian() const { return getGameType() == GType_LIVINGBOOKSV3 || getPlatform() == Common::kPlatformMacintosh; } diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index ba5e71be53..4a577464cc 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -186,7 +186,7 @@ static const char *mystFiles[] = { // qtw/myst/gar4wbf1.mov: gar4wbf2.mov has two butterflies instead of one // qtw/myst/libelev.mov: libup.mov is basically the same with sound -Common::String MohawkEngine_Myst::wrapMovieFilename(Common::String movieName, uint16 stack) { +Common::String MohawkEngine_Myst::wrapMovieFilename(const Common::String &movieName, uint16 stack) { // The Macintosh release of Myst ME stores its videos in a different folder if ((getFeatures() & GF_ME) && getPlatform() == Common::kPlatformMacintosh) return Common::String("CD Data/m/") + movieName + ".mov"; @@ -999,7 +999,7 @@ void MystResourceType5::handleMouseUp() { } // In Myst/Making of Myst, the paths are hardcoded ala Windows style without extension. Convert them. -Common::String MystResourceType6::convertMystVideoName(Common::String name) { +Common::String MystResourceType6::convertMystVideoName(const Common::String &name) { Common::String temp; for (uint32 i = 1; i < name.size(); i++) { diff --git a/engines/mohawk/myst.h b/engines/mohawk/myst.h index fb74ec83bc..3126fdd4fc 100644 --- a/engines/mohawk/myst.h +++ b/engines/mohawk/myst.h @@ -194,7 +194,7 @@ public: void handleAnimation(); protected: - static Common::String convertMystVideoName(Common::String name); + static Common::String convertMystVideoName(const Common::String &name); Common::String _videoFile; uint16 _left; uint16 _top; @@ -343,7 +343,7 @@ public: Common::SeekableReadStream *getRawData(uint32 tag, uint16 id); - Common::String wrapMovieFilename(Common::String movieName, uint16 stack); + Common::String wrapMovieFilename(const Common::String &movieName, uint16 stack); void reloadSaveList(); void runLoadDialog(); diff --git a/engines/mohawk/myst_saveload.cpp b/engines/mohawk/myst_saveload.cpp index b3ce5adb3a..a3b9af59a7 100644 --- a/engines/mohawk/myst_saveload.cpp +++ b/engines/mohawk/myst_saveload.cpp @@ -43,7 +43,7 @@ Common::StringArray MystSaveLoad::generateSaveGameList() { return _saveFileMan->listSavefiles("*.mys"); } -bool MystSaveLoad::loadGame(Common::String filename) { +bool MystSaveLoad::loadGame(const Common::String &filename) { if (_vm->getFeatures() & GF_DEMO) // Don't load games in the demo return false; @@ -324,7 +324,8 @@ bool MystSaveLoad::loadGame(Common::String filename) { return true; } -bool MystSaveLoad::saveGame(Common::String filename) { +bool MystSaveLoad::saveGame(const Common::String &fname) { + Common::String filename(fname); // Make sure we have the right extension if (!filename.hasSuffix(".mys") && !filename.hasSuffix(".MYS")) filename += ".mys"; @@ -431,7 +432,7 @@ bool MystSaveLoad::saveGame(Common::String filename) { return true; } -void MystSaveLoad::deleteSave(Common::String saveName) { +void MystSaveLoad::deleteSave(const Common::String &saveName) { debugC(kDebugSaveLoad, "Deleting save file \'%s\'", saveName.c_str()); _saveFileMan->removeSavefile(saveName.c_str()); } diff --git a/engines/mohawk/myst_saveload.h b/engines/mohawk/myst_saveload.h index cbb9557db5..33dd9a7e07 100644 --- a/engines/mohawk/myst_saveload.h +++ b/engines/mohawk/myst_saveload.h @@ -195,9 +195,9 @@ public: ~MystSaveLoad(); Common::StringArray generateSaveGameList(); - bool loadGame(Common::String); - bool saveGame(Common::String); - void deleteSave(Common::String); + bool loadGame(const Common::String &); + bool saveGame(const Common::String &); + void deleteSave(const Common::String &); void initMystVariables(MystVariables *_tv); void debug_printMystVariables(MystVariables *_tv); diff --git a/engines/mohawk/resource.cpp b/engines/mohawk/resource.cpp index e14eabcf45..ee82bb4cea 100644 --- a/engines/mohawk/resource.cpp +++ b/engines/mohawk/resource.cpp @@ -36,7 +36,7 @@ MohawkArchive::MohawkArchive() { _fileTable = NULL; } -bool MohawkArchive::open(Common::String filename) { +bool MohawkArchive::open(const Common::String &filename) { Common::File *file = new Common::File(); if (!file->open(filename)) { diff --git a/engines/mohawk/resource.h b/engines/mohawk/resource.h index a1a2aadf72..77e520eac7 100644 --- a/engines/mohawk/resource.h +++ b/engines/mohawk/resource.h @@ -179,7 +179,7 @@ public: MohawkArchive(); virtual ~MohawkArchive() { close(); } - bool open(Common::String filename); + bool open(const Common::String &filename); virtual bool open(Common::SeekableReadStream *stream); void close(); diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index d4eb944660..b20dc37f0e 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -160,7 +160,7 @@ static void printTabs(byte tabs) { debugN("\t"); } -void RivenScript::dumpScript(Common::StringArray varNames, Common::StringArray xNames, byte tabs) { +void RivenScript::dumpScript(const Common::StringArray &varNames, const Common::StringArray &xNames, byte tabs) { if (_stream->pos() != 0) _stream->seek(0); @@ -168,7 +168,7 @@ void RivenScript::dumpScript(Common::StringArray varNames, Common::StringArray x dumpCommands(varNames, xNames, tabs + 1); } -void RivenScript::dumpCommands(Common::StringArray varNames, Common::StringArray xNames, byte tabs) { +void RivenScript::dumpCommands(const Common::StringArray &varNames, const Common::StringArray &xNames, byte tabs) { uint16 commandCount = _stream->readUint16BE(); for (uint16 i = 0; i < commandCount; i++) { diff --git a/engines/mohawk/riven_scripts.h b/engines/mohawk/riven_scripts.h index a85cde1702..57ffa67ca0 100644 --- a/engines/mohawk/riven_scripts.h +++ b/engines/mohawk/riven_scripts.h @@ -57,7 +57,7 @@ public: ~RivenScript(); void runScript(); - void dumpScript(Common::StringArray varNames, Common::StringArray xNames, byte tabs); + void dumpScript(const Common::StringArray &varNames, const Common::StringArray &xNames, byte tabs); uint16 getScriptType() { return _scriptType; } uint16 getParentStack() { return _parentStack; } uint16 getParentCard() { return _parentCard; } @@ -80,7 +80,7 @@ private: uint16 _scriptType, _parentStack, _parentCard; bool _isRunning, _continueRunning; - void dumpCommands(Common::StringArray varNames, Common::StringArray xNames, byte tabs); + void dumpCommands(const Common::StringArray &varNames, const Common::StringArray &xNames, byte tabs); void processCommands(bool runCommands); static uint32 calculateCommandSize(Common::SeekableReadStream *script); diff --git a/engines/mohawk/video.cpp b/engines/mohawk/video.cpp index 04b880351e..ce2e2ae0f8 100644 --- a/engines/mohawk/video.cpp +++ b/engines/mohawk/video.cpp @@ -56,7 +56,7 @@ void VideoManager::stopVideos() { _videoStreams.clear(); } -void VideoManager::playMovie(Common::String filename, uint16 x, uint16 y, bool clearScreen) { +void VideoManager::playMovie(const Common::String &filename, uint16 x, uint16 y, bool clearScreen) { VideoHandle videoHandle = createVideoHandle(filename, x, y, false); if (videoHandle == NULL_VID_HANDLE) return; @@ -70,7 +70,7 @@ void VideoManager::playMovie(Common::String filename, uint16 x, uint16 y, bool c waitUntilMovieEnds(videoHandle); } -void VideoManager::playMovieCentered(Common::String filename, bool clearScreen) { +void VideoManager::playMovieCentered(const Common::String &filename, bool clearScreen) { VideoHandle videoHandle = createVideoHandle(filename, 0, 0, false); if (videoHandle == NULL_VID_HANDLE) return; @@ -127,7 +127,7 @@ void VideoManager::waitUntilMovieEnds(VideoHandle videoHandle) { _videoStreams[videoHandle].filename.clear(); } -void VideoManager::playBackgroundMovie(Common::String filename, int16 x, int16 y, bool loop) { +void VideoManager::playBackgroundMovie(const Common::String &filename, int16 x, int16 y, bool loop) { VideoHandle videoHandle = createVideoHandle(filename, x, y, loop); if (videoHandle == NULL_VID_HANDLE) return; @@ -356,7 +356,7 @@ VideoHandle VideoManager::createVideoHandle(uint16 id, uint16 x, uint16 y, bool return _videoStreams.size() - 1; } -VideoHandle VideoManager::createVideoHandle(Common::String filename, uint16 x, uint16 y, bool loop) { +VideoHandle VideoManager::createVideoHandle(const Common::String &filename, uint16 x, uint16 y, bool loop) { // First, check to see if that video is already playing for (uint32 i = 0; i < _videoStreams.size(); i++) if (_videoStreams[i].filename == filename) diff --git a/engines/mohawk/video.h b/engines/mohawk/video.h index 4c6ed05cef..c8aff5c4f9 100644 --- a/engines/mohawk/video.h +++ b/engines/mohawk/video.h @@ -72,9 +72,9 @@ public: ~VideoManager(); // Generic movie functions - void playMovie(Common::String filename, uint16 x = 0, uint16 y = 0, bool clearScreen = false); - void playMovieCentered(Common::String filename, bool clearScreen = true); - void playBackgroundMovie(Common::String filename, int16 x = -1, int16 y = -1, bool loop = false); + void playMovie(const Common::String &filename, uint16 x = 0, uint16 y = 0, bool clearScreen = false); + void playMovieCentered(const Common::String &filename, bool clearScreen = true); + void playBackgroundMovie(const Common::String &filename, int16 x = -1, int16 y = -1, bool loop = false); bool updateBackgroundMovies(); void pauseVideos(); void resumeVideos(); @@ -107,7 +107,7 @@ private: Common::Array<VideoEntry> _videoStreams; VideoHandle createVideoHandle(uint16 id, uint16 x, uint16 y, bool loop); - VideoHandle createVideoHandle(Common::String filename, uint16 x, uint16 y, bool loop); + VideoHandle createVideoHandle(const Common::String &filename, uint16 x, uint16 y, bool loop); void waitUntilMovieEnds(VideoHandle videoHandle); }; |