diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fios.cpp | 52 | ||||
-rw-r--r-- | src/fios.h | 32 | ||||
-rw-r--r-- | src/misc_gui.cpp | 1 |
3 files changed, 45 insertions, 40 deletions
diff --git a/src/fios.cpp b/src/fios.cpp index f48ed1dcc..726e72a0f 100644 --- a/src/fios.cpp +++ b/src/fios.cpp @@ -152,6 +152,10 @@ char *FiosBrowseTo(const FiosItem *item) snprintf(str_buffr, lengthof(str_buffr), "%s%s", path, item->name); return str_buffr; } + + case FIOS_TYPE_DRIVE: + case FIOS_TYPE_INVALID: + break; } return NULL; @@ -208,13 +212,13 @@ bool FileExists(const char *filename) #endif } -typedef byte fios_getlist_callback_proc(int mode, const char *filename, const char *ext, char *title); +typedef FiosType fios_getlist_callback_proc(SaveLoadDialogMode mode, const char *filename, const char *ext, char *title); /** Create a list of the files in a directory, according to some arbitrary rule. * @param mode The mode we are in. Some modes don't allow 'parent'. * @param callback_proc The function that is called where you need to do the filtering. * @return Return the list of files. */ -static FiosItem *FiosGetFileList(int mode, fios_getlist_callback_proc *callback_proc) +static FiosItem *FiosGetFileList(SaveLoadDialogMode mode, fios_getlist_callback_proc *callback_proc) { struct stat sb; struct dirent *dirent; @@ -277,7 +281,7 @@ static FiosItem *FiosGetFileList(int mode, fios_getlist_callback_proc *callback_ if ((t = strrchr(d_name, '.')) == NULL) continue; fios_title[0] = '\0'; // reset the title; - byte type = callback_proc(mode, d_name, t, fios_title); + FiosType type = callback_proc(mode, d_name, t, fios_title); if (type != FIOS_TYPE_INVALID) { fios = FiosAlloc(); fios->mtime = sb.st_mtime; @@ -313,7 +317,7 @@ static FiosItem *FiosGetFileList(int mode, fios_getlist_callback_proc *callback_ * @see FiosGetFileList * @see FiosGetSavegameList */ -static byte FiosGetSavegameListCallback(int mode, const char *file, const char *ext, char *title) +static FiosType FiosGetSavegameListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title) { /* Show savegame files * .SAV OpenTTD saved game @@ -339,16 +343,16 @@ static byte FiosGetSavegameListCallback(int mode, const char *file, const char * * @return A pointer to an array of FiosItem representing all the files to be shown in the save/load dialog. * @see FiosGetFileList */ -FiosItem *FiosGetSavegameList(int mode) +FiosItem *FiosGetSavegameList(SaveLoadDialogMode mode) { - static char *_fios_save_path = NULL; + static char *fios_save_path = NULL; - if (_fios_save_path == NULL) { - _fios_save_path = MallocT<char>(MAX_PATH); - FioGetDirectory(_fios_save_path, MAX_PATH, SAVE_DIR); + if (fios_save_path == NULL) { + fios_save_path = MallocT<char>(MAX_PATH); + FioGetDirectory(fios_save_path, MAX_PATH, SAVE_DIR); } - _fios_path = _fios_save_path; + _fios_path = fios_save_path; return FiosGetFileList(mode, &FiosGetSavegameListCallback); } @@ -363,7 +367,7 @@ FiosItem *FiosGetSavegameList(int mode) * @see FiosGetFileList * @see FiosGetScenarioList */ -static byte FiosGetScenarioListCallback(int mode, const char *file, const char *ext, char *title) +static FiosType FiosGetScenarioListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title) { /* Show scenario files * .SCN OpenTTD style scenario file @@ -387,22 +391,22 @@ static byte FiosGetScenarioListCallback(int mode, const char *file, const char * * @return A pointer to an array of FiosItem representing all the files to be shown in the save/load dialog. * @see FiosGetFileList */ -FiosItem *FiosGetScenarioList(int mode) +FiosItem *FiosGetScenarioList(SaveLoadDialogMode mode) { - static char *_fios_scn_path = NULL; + static char *fios_scn_path = NULL; /* Copy the default path on first run or on 'New Game' */ - if (_fios_scn_path == NULL) { - _fios_scn_path = MallocT<char>(MAX_PATH); - FioGetDirectory(_fios_scn_path, MAX_PATH, SCENARIO_DIR); + if (fios_scn_path == NULL) { + fios_scn_path = MallocT<char>(MAX_PATH); + FioGetDirectory(fios_scn_path, MAX_PATH, SCENARIO_DIR); } - _fios_path = _fios_scn_path; + _fios_path = fios_scn_path; return FiosGetFileList(mode, &FiosGetScenarioListCallback); } -static byte FiosGetHeightmapListCallback(int mode, const char *file, const char *ext, char *title) +static FiosType FiosGetHeightmapListCallback(SaveLoadDialogMode mode, const char *file, const char *ext, char *title) { /* Show heightmap files * .PNG PNG Based heightmap files @@ -419,16 +423,16 @@ static byte FiosGetHeightmapListCallback(int mode, const char *file, const char } /* Get a list of Heightmaps */ -FiosItem *FiosGetHeightmapList(int mode) +FiosItem *FiosGetHeightmapList(SaveLoadDialogMode mode) { - static char *_fios_hmap_path = NULL; + static char *fios_hmap_path = NULL; - if (_fios_hmap_path == NULL) { - _fios_hmap_path = MallocT<char>(MAX_PATH); - FioGetDirectory(_fios_hmap_path, MAX_PATH, HEIGHTMAP_DIR); + if (fios_hmap_path == NULL) { + fios_hmap_path = MallocT<char>(MAX_PATH); + FioGetDirectory(fios_hmap_path, MAX_PATH, HEIGHTMAP_DIR); } - _fios_path = _fios_hmap_path; + _fios_path = fios_hmap_path; return FiosGetFileList(mode, &FiosGetHeightmapListCallback); } diff --git a/src/fios.h b/src/fios.h index ccc548286..ca95b3578 100644 --- a/src/fios.h +++ b/src/fios.h @@ -42,23 +42,23 @@ enum FileType { FT_HEIGHTMAP, ///< heightmap file }; -enum { - FIOS_TYPE_DRIVE = 0, - FIOS_TYPE_PARENT = 1, - FIOS_TYPE_DIR = 2, - FIOS_TYPE_FILE = 3, - FIOS_TYPE_OLDFILE = 4, - FIOS_TYPE_SCENARIO = 5, - FIOS_TYPE_OLD_SCENARIO = 6, - FIOS_TYPE_DIRECT = 7, - FIOS_TYPE_PNG = 8, - FIOS_TYPE_BMP = 9, - FIOS_TYPE_INVALID = 255, +enum FiosType { + FIOS_TYPE_DRIVE, + FIOS_TYPE_PARENT, + FIOS_TYPE_DIR, + FIOS_TYPE_FILE, + FIOS_TYPE_OLDFILE, + FIOS_TYPE_SCENARIO, + FIOS_TYPE_OLD_SCENARIO, + FIOS_TYPE_DIRECT, + FIOS_TYPE_PNG, + FIOS_TYPE_BMP, + FIOS_TYPE_INVALID = 255, }; /* Deals with finding savegames */ struct FiosItem { - byte type; + FiosType type; uint64 mtime; char title[64]; char name[256 - 12 - 64]; @@ -82,11 +82,11 @@ extern SaveLoadDialogMode _saveload_mode; ///< defined in misc_gui.cpp void ShowSaveLoadDialog(SaveLoadDialogMode mode); /* Get a list of savegames */ -FiosItem *FiosGetSavegameList(int mode); +FiosItem *FiosGetSavegameList(SaveLoadDialogMode mode); /* Get a list of scenarios */ -FiosItem *FiosGetScenarioList(int mode); +FiosItem *FiosGetScenarioList(SaveLoadDialogMode mode); /* Get a list of Heightmaps */ -FiosItem *FiosGetHeightmapList(int mode); +FiosItem *FiosGetHeightmapList(SaveLoadDialogMode mode); /* Free the list of savegames */ void FiosFreeSavegameList(); /* Browse to. Returns a filename w/path if we reached a file. */ diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 78053470d..398529c04 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -1455,6 +1455,7 @@ static void MakeSortedSaveGameList() case FIOS_TYPE_DIR: sort_start++; break; case FIOS_TYPE_PARENT: sort_start++; break; case FIOS_TYPE_DRIVE: sort_end++; break; + default: break; } } |