Adjust stopped/depot detection for running costs division
Fix v/this use in Train::GetRunningCost
This commit is contained in:
@@ -464,12 +464,15 @@ Money Aircraft::GetRunningCost() const
|
|||||||
const Engine *e = this->GetEngine();
|
const Engine *e = this->GetEngine();
|
||||||
uint cost_factor = GetVehicleProperty(this, PROP_AIRCRAFT_RUNNING_COST_FACTOR, e->u.air.running_cost);
|
uint cost_factor = GetVehicleProperty(this, PROP_AIRCRAFT_RUNNING_COST_FACTOR, e->u.air.running_cost);
|
||||||
|
|
||||||
/* running costs if in depot -- I haven't gotten this one working yet, can't figure out how to tell if plane is in the depot */
|
if (this->cur_speed == 0) {
|
||||||
if (this->current_order.IsType(OT_GOTO_DEPOT)) cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot;
|
if (this->IsInDepot()) {
|
||||||
|
/* running costs if in depot */
|
||||||
/* running costs if stopped */
|
cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot;
|
||||||
if ((this->cur_speed == 0) && !(this->current_order.IsType(OT_GOTO_DEPOT))) cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped;
|
} else {
|
||||||
|
/* running costs if stopped */
|
||||||
|
cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return GetPrice(PR_RUNNING_AIRCRAFT, cost_factor, e->GetGRF());
|
return GetPrice(PR_RUNNING_AIRCRAFT, cost_factor, e->GetGRF());
|
||||||
}
|
}
|
||||||
|
@@ -2131,11 +2131,15 @@ Money RoadVehicle::GetRunningCost() const
|
|||||||
uint cost_factor = GetVehicleProperty(this, PROP_ROADVEH_RUNNING_COST_FACTOR, e->u.road.running_cost);
|
uint cost_factor = GetVehicleProperty(this, PROP_ROADVEH_RUNNING_COST_FACTOR, e->u.road.running_cost);
|
||||||
if (cost_factor == 0) return 0;
|
if (cost_factor == 0) return 0;
|
||||||
|
|
||||||
/* running costs if in depot */
|
if (this->cur_speed == 0) {
|
||||||
if (IsRoadDepotTile(this->tile)) cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot;
|
if (this->IsInDepot()) {
|
||||||
|
/* running costs if in depot */
|
||||||
/* running costs if stopped */
|
cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot;
|
||||||
if ((this->cur_speed == 0) && !(IsRoadDepotTile(this->tile))) cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped;
|
} else {
|
||||||
|
/* running costs if stopped */
|
||||||
|
cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return GetPrice(e->u.road.running_cost_class, cost_factor, e->GetGRF());
|
return GetPrice(e->u.road.running_cost_class, cost_factor, e->GetGRF());
|
||||||
}
|
}
|
||||||
|
@@ -230,11 +230,15 @@ Money Ship::GetRunningCost() const
|
|||||||
const Engine *e = this->GetEngine();
|
const Engine *e = this->GetEngine();
|
||||||
uint cost_factor = GetVehicleProperty(this, PROP_SHIP_RUNNING_COST_FACTOR, e->u.ship.running_cost);
|
uint cost_factor = GetVehicleProperty(this, PROP_SHIP_RUNNING_COST_FACTOR, e->u.ship.running_cost);
|
||||||
|
|
||||||
/* running costs if in depot */
|
if (this->cur_speed == 0) {
|
||||||
if (IsShipDepotTile(this->tile)) cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot;
|
if (this->IsInDepot()) {
|
||||||
|
/* running costs if in depot */
|
||||||
/* running costs if stopped */
|
cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot;
|
||||||
if ((this->cur_speed == 0) && !(IsShipDepotTile(this->tile))) cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped;
|
} else {
|
||||||
|
/* running costs if stopped */
|
||||||
|
cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return GetPrice(PR_RUNNING_SHIP, cost_factor, e->GetGRF());
|
return GetPrice(PR_RUNNING_SHIP, cost_factor, e->GetGRF());
|
||||||
}
|
}
|
||||||
|
@@ -6456,11 +6456,15 @@ Money Train::GetRunningCost() const
|
|||||||
/* Halve running cost for multiheaded parts */
|
/* Halve running cost for multiheaded parts */
|
||||||
if (v->IsMultiheaded()) cost_factor /= 2;
|
if (v->IsMultiheaded()) cost_factor /= 2;
|
||||||
|
|
||||||
/* running costs if in depot */
|
if (this->cur_speed == 0) {
|
||||||
if (v->track == TRACK_BIT_DEPOT) cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot;
|
if (this->IsInDepot()) {
|
||||||
|
/* running costs if in depot */
|
||||||
/* running costs if stopped */
|
cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot;
|
||||||
if ((v->cur_speed == 0) && !(v->track == TRACK_BIT_DEPOT)) cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped;
|
} else {
|
||||||
|
/* running costs if stopped */
|
||||||
|
cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cost += GetPrice(e->u.rail.running_cost_class, cost_factor, e->GetGRF());
|
cost += GetPrice(e->u.rail.running_cost_class, cost_factor, e->GetGRF());
|
||||||
} while ((v = v->GetNextVehicle()) != nullptr);
|
} while ((v = v->GetNextVehicle()) != nullptr);
|
||||||
|
Reference in New Issue
Block a user