forked from mirror/OpenTTD
(svn r4018) -Backport from trunk (4001:4002):
Add length parameter to FiosMakeSavegameName() and use this function for creating the full path instead of home-brewn snprintf. Use the title of a savegame in the saveload dialog-editbox. This gets rid of the '.sav' appended to each game as well as properly showing UTF-8 saves when this is implemented. Also don't change the text if the save has failed.
This commit is contained in:
6
os2.c
6
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user