mirror of https://github.com/OpenTTD/OpenTTD
(svn r27651) -Codechange: Introduce methods for setting the name and title of _file_to_saveload.
parent
597380e099
commit
6f201ce4a8
|
@ -363,9 +363,8 @@ DEF_CONSOLE_CMD(ConLoad)
|
|||
if (GetAbstractFileType(item->type) == FT_SAVEGAME) {
|
||||
_switch_mode = SM_LOAD_GAME;
|
||||
_file_to_saveload.SetMode(item->type);
|
||||
|
||||
strecpy(_file_to_saveload.name, FiosBrowseTo(item), lastof(_file_to_saveload.name));
|
||||
strecpy(_file_to_saveload.title, item->title, lastof(_file_to_saveload.title));
|
||||
_file_to_saveload.SetName(FiosBrowseTo(item));
|
||||
_file_to_saveload.SetTitle(item->title);
|
||||
} else {
|
||||
IConsolePrintF(CC_ERROR, "%s: Not a savegame.", file);
|
||||
}
|
||||
|
|
|
@ -537,9 +537,8 @@ public:
|
|||
if (this->selected != NULL && !_load_check_data.HasErrors()) {
|
||||
const char *name = FiosBrowseTo(this->selected);
|
||||
_file_to_saveload.SetMode(this->selected->type);
|
||||
|
||||
strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
|
||||
strecpy(_file_to_saveload.title, this->selected->title, lastof(_file_to_saveload.title));
|
||||
_file_to_saveload.SetName(name);
|
||||
_file_to_saveload.SetTitle(this->selected->title);
|
||||
|
||||
if (this->abstract_filetype == FT_HEIGHTMAP) {
|
||||
delete this;
|
||||
|
@ -602,8 +601,8 @@ public:
|
|||
} else {
|
||||
assert(this->abstract_filetype == FT_HEIGHTMAP);
|
||||
_file_to_saveload.SetMode(file->type);
|
||||
strecpy(_file_to_saveload.name, name, lastof(_file_to_saveload.name));
|
||||
strecpy(_file_to_saveload.title, file->title, lastof(_file_to_saveload.title));
|
||||
_file_to_saveload.SetName(name);
|
||||
_file_to_saveload.SetTitle(file->title);
|
||||
|
||||
delete this;
|
||||
ShowHeightmapLoad();
|
||||
|
|
|
@ -618,7 +618,7 @@ int openttd_main(int argc, char *argv[])
|
|||
case 'e': _switch_mode = (_switch_mode == SM_LOAD_GAME || _switch_mode == SM_LOAD_SCENARIO ? SM_LOAD_SCENARIO : SM_EDITOR); break;
|
||||
case 'g':
|
||||
if (mgo.opt != NULL) {
|
||||
strecpy(_file_to_saveload.name, mgo.opt, lastof(_file_to_saveload.name));
|
||||
_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);
|
||||
|
|
|
@ -2932,6 +2932,24 @@ void FileToSaveLoad::SetMode(FileOperation fop, AbstractFileType aft, DetailedFi
|
|||
this->abstract_ftype = aft;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the file.
|
||||
* @param name Name of the file.
|
||||
*/
|
||||
void FileToSaveLoad::SetName(const char *name)
|
||||
{
|
||||
strecpy(this->name, name, lastof(this->name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title of the file.
|
||||
* @param title Title of the file.
|
||||
*/
|
||||
void FileToSaveLoad::SetTitle(const char *title)
|
||||
{
|
||||
strecpy(this->title, title, lastof(this->title));
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Function to get the type of the savegame by looking at the file header.
|
||||
|
|
|
@ -32,6 +32,8 @@ struct FileToSaveLoad {
|
|||
|
||||
void SetMode(FiosType ft);
|
||||
void SetMode(FileOperation fop, AbstractFileType aft, DetailedFileType dft);
|
||||
void SetName(const char *name);
|
||||
void SetTitle(const char *title);
|
||||
};
|
||||
|
||||
/** Types of save games. */
|
||||
|
|
Loading…
Reference in New Issue