(svn r5819) - NewGRF: add support for refit costs specified in NewGRF. This may affect the default refit costs for the default rail vehicles.
authorpeter1138
Wed, 09 Aug 2006 20:44:23 +0000
changeset 4242 5738cbc9b2bd
parent 4241 8b399a9e42c4
child 4243 b0361faa4dfd
(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
roadveh_cmd.c
ship_cmd.c
table/engines.h
train_cmd.c
--- a/aircraft_cmd.c	Wed Aug 09 08:48:33 2006 +0000
+++ b/aircraft_cmd.c	Wed Aug 09 20:44:23 2006 +0000
@@ -594,7 +594,7 @@
 
 	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) {
--- a/roadveh_cmd.c	Wed Aug 09 08:48:33 2006 +0000
+++ b/roadveh_cmd.c	Wed Aug 09 20:44:23 2006 +0000
@@ -1798,7 +1798,7 @@
 
 	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) {
--- a/ship_cmd.c	Wed Aug 09 08:48:33 2006 +0000
+++ b/ship_cmd.c	Wed Aug 09 20:44:23 2006 +0000
@@ -1081,7 +1081,7 @@
 
 	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) {
--- a/table/engines.h	Wed Aug 09 08:48:33 2006 +0000
+++ b/table/engines.h	Wed Aug 09 20:44:23 2006 +0000
@@ -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
--- a/train_cmd.c	Wed Aug 09 08:48:33 2006 +0000
+++ b/train_cmd.c	Wed Aug 09 20:44:23 2006 +0000
@@ -1794,7 +1794,12 @@
 			};
 
 			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;