[Scummvm-cvs-logs] scummvm master -> 889f5d119a419b5f7f98341a8ae8d0159f9cf820
digitall
digitall at scummvm.org
Thu Jun 2 03:56:02 CEST 2011
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:
889f5d119a DRASCULA: Replace snprintf() usage with Common::String::format()
Commit: 889f5d119a419b5f7f98341a8ae8d0159f9cf820
https://github.com/scummvm/scummvm/commit/889f5d119a419b5f7f98341a8ae8d0159f9cf820
Author: D G Turner (digitall at scummvm.org)
Date: 2011-06-01T18:53:48-07:00
Commit Message:
DRASCULA: Replace snprintf() usage with Common::String::format()
Safer and less portability issues.
Changed paths:
engines/drascula/drascula.cpp
engines/drascula/drascula.h
engines/drascula/saveload.cpp
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp
index cac7f93..b4f009e 100644
--- a/engines/drascula/drascula.cpp
+++ b/engines/drascula/drascula.cpp
@@ -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;
}
diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h
index f9dcbe2..2b6aa0f 100644
--- a/engines/drascula/drascula.h
+++ b/engines/drascula/drascula.h
@@ -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();
diff --git a/engines/drascula/saveload.cpp b/engines/drascula/saveload.cpp
index 15f5855..664a082 100644
--- a/engines/drascula/saveload.cpp
+++ b/engines/drascula/saveload.cpp
@@ -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;
More information about the Scummvm-git-logs
mailing list