From 3763ec7652c8421ad18cb59ec88a0bd448e2ab23 Mon Sep 17 00:00:00 2001 From: tron Date: Tue, 15 Mar 2005 14:06:28 +0000 Subject: (svn r2012) When making a savegame name, don't append the extension, if it is already there --- os2.c | 13 +++++++++++-- unix.c | 13 +++++++++++-- win32.c | 13 +++++++++++-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/os2.c b/os2.c index 064dac66b..2764c3454 100644 --- a/os2.c +++ b/os2.c @@ -392,10 +392,19 @@ StringID FiosGetDescText(const char **path) 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) diff --git a/unix.c b/unix.c index 529c57d9e..d24255b8b 100644 --- a/unix.c +++ b/unix.c @@ -324,10 +324,19 @@ StringID FiosGetDescText(const char **path) 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) diff --git a/win32.c b/win32.c index 8f1e124d3..7003e7aef 100644 --- a/win32.c +++ b/win32.c @@ -1848,10 +1848,19 @@ StringID FiosGetDescText(const char **path) 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) -- cgit v1.2.3-70-g09d2