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

Function VehicleServiceInDepot

src/vehicle.cpp:178–193  ·  view source on GitHub ↗

* Service a vehicle and all subsequent vehicles in the consist * * @param *v The vehicle or vehicle chain being serviced */

Source from the content-addressed store, hash-verified

176 * @param *v The vehicle or vehicle chain being serviced
177 */
178void VehicleServiceInDepot(Vehicle *v)
179{
180 assert(v != nullptr);
181 SetWindowDirty(WC_VEHICLE_DETAILS, v->index); // ensure that last service date and reliability are updated
182
183 do {
184 v->date_of_last_service = TimerGameEconomy::date;
185 v->date_of_last_service_newgrf = TimerGameCalendar::date;
186 v->breakdowns_since_last_service = 0;
187 v->reliability = v->GetEngine()->reliability;
188 /* Prevent vehicles from breaking down directly after exiting the depot. */
189 v->breakdown_chance /= 4;
190 if (_settings_game.difficulty.vehicle_breakdowns == 1) v->breakdown_chance = 0; // on reduced breakdown
191 v = v->Next();
192 } while (v != nullptr && v->HasEngineType());
193}
194
195/**
196 * Check if the vehicle needs to go to a depot in near future (if a opportunity presents itself) for service or replacement.

Callers 9

CheckIfShipNeedsServiceFunction · 0.85
CheckShipStayInDepotFunction · 0.85
CheckTrainStayInDepotFunction · 0.85
CheckIfTrainNeedsServiceFunction · 0.85
VehicleEnterDepotFunction · 0.85
RoadVehLeaveDepotFunction · 0.85
AircraftLeaveHangarFunction · 0.85

Calls 4

SetWindowDirtyFunction · 0.85
HasEngineTypeMethod · 0.80
GetEngineMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected