Send economic information of all companies. */
| 376 | |
| 377 | /** Send economic information of all companies. */ |
| 378 | NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyEconomy() |
| 379 | { |
| 380 | for (const Company *company : Company::Iterate()) { |
| 381 | /* Get the income. */ |
| 382 | Money income = -std::reduce(std::begin(company->yearly_expenses[0]), std::end(company->yearly_expenses[0])); |
| 383 | |
| 384 | auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_COMPANY_ECONOMY); |
| 385 | |
| 386 | p->Send_uint8(company->index); |
| 387 | |
| 388 | /* Current information. */ |
| 389 | p->Send_uint64(company->money); |
| 390 | p->Send_uint64(company->current_loan); |
| 391 | p->Send_uint64(income); |
| 392 | p->Send_uint16(static_cast<uint16_t>(std::min<uint64_t>(UINT16_MAX, company->cur_economy.delivered_cargo.GetSum<OverflowSafeInt64>()))); |
| 393 | |
| 394 | /* Send stats for the last 2 quarters. */ |
| 395 | for (uint i = 0; i < 2; i++) { |
| 396 | p->Send_uint64(company->old_economy[i].company_value); |
| 397 | p->Send_uint16(company->old_economy[i].performance_history); |
| 398 | p->Send_uint16(static_cast<uint16_t>(std::min<uint64_t>(UINT16_MAX, company->old_economy[i].delivered_cargo.GetSum<OverflowSafeInt64>()))); |
| 399 | } |
| 400 | |
| 401 | this->SendPacket(std::move(p)); |
| 402 | } |
| 403 | |
| 404 | |
| 405 | return NETWORK_RECV_STATUS_OKAY; |
| 406 | } |
| 407 | |
| 408 | /** Send statistics about the companies. */ |
| 409 | NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyStats() |
no test coverage detected