mirror of https://github.com/OpenTTD/OpenTTD
(svn r27653) -Fix(r27647): Rename FileOperation enum and values to SaveLoadOperation to avoid nameclash with windows compiler toolkit.
parent
4001f6215e
commit
0adfb1ac6f
|
@ -67,7 +67,7 @@ public:
|
||||||
void ValidateFileList(bool force_reload = false)
|
void ValidateFileList(bool force_reload = false)
|
||||||
{
|
{
|
||||||
if (force_reload || !this->file_list_valid) {
|
if (force_reload || !this->file_list_valid) {
|
||||||
this->BuildFileList(FT_SAVEGAME, FOP_LOAD);
|
this->BuildFileList(FT_SAVEGAME, SLO_LOAD);
|
||||||
this->file_list_valid = true;
|
this->file_list_valid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,7 +318,7 @@ DEF_CONSOLE_CMD(ConSave)
|
||||||
char *filename = str_fmt("%s.sav", argv[1]);
|
char *filename = str_fmt("%s.sav", argv[1]);
|
||||||
IConsolePrint(CC_DEFAULT, "Saving map...");
|
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");
|
IConsolePrint(CC_ERROR, "Saving map failed");
|
||||||
} else {
|
} else {
|
||||||
IConsolePrintF(CC_DEFAULT, "Map successfully saved to %s", filename);
|
IConsolePrintF(CC_DEFAULT, "Map successfully saved to %s", filename);
|
||||||
|
|
|
@ -388,7 +388,7 @@ bool CrashLog::WriteSavegame(char *filename, const char *filename_last) const
|
||||||
seprintf(filename, filename_last, "%scrash.sav", _personal_dir);
|
seprintf(filename, filename_last, "%scrash.sav", _personal_dir);
|
||||||
|
|
||||||
/* Don't do a threaded saveload. */
|
/* 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 (...) {
|
} catch (...) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,12 @@ enum DetailedFileType {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Operation performed on the file. */
|
/** Operation performed on the file. */
|
||||||
enum FileOperation {
|
enum SaveLoadOperation {
|
||||||
FOP_CHECK, ///< Load file for checking and/or preview.
|
SLO_CHECK, ///< Load file for checking and/or preview.
|
||||||
FOP_LOAD, ///< File is being loaded.
|
SLO_LOAD, ///< File is being loaded.
|
||||||
FOP_SAVE, ///< File is being saved.
|
SLO_SAVE, ///< File is being saved.
|
||||||
|
|
||||||
FOP_INVALID, ///< Unknown file operation.
|
SLO_INVALID, ///< Unknown file operation.
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
32
src/fios.cpp
32
src/fios.cpp
|
@ -71,13 +71,13 @@ FileList::~FileList()
|
||||||
/**
|
/**
|
||||||
* Construct a file list with the given kind of files, for the stated purpose.
|
* Construct a file list with the given kind of files, for the stated purpose.
|
||||||
* @param abstract_filetype Kind of files to collect.
|
* @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();
|
this->Clear();
|
||||||
|
|
||||||
assert(fop == FOP_LOAD || FOP_SAVE);
|
assert(fop == SLO_LOAD || SLO_SAVE);
|
||||||
switch (abstract_filetype) {
|
switch (abstract_filetype) {
|
||||||
case FT_NONE:
|
case FT_NONE:
|
||||||
break;
|
break;
|
||||||
|
@ -274,13 +274,13 @@ bool FiosDelete(const char *name)
|
||||||
return unlink(filename) == 0;
|
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.
|
* Scanner to scan for a particular type of FIOS file.
|
||||||
*/
|
*/
|
||||||
class FiosFileScanner : public FileScanner {
|
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
|
fios_getlist_callback_proc *callback_proc; ///< Callback to check whether the file may be added
|
||||||
FileList &file_list; ///< Destination of the found files.
|
FileList &file_list; ///< Destination of the found files.
|
||||||
public:
|
public:
|
||||||
|
@ -290,7 +290,7 @@ public:
|
||||||
* @param callback_proc The function that is called where you need to do the filtering.
|
* @param callback_proc The function that is called where you need to do the filtering.
|
||||||
* @param file_list Destination of the found files.
|
* @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)
|
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 subdir The directory from where to start (global) searching.
|
||||||
* @param file_list Destination of the found files.
|
* @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 stat sb;
|
||||||
struct dirent *dirent;
|
struct dirent *dirent;
|
||||||
|
@ -456,7 +456,7 @@ static void GetFileTitle(const char *file, char *title, const char *last, Subdir
|
||||||
* @see FiosGetFileList
|
* @see FiosGetFileList
|
||||||
* @see FiosGetSavegameList
|
* @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
|
/* Show savegame files
|
||||||
* .SAV OpenTTD saved game
|
* .SAV OpenTTD saved game
|
||||||
|
@ -472,7 +472,7 @@ FiosType FiosGetSavegameListCallback(FileOperation fop, const char *file, const
|
||||||
return FIOS_TYPE_FILE;
|
return FIOS_TYPE_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fop == FOP_LOAD) {
|
if (fop == SLO_LOAD) {
|
||||||
if (strcasecmp(ext, ".ss1") == 0 || strcasecmp(ext, ".sv1") == 0 ||
|
if (strcasecmp(ext, ".ss1") == 0 || strcasecmp(ext, ".sv1") == 0 ||
|
||||||
strcasecmp(ext, ".sv2") == 0) {
|
strcasecmp(ext, ".sv2") == 0) {
|
||||||
if (title != NULL) GetOldSaveGameName(file, title, last);
|
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.
|
* @param file_list Destination of the found files.
|
||||||
* @see FiosGetFileList
|
* @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 = NULL;
|
||||||
static char *fios_save_path_last = NULL;
|
static char *fios_save_path_last = NULL;
|
||||||
|
@ -517,7 +517,7 @@ void FiosGetSavegameList(FileOperation fop, FileList &file_list)
|
||||||
* @see FiosGetFileList
|
* @see FiosGetFileList
|
||||||
* @see FiosGetScenarioList
|
* @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
|
/* Show scenario files
|
||||||
* .SCN OpenTTD style scenario file
|
* .SCN OpenTTD style scenario file
|
||||||
|
@ -528,7 +528,7 @@ static FiosType FiosGetScenarioListCallback(FileOperation fop, const char *file,
|
||||||
return FIOS_TYPE_SCENARIO;
|
return FIOS_TYPE_SCENARIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fop == FOP_LOAD) {
|
if (fop == SLO_LOAD) {
|
||||||
if (strcasecmp(ext, ".sv0") == 0 || strcasecmp(ext, ".ss0") == 0 ) {
|
if (strcasecmp(ext, ".sv0") == 0 || strcasecmp(ext, ".ss0") == 0 ) {
|
||||||
GetOldSaveGameName(file, title, last);
|
GetOldSaveGameName(file, title, last);
|
||||||
return FIOS_TYPE_OLD_SCENARIO;
|
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.
|
* @param file_list Destination of the found files.
|
||||||
* @see FiosGetFileList
|
* @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 = NULL;
|
||||||
static char *fios_scn_path_last = NULL;
|
static char *fios_scn_path_last = NULL;
|
||||||
|
@ -562,11 +562,11 @@ void FiosGetScenarioList(FileOperation fop, FileList &file_list)
|
||||||
char base_path[MAX_PATH];
|
char base_path[MAX_PATH];
|
||||||
FioGetDirectory(base_path, lastof(base_path), SCENARIO_DIR);
|
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);
|
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
|
/* Show heightmap files
|
||||||
* .PNG PNG Based 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 fop Purpose of collecting the list.
|
||||||
* @param file_list Destination of the found files.
|
* @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 = NULL;
|
||||||
static char *fios_hmap_path_last = NULL;
|
static char *fios_hmap_path_last = NULL;
|
||||||
|
|
12
src/fios.h
12
src/fios.h
|
@ -190,7 +190,7 @@ public:
|
||||||
this->files.Compact();
|
this->files.Compact();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildFileList(AbstractFileType abstract_filetype, FileOperation fop);
|
void BuildFileList(AbstractFileType abstract_filetype, SaveLoadOperation fop);
|
||||||
const FiosItem *FindItem(const char *file);
|
const FiosItem *FindItem(const char *file);
|
||||||
|
|
||||||
SmallVector<FiosItem, 32> files; ///< The list of files.
|
SmallVector<FiosItem, 32> files; ///< The list of files.
|
||||||
|
@ -207,11 +207,11 @@ DECLARE_ENUM_AS_BIT_SET(SortingBits)
|
||||||
/* Variables to display file lists */
|
/* Variables to display file lists */
|
||||||
extern SortingBits _savegame_sort_order;
|
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 FiosGetSavegameList(SaveLoadOperation fop, FileList &file_list);
|
||||||
void FiosGetScenarioList(FileOperation fop, FileList &file_list);
|
void FiosGetScenarioList(SaveLoadOperation fop, FileList &file_list);
|
||||||
void FiosGetHeightmapList(FileOperation fop, FileList &file_list);
|
void FiosGetHeightmapList(SaveLoadOperation fop, FileList &file_list);
|
||||||
|
|
||||||
const char *FiosBrowseTo(const FiosItem *item);
|
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 FiosMakeHeightmapName(char *buf, const char *name, const char *last);
|
||||||
void FiosMakeSavegameName(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);
|
int CDECL CompareFiosItems(const FiosItem *a, const FiosItem *b);
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,7 @@ struct SaveLoadWindow : public Window {
|
||||||
private:
|
private:
|
||||||
QueryString filename_editbox; ///< Filename editbox.
|
QueryString filename_editbox; ///< Filename editbox.
|
||||||
AbstractFileType abstract_filetype; /// Type of file to select.
|
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.
|
FileList fios_items; ///< Save game list.
|
||||||
FiosItem o_dir;
|
FiosItem o_dir;
|
||||||
const FiosItem *selected; ///< Selected game in #fios_items, or \c NULL.
|
const FiosItem *selected; ///< Selected game in #fios_items, or \c NULL.
|
||||||
|
@ -243,13 +243,13 @@ public:
|
||||||
this->filename_editbox.text.UpdateSize();
|
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)
|
: 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. */
|
/* For saving, construct an initial file name. */
|
||||||
if (this->fop == FOP_SAVE) {
|
if (this->fop == SLO_SAVE) {
|
||||||
switch (this->abstract_filetype) {
|
switch (this->abstract_filetype) {
|
||||||
case FT_SAVEGAME:
|
case FT_SAVEGAME:
|
||||||
this->GenerateFileName();
|
this->GenerateFileName();
|
||||||
|
@ -268,7 +268,7 @@ public:
|
||||||
this->filename_editbox.ok_button = WID_SL_SAVE_GAME;
|
this->filename_editbox.ok_button = WID_SL_SAVE_GAME;
|
||||||
|
|
||||||
this->CreateNestedTree(true);
|
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);
|
this->GetWidget<NWidgetStacked>(WID_SL_CONTENT_DOWNLOAD_SEL)->SetDisplayedPlane(SZSP_HORIZONTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,15 +276,15 @@ public:
|
||||||
StringID caption_string;
|
StringID caption_string;
|
||||||
switch (this->abstract_filetype) {
|
switch (this->abstract_filetype) {
|
||||||
case FT_SAVEGAME:
|
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;
|
break;
|
||||||
|
|
||||||
case FT_SCENARIO:
|
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;
|
break;
|
||||||
|
|
||||||
case FT_HEIGHTMAP:
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -328,7 +328,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Focus the edit box by default in the save windows */
|
/* 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()
|
virtual ~SaveLoadWindow()
|
||||||
|
@ -438,7 +438,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hide the NewGRF stuff when saving. We also hide the button. */
|
/* 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;
|
y += WD_PAR_VSEP_NORMAL;
|
||||||
if (y > y_max) break;
|
if (y > y_max) break;
|
||||||
|
|
||||||
|
@ -583,19 +583,19 @@ public:
|
||||||
|
|
||||||
if (GetDetailedFileType(file->type) == DFT_GAME_FILE) {
|
if (GetDetailedFileType(file->type) == DFT_GAME_FILE) {
|
||||||
/* Other detailed file types cannot be checked before. */
|
/* 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);
|
this->InvalidateData(1);
|
||||||
}
|
}
|
||||||
if (this->fop == FOP_SAVE) {
|
if (this->fop == SLO_SAVE) {
|
||||||
/* Copy clicked name to editbox */
|
/* Copy clicked name to editbox */
|
||||||
this->filename_editbox.text.Assign(file->title);
|
this->filename_editbox.text.Assign(file->title);
|
||||||
this->SetWidgetDirty(WID_SL_SAVE_OSK_TITLE);
|
this->SetWidgetDirty(WID_SL_SAVE_OSK_TITLE);
|
||||||
}
|
}
|
||||||
} else if (!_load_check_data.HasErrors()) {
|
} else if (!_load_check_data.HasErrors()) {
|
||||||
this->selected = file;
|
this->selected = file;
|
||||||
if (this->fop == FOP_LOAD) {
|
if (this->fop == SLO_LOAD) {
|
||||||
if (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO) {
|
if (this->abstract_filetype == FT_SAVEGAME || this->abstract_filetype == FT_SCENARIO) {
|
||||||
this->OnClick(pt, WID_SL_LOAD_BUTTON, 1);
|
this->OnClick(pt, WID_SL_LOAD_BUTTON, 1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -621,7 +621,7 @@ public:
|
||||||
ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
|
ShowErrorMessage(STR_NETWORK_ERROR_NOTAVAILABLE, INVALID_STRING_ID, WL_ERROR);
|
||||||
} else {
|
} else {
|
||||||
#if defined(ENABLE_NETWORK)
|
#if defined(ENABLE_NETWORK)
|
||||||
assert(this->fop == FOP_LOAD);
|
assert(this->fop == SLO_LOAD);
|
||||||
switch (this->abstract_filetype) {
|
switch (this->abstract_filetype) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
case FT_SCENARIO: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_SCENARIO); break;
|
case FT_SCENARIO: ShowNetworkContentListWindow(NULL, CONTENT_TYPE_SCENARIO); break;
|
||||||
|
@ -654,7 +654,7 @@ public:
|
||||||
virtual void OnTimeout()
|
virtual void OnTimeout()
|
||||||
{
|
{
|
||||||
/* Widgets WID_SL_DELETE_SELECTION and WID_SL_SAVE_GAME only exist when saving to a file. */
|
/* 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 (this->IsWidgetLowered(WID_SL_DELETE_SELECTION)) { // Delete button clicked
|
||||||
if (!FiosDelete(this->filename_editbox.text.buf)) {
|
if (!FiosDelete(this->filename_editbox.text.buf)) {
|
||||||
|
@ -707,7 +707,7 @@ public:
|
||||||
/* Selection changes */
|
/* Selection changes */
|
||||||
if (!gui_scope) break;
|
if (!gui_scope) break;
|
||||||
|
|
||||||
if (this->fop != FOP_LOAD) break;
|
if (this->fop != SLO_LOAD) break;
|
||||||
|
|
||||||
switch (this->abstract_filetype) {
|
switch (this->abstract_filetype) {
|
||||||
case FT_HEIGHTMAP:
|
case FT_HEIGHTMAP:
|
||||||
|
@ -764,12 +764,12 @@ static WindowDesc _save_dialog_desc(
|
||||||
* @param abstract_filetype Kind of file to handle.
|
* @param abstract_filetype Kind of file to handle.
|
||||||
* @param fop File operation to perform (load or save).
|
* @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);
|
DeleteWindowById(WC_SAVELOAD, 0);
|
||||||
|
|
||||||
WindowDesc *sld;
|
WindowDesc *sld;
|
||||||
if (fop == FOP_SAVE) {
|
if (fop == SLO_SAVE) {
|
||||||
sld = &_save_dialog_desc;
|
sld = &_save_dialog_desc;
|
||||||
} else {
|
} else {
|
||||||
/* Dialogue for loading a file. */
|
/* Dialogue for loading a file. */
|
||||||
|
|
|
@ -204,7 +204,7 @@ static void _GenerateWorld(void *)
|
||||||
if (_debug_desync_level > 0) {
|
if (_debug_desync_level > 0) {
|
||||||
char name[MAX_PATH];
|
char name[MAX_PATH];
|
||||||
seprintf(name, lastof(name), "dmp_cmds_%08x_%08x.sav", _settings_game.game_creation.generation_seed, _date);
|
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 (...) {
|
} catch (...) {
|
||||||
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP, true);
|
BasePersistentStorageArray::SwitchMode(PSM_LEAVE_GAMELOOP, true);
|
||||||
|
|
|
@ -111,9 +111,9 @@ struct SelectGameWindow : public Window {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_SGI_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, FOP_LOAD); break;
|
case WID_SGI_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
|
||||||
case WID_SGI_PLAY_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, FOP_LOAD); break;
|
case WID_SGI_PLAY_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_LOAD); break;
|
||||||
case WID_SGI_PLAY_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,FOP_LOAD); break;
|
case WID_SGI_PLAY_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_LOAD); break;
|
||||||
case WID_SGI_EDIT_SCENARIO: StartScenarioEditor(); break;
|
case WID_SGI_EDIT_SCENARIO: StartScenarioEditor(); break;
|
||||||
|
|
||||||
case WID_SGI_PLAY_NETWORK:
|
case WID_SGI_PLAY_NETWORK:
|
||||||
|
|
|
@ -520,7 +520,7 @@ bool ClientNetworkGameSocketHandler::IsConnected()
|
||||||
* DEF_CLIENT_RECEIVE_COMMAND has parameter: Packet *p
|
* 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)
|
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 */
|
/* The map is done downloading, load it */
|
||||||
ClearErrorMessages();
|
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! */
|
/* Long savegame loads shouldn't affect the lag calculation! */
|
||||||
this->last_packet = _realtime_tick;
|
this->last_packet = _realtime_tick;
|
||||||
|
|
|
@ -1187,17 +1187,17 @@ struct NetworkStartServerWindow : public Window {
|
||||||
|
|
||||||
case WID_NSS_LOAD_GAME:
|
case WID_NSS_LOAD_GAME:
|
||||||
_is_network_server = true;
|
_is_network_server = true;
|
||||||
ShowSaveLoadDialog(FT_SAVEGAME, FOP_LOAD);
|
ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_NSS_PLAY_SCENARIO:
|
case WID_NSS_PLAY_SCENARIO:
|
||||||
_is_network_server = true;
|
_is_network_server = true;
|
||||||
ShowSaveLoadDialog(FT_SCENARIO, FOP_LOAD);
|
ShowSaveLoadDialog(FT_SCENARIO, SLO_LOAD);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_NSS_PLAY_HEIGHTMAP:
|
case WID_NSS_PLAY_HEIGHTMAP:
|
||||||
_is_network_server = true;
|
_is_network_server = true;
|
||||||
ShowSaveLoadDialog(FT_HEIGHTMAP,FOP_LOAD);
|
ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_LOAD);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,7 +328,7 @@ static void LoadIntroGame(bool load_newgrfs = true)
|
||||||
SetupColoursAndInitialWindow();
|
SetupColoursAndInitialWindow();
|
||||||
|
|
||||||
/* Load the default opening screen savegame */
|
/* 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.
|
GenerateWorld(GWM_EMPTY, 64, 64); // if failed loading, make empty world.
|
||||||
WaitTillGeneratedWorld();
|
WaitTillGeneratedWorld();
|
||||||
SetLocalCompany(COMPANY_SPECTATOR);
|
SetLocalCompany(COMPANY_SPECTATOR);
|
||||||
|
@ -621,12 +621,12 @@ int openttd_main(int argc, char *argv[])
|
||||||
_file_to_saveload.SetName(mgo.opt);
|
_file_to_saveload.SetName(mgo.opt);
|
||||||
bool is_scenario = _switch_mode == SM_EDITOR || _switch_mode == SM_LOAD_SCENARIO;
|
bool is_scenario = _switch_mode == SM_EDITOR || _switch_mode == SM_LOAD_SCENARIO;
|
||||||
_switch_mode = is_scenario ? SM_LOAD_SCENARIO : SM_LOAD_GAME;
|
_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 */
|
/* 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, '.');
|
const char *t = strrchr(_file_to_saveload.name, '.');
|
||||||
if (t != NULL) {
|
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);
|
if (ft != FIOS_TYPE_INVALID) _file_to_saveload.SetMode(ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,10 +648,10 @@ int openttd_main(int argc, char *argv[])
|
||||||
|
|
||||||
char title[80];
|
char title[80];
|
||||||
title[0] = '\0';
|
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();
|
_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()) {
|
if (res != SL_OK || _load_check_data.HasErrors()) {
|
||||||
fprintf(stderr, "Failed to open savegame\n");
|
fprintf(stderr, "Failed to open savegame\n");
|
||||||
if (_load_check_data.HasErrors()) {
|
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 subdir default directory to look for filename, set to 0 if not needed
|
||||||
* @param lf Load filter to use, if NULL: use filename + subdir.
|
* @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));
|
assert(dft == DFT_GAME_FILE || (lf == NULL && dft == DFT_OLD_GAME_FILE));
|
||||||
GameMode ogm = _game_mode;
|
GameMode ogm = _game_mode;
|
||||||
|
|
||||||
|
@ -1158,7 +1158,7 @@ void SwitchToMode(SwitchMode new_mode)
|
||||||
|
|
||||||
case SM_SAVE_GAME: // Save game.
|
case SM_SAVE_GAME: // Save game.
|
||||||
/* Make network saved games on pause compatible to singleplayer */
|
/* 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());
|
SetDParamStr(0, GetSaveLoadErrorString());
|
||||||
ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, WL_ERROR);
|
ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, WL_ERROR);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1369,7 +1369,7 @@ void StateGameLoop()
|
||||||
/* Save the desync savegame if needed. */
|
/* Save the desync savegame if needed. */
|
||||||
char name[MAX_PATH];
|
char name[MAX_PATH];
|
||||||
seprintf(name, lastof(name), "dmp_cmds_%08x_%08x.sav", _settings_game.game_creation.generation_seed, _date);
|
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();
|
CheckCaches();
|
||||||
|
@ -1426,7 +1426,7 @@ static void DoAutosave()
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(sl, 2, "Autosaving to '%s'", buf);
|
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);
|
ShowErrorMessage(STR_ERROR_AUTOSAVE_FAILED, INVALID_STRING_ID, WL_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2778,10 +2778,10 @@ SaveOrLoadResult LoadWithFilter(LoadFilter *reader)
|
||||||
* @param threaded True when threaded saving is allowed
|
* @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)
|
* @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 */
|
/* 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 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);
|
if (!_do_autosave) ShowErrorMessage(STR_ERROR_SAVE_STILL_IN_PROGRESS, INVALID_STRING_ID, WL_ERROR);
|
||||||
return SL_OK;
|
return SL_OK;
|
||||||
|
@ -2790,7 +2790,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, FileOperation fop, DetailedFil
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* Load a TTDLX or TTDPatch game */
|
/* 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
|
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
|
/* 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);
|
assert(dft == DFT_GAME_FILE);
|
||||||
switch (fop) {
|
switch (fop) {
|
||||||
case FOP_CHECK:
|
case SLO_CHECK:
|
||||||
_sl.action = SLA_LOAD_CHECK;
|
_sl.action = SLA_LOAD_CHECK;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FOP_LOAD:
|
case SLO_LOAD:
|
||||||
_sl.action = SLA_LOAD;
|
_sl.action = SLA_LOAD;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FOP_SAVE:
|
case SLO_SAVE:
|
||||||
_sl.action = SLA_SAVE;
|
_sl.action = SLA_SAVE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: NOT_REACHED();
|
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 */
|
/* 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 != SLO_SAVE) fh = FioFOpenFile(filename, "rb", SAVE_DIR);
|
||||||
if (fh == NULL && fop != FOP_SAVE) fh = FioFOpenFile(filename, "rb", BASE_DIR);
|
if (fh == NULL && fop != SLO_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", SCENARIO_DIR);
|
||||||
|
|
||||||
if (fh == NULL) {
|
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);
|
DEBUG(desync, 1, "save: %08x; %02x; %s", _date, _date_fract, filename);
|
||||||
if (_network_server || !_settings_client.gui.threaded_saves) threaded = false;
|
if (_network_server || !_settings_client.gui.threaded_saves) threaded = false;
|
||||||
|
|
||||||
|
@ -2847,25 +2847,25 @@ SaveOrLoadResult SaveOrLoad(const char *filename, FileOperation fop, DetailedFil
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LOAD game */
|
/* LOAD game */
|
||||||
assert(fop == FOP_LOAD || fop == FOP_CHECK);
|
assert(fop == SLO_LOAD || fop == SLO_CHECK);
|
||||||
DEBUG(desync, 1, "load: %s", filename);
|
DEBUG(desync, 1, "load: %s", filename);
|
||||||
return DoLoad(new FileReader(fh), fop == FOP_CHECK);
|
return DoLoad(new FileReader(fh), fop == SLO_CHECK);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
/* This code may be executed both for old and new save games. */
|
/* This code may be executed both for old and new save games. */
|
||||||
ClearSaveLoadState();
|
ClearSaveLoadState();
|
||||||
|
|
||||||
/* Skip the "colour" character */
|
/* 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! */
|
/* 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) */
|
/** Do a save when exiting the game (_settings_client.gui.autosave_on_exit) */
|
||||||
void DoExitSave()
|
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)
|
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 aft Abstract file type.
|
||||||
* @param dft Detailed 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) {
|
if (aft == FT_INVALID || aft == FT_NONE) {
|
||||||
this->file_op = FOP_INVALID;
|
this->file_op = SLO_INVALID;
|
||||||
this->detail_ftype = DFT_INVALID;
|
this->detail_ftype = DFT_INVALID;
|
||||||
this->abstract_ftype = FT_INVALID;
|
this->abstract_ftype = FT_INVALID;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -24,14 +24,14 @@ enum SaveOrLoadResult {
|
||||||
|
|
||||||
/** Deals with the type of the savegame, independent of extension */
|
/** Deals with the type of the savegame, independent of extension */
|
||||||
struct FileToSaveLoad {
|
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).
|
DetailedFileType detail_ftype; ///< Concrete file type (PNG, BMP, old save, etc).
|
||||||
AbstractFileType abstract_ftype; ///< Abstract type of file (scenario, heightmap, etc).
|
AbstractFileType abstract_ftype; ///< Abstract type of file (scenario, heightmap, etc).
|
||||||
char name[MAX_PATH]; ///< Name of the file.
|
char name[MAX_PATH]; ///< Name of the file.
|
||||||
char title[255]; ///< Internal name of the game.
|
char title[255]; ///< Internal name of the game.
|
||||||
|
|
||||||
void SetMode(FiosType ft);
|
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 SetName(const char *name);
|
||||||
void SetTitle(const char *title);
|
void SetTitle(const char *title);
|
||||||
};
|
};
|
||||||
|
@ -51,7 +51,7 @@ extern FileToSaveLoad _file_to_saveload;
|
||||||
void GenerateDefaultSaveName(char *buf, const char *last);
|
void GenerateDefaultSaveName(char *buf, const char *last);
|
||||||
void SetSaveLoadError(uint16 str);
|
void SetSaveLoadError(uint16 str);
|
||||||
const char *GetSaveLoadErrorString();
|
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 WaitTillSaved();
|
||||||
void ProcessAsyncSaveFinish();
|
void ProcessAsyncSaveFinish();
|
||||||
void DoExitSave();
|
void DoExitSave();
|
||||||
|
|
|
@ -427,17 +427,17 @@ static CallBackFunction MenuClickSaveLoad(int index = 0)
|
||||||
{
|
{
|
||||||
if (_game_mode == GM_EDITOR) {
|
if (_game_mode == GM_EDITOR) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case SLEME_SAVE_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, FOP_SAVE); break;
|
case SLEME_SAVE_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_SAVE); break;
|
||||||
case SLEME_LOAD_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, FOP_LOAD); break;
|
case SLEME_LOAD_SCENARIO: ShowSaveLoadDialog(FT_SCENARIO, SLO_LOAD); break;
|
||||||
case SLEME_SAVE_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,FOP_SAVE); break;
|
case SLEME_SAVE_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_SAVE); break;
|
||||||
case SLEME_LOAD_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,FOP_LOAD); break;
|
case SLEME_LOAD_HEIGHTMAP: ShowSaveLoadDialog(FT_HEIGHTMAP,SLO_LOAD); break;
|
||||||
case SLEME_EXIT_TOINTRO: AskExitToGameMenu(); break;
|
case SLEME_EXIT_TOINTRO: AskExitToGameMenu(); break;
|
||||||
case SLEME_EXIT_GAME: HandleExitGameRequest(); break;
|
case SLEME_EXIT_GAME: HandleExitGameRequest(); break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case SLNME_SAVE_GAME: ShowSaveLoadDialog(FT_SAVEGAME, FOP_SAVE); break;
|
case SLNME_SAVE_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_SAVE); break;
|
||||||
case SLNME_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, FOP_LOAD); break;
|
case SLNME_LOAD_GAME: ShowSaveLoadDialog(FT_SAVEGAME, SLO_LOAD); break;
|
||||||
case SLNME_EXIT_TOINTRO: AskExitToGameMenu(); break;
|
case SLNME_EXIT_TOINTRO: AskExitToGameMenu(); break;
|
||||||
case SLNME_EXIT_GAME: HandleExitGameRequest(); break;
|
case SLNME_EXIT_GAME: HandleExitGameRequest(); break;
|
||||||
}
|
}
|
||||||
|
@ -1712,7 +1712,7 @@ struct MainToolbarWindow : Window {
|
||||||
case MTHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
|
case MTHK_FASTFORWARD: ToolbarFastForwardClick(this); break;
|
||||||
case MTHK_SETTINGS: ShowGameOptions(); break;
|
case MTHK_SETTINGS: ShowGameOptions(); break;
|
||||||
case MTHK_SAVEGAME: MenuClickSaveLoad(); 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_SMALLMAP: ShowSmallMap(); break;
|
||||||
case MTHK_TOWNDIRECTORY: ShowTownDirectory(); break;
|
case MTHK_TOWNDIRECTORY: ShowTownDirectory(); break;
|
||||||
case MTHK_SUBSIDIES: ShowSubsidiesList(); break;
|
case MTHK_SUBSIDIES: ShowSubsidiesList(); break;
|
||||||
|
|
|
@ -142,7 +142,7 @@ static void *_dedicated_video_mem;
|
||||||
/* Whether a fork has been done. */
|
/* Whether a fork has been done. */
|
||||||
bool _dedicated_forks;
|
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;
|
static FVideoDriver_Dedicated iFVideoDriver_Dedicated;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue