(svn r2012) When making a savegame name, don't append the extension, if it is already there
authortron
Tue, 15 Mar 2005 14:06:28 +0000
changeset 1508 faae7585cae7
parent 1507 18cb39ddddfd
child 1509 795ba683e4f0
(svn r2012) When making a savegame name, don't append the extension, if it is already there
os2.c
unix.c
win32.c
--- a/os2.c	Tue Mar 15 12:21:59 2005 +0000
+++ b/os2.c	Tue Mar 15 14:06:28 2005 +0000
@@ -392,10 +392,19 @@
 
 void FiosMakeSavegameName(char *buf, const char *name)
 {
+	const char* extension;
+	const char* period;
+
 	if (_game_mode == GM_EDITOR)
-		sprintf(buf, "%s\\%s.scn", _fios_path, name);
+		extension = ".scn";
 	else
-		sprintf(buf, "%s\\%s.sav", _fios_path, name);
+		extension = ".sav";
+
+	// Don't append the extension, if it is already there
+	period = strrchr(name, '.');
+	if (period != NULL && strcasecmp(period, extension) == 0) extension = "";
+
+	sprintf(buf, "%s\\%s%s", _fios_path, name, extension);
 }
 
 void FiosDelete(const char *name)
--- a/unix.c	Tue Mar 15 12:21:59 2005 +0000
+++ b/unix.c	Tue Mar 15 14:06:28 2005 +0000
@@ -324,10 +324,19 @@
 
 void FiosMakeSavegameName(char *buf, const char *name)
 {
+	const char* extension;
+	const char* period;
+
 	if (_game_mode == GM_EDITOR)
-		sprintf(buf, "%s/%s.scn", _fios_path, name);
+		extension = ".scn";
 	else
-		sprintf(buf, "%s/%s.sav", _fios_path, name);
+		extension = ".sav";
+
+	// Don't append the extension, if it is already there
+	period = strrchr(name, '.');
+	if (period != NULL && strcasecmp(period, extension) == 0) extension = "";
+
+	sprintf(buf, "%s/%s%s", _fios_path, name, extension);
 }
 
 void FiosDelete(const char *name)
--- a/win32.c	Tue Mar 15 12:21:59 2005 +0000
+++ b/win32.c	Tue Mar 15 14:06:28 2005 +0000
@@ -1848,10 +1848,19 @@
 
 void FiosMakeSavegameName(char *buf, const char *name)
 {
+	const char* extension;
+	const char* period;
+
 	if (_game_mode == GM_EDITOR)
-		sprintf(buf, "%s\\%s.scn", _fios_path, name);
+		extension = ".scn";
 	else
-		sprintf(buf, "%s\\%s.sav", _fios_path, name);
+		extension = ".sav";
+
+	// Don't append the extension, if it is already there
+	period = strrchr(name, '.');
+	if (period != NULL && strcasecmp(period, extension) == 0) extension = "";
+
+	sprintf(buf, "%s\\%s%s", _fios_path, name, extension);
 }
 
 void FiosDelete(const char *name)