File diff r28277:fe0d307deeb1 → r28278:1fc682037ca2
src/linkgraph/refresh.cpp
Show inline comments
 
@@ -212,50 +212,49 @@ void LinkRefresher::RefreshStats(const O
 

	
 
			if (this->vehicle->GetDisplayMaxSpeed() == 0) continue;
 

	
 
			/* If not allowed to merge link graphs, make sure the stations are
 
			 * already in the same link graph. */
 
			if (!this->allow_merge && st->goods[c].link_graph != st_to->goods[c].link_graph) {
 
				continue;
 
			}
 

	
 
			/* A link is at least partly restricted if a vehicle can't load at its source. */
 
			EdgeUpdateMode restricted_mode = (cur->GetLoadType() & OLFB_NO_LOAD) == 0 ?
 
						EUM_UNRESTRICTED : EUM_RESTRICTED;
 
			/* This estimates the travel time of the link as the time needed
 
			 * to travel between the stations at half the max speed of the consist.
 
			 * The result is in tiles/tick (= 2048 km-ish/h). */
 
			uint32_t time_estimate = DistanceManhattan(st->xy, st_to->xy) * 4096U / this->vehicle->GetDisplayMaxSpeed();
 

	
 
			/* If the vehicle is currently full loading, increase the capacities at the station
 
			 * where it is loading by an estimate of what it would have transported if it wasn't
 
			 * loading. Don't do that if the vehicle has been waiting for longer than the entire
 
			 * order list is supposed to take, though. If that is the case the total duration is
 
			 * probably far off and we'd greatly overestimate the capacity by increasing.*/
 
			if (this->is_full_loading && this->vehicle->orders != nullptr &&
 
					st->index == vehicle->last_station_visited &&
 
					this->vehicle->orders->GetTotalDuration() >
 
					(TimerGameTick::Ticks)this->vehicle->current_order_time) {
 
					this->vehicle->orders->GetTotalDuration() > this->vehicle->current_order_time) {
 
				uint effective_capacity = cargo_quantity * this->vehicle->load_unload_ticks;
 
				if (effective_capacity > (uint)this->vehicle->orders->GetTotalDuration()) {
 
					IncreaseStats(st, c, next_station, effective_capacity /
 
							this->vehicle->orders->GetTotalDuration(), 0, 0,
 
							EUM_INCREASE | restricted_mode);
 
				} else if (RandomRange(this->vehicle->orders->GetTotalDuration()) < effective_capacity) {
 
					IncreaseStats(st, c, next_station, 1, 0, 0, EUM_INCREASE | restricted_mode);
 
				} else {
 
					IncreaseStats(st, c, next_station, cargo_quantity, 0, time_estimate, EUM_REFRESH | restricted_mode);
 
				}
 
			} else {
 
				IncreaseStats(st, c, next_station, cargo_quantity, 0, time_estimate, EUM_REFRESH | restricted_mode);
 
			}
 
		}
 
	}
 
}
 

	
 
/**
 
 * Iterate over orders starting at \a cur and \a next and refresh links
 
 * associated with them. \a cur and \a next can be equal. If they're not they
 
 * must be "neighbours" in their order list, which means \a next must be directly
 
 * reachable from \a cur without passing any further OT_GOTO_STATION or
 
 * OT_IMPLICIT orders in between.
 
 * @param cur Current order being evaluated.