mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r11714) -Fix[FS#1569]: Do not allow player inauguration date on scenarios to be bigger than current year.
This will not (yet) be true if you are loading a scenario with the "-g" command line option.
This commit is contained in:
parent
5087a6cdd7
commit
e9a039b845
|
@ -32,6 +32,14 @@ enum SaveLoadDialogMode{
|
|||
SLD_NEW_GAME,
|
||||
};
|
||||
|
||||
/* The different types of files been handled by the system */
|
||||
enum FileType {
|
||||
FT_NONE, ///< nothing to do
|
||||
FT_SAVEGAME, ///< old or new savegame
|
||||
FT_SCENARIO, ///< old or new scenario
|
||||
FT_HEIGHTMAP, ///< heightmap file
|
||||
};
|
||||
|
||||
enum {
|
||||
FIOS_TYPE_DRIVE = 0,
|
||||
FIOS_TYPE_PARENT = 1,
|
||||
|
@ -57,6 +65,7 @@ struct FiosItem {
|
|||
/* Deals with the type of the savegame, independent of extension */
|
||||
struct SmallFiosItem {
|
||||
int mode; ///< savegame/scenario type (old, new)
|
||||
FileType filetype; ///< what type of file are we dealing with
|
||||
char name[MAX_PATH]; ///< name
|
||||
char title[255]; ///< internal name of the game
|
||||
};
|
||||
|
|
|
@ -1671,6 +1671,17 @@ static const WindowDesc _save_dialog_desc = {
|
|||
SaveLoadDlgWndProc,
|
||||
};
|
||||
|
||||
/** These values are used to convert the file/operations mode into a corresponding file type.
|
||||
* So each entry, as expressed by the related comment, is based on the enum */
|
||||
static const FileType _file_modetotype[] = {
|
||||
FT_SAVEGAME, ///< used for SLD_LOAD_GAME
|
||||
FT_SCENARIO, ///< used for SLD_LOAD_SCENARIO
|
||||
FT_SAVEGAME, ///< used for SLD_SAVE_GAME
|
||||
FT_SCENARIO, ///< used for SLD_SAVE_SCENARIO
|
||||
FT_HEIGHTMAP, ///< used for SLD_LOAD_HEIGHTMAP
|
||||
FT_SAVEGAME, ///< SLD_NEW_GAME
|
||||
};
|
||||
|
||||
void ShowSaveLoadDialog(SaveLoadDialogMode mode)
|
||||
{
|
||||
static const StringID saveload_captions[] = {
|
||||
|
@ -1692,6 +1703,9 @@ void ShowSaveLoadDialog(SaveLoadDialogMode mode)
|
|||
_saveload_mode = mode;
|
||||
SetBit(_no_scroll, SCROLL_SAVE);
|
||||
|
||||
/* Use an array to define what will be the current file type being handled
|
||||
* by current file mode */
|
||||
_file_to_saveload.filetype = _file_modetotype[mode];
|
||||
switch (mode) {
|
||||
case SLD_SAVE_GAME: GenerateFileName(); break;
|
||||
case SLD_SAVE_SCENARIO: strcpy(_edit_str_buf, "UNNAMED"); break;
|
||||
|
|
|
@ -810,6 +810,7 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
|
|||
char *name = FiosBrowseTo(nd->map);
|
||||
if (name != NULL) {
|
||||
SetFiosType(nd->map->type);
|
||||
_file_to_saveload.filetype = FT_SCENARIO;
|
||||
ttd_strlcpy(_file_to_saveload.name, name, sizeof(_file_to_saveload.name));
|
||||
ttd_strlcpy(_file_to_saveload.title, nd->map->title, sizeof(_file_to_saveload.title));
|
||||
|
||||
|
|
|
@ -1289,7 +1289,15 @@ static bool InitializeWindowsAndCaches()
|
|||
Player *players[MAX_PLAYERS];
|
||||
const Vehicle *v;
|
||||
|
||||
for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) players[i] = GetPlayer(i);
|
||||
for (PlayerID i = PLAYER_FIRST; i < MAX_PLAYERS; i++) {
|
||||
players[i] = GetPlayer(i);
|
||||
|
||||
/* For each player, verify (while loading a scenario) that the inauguration date is the current year and set it
|
||||
* accordingly if it is not the case. No need to set it on players that are not been used already,
|
||||
* thus the MIN_YEAR (which is really nothing more than Zero, initialized value) test */
|
||||
if (_file_to_saveload.filetype == FT_SCENARIO && players[i]->inaugurated_year != MIN_YEAR)
|
||||
players[i]->inaugurated_year = _cur_year;
|
||||
}
|
||||
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (!IsEngineCountable(v)) continue;
|
||||
|
|
Loading…
Reference in New Issue