[Scummvm-git-logs] scummvm master -> 4a6feaefc8e18598defacaa03ebdd334a4708cb4

yinsimei roseline.yin at gmail.com
Sat Jul 15 14:31:08 CEST 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4a6feaefc8 SLUDGE: Use String::format instead of sprintf


Commit: 4a6feaefc8e18598defacaa03ebdd334a4708cb4
    https://github.com/scummvm/scummvm/commit/4a6feaefc8e18598defacaa03ebdd334a4708cb4
Author: Simei Yin (roseline.yin at gmail.com)
Date: 2017-07-15T14:30:46+02:00

Commit Message:
SLUDGE: Use String::format instead of sprintf

Changed paths:
    engines/sludge/backdrop.cpp
    engines/sludge/builtin.cpp
    engines/sludge/sludger.cpp
    engines/sludge/variable.cpp
    engines/sludge/zbuffer.cpp


diff --git a/engines/sludge/backdrop.cpp b/engines/sludge/backdrop.cpp
index 8e2916e..25008b0 100644
--- a/engines/sludge/backdrop.cpp
+++ b/engines/sludge/backdrop.cpp
@@ -308,8 +308,7 @@ void loadBackDrop(int fileNum, int x, int y) {
 	}
 
 	if (!loadHSI(bigDataFile, x, y, false)) {
-		char mess[200];
-		sprintf(mess, "Can't paste overlay image outside scene dimensions\n\nX = %i\nY = %i\nWidth = %i\nHeight = %i", x, y, sceneWidth, sceneHeight);
+		Common::String mess = Common::String::format("Can't paste overlay image outside scene dimensions\n\nX = %i\nY = %i\nWidth = %i\nHeight = %i", x, y, sceneWidth, sceneHeight);
 		fatal(mess);
 	}
 
diff --git a/engines/sludge/builtin.cpp b/engines/sludge/builtin.cpp
index 56db190..9821eff 100644
--- a/engines/sludge/builtin.cpp
+++ b/engines/sludge/builtin.cpp
@@ -2507,7 +2507,7 @@ builtIn(setThumbnailSize) {
 		return BR_ERROR;
 	trimStack(fun->stack);
 	if (thumbWidth < 0 || thumbHeight < 0 || thumbWidth > (int)winWidth || thumbHeight > (int)winHeight) {
-		Common::String buff = thumbWidth + " x " + thumbHeight;
+		Common::String buff = Common::String::format("%i x %i", thumbWidth, thumbWidth);
 		fatal("Invalid thumbnail size", buff);
 		return BR_ERROR;
 	}
@@ -2624,8 +2624,7 @@ builtReturn callBuiltIn(int whichFunc, int numParams, loadedFunction *fun) {
 	if (whichFunc < NUM_FUNCS) {
 		if (paramNum[whichFunc] != -1) {
 			if (paramNum[whichFunc] != numParams) {
-				char buff[100];
-				sprintf(buff, "Built in function must have %i parameter%s", paramNum[whichFunc], (paramNum[whichFunc] == 1) ? "" : "s");
+				Common::String buff = Common::String::format("Built in function must have %i parameter%s", paramNum[whichFunc], (paramNum[whichFunc] == 1) ? "" : "s");
 				Common::String msg = buff;
 				fatal(msg);
 				return BR_ERROR;
diff --git a/engines/sludge/sludger.cpp b/engines/sludge/sludger.cpp
index d84688e..49edb2b 100644
--- a/engines/sludge/sludger.cpp
+++ b/engines/sludge/sludger.cpp
@@ -167,14 +167,14 @@ Common::File *openAndVerify(const Common::String &filename, char extra1, char ex
 	debug(kSludgeDebugDataLoad, "minVersion %i", minVersion);
 	fileVersion = majVersion * 256 + minVersion;
 
-	char txtVer[120];
+	Common::String txtVer = "";
 
 	if (fileVersion > WHOLE_VERSION) {
-		sprintf(txtVer, ERROR_VERSION_TOO_LOW_2, majVersion, minVersion);
+		txtVer = Common::String::format(ERROR_VERSION_TOO_LOW_2, majVersion, minVersion);
 		fatal(ERROR_VERSION_TOO_LOW_1, txtVer);
 		return NULL;
 	} else if (fileVersion < MINIM_VERSION) {
-		sprintf(txtVer, ERROR_VERSION_TOO_HIGH_2, majVersion, minVersion);
+		txtVer = Common::String::format(ERROR_VERSION_TOO_HIGH_2, majVersion, minVersion);
 		fatal(ERROR_VERSION_TOO_HIGH_1, txtVer);
 		return NULL;
 	}
diff --git a/engines/sludge/variable.cpp b/engines/sludge/variable.cpp
index 2b0d15f..a1c736a 100644
--- a/engines/sludge/variable.cpp
+++ b/engines/sludge/variable.cpp
@@ -307,11 +307,8 @@ Common::String getTextFromAnyVar(const variable &from) {
 		}
 
 		case SVT_INT: {
-			char *buff = new char[10];
-			sprintf(buff, "%i", from.varData.intValue);
-			Common::String res = buff;
-			delete []buff;
-			return res;
+			Common::String buff = Common::String::format("%i", from.varData.intValue);
+			return buff;
 		}
 
 		case SVT_FILE: {
diff --git a/engines/sludge/zbuffer.cpp b/engines/sludge/zbuffer.cpp
index 18094fb..e09e57d 100644
--- a/engines/sludge/zbuffer.cpp
+++ b/engines/sludge/zbuffer.cpp
@@ -115,8 +115,7 @@ bool setZBuffer(int num) {
 			return fatal("Extended Z-buffer format not supported in this version of the SLUDGE engine");
 	}
 	if (width != sceneWidth || height != sceneHeight) {
-		char tmp[256];
-		sprintf(tmp, "Z-w: %d Z-h:%d w: %d, h:%d", width, height, sceneWidth, sceneHeight);
+		Common::String tmp = Common::String::format("Z-w: %d Z-h:%d w: %d, h:%d", width, height, sceneWidth, sceneHeight);
 		return fatal("Z-buffer width and height don't match scene width and height", tmp);
 	}
 





More information about the Scummvm-git-logs mailing list