diff options
author | celestar <celestar@openttd.org> | 2006-05-11 14:08:03 +0000 |
---|---|---|
committer | celestar <celestar@openttd.org> | 2006-05-11 14:08:03 +0000 |
commit | 30bc705e48a44471474563bfc4ef00d44ae174f4 (patch) | |
tree | 0d1181189ed3020cd6aa6084b49764f434727d5a | |
parent | c764bc35f566161bb25d08b586f3e0df3e389a1f (diff) | |
download | openttd-30bc705e48a44471474563bfc4ef00d44ae174f4.tar.xz |
(svn r4828) -Feature (FS#150) Add a new console command "players" that lists current players along with basic stats (ledow)
-rw-r--r-- | console_cmds.c | 27 | ||||
-rw-r--r-- | network.h | 1 |
2 files changed, 28 insertions, 0 deletions
diff --git a/console_cmds.c b/console_cmds.c index 494cc945d..3194ed1b5 100644 --- a/console_cmds.c +++ b/console_cmds.c @@ -18,6 +18,12 @@ #include "hal.h" /* for file list */ #include "vehicle.h" #include "station.h" +#include "strings.h" + +#ifdef ENABLE_NETWORK + #include "table/strings.h" + #include "network.h" +#endif /*ENABLE_NETWORK*/ // ** scriptfile handling ** // static FILE *_script_file; @@ -1126,6 +1132,25 @@ DEF_CONSOLE_CMD(ConSay) return true; } +DEF_CONSOLE_CMD(ConPlayers) +{ + Player *p; + + if (argc == 0) { + IConsoleHelp("List the in-game details of all clients connected to the server. Usage 'players'"); + return true; + } + NetworkPopulateCompanyInfo(); + + FOR_ALL_PLAYERS(p) { + if (!p->is_active) + continue; + IConsolePrintF(8, "#:%d Company Name: '%s' Year Founded: '%d' Money: '%d' Loan: '%d' Value: '%d'", p->index, _network_player_info[p->index].company_name, p->inaugurated_year + MAX_YEAR_BEGIN_REAL, p->player_money, p->current_loan, CalculateCompanyValue(p)); + } + + return true; +} + DEF_CONSOLE_CMD(ConSayPlayer) { if (argc == 0) { @@ -1384,6 +1409,8 @@ void IConsoleStdLibRegister(void) /*** Networking commands ***/ IConsoleCmdRegister("say", ConSay); IConsoleCmdHookAdd("say", ICONSOLE_HOOK_ACCESS, ConHookNeedNetwork); + IConsoleCmdRegister("players", ConPlayers); + IConsoleCmdHookAdd("players", ICONSOLE_HOOK_ACCESS, ConHookServerOnly); IConsoleCmdRegister("say_player", ConSayPlayer); IConsoleCmdHookAdd("say_player", ICONSOLE_HOOK_ACCESS, ConHookNeedNetwork); IConsoleCmdRegister("say_client", ConSayClient); @@ -229,5 +229,6 @@ void NetworkUpdateClientInfo(uint16 client_index); void NetworkAddServer(const char *b); void NetworkRebuildHostList(void); bool NetworkChangeCompanyPassword(byte argc, char *argv[]); +void NetworkPopulateCompanyInfo(void); #endif /* NETWORK_H */ |