1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-24 06:59:10 +00:00

Codechange: Using alias and std::array for company expense storage. (#11273)

This simplifies passing yearly expenses to functions and use of std algorithms.
This commit is contained in:
2023-09-09 14:15:53 +01:00
committed by GitHub
parent 00f13282a9
commit afc1ea8135
5 changed files with 12 additions and 9 deletions

View File

@@ -383,10 +383,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyEconomy()
{
for (const Company *company : Company::Iterate()) {
/* Get the income. */
Money income = 0;
for (uint i = 0; i < lengthof(company->yearly_expenses[0]); i++) {
income -= company->yearly_expenses[0][i];
}
Money income = -std::reduce(std::begin(company->yearly_expenses[0]), std::end(company->yearly_expenses[0]));
Packet *p = new Packet(ADMIN_PACKET_SERVER_COMPANY_ECONOMY);