Permalink
Browse files

SLUDGE: Use String::format instead of sprintf

  • Loading branch information...
yinsimei committed Jul 15, 2017
1 parent 6b78f4a commit 4a6feaefc8e18598defacaa03ebdd334a4708cb4
@@ -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);
}
@@ -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;
@@ -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;
}
@@ -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: {
@@ -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);
}

0 comments on commit 4a6feae

Please sign in to comment.