diff options
author | Darkvater <darkvater@openttd.org> | 2006-01-25 18:11:06 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2006-01-25 18:11:06 +0000 |
commit | 78fa9c73933a10e052ed9358a73dc1015f49d14b (patch) | |
tree | 2e2b02a496376c4fb097825d484c2c4a6f6f5492 /console_cmds.c | |
parent | 42a9353ae2283939609d068725d89ac93f199bcd (diff) | |
download | openttd-78fa9c73933a10e052ed9358a73dc1015f49d14b.tar.xz |
(svn r3427) - Feature: Allow seeing and setting the maximum amount of companies and spectators for a server. This can be changed/viewed during runtime as well in the console.
Diffstat (limited to 'console_cmds.c')
-rw-r--r-- | console_cmds.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/console_cmds.c b/console_cmds.c index 484925edc..971a4bfcd 100644 --- a/console_cmds.c +++ b/console_cmds.c @@ -381,7 +381,7 @@ DEF_CONSOLE_CMD(ConBan) } if (index == NETWORK_SERVER_INDEX) { - IConsolePrint(_icolour_def, "Silly boy, you can not ban yourself!"); + IConsoleError("Silly boy, you can not ban yourself!"); return true; } @@ -511,7 +511,7 @@ DEF_CONSOLE_CMD(ConStatus) const NetworkClientState *cs; if (argc == 0) { - IConsoleHelp("List the status of all clients connected to the server: Usage 'status'"); + IConsoleHelp("List the status of all clients connected to the server. Usage 'status'"); return true; } @@ -527,6 +527,35 @@ DEF_CONSOLE_CMD(ConStatus) return true; } +DEF_CONSOLE_CMD(ConServerInfo) +{ + const NetworkGameInfo *gi; + + if (argc == 0) { + IConsoleHelp("List current and maximum client/player limits. Usage 'server_info'"); + IConsoleHelp("You can change these values by setting the variables 'max_clients', 'max_companies' and 'max_spectators'"); + return true; + } + + gi = &_network_game_info; + IConsolePrintF(_icolour_def, "Current/maximum clients: %2d/%2d", gi->clients_on, gi->clients_max); + IConsolePrintF(_icolour_def, "Current/maximum companies: %2d/%2d", gi->companies_on, gi->companies_max); + IConsolePrintF(_icolour_def, "Current/maximum spectators: %2d/%2d", gi->spectators_on, gi->spectators_max); + + return true; +} + +DEF_CONSOLE_HOOK(ConHookValidateMaxClientsCount) { + /* XXX - hardcoded, string limiation -- TrueLight + * XXX - also see network.c:NetworkStartup ~1343 */ + if (_network_game_info.clients_max > 10) { + _network_game_info.clients_max = 10; + IConsoleError("Maximum clients is 10, truncating."); + } + + return true; +} + DEF_CONSOLE_CMD(ConKick) { NetworkClientInfo *ci; @@ -549,7 +578,7 @@ DEF_CONSOLE_CMD(ConKick) } if (index == NETWORK_SERVER_INDEX) { - IConsolePrint(_icolour_def, "Silly boy, you can not kick yourself!"); + IConsoleError("Silly boy, you can not kick yourself!"); return true; } @@ -1405,6 +1434,13 @@ void IConsoleStdLibRegister(void) IConsoleVarHookAdd("server_advertise", ICONSOLE_HOOK_ACCESS, ConHookServerOnly); IConsoleVarHookAdd("server_advertise", ICONSOLE_HOOK_POST_ACTION, ConHookServerAdvertise); + IConsoleVarRegister("max_clients", &_network_game_info.clients_max, ICONSOLE_VAR_BYTE, "Control the maximum amount of connected players during runtime. Default value: 10"); + IConsoleVarHookAdd("max_clients", ICONSOLE_HOOK_ACCESS, ConHookServerOnly); + IConsoleVarHookAdd("max_clients", ICONSOLE_HOOK_POST_ACTION, ConHookValidateMaxClientsCount); + IConsoleVarRegister("max_companies", &_network_game_info.companies_max, ICONSOLE_VAR_BYTE, "Control the maximum amount of active companies during runtime. Default value: 8"); + IConsoleVarHookAdd("max_companies", ICONSOLE_HOOK_ACCESS, ConHookServerOnly); + IConsoleVarRegister("max_spectators", &_network_game_info.spectators_max, ICONSOLE_VAR_BYTE, "Control the maximum amount of active spectators during runtime. Default value: 9"); + IConsoleVarHookAdd("max_spectators", ICONSOLE_HOOK_ACCESS, ConHookServerOnly); IConsoleVarRegister("pause_on_join", &_network_pause_on_join, ICONSOLE_VAR_BOOLEAN, "Set if the server should pause gameplay while a client is joining. This might help slow users"); IConsoleVarHookAdd("pause_on_join", ICONSOLE_HOOK_ACCESS, ConHookServerOnly); |