summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hal.h2
-rw-r--r--misc_gui.c4
-rw-r--r--os2.c6
-rw-r--r--unix.c6
-rw-r--r--win32.c6
5 files changed, 12 insertions, 12 deletions
diff --git a/hal.h b/hal.h
index 7c4625c44..d2abd52ce 100644
--- a/hal.h
+++ b/hal.h
@@ -88,7 +88,7 @@ StringID FiosGetDescText(const char **path, uint32 *tot);
// Delete a name
bool FiosDelete(const char *name);
// Make a filename from a name
-void FiosMakeSavegameName(char *buf, const char *name);
+void FiosMakeSavegameName(char *buf, const char *name, size_t size);
int CDECL compare_FiosItems(const void *a, const void *b);
diff --git a/misc_gui.c b/misc_gui.c
index 492f34fcd..3301338ae 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -1325,7 +1325,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
DeleteWindow(w);
} else {
// SLD_SAVE_GAME, SLD_SAVE_SCENARIO copy clicked name to editbox
- ttd_strlcpy(WP(w, querystr_d).text.buf, file->name, WP(w, querystr_d).text.maxlength);
+ ttd_strlcpy(WP(w, querystr_d).text.buf, file->title, WP(w, querystr_d).text.maxlength);
UpdateTextBufferSize(&WP(w, querystr_d).text);
InvalidateWidget(w, 10);
}
@@ -1368,7 +1368,7 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
}
} else if (HASBIT(w->click_state, 12)) { /* Save button clicked */
_switch_mode = SM_SAVE;
- FiosMakeSavegameName(_file_to_saveload.name, WP(w,querystr_d).text.buf);
+ FiosMakeSavegameName(_file_to_saveload.name, WP(w,querystr_d).text.buf, sizeof(_file_to_saveload.name));
/* In the editor set up the vehicle engines correctly (date might have changed) */
if (_game_mode == GM_EDITOR) StartupEngines();
diff --git a/os2.c b/os2.c
index c2fd448f3..3b6c48e2c 100644
--- a/os2.c
+++ b/os2.c
@@ -401,7 +401,7 @@ StringID FiosGetDescText(const char **path, uint32 *tot)
return STR_4006_UNABLE_TO_READ_DRIVE;
}
-void FiosMakeSavegameName(char *buf, const char *name)
+void FiosMakeSavegameName(char *buf, const char *name, size_t size)
{
const char* extension;
const char* period;
@@ -415,14 +415,14 @@ void FiosMakeSavegameName(char *buf, const char *name)
period = strrchr(name, '.');
if (period != NULL && strcasecmp(period, extension) == 0) extension = "";
- sprintf(buf, "%s\\%s%s", _fios_path, name, extension);
+ snprintf(buf, size, "%s\\%s%s", _fios_path, name, extension);
}
bool FiosDelete(const char *name)
{
char path[512];
- snprintf(path, lengthof(path), "%s\\%s", _fios_path, name);
+ FiosMakeSavegameName(path, name, sizeof(path));
return unlink(path) == 0;
}
diff --git a/unix.c b/unix.c
index 80a2802b9..291e90110 100644
--- a/unix.c
+++ b/unix.c
@@ -362,7 +362,7 @@ StringID FiosGetDescText(const char **path, uint32 *tot)
return STR_4005_BYTES_FREE;
}
-void FiosMakeSavegameName(char *buf, const char *name)
+void FiosMakeSavegameName(char *buf, const char *name, size_t size)
{
const char* extension;
const char* period;
@@ -376,14 +376,14 @@ void FiosMakeSavegameName(char *buf, const char *name)
period = strrchr(name, '.');
if (period != NULL && strcasecmp(period, extension) == 0) extension = "";
- sprintf(buf, "%s/%s%s", _fios_path, name, extension);
+ snprintf(buf, size, "%s/%s%s", _fios_path, name, extension);
}
bool FiosDelete(const char *name)
{
char path[512];
- snprintf(path, lengthof(path), "%s/%s", _fios_path, name);
+ FiosMakeSavegameName(path, name, sizeof(path));
return unlink(path) == 0;
}
diff --git a/win32.c b/win32.c
index f4e642efc..096702cf0 100644
--- a/win32.c
+++ b/win32.c
@@ -963,7 +963,7 @@ StringID FiosGetDescText(const char **path, uint32 *tot)
return sid;
}
-void FiosMakeSavegameName(char *buf, const char *name)
+void FiosMakeSavegameName(char *buf, const char *name, size_t size)
{
const char* extension;
const char* period;
@@ -977,14 +977,14 @@ void FiosMakeSavegameName(char *buf, const char *name)
period = strrchr(name, '.');
if (period != NULL && strcasecmp(period, extension) == 0) extension = "";
- sprintf(buf, "%s\\%s%s", _fios_path, name, extension);
+ snprintf(buf, size, "%s\\%s%s", _fios_path, name, extension);
}
bool FiosDelete(const char *name)
{
char path[512];
- snprintf(path, lengthof(path), "%s\\%s", _fios_path, name);
+ FiosMakeSavegameName(path, name, sizeof(path));
return DeleteFile(path) != 0;
}