MADE: Remove all instances of s(n)printf

This commit is contained in:
Max Horn 2011-06-02 10:49:09 +02:00
parent 668ae0363e
commit 080b590261
5 changed files with 20 additions and 23 deletions

View File

@ -106,7 +106,7 @@ void Object::setVectorItem(int16 index, int16 value) {
}
}
void Object::dump(const char *filename) {
void Object::dump(const Common::String &filename) {
/*
FILE *o = fopen(filename, "wb");
fwrite(_objData, _objSize, 1, o);
@ -373,9 +373,7 @@ int16 GameDatabase::setObjectProperty(int16 objectIndex, int16 propertyId, int16
void GameDatabase::dumpObject(int16 index) {
Object *obj = getObject(index);
char fn[512];
sprintf(fn, "obj%04X.0", index);
obj->dump(fn);
obj->dump(Common::String::format("obj%04X.0", index));
}

View File

@ -62,7 +62,7 @@ public:
int16 getVectorItem(int16 index);
void setVectorItem(int16 index, int16 value);
void dump(const char *filename);
void dump(const Common::String &filename);
protected:
bool _freeData;

View File

@ -181,9 +181,7 @@ void MadeEngine::resetAllTimers() {
}
Common::String MadeEngine::getSavegameFilename(int16 saveNum) {
char filename[256];
snprintf(filename, 256, "%s.%03d", getTargetName().c_str(), saveNum);
return filename;
return Common::String::format("%s.%03d", getTargetName().c_str(), saveNum);
}
void MadeEngine::handleEvents() {

View File

@ -639,10 +639,9 @@ void ScriptInterpreter::dumpScript(int16 objectIndex, int *opcodeStats, int *ext
const char *sig = _commands[opcode - 1].sig;
int valueType; /* 0: dec; 1: hex; 2: extended function */
int16 value;
char tempStr[32];
opcodeStats[opcode - 1]++;
snprintf(tempStr, 32, "[%04X] ", (uint16)(code - codeStart - 1));
codeLine += tempStr;
codeLine += Common::String::format("[%04X] ", (uint16)(code - codeStart - 1));
codeLine += desc;
for (; *sig != '\0'; sig++) {
codeLine += " ";
@ -670,19 +669,21 @@ void ScriptInterpreter::dumpScript(int16 objectIndex, int *opcodeStats, int *ext
value = *code++;
break;
}
Common::String tempStr;
switch (valueType) {
case 0:
snprintf(tempStr, 32, "%d", value);
tempStr = Common::String::format("%d", value);
break;
case 1:
snprintf(tempStr, 32, "0x%X", value);
tempStr = Common::String::format("0x%X", value);
break;
case 2:
if (value < _functions->getCount()) {
snprintf(tempStr, 32, "%s", _functions->getFuncName(value));
tempStr = Common::String::format("%s", _functions->getFuncName(value));
externStats[value]++;
} else {
snprintf(tempStr, 32, "invalid: %d", value);
tempStr = Common::String::format("invalid: %d", value);
}
break;
}

View File

@ -502,28 +502,28 @@ int16 ScriptFunctions::sfDrawText(int16 argc, int16 *argv) {
}
if (text) {
char finalText[1024];
Common::String finalText;
switch (argc) {
case 1:
snprintf(finalText, 1024, "%s", text);
finalText = text;
break;
case 2:
snprintf(finalText, 1024, text, argv[0]);
finalText = Common::String::format(text, argv[0]);
break;
case 3:
snprintf(finalText, 1024, text, argv[1], argv[0]);
finalText = Common::String::format(text, argv[1], argv[0]);
break;
case 4:
snprintf(finalText, 1024, text, argv[2], argv[1], argv[0]);
finalText = Common::String::format(text, argv[2], argv[1], argv[0]);
break;
case 5:
snprintf(finalText, 1024, text, argv[3], argv[2], argv[1], argv[0]);
finalText = Common::String::format(text, argv[3], argv[2], argv[1], argv[0]);
break;
default:
finalText[0] = '\0';
// Leave it empty
break;
}
_vm->_screen->printText(finalText);
_vm->_screen->printText(finalText.c_str());
}
return 0;