(svn r26576) -Fix [FS#6003]: [Network] AIs would not reset certain network state information upon creation of their company

This commit is contained in:
rubidium
2014-05-11 12:52:21 +00:00
parent a363b2c317
commit 4a52300838
4 changed files with 34 additions and 46 deletions

View File

@@ -71,7 +71,7 @@ void NetworkServerYearlyLoop();
void NetworkServerSendConfigUpdate();
void NetworkServerShowStatusToConsole();
bool NetworkServerStart();
void NetworkServerUpdateCompanyPassworded(CompanyID company_id, bool passworded);
void NetworkServerNewCompany(const Company *company, NetworkClientInfo *ci);
bool NetworkServerChangeClientName(ClientID client_id, const char *new_name);

View File

@@ -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 */

View File

@@ -123,6 +123,7 @@ public:
void NetworkServer_Tick(bool send_frame);
void NetworkServerSetCompanyPassword(CompanyID company_id, const char *password, bool already_hashed = true);
void NetworkServerUpdateCompanyPassworded(CompanyID company_id, bool passworded);
/**
* Iterate over all the sockets from a given starting point.