File diff r26193:4bc7915a2156 → r26194:f7347205838e
src/roadveh_cmd.cpp
Show inline comments
 
@@ -291,12 +291,13 @@ CommandCost CmdBuildRoadVehicle(DoComman
 
		v->last_loading_station = INVALID_STATION;
 
		v->engine_type = e->index;
 
		v->gcache.first_engine = INVALID_ENGINE; // needs to be set before first callback
 

	
 
		v->reliability = e->reliability;
 
		v->reliability_spd_dec = e->reliability_spd_dec;
 
		v->breakdown_chance = 128;
 
		v->max_age = e->GetLifeLengthInDays();
 

	
 
		v->SetServiceInterval(Company::Get(v->owner)->settings.vehicle.servint_roadveh);
 

	
 
		v->date_of_last_service = _date;
 
		v->build_year = _cur_year;
 
@@ -372,13 +373,12 @@ CommandCost CmdTurnRoadVeh(DoCommandFlag
 

	
 
	CommandCost ret = CheckOwnership(v->owner);
 
	if (ret.Failed()) return ret;
 

	
 
	if ((v->vehstatus & VS_STOPPED) ||
 
			(v->vehstatus & VS_CRASHED) ||
 
			v->breakdown_ctr != 0 ||
 
			v->overtaking != 0 ||
 
			v->state == RVSB_WORMHOLE ||
 
			v->IsInDepot() ||
 
			v->current_order.IsType(OT_LOADING)) {
 
		return CMD_ERROR;
 
	}
 
@@ -809,12 +809,15 @@ static void RoadVehCheckOvertake(RoadVeh
 
	/* Don't overtake in stations */
 
	if (IsTileType(v->tile, MP_STATION) || IsTileType(u->tile, MP_STATION)) return;
 

	
 
	/* For now, articulated road vehicles can't overtake anything. */
 
	if (v->HasArticulatedPart()) return;
 

	
 
	/* Don't overtake if the vehicle is broken or about to break down */
 
	if (v->breakdown_ctr != 0) return;
 

	
 
	/* Vehicles are not driving in same direction || direction is not a diagonal direction */
 
	if (v->direction != u->direction || !(v->direction & 1)) return;
 

	
 
	/* Check if vehicle is in a road stop, depot, tunnel or bridge or not on a straight road */
 
	if (v->state >= RVSB_IN_ROAD_STOP || !IsStraightRoadTrackdir((Trackdir)(v->state & RVSB_TRACKDIR_MASK))) return;
 

	
 
@@ -1570,14 +1573,13 @@ static bool RoadVehController(RoadVehicl
 
	/* handle crashed */
 
	if (v->vehstatus & VS_CRASHED || RoadVehCheckTrainCrash(v)) {
 
		return RoadVehIsCrashed(v);
 
	}
 

	
 
	/* road vehicle has broken down? */
 
	if (v->HandleBreakdown()) return true;
 
	if (v->vehstatus & VS_STOPPED) {
 
	if (v->HandleBreakdown() || v->vehstatus & VS_STOPPED) {
 
		v->SetLastSpeed();
 
		return true;
 
	}
 

	
 
	ProcessOrders(v);
 
	v->HandleLoading();
 
@@ -1631,12 +1633,13 @@ static bool RoadVehController(RoadVehicl
 
Money RoadVehicle::GetRunningCost() const
 
{
 
	const Engine *e = this->GetEngine();
 
	if (e->u.road.running_cost_class == INVALID_PRICE) return 0;
 

	
 
	uint cost_factor = GetVehicleProperty(this, PROP_ROADVEH_RUNNING_COST_FACTOR, e->u.road.running_cost);
 
	cost_factor *= _settings_game.economy.running_cost_multiplier_road;
 
	if (cost_factor == 0) return 0;
 

	
 
	return GetPrice(e->u.road.running_cost_class, cost_factor, e->GetGRF());
 
}
 

	
 
bool RoadVehicle::Tick()