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:
PeterN
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

@@ -750,8 +750,9 @@ static IntervalTimer<TimerGameCalendar> _companies_yearly({TimerGameCalendar::YE
{
/* Copy statistics */
for (Company *c : Company::Iterate()) {
memmove(&c->yearly_expenses[1], &c->yearly_expenses[0], sizeof(c->yearly_expenses) - sizeof(c->yearly_expenses[0]));
memset(&c->yearly_expenses[0], 0, sizeof(c->yearly_expenses[0]));
/* Move expenses to previous years. */
std::rotate(std::rbegin(c->yearly_expenses), std::rbegin(c->yearly_expenses) + 1, std::rend(c->yearly_expenses));
c->yearly_expenses[0] = {};
SetWindowDirty(WC_FINANCES, c->index);
}