diff options
author | alberth <alberth@openttd.org> | 2016-09-04 16:06:50 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2016-09-04 16:06:50 +0000 |
commit | 0adfb1ac6f8fa99ede48daaebd5fc4184c9797e3 (patch) | |
tree | 281a80ddd52788410aba4b4c73aa4f80523e2d1b /src | |
parent | 4001f6215e5d1e56aba121c226fb7e824a170f21 (diff) | |
download | openttd-0adfb1ac6f8fa99ede48daaebd5fc4184c9797e3.tar.xz |
(svn r27653) -Fix(r27647): Rename FileOperation enum and values to SaveLoadOperation to avoid nameclash with windows compiler toolkit.
Diffstat (limited to 'src')
-rw-r--r-- | src/console_cmds.cpp | 4 | ||||
-rw-r--r-- | src/crashlog.cpp | 2 | ||||
-rw-r--r-- | src/fileio_type.h | 10 | ||||
-rw-r--r-- | src/fios.cpp | 32 | ||||
-rw-r--r-- | src/fios.h | 12 | ||||
-rw-r--r-- | src/fios_gui.cpp | 36 | ||||
-rw-r--r-- | src/genworld.cpp | 2 | ||||
-rw-r--r-- | src/intro_gui.cpp | 6 | ||||
-rw-r--r-- | src/network/network_client.cpp | 4 | ||||
-rw-r--r-- | src/network/network_gui.cpp | 6 | ||||
-rw-r--r-- | src/openttd.cpp | 20 | ||||
-rw-r--r-- | src/saveload/saveload.cpp | 40 | ||||
-rw-r--r-- | src/saveload/saveload.h | 6 | ||||
-rw-r--r-- | src/toolbar_gui.cpp | 14 | ||||
-rw-r--r-- | src/video/dedicated_v.cpp | 2 |
15 files changed, 98 insertions, 98 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 863929b94..9cfc8e8f9 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -67,7 +67,7 @@ public: void ValidateFileList(bool force_reload = false) { if (force_reload || !this->file_list_valid) { - this->BuildFileList(FT_SAVEGAME, FOP_LOAD); + this->BuildFileList(FT_SAVEGAME, SLO_LOAD); this->file_list_valid = true; } } @@ -318,7 +318,7 @@ DEF_CONSOLE_CMD(ConSave) char *filename = str_fmt("%s.sav", argv[1]); IConsolePrint(CC_DEFAULT, "Saving map..."); - if (SaveOrLoad(filename, FOP_SAVE, DFT_GAME_FILE, SAVE_DIR) != SL_OK) { + if (SaveOrLoad(filename, SLO_SAVE, DFT_GAME_FILE, SAVE_DIR) != SL_OK) { IConsolePrint(CC_ERROR, "Saving map failed"); } else { IConsolePrintF(CC_DEFAULT, "Map successfully saved to %s", filename); diff --git a/src/crashlog.cpp b/src/crashlog.cpp index 83beb94ff..53a85e442 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -388,7 +388,7 @@ bool CrashLog::WriteSavegame(char *filename, const char *filename_last) const seprintf(filename, filename_last, "%scrash.sav", _personal_dir); /* Don't do a threaded saveload. */ - return SaveOrLoad(filename, FOP_SAVE, DFT_GAME_FILE, NO_DIRECTORY, false) == SL_OK; + return SaveOrLoad(filename, SLO_SAVE, DFT_GAME_FILE, NO_DIRECTORY, false) == SL_OK; } catch (...) { return false; } diff --git a/src/fileio_type.h b/src/fileio_type.h index 0c4602bba..fd3ac8455 100644 --- a/src/fileio_type.h +++ b/src/fileio_type.h @@ -46,12 +46,12 @@ enum DetailedFileType { }; /** Operation performed on the file. */ -enum FileOperation { - FOP_CHECK, ///< Load file for checking and/or preview. - FOP_LOAD, ///< File is being loaded. - FOP_SAVE, ///< File is being saved. +enum SaveLoadOperation { + SLO_CHECK, ///< Load file for checking and/or preview. + SLO_LOAD, ///< File is being loaded. + SLO_SAVE, ///< File is being saved. - FOP_INVALID, ///< Unknown file operation. + SLO_INVALID, ///< Unknown file operation. }; /** diff --git a/src/fios.cpp b/src/fios.cpp index 987542acc..8ed01152f 100644 --- a/src/fios.cpp +++ b/src/fios.cpp @@ -71,13 +71,13 @@ FileList::~FileList() /** * Construct a file list with the given kind of files, for the stated purpose. * @param abstract_filetype Kind of files to collect. - * @param fop Purpose of the collection, either #FOP_LOAD or #FOP_SAVE. + * @param fop Purpose of the collection, either #SLO_LOAD or #SLO_SAVE. */ -void FileList::BuildFileList(AbstractFileType abstract_filetype, FileOperation fop) +void FileList::BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperation fop) { this->Clear(); - assert(fop == FOP_LOAD || FOP_SAVE); + assert(fop == SLO_LOAD || SLO_SAVE); switch (abstract_filetype) { case FT_NONE: break; @@ -274,13 +274,13 @@ bool FiosDelete(const char *name) return unlink(filename) == 0; } -typedef FiosType fios_getlist_callback_proc(FileOperation fop, const char *filename, const char *ext, char *title, const char *last); +typedef FiosType fios_getlist_callback_proc(SaveLoadOperation fop, const char *filename, const char *ext, char *title, const char *last); /** * Scanner to scan for a particular type of FIOS file. */ class FiosFileScanner : public FileScanner { - FileOperation fop; ///< The kind of file we are looking for. + SaveLoadOperation fop; ///< The kind of file we are looking for. fios_getlist_callback_proc *callback_proc; ///< Callback to check whether the file may be added FileList &file_list; ///< Destination of the found files. public: @@ -290,7 +290,7 @@ public: * @param callback_proc The function that is called where you need to do the filtering. * @param file_list Destination of the found files. */ - FiosFileScanner(FileOperation fop, fios_getlist_callback_proc *callback_proc, FileList &file_list) : + FiosFileScanner(SaveLoadOperation fop, fios_getlist_callback_proc *callback_proc, FileList &file_list) : fop(fop), callback_proc(callback_proc), file_list(file_list) {} @@ -354,7 +354,7 @@ bool FiosFileScanner::AddFile(const char *filename, size_t basepath_length, cons * @param subdir The directory from where to start (global) searching. * @param file_list Destination of the found files. */ -static void FiosGetFileList(FileOperation fop, fios_getlist_callback_proc *callback_proc, Subdirectory subdir, FileList &file_list) +static void FiosGetFileList(SaveLoadOperation fop, fios_getlist_callback_proc *callback_proc, Subdirectory subdir, FileList &file_list) { struct stat sb; struct dirent *dirent; @@ -456,7 +456,7 @@ static void GetFileTitle(const char *file, char *title, const char *last, Subdir * @see FiosGetFileList * @see FiosGetSavegameList */ -FiosType FiosGetSavegameListCallback(FileOperation fop, const char *file, const char *ext, char *title, const char *last) +FiosType FiosGetSavegameListCallback(SaveLoadOperation fop, const char *file, const char *ext, char *title, const char *last) { /* Show savegame files * .SAV OpenTTD saved game @@ -472,7 +472,7 @@ FiosType FiosGetSavegameListCallback(FileOperation fop, const char *file, const return FIOS_TYPE_FILE; } - if (fop == FOP_LOAD) { + if (fop == SLO_LOAD) { if (strcasecmp(ext, ".ss1") == 0 || strcasecmp(ext, ".sv1") == 0 || strcasecmp(ext, ".sv2") == 0) { if (title != NULL) GetOldSaveGameName(file, title, last); @@ -489,7 +489,7 @@ FiosType FiosGetSavegameListCallback(FileOperation fop, const char *file, const * @param file_list Destination of the found files. * @see FiosGetFileList */ -void FiosGetSavegameList(FileOperation fop, FileList &file_list) +void FiosGetSavegameList(SaveLoadOperation fop, FileList &file_list) { static char *fios_save_path = NULL; static char *fios_save_path_last = NULL; @@ -517,7 +517,7 @@ void FiosGetSavegameList(FileOperation fop, FileList &file_list) * @see FiosGetFileList * @see FiosGetScenarioList */ -static FiosType FiosGetScenarioListCallback(FileOperation fop, const char *file, const char *ext, char *title, const char *last) +static FiosType FiosGetScenarioListCallback(SaveLoadOperation fop, const char *file, const char *ext, char *title, const char *last) { /* Show scenario files * .SCN OpenTTD style scenario file @@ -528,7 +528,7 @@ static FiosType FiosGetScenarioListCallback(FileOperation fop, const char *file, return FIOS_TYPE_SCENARIO; } - if (fop == FOP_LOAD) { + if (fop == SLO_LOAD) { if (strcasecmp(ext, ".sv0") == 0 || strcasecmp(ext, ".ss0") == 0 ) { GetOldSaveGameName(file, title, last); return FIOS_TYPE_OLD_SCENARIO; @@ -544,7 +544,7 @@ static FiosType FiosGetScenarioListCallback(FileOperation fop, const char *file, * @param file_list Destination of the found files. * @see FiosGetFileList */ -void FiosGetScenarioList(FileOperation fop, FileList &file_list) +void FiosGetScenarioList(SaveLoadOperation fop, FileList &file_list) { static char *fios_scn_path = NULL; static char *fios_scn_path_last = NULL; @@ -562,11 +562,11 @@ void FiosGetScenarioList(FileOperation fop, FileList &file_list) char base_path[MAX_PATH]; FioGetDirectory(base_path, lastof(base_path), SCENARIO_DIR); - Subdirectory subdir = (fop == FOP_LOAD && strcmp(base_path, _fios_path) == 0) ? SCENARIO_DIR : NO_DIRECTORY; + Subdirectory subdir = (fop == SLO_LOAD && strcmp(base_path, _fios_path) == 0) ? SCENARIO_DIR : NO_DIRECTORY; FiosGetFileList(fop, &FiosGetScenarioListCallback, subdir, file_list); } -static FiosType FiosGetHeightmapListCallback(FileOperation fop, const char *file, const char *ext, char *title, const char *last) +static FiosType FiosGetHeightmapListCallback(SaveLoadOperation fop, const char *file, const char *ext, char *title, const char *last) { /* Show heightmap files * .PNG PNG Based heightmap files @@ -615,7 +615,7 @@ static FiosType FiosGetHeightmapListCallback(FileOperation fop, const char *file * @param fop Purpose of collecting the list. * @param file_list Destination of the found files. */ -void FiosGetHeightmapList(FileOperation fop, FileList &file_list) +void FiosGetHeightmapList(SaveLoadOperation fop, FileList &file_list) { static char *fios_hmap_path = NULL; static char *fios_hmap_path_last = NULL; diff --git a/src/fios.h b/src/fios.h index 80654812b..51e0c275a 100644 --- a/src/fios.h +++ b/src/fios.h @@ -190,7 +190,7 @@ public: this->files.Compact(); } - void BuildFileList(AbstractFileType abstract_filetype, FileOperation fop); + void BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperation fop); const FiosItem *FindItem(const char *file); SmallVector<FiosItem, 32> files; ///< The list of files. @@ -207,11 +207,11 @@ DECLARE_ENUM_AS_BIT_SET(SortingBits) /* Variables to display file lists */ extern SortingBits _savegame_sort_order; -void ShowSaveLoadDialog(AbstractFileType abstract_filetype, FileOperation fop); +void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop); -void FiosGetSavegameList(FileOperation fop, FileList &file_list); -void FiosGetScenarioList(FileOperation fop, FileList &file_list); -void FiosGetHeightmapList(FileOperation fop, FileList &file_list); +void FiosGetSavegameList(SaveLoadOperation fop, FileList &file_list); +void FiosGetScenarioList(SaveLoadOperation fop, FileList &file_list); +void FiosGetHeightmapList(SaveLoadOperation fop, FileList &file_list); const char *FiosBrowseTo(const FiosItem *item); @@ -220,7 +220,7 @@ bool FiosDelete(const char *name); void FiosMakeHeightmapName(char *buf, const char *name, const char *last); void FiosMakeSavegameName(char *buf, const char *name, const char *last); -FiosType FiosGetSavegameListCallback(FileOperation fop, const char *file, const char *ext, char *title, const char *last); +FiosType FiosGetSavegameListCallback(SaveLoadOperation fop, const char *file, const char *ext, char *title, const char *last); int CDECL CompareFiosItems(const FiosItem *a, const FiosItem *b); diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index a0f0f1b29..e6cd9625c 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -229,7 +229,7 @@ struct SaveLoadWindow : public Window { private: QueryString filename_editbox; ///< Filename editbox. AbstractFileType abstract_filetype; /// Type of file to select. - FileOperation fop; ///< File operation to perform. + SaveLoadOperation fop; ///< File operation to perform. FileList fios_items; ///< Save game list. FiosItem o_dir; const FiosItem *selected; ///< Selected game in #fios_items, or \c NULL. @@ -243,13 +243,13 @@ public: this->filename_editbox.text.UpdateSize(); } - SaveLoadWindow(WindowDesc *desc, AbstractFileType abstract_filetype, FileOperation fop) + SaveLoadWindow(WindowDesc *desc, AbstractFileType abstract_filetype, SaveLoadOperation fop) : Window(desc), filename_editbox(64), abstract_filetype(abstract_filetype), fop(fop) { - assert(this->fop == FOP_SAVE || this->fop == FOP_LOAD); + assert(this->fop == SLO_SAVE || this->fop == SLO_LOAD); /* For saving, construct an initial file name. */ - if (this->fop == FOP_SAVE) { + if (this->fop == SLO_SAVE) { switch (this->abstract_filetype) { case FT_SAVEGAME: this->GenerateFileName(); @@ -268,7 +268,7 @@ public: this->filename_editbox.ok_button = WID_SL_SAVE_GAME; this->CreateNestedTree(true); - if (this->fop == FOP_LOAD && this->abstract_filetype == FT_SAVEGAME) { + if (this->fop == SLO_LOAD && this->abstract_filetype == FT_SAVEGAME) { this->GetWidget<NWidgetStacked>(WID_SL_CONTENT_DOWNLOAD_SEL)->SetDisplayedPlane(SZSP_HORIZONTAL); } @@ -276,15 +276,15 @@ public: StringID caption_string; switch (this->abstract_filetype) { case FT_SAVEGAME: - caption_string = (this->fop == FOP_SAVE) ? STR_SAVELOAD_SAVE_CAPTION : STR_SAVELOAD_LOAD_CAPTION; + caption_string = (this->fop == SLO_SAVE) ? STR_SAVELOAD_SAVE_CAPTION : STR_SAVELOAD_LOAD_CAPTION; break; case FT_SCENARIO: - caption_string = (this->fop == FOP_SAVE) ? STR_SAVELOAD_SAVE_SCENARIO : STR_SAVELOAD_LOAD_SCENARIO; + caption_string = (this->fop == SLO_SAVE) ? STR_SAVELOAD_SAVE_SCENARIO : STR_SAVELOAD_LOAD_SCENARIO; break; case FT_HEIGHTMAP: - caption_string = (this->fop == FOP_SAVE) ? STR_SAVELOAD_SAVE_HEIGHTMAP : STR_SAVELOAD_LOAD_HEIGHTMAP; + caption_string = (this->fop == SLO_SAVE) ? STR_SAVELOAD_SAVE_HEIGHTMAP : STR_SAVELOAD_LOAD_HEIGHTMAP; break; default: @@ -328,7 +328,7 @@ public: } /* Focus the edit box by default in the save windows */ - if (this->fop == FOP_SAVE) this->SetFocusedWidget(WID_SL_SAVE_OSK_TITLE); + if (this->fop == SLO_SAVE) this->SetFocusedWidget(WID_SL_SAVE_OSK_TITLE); } virtual ~SaveLoadWindow() @@ -438,7 +438,7 @@ public: } /* Hide the NewGRF stuff when saving. We also hide the button. */ - if (this->fop == FOP_LOAD && (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO)) { + if (this->fop == SLO_LOAD && (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO)) { y += WD_PAR_VSEP_NORMAL; if (y > y_max) break; @@ -583,19 +583,19 @@ public: if (GetDetailedFileType(file->type) == DFT_GAME_FILE) { /* Other detailed file types cannot be checked before. */ - SaveOrLoad(name, FOP_CHECK, DFT_GAME_FILE, NO_DIRECTORY, false); + SaveOrLoad(name, SLO_CHECK, DFT_GAME_FILE, NO_DIRECTORY, false); } this->InvalidateData(1); } - if (this->fop == FOP_SAVE) { + if (this->fop == SLO_SAVE) { /* Copy clicked name to editbox */ this->filename_editbox.text.Assign(file->title); this->SetWidgetDirty(WID_SL_SAVE_OSK_TITLE); } } else if (!_load_check_data.HasErrors()) { this->selected = file; - if (this->fop == FOP_LOAD) { + if (this->fop == SLO_LOAD) { if (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO) { this->OnClick(pt, WID_SL_LOAD_BUTTON, 1); } else { @@ -621,7 +621,7 @@ public: ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR); } else { #if defined(ENABLE_NETWORK) - assert(this->fop == FOP_LOAD); + assert(this->fop == SLO_LOAD); switch (this->abstract_filetype) { default: NOT_REACHED(); case FT_SCENARIO: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_SCENARIO); break; @@ -654,7 +654,7 @@ public: virtual void OnTimeout() { /* Widgets WID_SL_DELETE_SELECTION and WID_SL_SAVE_GAME only exist when saving to a file. */ - if (this->fop != FOP_SAVE) return; + if (this->fop != SLO_SAVE) return; if (this->IsWidgetLowered(WID_SL_DELETE_SELECTION)) { // Delete button clicked if (!FiosDelete(this->filename_editbox.text.buf)) { @@ -707,7 +707,7 @@ public: /* Selection changes */ if (!gui_scope) break; - if (this->fop != FOP_LOAD) break; + if (this->fop != SLO_LOAD) break; switch (this->abstract_filetype) { case FT_HEIGHTMAP: @@ -764,12 +764,12 @@ static WindowDesc _save_dialog_desc( * @param abstract_filetype Kind of file to handle. * @param fop File operation to perform (load or save). */ -void ShowSaveLoadDialog(AbstractFileType abstract_filetype, FileOperation fop) +void ShowSaveLoadDialog(AbstractFileType abstract_filetype, SaveLoadOperation fop) { DeleteWindowById(WC_SAVELOAD, 0); WindowDesc *sld; - if (fop == FOP_SAVE) { + if (fop == SLO_SAVE) { sld = &_save_dialog_desc; } else { /* Dialogue for loading a file. */ diff --git a/src/genworld.cpp b/src/genworld.cpp index 95e28fcdf..a08b32311 100644 --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -204,7 +204,7 @@ static void _GenerateWorld(void *) if (_debug_desync_level > 0) { char name[MAX_PATH]; seprintf(name, lastof(name), "dmp_cmds_%08x_%08x.sav", _settings_game.game_creation.generation_seed, _date); - SaveOrLoad(name, FOP_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR, false); + SaveOrLoad(name, SLO_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR, false); } } catch (...) { BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP, true); diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index b6ac73cb7..a09a59a10 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -111,9 +111,9 @@ struct SelectGameWindow : public Window { } break; - case WID_SGI_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, FOP_LOAD); break; - case WID_SGI_PLAY_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, FOP_LOAD); break; - case WID_SGI_PLAY_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,FOP_LOAD); break; + case WID_SGI_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break; + case WID_SGI_PLAY_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_LOAD); break; + case WID_SGI_PLAY_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_LOAD); break; case WID_SGI_EDIT_SCENARIO: StartScenarioEditor(); break; case WID_SGI_PLAY_NETWORK: diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index a33e5c681..edfe4587f 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -520,7 +520,7 @@ bool ClientNetworkGameSocketHandler::IsConnected() * DEF_CLIENT_RECEIVE_COMMAND has parameter: Packet *p ************/ -extern bool SafeLoad(const char *filename, FileOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf = NULL); +extern bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf = NULL); NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FULL(Packet *p) { @@ -836,7 +836,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE(Packet /* The map is done downloading, load it */ ClearErrorMessages(); - bool load_success = SafeLoad(NULL, FOP_LOAD, DFT_GAME_FILE, GM_NORMAL, NO_DIRECTORY, lf); + bool load_success = SafeLoad(NULL, SLO_LOAD, DFT_GAME_FILE, GM_NORMAL, NO_DIRECTORY, lf); /* Long savegame loads shouldn't affect the lag calculation! */ this->last_packet = _realtime_tick; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index c3aef5b0f..520c4f60a 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1187,17 +1187,17 @@ struct NetworkStartServerWindow : public Window { case WID_NSS_LOAD_GAME: _is_network_server = true; - ShowSaveLoadDialog(FT_SAVEGAME, FOP_LOAD); + ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break; case WID_NSS_PLAY_SCENARIO: _is_network_server = true; - ShowSaveLoadDialog(FT_SCENARIO, FOP_LOAD); + ShowSaveLoadDialog(FT_SCENARIO, SLO_LOAD); break; case WID_NSS_PLAY_HEIGHTMAP: _is_network_server = true; - ShowSaveLoadDialog(FT_HEIGHTMAP,FOP_LOAD); + ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_LOAD); break; } } diff --git a/src/openttd.cpp b/src/openttd.cpp index f00ce74c3..58f011b08 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -328,7 +328,7 @@ static void LoadIntroGame(bool load_newgrfs = true) SetupColoursAndInitialWindow(); /* Load the default opening screen savegame */ - if (SaveOrLoad("opntitle.dat", FOP_LOAD, DFT_GAME_FILE, BASESET_DIR) != SL_OK) { + if (SaveOrLoad("opntitle.dat", SLO_LOAD, DFT_GAME_FILE, BASESET_DIR) != SL_OK) { GenerateWorld(GWM_EMPTY, 64, 64); // if failed loading, make empty world. WaitTillGeneratedWorld(); SetLocalCompany(COMPANY_SPECTATOR); @@ -621,12 +621,12 @@ int openttd_main(int argc, char *argv[]) _file_to_saveload.SetName(mgo.opt); bool is_scenario = _switch_mode == SM_EDITOR || _switch_mode == SM_LOAD_SCENARIO; _switch_mode = is_scenario ? SM_LOAD_SCENARIO : SM_LOAD_GAME; - _file_to_saveload.SetMode(FOP_LOAD, is_scenario ? FT_SCENARIO : FT_SAVEGAME, DFT_GAME_FILE); + _file_to_saveload.SetMode(SLO_LOAD, is_scenario ? FT_SCENARIO : FT_SAVEGAME, DFT_GAME_FILE); /* if the file doesn't exist or it is not a valid savegame, let the saveload code show an error */ const char *t = strrchr(_file_to_saveload.name, '.'); if (t != NULL) { - FiosType ft = FiosGetSavegameListCallback(FOP_LOAD, _file_to_saveload.name, t, NULL, NULL); + FiosType ft = FiosGetSavegameListCallback(SLO_LOAD, _file_to_saveload.name, t, NULL, NULL); if (ft != FIOS_TYPE_INVALID) _file_to_saveload.SetMode(ft); } @@ -648,10 +648,10 @@ int openttd_main(int argc, char *argv[]) char title[80]; title[0] = '\0'; - FiosGetSavegameListCallback(FOP_LOAD, mgo.opt, strrchr(mgo.opt, '.'), title, lastof(title)); + FiosGetSavegameListCallback(SLO_LOAD, mgo.opt, strrchr(mgo.opt, '.'), title, lastof(title)); _load_check_data.Clear(); - SaveOrLoadResult res = SaveOrLoad(mgo.opt, FOP_CHECK, DFT_GAME_FILE, SAVE_DIR, false); + SaveOrLoadResult res = SaveOrLoad(mgo.opt, SLO_CHECK, DFT_GAME_FILE, SAVE_DIR, false); if (res != SL_OK || _load_check_data.HasErrors()) { fprintf(stderr, "Failed to open savegame\n"); if (_load_check_data.HasErrors()) { @@ -998,9 +998,9 @@ static void MakeNewEditorWorld() * @param subdir default directory to look for filename, set to 0 if not needed * @param lf Load filter to use, if NULL: use filename + subdir. */ -bool SafeLoad(const char *filename, FileOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf = NULL) +bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf = NULL) { - assert(fop == FOP_LOAD); + assert(fop == SLO_LOAD); assert(dft == DFT_GAME_FILE || (lf == NULL && dft == DFT_OLD_GAME_FILE)); GameMode ogm = _game_mode; @@ -1158,7 +1158,7 @@ void SwitchToMode(SwitchMode new_mode) case SM_SAVE_GAME: // Save game. /* Make network saved games on pause compatible to singleplayer */ - if (SaveOrLoad(_file_to_saveload.name, FOP_SAVE, DFT_GAME_FILE, NO_DIRECTORY) != SL_OK) { + if (SaveOrLoad(_file_to_saveload.name, SLO_SAVE, DFT_GAME_FILE, NO_DIRECTORY) != SL_OK) { SetDParamStr(0, GetSaveLoadErrorString()); ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, WL_ERROR); } else { @@ -1369,7 +1369,7 @@ void StateGameLoop() /* Save the desync savegame if needed. */ char name[MAX_PATH]; seprintf(name, lastof(name), "dmp_cmds_%08x_%08x.sav", _settings_game.game_creation.generation_seed, _date); - SaveOrLoad(name, FOP_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR, false); + SaveOrLoad(name, SLO_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR, false); } CheckCaches(); @@ -1426,7 +1426,7 @@ static void DoAutosave() } DEBUG(sl, 2, "Autosaving to '%s'", buf); - if (SaveOrLoad(buf, FOP_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR) != SL_OK) { + if (SaveOrLoad(buf, SLO_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR) != SL_OK) { ShowErrorMessage(STR_ERROR_AUTOSAVE_FAILED, INVALID_STRING_ID, WL_ERROR); } } diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 8da0d0398..7b7341115 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -2778,10 +2778,10 @@ SaveOrLoadResult LoadWithFilter(LoadFilter *reader) * @param threaded True when threaded saving is allowed * @return Return the result of the action. #SL_OK, #SL_ERROR, or #SL_REINIT ("unload" the game) */ -SaveOrLoadResult SaveOrLoad(const char *filename, FileOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded) +SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded) { /* An instance of saving is already active, so don't go saving again */ - if (_sl.saveinprogress && fop == FOP_SAVE && dft == DFT_GAME_FILE && threaded) { + if (_sl.saveinprogress && fop == SLO_SAVE && dft == DFT_GAME_FILE && threaded) { /* if not an autosave, but a user action, show error message */ if (!_do_autosave) ShowErrorMessage(STR_ERROR_SAVE_STILL_IN_PROGRESS, INVALID_STRING_ID, WL_ERROR); return SL_OK; @@ -2790,7 +2790,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, FileOperation fop, DetailedFil try { /* Load a TTDLX or TTDPatch game */ - if (fop == FOP_LOAD && dft == DFT_OLD_GAME_FILE) { + if (fop == SLO_LOAD && dft == DFT_OLD_GAME_FILE) { InitializeGame(256, 256, true, true); // set a mapsize of 256x256 for TTDPatch games or it might get confused /* TTD/TTO savegames have no NewGRFs, TTDP savegame have them @@ -2813,33 +2813,33 @@ SaveOrLoadResult SaveOrLoad(const char *filename, FileOperation fop, DetailedFil assert(dft == DFT_GAME_FILE); switch (fop) { - case FOP_CHECK: + case SLO_CHECK: _sl.action = SLA_LOAD_CHECK; break; - case FOP_LOAD: + case SLO_LOAD: _sl.action = SLA_LOAD; break; - case FOP_SAVE: + case SLO_SAVE: _sl.action = SLA_SAVE; break; default: NOT_REACHED(); } - FILE *fh = (fop == FOP_SAVE) ? FioFOpenFile(filename, "wb", sb) : FioFOpenFile(filename, "rb", sb); + FILE *fh = (fop == SLO_SAVE) ? FioFOpenFile(filename, "wb", sb) : FioFOpenFile(filename, "rb", sb); /* Make it a little easier to load savegames from the console */ - if (fh == NULL && fop != FOP_SAVE) fh = FioFOpenFile(filename, "rb", SAVE_DIR); - if (fh == NULL && fop != FOP_SAVE) fh = FioFOpenFile(filename, "rb", BASE_DIR); - if (fh == NULL && fop != FOP_SAVE) fh = FioFOpenFile(filename, "rb", SCENARIO_DIR); + if (fh == NULL && fop != SLO_SAVE) fh = FioFOpenFile(filename, "rb", SAVE_DIR); + if (fh == NULL && fop != SLO_SAVE) fh = FioFOpenFile(filename, "rb", BASE_DIR); + if (fh == NULL && fop != SLO_SAVE) fh = FioFOpenFile(filename, "rb", SCENARIO_DIR); if (fh == NULL) { - SlError(fop == FOP_SAVE ? STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE : STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE); + SlError(fop == SLO_SAVE ? STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE : STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE); } - if (fop == FOP_SAVE) { // SAVE game + if (fop == SLO_SAVE) { // SAVE game DEBUG(desync, 1, "save: %08x; %02x; %s", _date, _date_fract, filename); if (_network_server || !_settings_client.gui.threaded_saves) threaded = false; @@ -2847,25 +2847,25 @@ SaveOrLoadResult SaveOrLoad(const char *filename, FileOperation fop, DetailedFil } /* LOAD game */ - assert(fop == FOP_LOAD || fop == FOP_CHECK); + assert(fop == SLO_LOAD || fop == SLO_CHECK); DEBUG(desync, 1, "load: %s", filename); - return DoLoad(new FileReader(fh), fop == FOP_CHECK); + return DoLoad(new FileReader(fh), fop == SLO_CHECK); } catch (...) { /* This code may be executed both for old and new save games. */ ClearSaveLoadState(); /* Skip the "colour" character */ - if (fop != FOP_CHECK) DEBUG(sl, 0, "%s", GetSaveLoadErrorString() + 3); + if (fop != SLO_CHECK) DEBUG(sl, 0, "%s", GetSaveLoadErrorString() + 3); /* A saver/loader exception!! reinitialize all variables to prevent crash! */ - return (fop == FOP_LOAD) ? SL_REINIT : SL_ERROR; + return (fop == SLO_LOAD) ? SL_REINIT : SL_ERROR; } } /** Do a save when exiting the game (_settings_client.gui.autosave_on_exit) */ void DoExitSave() { - SaveOrLoad("exit.sav", FOP_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR); + SaveOrLoad("exit.sav", SLO_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR); } /** @@ -2909,7 +2909,7 @@ void GenerateDefaultSaveName(char *buf, const char *last) */ void FileToSaveLoad::SetMode(FiosType ft) { - this->SetMode(FOP_LOAD, GetAbstractFileType(ft), GetDetailedFileType(ft)); + this->SetMode(SLO_LOAD, GetAbstractFileType(ft), GetDetailedFileType(ft)); } /** @@ -2918,10 +2918,10 @@ void FileToSaveLoad::SetMode(FiosType ft) * @param aft Abstract file type. * @param dft Detailed file type. */ -void FileToSaveLoad::SetMode(FileOperation fop, AbstractFileType aft, DetailedFileType dft) +void FileToSaveLoad::SetMode(SaveLoadOperation fop, AbstractFileType aft, DetailedFileType dft) { if (aft == FT_INVALID || aft == FT_NONE) { - this->file_op = FOP_INVALID; + this->file_op = SLO_INVALID; this->detail_ftype = DFT_INVALID; this->abstract_ftype = FT_INVALID; return; diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index b25e91e2c..1513355c8 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -24,14 +24,14 @@ enum SaveOrLoadResult { /** Deals with the type of the savegame, independent of extension */ struct FileToSaveLoad { - FileOperation file_op; ///< File operation to perform. + SaveLoadOperation file_op; ///< File operation to perform. DetailedFileType detail_ftype; ///< Concrete file type (PNG, BMP, old save, etc). AbstractFileType abstract_ftype; ///< Abstract type of file (scenario, heightmap, etc). char name[MAX_PATH]; ///< Name of the file. char title[255]; ///< Internal name of the game. void SetMode(FiosType ft); - void SetMode(FileOperation fop, AbstractFileType aft, DetailedFileType dft); + void SetMode(SaveLoadOperation fop, AbstractFileType aft, DetailedFileType dft); void SetName(const char *name); void SetTitle(const char *title); }; @@ -51,7 +51,7 @@ extern FileToSaveLoad _file_to_saveload; void GenerateDefaultSaveName(char *buf, const char *last); void SetSaveLoadError(uint16 str); const char *GetSaveLoadErrorString(); -SaveOrLoadResult SaveOrLoad(const char *filename, FileOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded = true); +SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded = true); void WaitTillSaved(); void ProcessAsyncSaveFinish(); void DoExitSave(); diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 55b49fd74..2649552f4 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -427,17 +427,17 @@ static CallBackFunction MenuClickSaveLoad(int index = 0) { if (_game_mode == GM_EDITOR) { switch (index) { - case SLEME_SAVE_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, FOP_SAVE); break; - case SLEME_LOAD_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, FOP_LOAD); break; - case SLEME_SAVE_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,FOP_SAVE); break; - case SLEME_LOAD_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,FOP_LOAD); break; + case SLEME_SAVE_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_SAVE); break; + case SLEME_LOAD_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_LOAD); break; + case SLEME_SAVE_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_SAVE); break; + case SLEME_LOAD_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_LOAD); break; case SLEME_EXIT_TOINTRO: AskExitToGameMenu(); break; case SLEME_EXIT_GAME: HandleExitGameRequest(); break; } } else { switch (index) { - case SLNME_SAVE_GAME: ShowSaveLoadDialog(FT_SAVEGAME, FOP_SAVE); break; - case SLNME_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, FOP_LOAD); break; + case SLNME_SAVE_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_SAVE); break; + case SLNME_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break; case SLNME_EXIT_TOINTRO: AskExitToGameMenu(); break; case SLNME_EXIT_GAME: HandleExitGameRequest(); break; } @@ -1712,7 +1712,7 @@ struct MainToolbarWindow : Window { case MTHK_FASTFORWARD: ToolbarFastForwardClick(this); break; case MTHK_SETTINGS: ShowGameOptions(); break; case MTHK_SAVEGAME: MenuClickSaveLoad(); break; - case MTHK_LOADGAME: ShowSaveLoadDialog(FT_SAVEGAME, FOP_LOAD); break; + case MTHK_LOADGAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break; case MTHK_SMALLMAP: ShowSmallMap(); break; case MTHK_TOWNDIRECTORY: ShowTownDirectory(); break; case MTHK_SUBSIDIES: ShowSubsidiesList(); break; diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp index 95d40cd00..e038df975 100644 --- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -142,7 +142,7 @@ static void *_dedicated_video_mem; /* Whether a fork has been done. */ bool _dedicated_forks; -extern bool SafeLoad(const char *filename, FileOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf = NULL); +extern bool SafeLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, GameMode newgm, Subdirectory subdir, struct LoadFilter *lf = NULL); static FVideoDriver_Dedicated iFVideoDriver_Dedicated; |