[Scummvm-cvs-logs] SF.net SVN: scummvm: [23551] scummvm/trunk/engines/sword2

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Sat Jul 22 11:05:18 CEST 2006


Revision: 23551
Author:   eriktorbjorn
Date:     2006-07-22 02:05:13 -0700 (Sat, 22 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=23551&view=rev

Log Message:
-----------
Cleanup.

Modified Paths:
--------------
    scummvm/trunk/engines/sword2/saveload.cpp
    scummvm/trunk/engines/sword2/sword2.h
Modified: scummvm/trunk/engines/sword2/saveload.cpp
===================================================================
--- scummvm/trunk/engines/sword2/saveload.cpp	2006-07-22 06:09:13 UTC (rev 23550)
+++ scummvm/trunk/engines/sword2/saveload.cpp	2006-07-22 09:05:13 UTC (rev 23551)
@@ -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,10 +123,8 @@
 }
 
 uint32 Sword2Engine::saveData(uint16 slotNo, byte *buffer, uint32 bufferSize) {
-	char saveFileName[MAX_FILENAME_LEN];
+	char *saveFileName = getSaveFileName(slotNo);
 
-	sprintf(saveFileName, "%s.%.3d", _targetName.c_str(), slotNo);
-
 	Common::OutSaveFile *out;
 
 	if (!(out = _saveFileMan->openForSaving(saveFileName))) {
@@ -201,10 +201,8 @@
 }
 
 uint32 Sword2Engine::restoreData(uint16 slotNo, byte *buffer, uint32 bufferSize) {
-	char saveFileName[MAX_FILENAME_LEN];
+	char *saveFileName = getSaveFileName(slotNo);
 
-	sprintf(saveFileName, "%s.%.3d", _targetName.c_str(), slotNo);
-
 	Common::InSaveFile *in;
 
 	if (!(in = _saveFileMan->openForLoading(saveFileName))) {
@@ -368,10 +366,8 @@
  */
 
 uint32 Sword2Engine::getSaveDescription(uint16 slotNo, byte *description) {
-	char saveFileName[MAX_FILENAME_LEN];
+	char *saveFileName = getSaveFileName(slotNo);
 
-	sprintf(saveFileName, "%s.%.3d", _targetName.c_str(), slotNo);
-
 	Common::InSaveFile *in;
 
 	if (!(in = _saveFileMan->openForLoading(saveFileName))) {
@@ -393,10 +389,8 @@
 }
 
 bool Sword2Engine::saveExists(uint16 slotNo) {
-	char saveFileName[MAX_FILENAME_LEN];
+	char *saveFileName = getSaveFileName(slotNo);
 
-	sprintf(saveFileName, "%s.%.3d", _targetName.c_str(), slotNo);
-
 	Common::InSaveFile *in;
 
 	if (!(in = _saveFileMan->openForLoading(saveFileName))) {

Modified: scummvm/trunk/engines/sword2/sword2.h
===================================================================
--- scummvm/trunk/engines/sword2/sword2.h	2006-07-22 06:09:13 UTC (rev 23550)
+++ scummvm/trunk/engines/sword2/sword2.h	2006-07-22 09:05:13 UTC (rev 23551)
@@ -197,6 +197,7 @@
 	bool saveExists();
 	bool saveExists(uint16 slotNo);
 	uint32 restoreFromBuffer(byte *buffer, uint32 size);
+	char *getSaveFileName(uint16 slotNo);
 	uint32 findBufferSize();
 
 	bool _gamePaused;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list