Mercurial > hg > openttd
changeset 8152:32bfb56e7e0e draft
(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.
author | belugas <belugas@openttd.org> |
---|---|
date | Fri, 28 Dec 2007 04:20:56 +0000 |
parents | bee108a98a39 |
children | a18e5c54295e |
files | src/fios.h src/misc_gui.cpp src/network/network_gui.cpp src/openttd.cpp |
diffstat | 4 files changed, 33 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/fios.h +++ b/src/fios.h @@ -32,6 +32,14 @@ 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 @@ /* 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 };
--- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -1671,6 +1671,17 @@ 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 @@ _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;
--- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -810,6 +810,7 @@ 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));
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -1289,7 +1289,15 @@ 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;