DRASCULA: Replace snprintf() usage with Common::String::format()
Safer and less portability issues.
This commit is contained in:
parent
8356656575
commit
889f5d119a
3 changed files with 19 additions and 20 deletions
|
@ -893,9 +893,9 @@ bool DrasculaEngine::loadDrasculaDat() {
|
|||
ver = in.readByte();
|
||||
|
||||
if (ver != DRASCULA_DAT_VER) {
|
||||
snprintf(buf, 256, "File 'drascula.dat' is wrong version. Expected %d but got %d. Get it from the ScummVM website", DRASCULA_DAT_VER, ver);
|
||||
GUIErrorMessage(buf);
|
||||
warning("%s", buf);
|
||||
Common::String errorMessage = Common::String::format("File 'drascula.dat' is wrong version. Expected %d but got %d. Get it from the ScummVM website", DRASCULA_DAT_VER, ver);
|
||||
GUIErrorMessage(errorMessage);
|
||||
warning("%s", errorMessage.c_str());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -588,7 +588,7 @@ public:
|
|||
void quadrant_2();
|
||||
void quadrant_3();
|
||||
void quadrant_4();
|
||||
void saveGame(char[]);
|
||||
void saveGame(const char *gameName);
|
||||
void increaseFrameNum();
|
||||
int whichObject();
|
||||
bool checkMenuFlags();
|
||||
|
|
|
@ -28,24 +28,23 @@ namespace Drascula {
|
|||
|
||||
bool DrasculaEngine::saveLoadScreen() {
|
||||
char names[10][23];
|
||||
char file[50];
|
||||
char fileEpa[50];
|
||||
Common::String file;
|
||||
int n, n2, num_sav = 0, y = 27;
|
||||
Common::InSaveFile *sav;
|
||||
|
||||
clearRoom();
|
||||
|
||||
snprintf(fileEpa, 50, "%s.epa", _targetName.c_str());
|
||||
Common::String fileEpa = Common::String::format("%s.epa", _targetName.c_str());
|
||||
if (!(sav = _saveFileMan->openForLoading(fileEpa))) {
|
||||
Common::OutSaveFile *epa;
|
||||
if (!(epa = _saveFileMan->openForSaving(fileEpa)))
|
||||
error("Can't open %s file", fileEpa);
|
||||
error("Can't open %s file", fileEpa.c_str());
|
||||
for (n = 0; n < NUM_SAVES; n++)
|
||||
epa->writeString("*\n");
|
||||
epa->finalize();
|
||||
delete epa;
|
||||
if (!(sav = _saveFileMan->openForLoading(fileEpa))) {
|
||||
error("Can't open %s file", fileEpa);
|
||||
error("Can't open %s file", fileEpa.c_str());
|
||||
}
|
||||
}
|
||||
for (n = 0; n < NUM_SAVES; n++) {
|
||||
|
@ -88,11 +87,11 @@ bool DrasculaEngine::saveLoadScreen() {
|
|||
enterName();
|
||||
strcpy(names[n], select);
|
||||
if (selectionMade == 1) {
|
||||
snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1);
|
||||
saveGame(file);
|
||||
file = Common::String::format("%s%02d", _targetName.c_str(), n + 1);
|
||||
saveGame(file.c_str());
|
||||
Common::OutSaveFile *tsav;
|
||||
if (!(tsav = _saveFileMan->openForSaving(fileEpa))) {
|
||||
error("Can't open %s file", fileEpa);
|
||||
error("Can't open %s file", fileEpa.c_str());
|
||||
}
|
||||
for (n = 0; n < NUM_SAVES; n++) {
|
||||
tsav->writeString(names[n]);
|
||||
|
@ -110,7 +109,7 @@ bool DrasculaEngine::saveLoadScreen() {
|
|||
y = y + 9;
|
||||
}
|
||||
if (selectionMade == 1) {
|
||||
snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1);
|
||||
file = Common::String::format("%s%02d", _targetName.c_str(), n + 1);
|
||||
}
|
||||
num_sav = n;
|
||||
}
|
||||
|
@ -127,11 +126,11 @@ bool DrasculaEngine::saveLoadScreen() {
|
|||
}
|
||||
|
||||
if (selectionMade == 1) {
|
||||
snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1);
|
||||
saveGame(file);
|
||||
file = Common::String::format("%s%02d", _targetName.c_str(), n + 1);
|
||||
saveGame(file.c_str());
|
||||
Common::OutSaveFile *tsav;
|
||||
if (!(tsav = _saveFileMan->openForSaving(fileEpa))) {
|
||||
error("Can't open %s file", fileEpa);
|
||||
error("Can't open %s file", fileEpa.c_str());
|
||||
}
|
||||
for (n = 0; n < NUM_SAVES; n++) {
|
||||
tsav->writeString(names[n]);
|
||||
|
@ -143,16 +142,16 @@ bool DrasculaEngine::saveLoadScreen() {
|
|||
}
|
||||
|
||||
if (mouseX > 125 && mouseY > 123 && mouseX < 199 && mouseY < 149 && selectionMade == 1) {
|
||||
if (!loadGame(file)) {
|
||||
if (!loadGame(file.c_str())) {
|
||||
_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
} else if (mouseX > 208 && mouseY > 123 && mouseX < 282 && mouseY < 149 && selectionMade == 1) {
|
||||
saveGame(file);
|
||||
saveGame(file.c_str());
|
||||
Common::OutSaveFile *tsav;
|
||||
if (!(tsav = _saveFileMan->openForSaving(fileEpa))) {
|
||||
error("Can't open %s file", fileEpa);
|
||||
error("Can't open %s file", fileEpa.c_str());
|
||||
}
|
||||
for (n = 0; n < NUM_SAVES; n++) {
|
||||
tsav->writeString(names[n]);
|
||||
|
@ -229,7 +228,7 @@ bool DrasculaEngine::loadGame(const char *gameName) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void DrasculaEngine::saveGame(char gameName[]) {
|
||||
void DrasculaEngine::saveGame(const char *gameName) {
|
||||
Common::OutSaveFile *out;
|
||||
int l;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue