diff options
author | rubidium <rubidium@openttd.org> | 2014-05-11 12:52:21 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2014-05-11 12:52:21 +0000 |
commit | 4a523008385fe24dd2bc1683bb41c169285e6d3b (patch) | |
tree | d673bb01f3f80a4566979ddd91a68a6d76b1e310 /src/network/network_server.cpp | |
parent | a363b2c317c681888ca0f09c94f3c811f04b9921 (diff) | |
download | openttd-4a523008385fe24dd2bc1683bb41c169285e6d3b.tar.xz |
(svn r26576) -Fix [FS#6003]: [Network] AIs would not reset certain network state information upon creation of their company
Diffstat (limited to 'src/network/network_server.cpp')
-rw-r--r-- | src/network/network_server.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 84337f5f7..9ac1a03aa 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -2173,4 +2173,31 @@ void NetworkPrintClients() } } +/** + * Perform all the server specific administration of a new company. + * @param c The newly created company; can't be NULL. + * @param ci The client information of the client that made the company; can be NULL. + */ +void NetworkServerNewCompany(const Company *c, NetworkClientInfo *ci) +{ + assert(c != NULL); + + if (!_network_server) return; + + _network_company_states[c->index].months_empty = 0; + _network_company_states[c->index].password[0] = '\0'; + NetworkServerUpdateCompanyPassworded(c->index, false); + + if (ci != NULL) { + /* ci is NULL when replaying, or for AIs. In neither case there is a client. */ + ci->client_playas = c->index; + NetworkUpdateClientInfo(ci->client_id); + NetworkSendCommand(0, 0, 0, CMD_RENAME_PRESIDENT, NULL, ci->client_name, c->index); + NetworkServerSendChat(NETWORK_ACTION_COMPANY_NEW, DESTTYPE_BROADCAST, 0, "", ci->client_id, c->index + 1); + } + + /* Announce new company on network. */ + NetworkAdminCompanyInfo(c, true); +} + #endif /* ENABLE_NETWORK */ |