MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SendCompanyStats

Method SendCompanyStats

src/network/network_admin.cpp:409–433  ·  view source on GitHub ↗

Send statistics about the companies. */

Source from the content-addressed store, hash-verified

407
408/** Send statistics about the companies. */
409NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyStats()
410{
411 /* Fetch the latest version of the stats. */
412 NetworkCompanyStatsArray company_stats = NetworkGetCompanyStats();
413
414 /* Go through all the companies. */
415 for (const Company *company : Company::Iterate()) {
416 auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_STATS);
417
418 /* Send the information. */
419 p->Send_uint8(company->index);
420
421 for (uint i = 0; i < NETWORK_VEH_END; i++) {
422 p->Send_uint16(company_stats[company->index].num_vehicle[i]);
423 }
424
425 for (uint i = 0; i < NETWORK_VEH_END; i++) {
426 p->Send_uint16(company_stats[company->index].num_station[i]);
427 }
428
429 this->SendPacket(std::move(p));
430 }
431
432 return NETWORK_RECV_STATUS_OKAY;
433}
434
435/**
436 * Send a chat message.

Callers 2

Receive_ADMIN_POLLMethod · 0.95
NetworkAdminUpdateFunction · 0.80

Calls 4

NetworkGetCompanyStatsFunction · 0.85
Send_uint16Method · 0.80
Send_uint8Method · 0.45
SendPacketMethod · 0.45

Tested by

no test coverage detected