MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / OnNewEconomyDay

Method OnNewEconomyDay

src/aircraft_cmd.cpp:454–477  ·  view source on GitHub ↗

Economy day handler */

Source from the content-addressed store, hash-verified

452
453/** Economy day handler */
454void Aircraft::OnNewEconomyDay()
455{
456 if (!this->IsNormalAircraft()) return;
457 EconomyAgeVehicle(this);
458
459 if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
460
461 CheckOrders(this);
462
463 CheckVehicleBreakdown(this);
464 CheckIfAircraftNeedsService(this);
465
466 if (this->running_ticks == 0) return;
467
468 CommandCost cost(EXPENSES_AIRCRAFT_RUN, this->GetRunningCost() * this->running_ticks / (CalendarTime::DAYS_IN_YEAR * Ticks::DAY_TICKS));
469
470 this->profit_this_year -= cost.GetCost();
471 this->running_ticks = 0;
472
473 SubtractMoneyFromCompanyFract(this->owner, cost);
474
475 SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
476 SetWindowClassesDirty(WC_AIRCRAFT_LIST);
477}
478
479static void HelicopterTickHandler(Aircraft *v)
480{

Callers

nothing calls this directly

Calls 11

IsNormalAircraftMethod · 0.95
GetRunningCostMethod · 0.95
EconomyAgeVehicleFunction · 0.85
DecreaseVehicleValueFunction · 0.85
CheckOrdersFunction · 0.85
CheckVehicleBreakdownFunction · 0.85
SetWindowDirtyFunction · 0.85
SetWindowClassesDirtyFunction · 0.85
GetCostMethod · 0.45

Tested by

no test coverage detected