mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r8784) -Regression (r7274 most likely): Unable to load TTDP (on *NIX) games because the static buffer used for name conversion is overwritten in the callback function.
This commit is contained in:
parent
f731d7ffc4
commit
1aab4a368b
|
@ -212,6 +212,7 @@ static FiosItem *FiosGetFileList(int mode, fios_getlist_callback_proc *callback_
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
FiosItem *fios;
|
FiosItem *fios;
|
||||||
int sort_start;
|
int sort_start;
|
||||||
|
char d_name[sizeof(fios->name)];
|
||||||
|
|
||||||
/* A parent directory link exists if we are not in the root directory */
|
/* A parent directory link exists if we are not in the root directory */
|
||||||
if (!FiosIsRoot(_fios_path) && mode != SLD_NEW_GAME) {
|
if (!FiosIsRoot(_fios_path) && mode != SLD_NEW_GAME) {
|
||||||
|
@ -225,7 +226,7 @@ static FiosItem *FiosGetFileList(int mode, fios_getlist_callback_proc *callback_
|
||||||
/* Show subdirectories */
|
/* Show subdirectories */
|
||||||
if (mode != SLD_NEW_GAME && (dir = opendir(_fios_path)) != NULL) {
|
if (mode != SLD_NEW_GAME && (dir = opendir(_fios_path)) != NULL) {
|
||||||
while ((dirent = readdir(dir)) != NULL) {
|
while ((dirent = readdir(dir)) != NULL) {
|
||||||
const char *d_name = FS2OTTD(dirent->d_name);
|
ttd_strlcpy(d_name, FS2OTTD(dirent->d_name), sizeof(d_name));
|
||||||
|
|
||||||
/* found file must be directory, but not '.' or '..' */
|
/* found file must be directory, but not '.' or '..' */
|
||||||
if (FiosIsValidFile(_fios_path, dirent, &sb) && (sb.st_mode & S_IFDIR) &&
|
if (FiosIsValidFile(_fios_path, dirent, &sb) && (sb.st_mode & S_IFDIR) &&
|
||||||
|
@ -258,8 +259,7 @@ static FiosItem *FiosGetFileList(int mode, fios_getlist_callback_proc *callback_
|
||||||
while ((dirent = readdir(dir)) != NULL) {
|
while ((dirent = readdir(dir)) != NULL) {
|
||||||
char fios_title[64];
|
char fios_title[64];
|
||||||
char *t;
|
char *t;
|
||||||
char *d_name = (char*)FS2OTTD(dirent->d_name);
|
ttd_strlcpy(d_name, FS2OTTD(dirent->d_name), sizeof(d_name));
|
||||||
byte type;
|
|
||||||
|
|
||||||
if (!FiosIsValidFile(_fios_path, dirent, &sb) || !(sb.st_mode & S_IFREG)) continue;
|
if (!FiosIsValidFile(_fios_path, dirent, &sb) || !(sb.st_mode & S_IFREG)) continue;
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ static FiosItem *FiosGetFileList(int mode, fios_getlist_callback_proc *callback_
|
||||||
if ((t = strrchr(d_name, '.')) == NULL) continue;
|
if ((t = strrchr(d_name, '.')) == NULL) continue;
|
||||||
fios_title[0] = '\0'; // reset the title;
|
fios_title[0] = '\0'; // reset the title;
|
||||||
|
|
||||||
type = callback_proc(mode, d_name, t, fios_title);
|
byte type = callback_proc(mode, d_name, t, fios_title);
|
||||||
if (type != FIOS_TYPE_INVALID) {
|
if (type != FIOS_TYPE_INVALID) {
|
||||||
fios = FiosAlloc();
|
fios = FiosAlloc();
|
||||||
fios->mtime = sb.st_mtime;
|
fios->mtime = sb.st_mtime;
|
||||||
|
|
Loading…
Reference in New Issue