aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2006-07-22 09:05:13 +0000
committerTorbjörn Andersson2006-07-22 09:05:13 +0000
commit8242e6966d45c20316887b9c7f4691ad4d65fc03 (patch)
tree1159aeb1b9d81f76d03a6311cfbdbb1220015be6
parenteb23d7b9a091cbdccb3ef48573874a0389fce5bc (diff)
downloadscummvm-rg350-8242e6966d45c20316887b9c7f4691ad4d65fc03.tar.gz
scummvm-rg350-8242e6966d45c20316887b9c7f4691ad4d65fc03.tar.bz2
scummvm-rg350-8242e6966d45c20316887b9c7f4691ad4d65fc03.zip
Cleanup.
svn-id: r23551
-rw-r--r--engines/sword2/saveload.cpp28
-rw-r--r--engines/sword2/sword2.h1
2 files changed, 12 insertions, 17 deletions
diff --git a/engines/sword2/saveload.cpp b/engines/sword2/saveload.cpp
index dcaded4529..eb7b6e0b0c 100644
--- a/engines/sword2/saveload.cpp
+++ b/engines/sword2/saveload.cpp
@@ -44,17 +44,19 @@
namespace Sword2 {
-// A savegame consists of a header and the global variables
+char *Sword2Engine::getSaveFileName(uint16 slotNo) {
+ static char buf[128];
-// Max length of a savegame filename
-#define MAX_FILENAME_LEN 128
+ snprintf(buf, sizeof(buf), "%s.%.3d", _targetName.c_str(), slotNo);
+ return buf;
+}
/**
- * Calculate size of required savegame buffer
+ * Calculate size of required savegame buffer. A savegame consists of a header
+ * and the global variables.
*/
uint32 Sword2Engine::findBufferSize() {
- // Size of savegame header + size of global variables
return 212 + _resman->fetchLen(1);
}
@@ -121,9 +123,7 @@ uint32 Sword2Engine::saveGame(uint16 slotNo, byte *desc) {
}
uint32 Sword2Engine::saveData(uint16 slotNo, byte *buffer, uint32 bufferSize) {
- char saveFileName[MAX_FILENAME_LEN];
-
- sprintf(saveFileName, "%s.%.3d", _targetName.c_str(), slotNo);
+ char *saveFileName = getSaveFileName(slotNo);
Common::OutSaveFile *out;
@@ -201,9 +201,7 @@ uint32 Sword2Engine::restoreGame(uint16 slotNo) {
}
uint32 Sword2Engine::restoreData(uint16 slotNo, byte *buffer, uint32 bufferSize) {
- char saveFileName[MAX_FILENAME_LEN];
-
- sprintf(saveFileName, "%s.%.3d", _targetName.c_str(), slotNo);
+ char *saveFileName = getSaveFileName(slotNo);
Common::InSaveFile *in;
@@ -368,9 +366,7 @@ uint32 Sword2Engine::restoreFromBuffer(byte *buffer, uint32 size) {
*/
uint32 Sword2Engine::getSaveDescription(uint16 slotNo, byte *description) {
- char saveFileName[MAX_FILENAME_LEN];
-
- sprintf(saveFileName, "%s.%.3d", _targetName.c_str(), slotNo);
+ char *saveFileName = getSaveFileName(slotNo);
Common::InSaveFile *in;
@@ -393,9 +389,7 @@ bool Sword2Engine::saveExists() {
}
bool Sword2Engine::saveExists(uint16 slotNo) {
- char saveFileName[MAX_FILENAME_LEN];
-
- sprintf(saveFileName, "%s.%.3d", _targetName.c_str(), slotNo);
+ char *saveFileName = getSaveFileName(slotNo);
Common::InSaveFile *in;
diff --git a/engines/sword2/sword2.h b/engines/sword2/sword2.h
index 31ab253830..79b07c9918 100644
--- a/engines/sword2/sword2.h
+++ b/engines/sword2/sword2.h
@@ -197,6 +197,7 @@ public:
bool saveExists();
bool saveExists(uint16 slotNo);
uint32 restoreFromBuffer(byte *buffer, uint32 size);
+ char *getSaveFileName(uint16 slotNo);
uint32 findBufferSize();
bool _gamePaused;