File diff r27147:5d938ed2c7b5 → r27148:4e041ae27b9d
src/vehicle.cpp
Show inline comments
 
@@ -165,13 +165,13 @@ bool Vehicle::NeedsAutorenewing(const Co
 
void VehicleServiceInDepot(Vehicle *v)
 
{
 
	assert(v != nullptr);
 
	SetWindowDirty(WC_VEHICLE_DETAILS, v->index); // ensure that last service date and reliability are updated
 

	
 
	do {
 
		v->date_of_last_service = _date;
 
		v->date_of_last_service = TimerGameCalendar::date;
 
		v->breakdowns_since_last_service = 0;
 
		v->reliability = v->GetEngine()->reliability;
 
		/* Prevent vehicles from breaking down directly after exiting the depot. */
 
		v->breakdown_chance /= 4;
 
		if (_settings_game.difficulty.vehicle_breakdowns == 1) v->breakdown_chance = 0; // on reduced breakdown
 
		v = v->Next();
 
@@ -191,13 +191,13 @@ bool Vehicle::NeedsServicing() const
 
	if (this->vehstatus & (VS_STOPPED | VS_CRASHED)) return false;
 

	
 
	/* Are we ready for the next service cycle? */
 
	const Company *c = Company::Get(this->owner);
 
	if (this->ServiceIntervalIsPercent() ?
 
			(this->reliability >= this->GetEngine()->reliability * (100 - this->GetServiceInterval()) / 100) :
 
			(this->date_of_last_service + this->GetServiceInterval() >= _date)) {
 
			(this->date_of_last_service + this->GetServiceInterval() >= TimerGameCalendar::date)) {
 
		return false;
 
	}
 

	
 
	/* If we're servicing anyway, because we have not disabled servicing when
 
	 * there are no breakdowns or we are playing with breakdowns, bail out. */
 
	if (!_settings_game.order.no_servicing_if_no_breakdowns ||
 
@@ -917,21 +917,21 @@ void VehicleEnteredDepotThisTick(Vehicle
 
	 * stopped the vehicle, so autoreplace can start it again */
 
	v->vehstatus |= VS_STOPPED;
 
}
 

	
 
/**
 
 * Increases the day counter for all vehicles and calls 1-day and 32-day handlers.
 
 * Each tick, it processes vehicles with "index % DAY_TICKS == _date_fract",
 
 * Each tick, it processes vehicles with "index % DAY_TICKS == TimerGameCalendar::date_fract",
 
 * so each day, all vehicles are processes in DAY_TICKS steps.
 
 */
 
static void RunVehicleDayProc()
 
{
 
	if (_game_mode != GM_NORMAL) return;
 

	
 
	/* Run the day_proc for every DAY_TICKS vehicle starting at _date_fract. */
 
	for (size_t i = _date_fract; i < Vehicle::GetPoolSize(); i += DAY_TICKS) {
 
	/* Run the day_proc for every DAY_TICKS vehicle starting at TimerGameCalendar::date_fract. */
 
	for (size_t i = TimerGameCalendar::date_fract; i < Vehicle::GetPoolSize(); i += DAY_TICKS) {
 
		Vehicle *v = Vehicle::Get(i);
 
		if (v == nullptr) continue;
 

	
 
		/* Call the 32-day callback if needed */
 
		if ((v->day_counter & 0x1F) == 0 && v->HasEngineType()) {
 
			uint16 callback = GetVehicleCallback(CBID_VEHICLE_32DAY_CALLBACK, 0, 0, v->engine_type, v);