(svn r11829) -Feature: allow reloading openttd.cfg when starting a new game on a dedicated server. Patch by dihedral.

pull/155/head
rubidium 17 years ago
parent 90acd52f22
commit 0ca79e2fb8

@ -1652,6 +1652,8 @@ void IConsoleStdLibRegister()
IConsoleVarRegister("min_players", &_network_min_players, ICONSOLE_VAR_BYTE, "Automatically pause the game when the number of active players passes below the given amount");
IConsoleVarHookAdd("min_players", ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
IConsoleVarHookAdd("min_players", ICONSOLE_HOOK_POST_ACTION, ConHookCheckMinPlayers);
IConsoleVarRegister("reload_cfg", &_network_reload_cfg, ICONSOLE_VAR_BOOLEAN, "reload the entire config file between the end of this game, and starting the next new game - dedicated servers");
IConsoleVarHookAdd("reload_cfg", ICONSOLE_HOOK_ACCESS, ConHookServerOnly);
#endif /* ENABLE_NETWORK */

@ -38,6 +38,8 @@ extern const char _openttd_revision[];
#include "table/strings.h"
bool _network_reload_cfg;
/* Check whether NETWORK_NUM_LANDSCAPES is still in sync with NUM_LANDSCAPE */
assert_compile((int)NETWORK_NUM_LANDSCAPES == (int)NUM_LANDSCAPE);

@ -211,6 +211,7 @@ VARDEF bool _network_server; ///< network-server is active
VARDEF bool _network_available; ///< is network mode available?
VARDEF bool _network_dedicated; ///< are we a dedicated server?
VARDEF bool _network_advertise; ///< is the server advertising to the master server?
extern bool _network_reload_cfg; ///< will we reload the entire config for the next game?
#else /* ENABLE_NETWORK */
/* Network function stubs when networking is disabled */

@ -843,6 +843,13 @@ void SwitchMode(int new_mode)
if (_is_network_server) {
/* But not if we are going to the menu */
if (new_mode != SM_MENU) {
/* check if we should reload the config */
if (_network_reload_cfg) {
LoadFromConfig();
_patches = _patches_newgame;
_opt = _opt_newgame;
ResetGRFConfig(false);
}
NetworkServerStart();
} else {
/* This client no longer wants to be a network-server */

@ -1307,6 +1307,7 @@ static const SettingDescGlobVarList _network_settings[] = {
SDTG_VAR("restart_game_year", SLE_INT32, S,D0, _network_restart_game_year, 0, MIN_YEAR, MAX_YEAR, 1, STR_NULL, NULL),
SDTG_VAR("min_players", SLE_UINT8, S, 0, _network_min_players, 0, 0, 10, 0, STR_NULL, NULL),
SDTG_OMANY("server_lang", SLE_UINT8, S, 0, _network_game_info.server_lang, 0, 28, "ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN", STR_NULL, NULL),
SDTG_BOOL("reload_cfg", S, 0, _network_reload_cfg, false, STR_NULL, NULL),
SDTG_END()
};
#endif /* ENABLE_NETWORK */

Loading…
Cancel
Save