[Scummvm-cvs-logs] SF.net SVN: scummvm:[54443] scummvm/trunk/engines/mohawk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Nov 23 23:32:39 CET 2010


Revision: 54443
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54443&view=rev
Author:   fingolfin
Date:     2010-11-23 22:32:39 +0000 (Tue, 23 Nov 2010)

Log Message:
-----------
MOHAWK: Pass objs by const ref not by value

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/dialogs.cpp
    scummvm/trunk/engines/mohawk/dialogs.h
    scummvm/trunk/engines/mohawk/livingbooks.cpp
    scummvm/trunk/engines/mohawk/livingbooks.h
    scummvm/trunk/engines/mohawk/myst.cpp
    scummvm/trunk/engines/mohawk/myst.h
    scummvm/trunk/engines/mohawk/myst_saveload.cpp
    scummvm/trunk/engines/mohawk/myst_saveload.h
    scummvm/trunk/engines/mohawk/resource.cpp
    scummvm/trunk/engines/mohawk/resource.h
    scummvm/trunk/engines/mohawk/riven_scripts.cpp
    scummvm/trunk/engines/mohawk/riven_scripts.h
    scummvm/trunk/engines/mohawk/video.cpp
    scummvm/trunk/engines/mohawk/video.h

Modified: scummvm/trunk/engines/mohawk/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/dialogs.cpp	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/dialogs.cpp	2010-11-23 22:32:39 UTC (rev 54443)
@@ -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 @@
 	_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) {

Modified: scummvm/trunk/engines/mohawk/dialogs.h
===================================================================
--- scummvm/trunk/engines/mohawk/dialogs.h	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/dialogs.h	2010-11-23 22:32:39 UTC (rev 54443)
@@ -48,9 +48,9 @@
 	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 @@
 
 class PauseDialog : public InfoDialog {
 public:
-	PauseDialog(MohawkEngine* vm, Common::String message);
+	PauseDialog(MohawkEngine* vm, const Common::String &message);
 	virtual void handleKeyDown(Common::KeyState state);
 };
 

Modified: scummvm/trunk/engines/mohawk/livingbooks.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.cpp	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/livingbooks.cpp	2010-11-23 22:32:39 UTC (rev 54443)
@@ -119,7 +119,7 @@
 	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 @@
 	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 &section, 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 &section, 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 &section, 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 @@
 	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++) {

Modified: scummvm/trunk/engines/mohawk/livingbooks.h
===================================================================
--- scummvm/trunk/engines/mohawk/livingbooks.h	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/livingbooks.h	2010-11-23 22:32:39 UTC (rev 54443)
@@ -61,7 +61,7 @@
 
 	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 @@
 	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 &section, const Common::String &key);
+	int getIntFromConfig(const Common::String &section, const Common::String &key);
+	Common::String getFileNameFromConfig(const Common::String &section, const Common::String &key);
 
 	// Platform/Version functions
 	bool isBigEndian() const { return getGameType() == GType_LIVINGBOOKSV3 || getPlatform() == Common::kPlatformMacintosh; }

Modified: scummvm/trunk/engines/mohawk/myst.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst.cpp	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/myst.cpp	2010-11-23 22:32:39 UTC (rev 54443)
@@ -186,7 +186,7 @@
 // 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 @@
 }
 
 // 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++) {

Modified: scummvm/trunk/engines/mohawk/myst.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst.h	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/myst.h	2010-11-23 22:32:39 UTC (rev 54443)
@@ -194,7 +194,7 @@
 	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 @@
 
 	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();

Modified: scummvm/trunk/engines/mohawk/myst_saveload.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/myst_saveload.cpp	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/myst_saveload.cpp	2010-11-23 22:32:39 UTC (rev 54443)
@@ -43,7 +43,7 @@
 	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 @@
 	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 @@
 	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());
 }

Modified: scummvm/trunk/engines/mohawk/myst_saveload.h
===================================================================
--- scummvm/trunk/engines/mohawk/myst_saveload.h	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/myst_saveload.h	2010-11-23 22:32:39 UTC (rev 54443)
@@ -195,9 +195,9 @@
 	~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);

Modified: scummvm/trunk/engines/mohawk/resource.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/resource.cpp	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/resource.cpp	2010-11-23 22:32:39 UTC (rev 54443)
@@ -36,7 +36,7 @@
 	_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)) {

Modified: scummvm/trunk/engines/mohawk/resource.h
===================================================================
--- scummvm/trunk/engines/mohawk/resource.h	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/resource.h	2010-11-23 22:32:39 UTC (rev 54443)
@@ -179,7 +179,7 @@
 	MohawkArchive();
 	virtual ~MohawkArchive() { close(); }
 
-	bool open(Common::String filename);
+	bool open(const Common::String &filename);
 	virtual bool open(Common::SeekableReadStream *stream);
 	void close();
 

Modified: scummvm/trunk/engines/mohawk/riven_scripts.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_scripts.cpp	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/riven_scripts.cpp	2010-11-23 22:32:39 UTC (rev 54443)
@@ -160,7 +160,7 @@
 		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 @@
 	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++) {

Modified: scummvm/trunk/engines/mohawk/riven_scripts.h
===================================================================
--- scummvm/trunk/engines/mohawk/riven_scripts.h	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/riven_scripts.h	2010-11-23 22:32:39 UTC (rev 54443)
@@ -57,7 +57,7 @@
 	~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 @@
 	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);

Modified: scummvm/trunk/engines/mohawk/video.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/video.cpp	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/video.cpp	2010-11-23 22:32:39 UTC (rev 54443)
@@ -56,7 +56,7 @@
 	_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 @@
 	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 @@
 	_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 @@
 	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)

Modified: scummvm/trunk/engines/mohawk/video.h
===================================================================
--- scummvm/trunk/engines/mohawk/video.h	2010-11-23 22:27:40 UTC (rev 54442)
+++ scummvm/trunk/engines/mohawk/video.h	2010-11-23 22:32:39 UTC (rev 54443)
@@ -72,9 +72,9 @@
 	~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 @@
 	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);
 };
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list