mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-12 17:19:09 +00:00
Codechange: Iterate group vehicle lists for IntervalTimer<TimerGameCalendar> _vehicles_yearly
This commit is contained in:
@@ -2802,29 +2802,35 @@ void Vehicle::RemoveFromShared()
|
|||||||
|
|
||||||
static IntervalTimer<TimerGameCalendar> _vehicles_yearly({TimerGameCalendar::YEAR, TimerGameCalendar::Priority::VEHICLE}, [](auto)
|
static IntervalTimer<TimerGameCalendar> _vehicles_yearly({TimerGameCalendar::YEAR, TimerGameCalendar::Priority::VEHICLE}, [](auto)
|
||||||
{
|
{
|
||||||
for (Vehicle *v : Vehicle::Iterate()) {
|
for (const Company *c : Company::Iterate()) {
|
||||||
if (v->IsPrimaryVehicle()) {
|
for (VehicleType type = VEH_BEGIN; type < VEH_COMPANY_END; type++) {
|
||||||
/* show warning if vehicle is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) */
|
const VehicleList &vehicle_list = c->group_all[type].vehicle_list;
|
||||||
Money profit = v->GetDisplayProfitThisYear();
|
for (const Vehicle *vehicle : vehicle_list) {
|
||||||
if (v->age >= 730 && profit < 0) {
|
Vehicle *v = Vehicle::Get(vehicle->index);
|
||||||
if (_settings_client.gui.vehicle_income_warn && v->owner == _local_company) {
|
|
||||||
SetDParam(0, v->index);
|
|
||||||
SetDParam(1, profit);
|
|
||||||
AddVehicleAdviceNewsItem(STR_NEWS_VEHICLE_IS_UNPROFITABLE, v->index);
|
|
||||||
}
|
|
||||||
AI::NewEvent(v->owner, new ScriptEventVehicleUnprofitable(v->index));
|
|
||||||
}
|
|
||||||
|
|
||||||
v->profit_last_year = v->profit_this_year;
|
/* show warning if vehicle is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) */
|
||||||
v->profit_this_year = 0;
|
Money profit = v->GetDisplayProfitThisYear();
|
||||||
SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
|
if (v->age >= 730 && profit < 0) {
|
||||||
|
if (_settings_client.gui.vehicle_income_warn && v->owner == _local_company) {
|
||||||
|
SetDParam(0, v->index);
|
||||||
|
SetDParam(1, profit);
|
||||||
|
AddVehicleAdviceNewsItem(STR_NEWS_VEHICLE_IS_UNPROFITABLE, v->index);
|
||||||
|
}
|
||||||
|
AI::NewEvent(v->owner, new ScriptEventVehicleUnprofitable(v->index));
|
||||||
|
}
|
||||||
|
|
||||||
|
v->profit_last_year = v->profit_this_year;
|
||||||
|
v->profit_this_year = 0;
|
||||||
|
SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
|
||||||
|
|
||||||
|
}
|
||||||
|
GroupStatistics::UpdateProfits();
|
||||||
|
SetWindowClassesDirty(WC_TRAINS_LIST);
|
||||||
|
SetWindowClassesDirty(WC_SHIPS_LIST);
|
||||||
|
SetWindowClassesDirty(WC_ROADVEH_LIST);
|
||||||
|
SetWindowClassesDirty(WC_AIRCRAFT_LIST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GroupStatistics::UpdateProfits();
|
|
||||||
SetWindowClassesDirty(WC_TRAINS_LIST);
|
|
||||||
SetWindowClassesDirty(WC_SHIPS_LIST);
|
|
||||||
SetWindowClassesDirty(WC_ROADVEH_LIST);
|
|
||||||
SetWindowClassesDirty(WC_AIRCRAFT_LIST);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user