@@ -35,16 +35,13 @@
#include "ai/ai.hpp"
#include "ai/ai_config.hpp"
#include "newgrf.h"
#include "console_func.h"
#include "engine_base.h"
#include "game/game.hpp"
#ifdef ENABLE_NETWORK
#include "table/strings.h"
#endif /* ENABLE_NETWORK */
/* scriptfile handling */
static bool _script_running; ///< Script is running (used to abort execution when #ConReturn is encountered).
/* console command defines */
#define DEF_CONSOLE_CMD(function) static bool function(byte argc, char *argv[])
@@ -1528,12 +1525,51 @@ DEF_CONSOLE_CMD(ConListAliases)
}
return true;
DEF_CONSOLE_CMD(ConCompanies)
{
if (argc == 0) {
IConsoleHelp("List the details of all companies in the game. Usage 'companies'");
Company *c;
FOR_ALL_COMPANIES(c) {
/* Grab the company name */
char company_name[512];
SetDParam(0, c->index);
GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
const char *password_state = "";
if (c->is_ai) {
password_state = "AI";
else if (_network_server) {
password_state = StrEmpty(_network_company_states[c->index].password) ? "unprotected" : "protected";
#endif
char colour[512];
GetString(colour, STR_COLOUR_DARK_BLUE + _company_colours[c->index], lastof(colour));
IConsolePrintF(CC_INFO, "#:%d(%s) Company Name: '%s' Year Founded: %d Money: " OTTD_PRINTF64 " Loan: " OTTD_PRINTF64 " Value: " OTTD_PRINTF64 " (T:%d, R:%d, P:%d, S:%d) %s",
c->index + 1, colour, company_name,
c->inaugurated_year, (int64)c->money, (int64)c->current_loan, (int64)CalculateCompanyValue(c),
c->group_all[VEH_TRAIN].num_vehicle,
c->group_all[VEH_ROAD].num_vehicle,
c->group_all[VEH_AIRCRAFT].num_vehicle,
c->group_all[VEH_SHIP].num_vehicle,
password_state);
DEF_CONSOLE_CMD(ConSay)
IConsoleHelp("Chat to your fellow players in a multiplayer game. Usage: 'say \"<msg>\"'");
@@ -1549,44 +1585,12 @@ DEF_CONSOLE_CMD(ConSay)
NetworkServerSendChat(NETWORK_ACTION_CHAT, DESTTYPE_BROADCAST, 0, argv[1], CLIENT_ID_SERVER, from_admin);
IConsoleHelp("List the in-game details of all clients connected to the server. Usage 'companies'");
NetworkCompanyStats company_stats[MAX_COMPANIES];
NetworkPopulateCompanyStats(company_stats);
char company_name[NETWORK_COMPANY_NAME_LENGTH];
char buffer[512];
const NetworkCompanyStats *stats = &company_stats[c->index];
GetString(buffer, STR_COLOUR_DARK_BLUE + _company_colours[c->index], lastof(buffer));
IConsolePrintF(CC_INFO, "#:%d(%s) Company Name: '%s' Year Founded: %d Money: " OTTD_PRINTF64 " Loan: " OTTD_PRINTF64 " Value: " OTTD_PRINTF64 " (T:%d, R:%d, P:%d, S:%d) %sprotected",
c->index + 1, buffer, company_name, c->inaugurated_year, (int64)c->money, (int64)c->current_loan, (int64)CalculateCompanyValue(c),
/* trains */ stats->num_vehicle[0],
/* lorry + bus */ stats->num_vehicle[1] + stats->num_vehicle[2],
/* planes */ stats->num_vehicle[3],
/* ships */ stats->num_vehicle[4],
/* protected */ StrEmpty(_network_company_states[c->index].password) ? "un" : "");
DEF_CONSOLE_CMD(ConSayCompany)
IConsoleHelp("Chat to a certain company in a multiplayer game. Usage: 'say_company <company-no> \"<msg>\"'");
IConsoleHelp("CompanyNo is the company that plays as company <companyno>, 1 through max_companies");
@@ -1936,23 +1940,24 @@ void IConsoleStdLibRegister()
IConsoleCmdRegister("stop_ai", ConStopAI);
IConsoleCmdRegister("list_game", ConListGame);
IConsoleCmdRegister("list_game_libs", ConListGameLibs);
IConsoleCmdRegister("rescan_game", ConRescanGame);
IConsoleCmdRegister("companies", ConCompanies);
IConsoleAliasRegister("players", "companies");
/* networking functions */
/* Content downloading is only available with ZLIB */
#if defined(WITH_ZLIB)
IConsoleCmdRegister("content", ConContent);
#endif /* defined(WITH_ZLIB) */
/*** Networking commands ***/
IConsoleCmdRegister("say", ConSay, ConHookNeedNetwork);
IConsoleCmdRegister("companies", ConCompanies, ConHookServerOnly);
IConsoleCmdRegister("say_company", ConSayCompany, ConHookNeedNetwork);
IConsoleAliasRegister("say_player", "say_company %+");
IConsoleCmdRegister("say_client", ConSayClient, ConHookNeedNetwork);
IConsoleCmdRegister("connect", ConNetworkConnect, ConHookClientOnly);
IConsoleCmdRegister("clients", ConNetworkClients, ConHookNeedNetwork);
Status change: