Fix 3c047b1: AIGroup.GetProfitLastYear could get values different than those displayed in GUI (#10227)

* Change: Store "all time" and "since minimum age" last year profits on groups

* Fix: Update last year profit for groups when copying vehicle statistics on autoreplace

* Codechange: Refactor profit last year

* Change: Rename some group related items for clarity

* Change: Reorder the fields in GroupStatistics

That way less memory gets wasted.
This commit is contained in:
SamuXarick
2023-01-22 13:14:02 +00:00
committed by GitHub
parent 8b5fa2cc7b
commit b2a5ebcfc4
5 changed files with 55 additions and 34 deletions

View File

@@ -1379,7 +1379,7 @@ void AgeVehicle(Vehicle *v)
{
if (v->age < MAX_DAY) {
v->age++;
if (v->IsPrimaryVehicle() && v->age == VEHICLE_PROFIT_MIN_AGE + 1) GroupStatistics::VehicleReachedProfitAge(v);
if (v->IsPrimaryVehicle() && v->age == VEHICLE_PROFIT_MIN_AGE + 1) GroupStatistics::VehicleReachedMinAge(v);
}
if (!v->IsPrimaryVehicle() && (v->type != VEH_TRAIN || !Train::From(v)->IsEngine())) return;