[Scummvm-cvs-logs] SF.net SVN: scummvm:[48957] scummvm/trunk/engines/scumm

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed May 5 22:43:22 CEST 2010


Revision: 48957
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48957&view=rev
Author:   fingolfin
Date:     2010-05-05 20:43:22 +0000 (Wed, 05 May 2010)

Log Message:
-----------
SCUMM: Convert some code to use Common::String

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/he/logic_he.cpp
    scummvm/trunk/engines/scumm/script_v0.cpp
    scummvm/trunk/engines/scumm/script_v2.cpp
    scummvm/trunk/engines/scumm/scumm_v2.h

Modified: scummvm/trunk/engines/scumm/he/logic_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/logic_he.cpp	2010-05-05 17:54:34 UTC (rev 48956)
+++ scummvm/trunk/engines/scumm/he/logic_he.cpp	2010-05-05 20:43:22 UTC (rev 48957)
@@ -75,22 +75,17 @@
 
 int32 LogicHE::dispatch(int op, int numArgs, int32 *args) {
 #if 1
-	char tmp[32], str[256];
+	Common::String str;
 
+	str = Common::String::printf("LogicHE::dispatch(%d, %d, [", op, numArgs);
 	if (numArgs > 0)
-		snprintf(tmp, 32, "%d", args[0]);
-	else
-		*tmp = 0;
-
-	snprintf(str, 256, "LogicHE::dispatch(%d, %d, [%s", op, numArgs, tmp);
-
+		str += Common::String::printf("%d", args[0]);
 	for (int i = 1; i < numArgs; i++) {
-		snprintf(tmp, 32, ", %d", args[i]);
-		strncat(str, tmp, sizeof(str) - strlen(str) - 1);
+		str += Common::String::printf(", %d", args[i]);
 	}
-	strncat(str, "])", sizeof(str) - strlen(str) - 1);
+	str += "])";
 
-	debug(0, "%s", str);
+	debug(0, "%s", str.c_str());
 #else
 	// Used for parallel trace utility
 	for (int i = 0; i < numArgs; i++)

Modified: scummvm/trunk/engines/scumm/script_v0.cpp
===================================================================
--- scummvm/trunk/engines/scumm/script_v0.cpp	2010-05-05 17:54:34 UTC (rev 48956)
+++ scummvm/trunk/engines/scumm/script_v0.cpp	2010-05-05 20:43:22 UTC (rev 48957)
@@ -425,8 +425,8 @@
 
 	// Append the 'object-name'
 	if (temp) {
-		strcat(_sentenceBuf, " ");
-		strcat(_sentenceBuf, (const char*)temp);
+		_sentenceBuf += " ";
+		_sentenceBuf += (const char *)temp;
 	}
 
 	// Append the modifier? (With / On / To / In)
@@ -469,7 +469,7 @@
 			lang = 0;	// Default to english
 		}
 
-		strcat(_sentenceBuf, prepositions[lang][sentencePrep]);
+		_sentenceBuf += prepositions[lang][sentencePrep];
 	}
 }
 
@@ -482,7 +482,7 @@
 
 	// Current Verb, Walk/Use
 	if (getResourceAddress(rtVerb, _activeVerb)) {
-		strcpy(_sentenceBuf, (char*)getResourceAddress(rtVerb, _activeVerb));
+		_sentenceBuf = (char *)getResourceAddress(rtVerb, _activeVerb);
 	} else {
 		return;
 	}
@@ -528,8 +528,8 @@
 	if (_activeActor) {
 		Actor *a = derefActor(_activeActor, "");
 
-		strcat(_sentenceBuf, " ");
-		strcat(_sentenceBuf, (const char*)a->getActorName());
+		_sentenceBuf += " ";
+		_sentenceBuf += (const char *)a->getActorName();
 	}
 
 	_string[2].charset = 1;
@@ -539,7 +539,7 @@
 	_string[2].color = 16;
 
 	byte string[80];
-	char *ptr = _sentenceBuf;
+	const char *ptr = _sentenceBuf.c_str();
 	int i = 0, len = 0;
 
 	// Maximum length of printable characters
@@ -562,7 +562,7 @@
 	sentenceline.right = _virtscr[kVerbVirtScreen].w - 1;
 	restoreBackground(sentenceline);
 
-	drawString(2, (byte*)string);
+	drawString(2, (byte *)string);
 }
 
 void ScummEngine_v0::o_stopCurrentScript() {

Modified: scummvm/trunk/engines/scumm/script_v2.cpp
===================================================================
--- scummvm/trunk/engines/scumm/script_v2.cpp	2010-05-05 17:54:34 UTC (rev 48956)
+++ scummvm/trunk/engines/scumm/script_v2.cpp	2010-05-05 20:43:22 UTC (rev 48957)
@@ -965,15 +965,15 @@
 		return;
 
 	if (getResourceAddress(rtVerb, slot))
-		strcpy(_sentenceBuf, (char*)getResourceAddress(rtVerb, slot));
+		_sentenceBuf = (char *)getResourceAddress(rtVerb, slot);
 	else
 		return;
 
 	if (VAR(VAR_SENTENCE_OBJECT1) > 0) {
 		temp = getObjOrActorName(VAR(VAR_SENTENCE_OBJECT1));
 		if (temp) {
-			strcat(_sentenceBuf, " ");
-			strcat(_sentenceBuf, (const char*)temp);
+			_sentenceBuf += " ";
+			_sentenceBuf += (const char *)temp;
 		}
 
 		// For V1 games, the engine must compute the preposition.
@@ -1018,16 +1018,16 @@
 		}
 
 		if (_game.platform == Common::kPlatformNES) {
-			strcat(_sentenceBuf, (const char *)(getResourceAddress(rtCostume, 78) + VAR(VAR_SENTENCE_PREPOSITION) * 8 + 2));
+			_sentenceBuf += (const char *)(getResourceAddress(rtCostume, 78) + VAR(VAR_SENTENCE_PREPOSITION) * 8 + 2);
 		} else
-			strcat(_sentenceBuf, prepositions[lang][VAR(VAR_SENTENCE_PREPOSITION)]);
+			_sentenceBuf += prepositions[lang][VAR(VAR_SENTENCE_PREPOSITION)];
 	}
 
 	if (VAR(VAR_SENTENCE_OBJECT2) > 0) {
 		temp = getObjOrActorName(VAR(VAR_SENTENCE_OBJECT2));
 		if (temp) {
-			strcat(_sentenceBuf, " ");
-			strcat(_sentenceBuf, (const char*)temp);
+			_sentenceBuf += " ";
+			_sentenceBuf += (const char *)temp;
 		}
 	}
 
@@ -1044,7 +1044,7 @@
 		_string[2].color = 13;
 
 	byte string[80];
-	char *ptr = _sentenceBuf;
+	const char *ptr = _sentenceBuf.c_str();
 	int i = 0, len = 0;
 
 	// Maximum length of printable characters
@@ -1078,7 +1078,7 @@
 	}
 	restoreBackground(sentenceline);
 
-	drawString(2, (byte*)string);
+	drawString(2, (byte *)string);
 }
 
 void ScummEngine_v2::o2_ifClassOfIs() {

Modified: scummvm/trunk/engines/scumm/scumm_v2.h
===================================================================
--- scummvm/trunk/engines/scumm/scumm_v2.h	2010-05-05 17:54:34 UTC (rev 48956)
+++ scummvm/trunk/engines/scumm/scumm_v2.h	2010-05-05 20:43:22 UTC (rev 48957)
@@ -44,7 +44,7 @@
 	V2MouseoverBox _mouseOverBoxesV2[7];
 	int8 _mouseOverBoxV2;
 
-	char _sentenceBuf[256];
+	Common::String _sentenceBuf;
 	uint16 _inventoryOffset;
 
 	int _activeInventory;


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