* Perform all the server specific administration of a new company. * @param c The newly created company; can't be nullptr. * @param ci The client information of the client that made the company; can be nullptr. */
| 2148 | * @param ci The client information of the client that made the company; can be nullptr. |
| 2149 | */ |
| 2150 | void NetworkServerNewCompany(const Company *c, NetworkClientInfo *ci) |
| 2151 | { |
| 2152 | assert(c != nullptr); |
| 2153 | |
| 2154 | if (!_network_server) return; |
| 2155 | |
| 2156 | if (ci != nullptr) { |
| 2157 | /* ci is nullptr when replaying, or for AIs. In neither case there is a client. */ |
| 2158 | ci->client_playas = c->index; |
| 2159 | NetworkUpdateClientInfo(ci->client_id); |
| 2160 | |
| 2161 | /* |
| 2162 | * This function is called from a command, but is only called for the server. |
| 2163 | * The client information is managed out-of-band from the commands, so to not have a |
| 2164 | * different state/president/company name in the different clients, we need to |
| 2165 | * circumvent the normal ::Post logic and go directly to sending the command. |
| 2166 | */ |
| 2167 | Command<CMD_COMPANY_ALLOW_LIST_CTRL>::SendNet(STR_NULL, c->index, CALCA_ADD, ci->public_key); |
| 2168 | Command<CMD_RENAME_PRESIDENT>::SendNet(STR_NULL, c->index, ci->client_name); |
| 2169 | |
| 2170 | NetworkServerSendChat(NETWORK_ACTION_COMPANY_NEW, DESTTYPE_BROADCAST, 0, "", ci->client_id, c->index + 1); |
| 2171 | } |
| 2172 | } |
no test coverage detected