From 42bcee22bd7d3a8582abe88e5f087b205c872505 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Wed, 9 Aug 2006 20:44:23 +0000 Subject: [PATCH] (svn r5819) - NewGRF: add support for refit costs specified in NewGRF. This may affect the default refit costs for the default rail vehicles. --- aircraft_cmd.c | 2 +- roadveh_cmd.c | 2 +- ship_cmd.c | 2 +- table/engines.h | 4 ++-- train_cmd.c | 7 ++++++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/aircraft_cmd.c b/aircraft_cmd.c index 913fda5bd7..3136865e5a 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -594,7 +594,7 @@ int32 CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) cost = 0; if (IS_HUMAN_PLAYER(v->owner) && new_cid != v->cargo_type) { - cost = _price.aircraft_base >> 7; + cost = (EngInfo(v->engine_type)->refit_cost * _price.aircraft_base) >> 10; } if (flags & DC_EXEC) { diff --git a/roadveh_cmd.c b/roadveh_cmd.c index f701937c4c..875ef6241d 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -1798,7 +1798,7 @@ int32 CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) cost = 0; if (IS_HUMAN_PLAYER(v->owner) && new_cid != v->cargo_type) { - cost = _price.roadveh_base >> 7; + cost = (EngInfo(v->engine_type)->refit_cost * _price.roadveh_base) >> 10; } if (flags & DC_EXEC) { diff --git a/ship_cmd.c b/ship_cmd.c index 009d243fa9..a47882f11f 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -1081,7 +1081,7 @@ int32 CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) cost = 0; if (IS_HUMAN_PLAYER(v->owner) && new_cid != v->cargo_type) { - cost = _price.ship_base >> 7; + cost = (EngInfo(v->engine_type)->refit_cost * _price.ship_base) >> 10; } if (flags & DC_EXEC) { diff --git a/table/engines.h b/table/engines.h index c59ce94cf2..9365c7f8cb 100644 --- a/table/engines.h +++ b/table/engines.h @@ -15,7 +15,7 @@ * @param e Rail Type of the vehicle * @param f Bitmask of the climates */ -#define MK(a, b, c, d, e, f) { a, b, c, d, e, f, 0, 0, 0, 0 } +#define MK(a, b, c, d, e, f) { a, b, c, d, e, f, 0, 8, 0, 0 } /** Writes the properties of a train carriage into the EngineInfo struct. * @see EngineInfo * @param a Introduction date @@ -23,7 +23,7 @@ * @param f Bitmask of the climates * @note the 0x80 in parameter b sets the "is carriage bit" */ -#define MW(a, b, c, d, e, f) { a, b | 0x80, c, d, e, f, 0, 0, 0, 0 } +#define MW(a, b, c, d, e, f) { a, b | 0x80, c, d, e, f, 0, 8, 0, 0 } // Rail types // R = Conventional railway diff --git a/train_cmd.c b/train_cmd.c index 9fd87146c9..1bcc1bffa1 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -1794,7 +1794,12 @@ int32 CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) }; if (amount != 0) { - if (new_cid != v->cargo_type) cost += _price.build_railvehicle >> 8; + if (new_cid != v->cargo_type) { + int32 base_cost = (rvi->flags & RVI_WAGON) ? + _price.build_railwagon : _price.build_railvehicle; + cost += (EngInfo(v->engine_type)->refit_cost * base_cost) >> 9; + } + num += amount; if (flags & DC_EXEC) { v->cargo_count = (v->cargo_type == new_cid) ? min(amount, v->cargo_count) : 0;