mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r18011) -Feature(ette): [NewGRF] CB 36 for roadvehicle property 09 'running cost factor'.
This commit is contained in:
parent
cc320dc4d0
commit
6ca8f6e380
|
@ -205,11 +205,15 @@ uint Engine::GetDisplayDefaultCapacity(uint16 *mail_capacity) const
|
||||||
Money Engine::GetRunningCost() const
|
Money Engine::GetRunningCost() const
|
||||||
{
|
{
|
||||||
switch (this->type) {
|
switch (this->type) {
|
||||||
case VEH_ROAD:
|
case VEH_ROAD: {
|
||||||
return this->u.road.running_cost * GetPriceByIndex(this->u.road.running_cost_class) >> 8;
|
if (this->u.road.running_cost_class == INVALID_PRICE) return 0;
|
||||||
|
return GetEngineProperty(this->index, PROP_ROADVEH_RUNNING_COST_FACTOR, this->u.road.running_cost) * GetPriceByIndex(this->u.road.running_cost_class) >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
case VEH_TRAIN:
|
case VEH_TRAIN: {
|
||||||
|
if (this->u.rail.running_cost_class == INVALID_PRICE) return 0;
|
||||||
return GetEngineProperty(this->index, PROP_TRAIN_RUNNING_COST_FACTOR, this->u.rail.running_cost) * GetPriceByIndex(this->u.rail.running_cost_class) >> 8;
|
return GetEngineProperty(this->index, PROP_TRAIN_RUNNING_COST_FACTOR, this->u.rail.running_cost) * GetPriceByIndex(this->u.rail.running_cost_class) >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
case VEH_SHIP:
|
case VEH_SHIP:
|
||||||
return GetEngineProperty(this->index, PROP_SHIP_RUNNING_COST_FACTOR, this->u.ship.running_cost) * _price[PR_RUNNING_SHIP] >> 8;
|
return GetEngineProperty(this->index, PROP_SHIP_RUNNING_COST_FACTOR, this->u.ship.running_cost) * _price[PR_RUNNING_SHIP] >> 8;
|
||||||
|
@ -233,6 +237,7 @@ Money Engine::GetCost() const
|
||||||
} else {
|
} else {
|
||||||
return GetEngineProperty(this->index, PROP_TRAIN_COST_FACTOR, this->u.rail.cost_factor) * (_price[PR_BUILD_VEHICLE_TRAIN] >> 3) >> 5;
|
return GetEngineProperty(this->index, PROP_TRAIN_COST_FACTOR, this->u.rail.cost_factor) * (_price[PR_BUILD_VEHICLE_TRAIN] >> 3) >> 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VEH_SHIP:
|
case VEH_SHIP:
|
||||||
return GetEngineProperty(this->index, PROP_SHIP_COST_FACTOR, this->u.ship.cost_factor) * (_price[PR_BUILD_VEHICLE_SHIP] >> 3) >> 5;
|
return GetEngineProperty(this->index, PROP_SHIP_COST_FACTOR, this->u.ship.cost_factor) * (_price[PR_BUILD_VEHICLE_SHIP] >> 3) >> 5;
|
||||||
|
|
||||||
|
|
|
@ -752,7 +752,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
|
||||||
rvi->max_speed = grf_load_byte(&buf);
|
rvi->max_speed = grf_load_byte(&buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x09: // Running cost factor
|
case PROP_ROADVEH_RUNNING_COST_FACTOR: // 0x09 Running cost factor
|
||||||
rvi->running_cost = grf_load_byte(&buf);
|
rvi->running_cost = grf_load_byte(&buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ enum PropertyID {
|
||||||
PROP_TRAIN_TRACTIVE_EFFORT = 0x1F, ///< Tractive effort coefficient in 1/256
|
PROP_TRAIN_TRACTIVE_EFFORT = 0x1F, ///< Tractive effort coefficient in 1/256
|
||||||
PROP_TRAIN_USER_DATA = 0x25, ///< User defined data for vehicle variable 0x42
|
PROP_TRAIN_USER_DATA = 0x25, ///< User defined data for vehicle variable 0x42
|
||||||
|
|
||||||
|
PROP_ROADVEH_RUNNING_COST_FACTOR = 0x09, ///< Yearly runningcost
|
||||||
PROP_ROADVEH_CARGO_CAPACITY = 0x0F, ///< Capacity
|
PROP_ROADVEH_CARGO_CAPACITY = 0x0F, ///< Capacity
|
||||||
PROP_ROADVEH_COST_FACTOR = 0x11, ///< Purchase cost
|
PROP_ROADVEH_COST_FACTOR = 0x11, ///< Purchase cost
|
||||||
|
|
||||||
|
|
|
@ -121,13 +121,7 @@ struct RoadVehicle : public SpecializedVehicle<RoadVehicle, VEH_ROAD> {
|
||||||
SpriteID GetImage(Direction direction) const;
|
SpriteID GetImage(Direction direction) const;
|
||||||
int GetDisplaySpeed() const { return this->cur_speed / 2; }
|
int GetDisplaySpeed() const { return this->cur_speed / 2; }
|
||||||
int GetDisplayMaxSpeed() const { return this->max_speed / 2; }
|
int GetDisplayMaxSpeed() const { return this->max_speed / 2; }
|
||||||
|
Money GetRunningCost() const;
|
||||||
Money GetRunningCost() const
|
|
||||||
{
|
|
||||||
const RoadVehicleInfo *rvi = RoadVehInfo(this->engine_type);
|
|
||||||
return rvi->running_cost * GetPriceByIndex(rvi->running_cost_class);
|
|
||||||
}
|
|
||||||
|
|
||||||
int GetDisplayImageWidth(Point *offset = NULL) const;
|
int GetDisplayImageWidth(Point *offset = NULL) const;
|
||||||
bool IsInDepot() const { return this->state == RVSB_IN_DEPOT; }
|
bool IsInDepot() const { return this->state == RVSB_IN_DEPOT; }
|
||||||
bool IsStoppedInDepot() const;
|
bool IsStoppedInDepot() const;
|
||||||
|
|
|
@ -1821,6 +1821,17 @@ static bool RoadVehController(RoadVehicle *v)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Money RoadVehicle::GetRunningCost() const
|
||||||
|
{
|
||||||
|
const RoadVehicleInfo *rvi = RoadVehInfo(this->engine_type);
|
||||||
|
if (rvi->running_cost_class == INVALID_PRICE) return 0;
|
||||||
|
|
||||||
|
uint cost_factor = GetVehicleProperty(this, PROP_ROADVEH_RUNNING_COST_FACTOR, rvi->running_cost);
|
||||||
|
if (cost_factor == 0) return 0;
|
||||||
|
|
||||||
|
return cost_factor * GetPriceByIndex(rvi->running_cost_class);
|
||||||
|
}
|
||||||
|
|
||||||
bool RoadVehicle::Tick()
|
bool RoadVehicle::Tick()
|
||||||
{
|
{
|
||||||
if (this->IsRoadVehFront()) {
|
if (this->IsRoadVehFront()) {
|
||||||
|
|
|
@ -4438,7 +4438,7 @@ Money Train::GetRunningCost() const
|
||||||
const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
|
const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
|
||||||
if (rvi->running_cost_class == INVALID_PRICE) continue;
|
if (rvi->running_cost_class == INVALID_PRICE) continue;
|
||||||
|
|
||||||
byte cost_factor = GetVehicleProperty(v, PROP_TRAIN_RUNNING_COST_FACTOR, rvi->running_cost);
|
uint cost_factor = GetVehicleProperty(v, PROP_TRAIN_RUNNING_COST_FACTOR, rvi->running_cost);
|
||||||
if (cost_factor == 0) continue;
|
if (cost_factor == 0) continue;
|
||||||
|
|
||||||
/* Halve running cost for multiheaded parts */
|
/* Halve running cost for multiheaded parts */
|
||||||
|
|
Loading…
Reference in New Issue