summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhackykid <hackykid@openttd.org>2005-06-03 10:39:30 +0000
committerhackykid <hackykid@openttd.org>2005-06-03 10:39:30 +0000
commit52ebf02f2fa35447b7455b78bab060ede9916304 (patch)
treed3f3e4b5c205c4a1d8156cbf146d05b01db0adf6
parent6849e086f5a19094129e2b7b2046421fad571774 (diff)
downloadopenttd-52ebf02f2fa35447b7455b78bab060ede9916304.tar.xz
(svn r2401) - Fix: [newgrf] Finish up callback mechanism, implement 'refit capacity' callback slightly more correct.
-rw-r--r--engine.h12
-rw-r--r--newgrf.c8
-rw-r--r--table/engines.h242
-rw-r--r--train_cmd.c18
4 files changed, 147 insertions, 133 deletions
diff --git a/engine.h b/engine.h
index b27b094c3..698506afb 100644
--- a/engine.h
+++ b/engine.h
@@ -14,6 +14,7 @@ typedef struct RailVehicleInfo {
byte engclass; // 0: steam, 1: diesel, 2: electric
byte capacity;
byte cargo_type;
+ byte callbackmask; // see CallbackMask enum
} RailVehicleInfo;
typedef struct ShipVehicleInfo {
@@ -122,11 +123,18 @@ enum GlobalCargo {
NUM_GLOBAL_CID = 31
};
-// This enum only lists implemented callbacks
+// This enum lists the implemented callbacks
+// Use as argument for the GetCallBackResult function (see comments there)
enum CallbackID {
// Refit capacity, the passed vehicle needs to have its ->cargo_type set to
// the cargo we are refitting to, returns the new cargo capacity
- CB_REFIT_CAP = 0x15,
+ CBID_REFIT_CAP = 0x15,
+};
+
+// bit positions for rvi->callbackmask, indicates which callbacks are used by an engine
+// (some callbacks are always used, and dont appear here)
+enum CallbackMask {
+ CBM_REFIT_CAP = 3,
};
enum {
diff --git a/newgrf.c b/newgrf.c
index 729594d36..445bd38e8 100644
--- a/newgrf.c
+++ b/newgrf.c
@@ -343,7 +343,12 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
_engine_refit_masks[engine + i] = refit_mask;
}
} break;
-
+ case 0x1E: /* Callback */
+ FOR_EACH_OBJECT {
+ byte callbacks = grf_load_byte(&buf);
+ rvi[i].callbackmask = callbacks;
+ }
+ break;
/* TODO */
/* Fall-through for unimplemented two bytes long properties. */
case 0x1B: /* Powered wagons power bonus */
@@ -353,7 +358,6 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
/* Fall-through for unimplemented one byte long properties. */
case 0x1A: /* Sort order */
case 0x1C: /* Refit cost */
- case 0x1E: /* Callback */
case 0x1F: /* Tractive effort */
case 0x20: /* Air drag */
case 0x21: /* Shorter tenders */
diff --git a/table/engines.h b/table/engines.h
index 796a767dc..bf4b0eb3f 100644
--- a/table/engines.h
+++ b/table/engines.h
@@ -266,127 +266,127 @@ EngineInfo _engine_info[TOTAL_NUM_ENGINES] = {
};
RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES] = {
- // image_index max_speed (kph) running_cost_base
- // | flags | power (hp) | running_cost_class
- // | | base_cost | weight | capacity
- // | | | | | | | | | cargo_type
- // | | | | | | | | | |
- { 2, 0, 7, 64, 300, 47, 50, 0, 0, 0 }, /* 0 */
- { 19, 0, 8, 80, 600, 65, 65, 1, 0, 0 }, /* 1 */
- { 2, 0, 10, 72, 400, 85, 90, 0, 0, 0 }, /* 2 */
- { 0, 0, 15, 96, 900, 130, 130, 0, 0, 0 }, /* 3 */
- { 1, 0, 19, 112, 1000, 140, 145, 0, 0, 0 }, /* 4 */
- { 12, 0, 16, 120, 1400, 95, 125, 1, 0, 0 }, /* 5 */
- { 14, 0, 20, 152, 2000, 120, 135, 1, 0, 0 }, /* 6 */
- { 3, 0, 14, 88, 1100, 145, 130, 0, 0, 0 }, /* 7 */
- { 0, 0, 13, 112, 1000, 131, 120, 0, 0, 0 }, /* 8 */
- { 1, 0, 19, 128, 1200, 162, 140, 0, 0, 0 }, /* 9 */
- { 0, 0, 22, 144, 1600, 170, 130, 0, 0, 0 }, /* 10 */
- { 8, 1, 11, 112, 600/2,32/2, 85/2, 1, 38, CT_PASSENGERS }, /* 11 */
- { 10, 1, 14, 120, 700/2,38/2, 70/2, 1, 40, CT_PASSENGERS }, /* 12 */
- { 4, 0, 15, 128, 1250, 72, 95, 1, 0, 0 }, /* 13 */
- { 5, 0, 17, 144, 1750, 101, 120, 1, 0, 0 }, /* 14 */
- { 4, 0, 18, 160, 2580, 112, 140, 1, 0, 0 }, /* 15 */
- { 14, 0, 23, 96, 4000, 150, 135, 1, 0, 0 }, /* 16 */
- { 12, 0, 16, 112, 2400, 120, 105, 1, 0, 0 }, /* 17 */
- { 13, 0, 30, 112, 6600, 207, 155, 1, 0, 0 }, /* 18 */
- { 15, 0, 18, 104, 1500, 110, 105, 1, 0, 0 }, /* 19 */
- { 16, 1, 35, 160, 3500/2,95/2, 205/2, 1, 0, 0 }, /* 20 */
- { 18, 0, 21, 104, 2200, 120, 145, 1, 0, 0 }, /* 21 */
- { 6, 1, 20, 200, 4500/2,70/2, 190/2, 1, 4, CT_MAIL }, /* 22 */
- { 20, 0, 26, 160, 3600, 84, 180, 2, 0, 0 }, /* 23 */
- { 20, 0, 30, 176, 5000, 82, 205, 2, 0, 0 }, /* 24 */
- { 21, 1, 40, 240, 7000/2,90/2, 240/2, 2, 0, 0 }, /* 25 */
- { 23, 1, 43, 264, 8000/2,95/2, 250/2, 2, 0, 0 }, /* 26 */
- { 33, 2, 247, 0, 0, 25, 0, 0, 40, CT_PASSENGERS }, /* 27 */
- { 35, 2, 228, 0, 0, 21, 0, 0, 30, CT_MAIL }, /* 28 */
- { 34, 2, 176, 0, 0, 18, 0, 0, 30, CT_COAL }, /* 29 */
- { 36, 2, 200, 0, 0, 24, 0, 0, 30, CT_OIL }, /* 30 */
- { 37, 2, 192, 0, 0, 20, 0, 0, 25, CT_LIVESTOCK }, /* 31 */
- { 38, 2, 190, 0, 0, 21, 0, 0, 25, CT_GOODS }, /* 32 */
- { 39, 2, 182, 0, 0, 19, 0, 0, 30, CT_GRAIN }, /* 33 */
- { 40, 2, 181, 0, 0, 16, 0, 0, 30, CT_WOOD }, /* 34 */
- { 41, 2, 179, 0, 0, 19, 0, 0, 30, CT_IRON_ORE }, /* 35 */
- { 42, 2, 196, 0, 0, 18, 0, 0, 20, CT_STEEL }, /* 36 */
- { 43, 2, 255, 0, 0, 30, 0, 0, 20, CT_VALUABLES }, /* 37 */
- { 44, 2, 191, 0, 0, 22, 0, 0, 25, CT_FOOD }, /* 38 */
- { 45, 2, 196, 0, 0, 18, 0, 0, 20, CT_PAPER }, /* 39 */
- { 46, 2, 179, 0, 0, 19, 0, 0, 30, CT_COPPER_ORE }, /* 40 */
- { 47, 2, 199, 0, 0, 25, 0, 0, 25, CT_WATER }, /* 41 */
- { 48, 2, 182, 0, 0, 18, 0, 0, 25, CT_FRUIT }, /* 42 */
- { 49, 2, 185, 0, 0, 19, 0, 0, 21, CT_RUBBER }, /* 43 */
- { 50, 2, 176, 0, 0, 19, 0, 0, 30, CT_SUGAR }, /* 44 */
- { 51, 2, 178, 0, 0, 20, 0, 0, 30, CT_COTTON_CANDY }, /* 45 */
- { 52, 2, 192, 0, 0, 20, 0, 0, 30, CT_TOFFEE }, /* 46 */
- { 53, 2, 190, 0, 0, 21, 0, 0, 20, CT_BUBBLES }, /* 47 */
- { 54, 2, 182, 0, 0, 24, 0, 0, 25, CT_COLA }, /* 48 */
- { 55, 2, 181, 0, 0, 21, 0, 0, 25, CT_CANDY }, /* 49 */
- { 56, 2, 183, 0, 0, 21, 0, 0, 20, CT_TOYS }, /* 50 */
- { 57, 2, 196, 0, 0, 18, 0, 0, 22, CT_BATTERIES }, /* 51 */
- { 58, 2, 193, 0, 0, 18, 0, 0, 25, CT_FIZZY_DRINKS }, /* 52 */
- { 59, 2, 191, 0, 0, 18, 0, 0, 30, CT_PLASTIC }, /* 53 */
- { 25, 0, 52, 304, 9000, 95, 230, 2, 0, 0 }, /* 54 */
- { 26, 1, 60, 336, 10000/2,85/2, 240/2, 2, 25, CT_PASSENGERS }, /* 55 */
- { 26, 0, 53, 320, 5000, 95, 230, 2, 0, 0 }, /* 56 */
- { 60, 2, 247, 0, 0, 25, 0, 0, 45, CT_PASSENGERS }, /* 57 */
- { 62, 2, 228, 0, 0, 21, 0, 0, 35, CT_MAIL }, /* 58 */
- { 61, 2, 176, 0, 0, 18, 0, 0, 35, CT_COAL }, /* 59 */
- { 63, 2, 200, 0, 0, 24, 0, 0, 35, CT_OIL }, /* 60 */
- { 64, 2, 192, 0, 0, 20, 0, 0, 30, CT_LIVESTOCK }, /* 61 */
- { 65, 2, 190, 0, 0, 21, 0, 0, 30, CT_GOODS }, /* 62 */
- { 66, 2, 182, 0, 0, 19, 0, 0, 35, CT_GRAIN }, /* 63 */
- { 67, 2, 181, 0, 0, 16, 0, 0, 35, CT_WOOD }, /* 64 */
- { 68, 2, 179, 0, 0, 19, 0, 0, 35, CT_IRON_ORE }, /* 65 */
- { 69, 2, 196, 0, 0, 18, 0, 0, 25, CT_STEEL }, /* 66 */
- { 70, 2, 255, 0, 0, 30, 0, 0, 25, CT_VALUABLES }, /* 67 */
- { 71, 2, 191, 0, 0, 22, 0, 0, 30, CT_FOOD }, /* 68 */
- { 72, 2, 196, 0, 0, 18, 0, 0, 25, CT_PAPER }, /* 69 */
- { 73, 2, 179, 0, 0, 19, 0, 0, 35, CT_COPPER_ORE }, /* 70 */
- { 47, 2, 199, 0, 0, 25, 0, 0, 30, CT_WATER }, /* 71 */
- { 48, 2, 182, 0, 0, 18, 0, 0, 30, CT_FRUIT }, /* 72 */
- { 49, 2, 185, 0, 0, 19, 0, 0, 26, CT_RUBBER }, /* 73 */
- { 50, 2, 176, 0, 0, 19, 0, 0, 35, CT_SUGAR }, /* 74 */
- { 51, 2, 178, 0, 0, 20, 0, 0, 35, CT_COTTON_CANDY }, /* 75 */
- { 52, 2, 192, 0, 0, 20, 0, 0, 35, CT_TOFFEE }, /* 76 */
- { 53, 2, 190, 0, 0, 21, 0, 0, 25, CT_BUBBLES }, /* 77 */
- { 54, 2, 182, 0, 0, 24, 0, 0, 30, CT_COLA }, /* 78 */
- { 55, 2, 181, 0, 0, 21, 0, 0, 30, CT_CANDY }, /* 79 */
- { 56, 2, 183, 0, 0, 21, 0, 0, 25, CT_TOYS }, /* 80 */
- { 57, 2, 196, 0, 0, 18, 0, 0, 27, CT_BATTERIES }, /* 81 */
- { 58, 2, 193, 0, 0, 18, 0, 0, 30, CT_FIZZY_DRINKS }, /* 82 */
- { 59, 2, 191, 0, 0, 18, 0, 0, 35, CT_PLASTIC }, /* 83 */
- { 28, 0, 70, 400, 10000, 105, 250, 2, 0, 0 }, /* 84 */
- { 29, 0, 74, 448, 12000, 120, 253, 2, 0, 0 }, /* 85 */
- { 30, 0, 82, 480, 15000, 130, 254, 2, 0, 0 }, /* 86 */
- { 31, 1, 95, 640, 20000/2,150/2,255/2, 2, 0, 0 }, /* 87 */
- { 28, 0, 70, 480, 10000, 120, 250, 2, 0, 0 }, /* 88 */
- { 60, 2, 247, 0, 0, 25, 0, 0, 47, CT_PASSENGERS }, /* 89 */
- { 62, 2, 228, 0, 0, 21, 0, 0, 37, CT_MAIL }, /* 90 */
- { 61, 2, 176, 0, 0, 18, 0, 0, 37, CT_COAL }, /* 91 */
- { 63, 2, 200, 0, 0, 24, 0, 0, 37, CT_OIL }, /* 92 */
- { 64, 2, 192, 0, 0, 20, 0, 0, 32, CT_LIVESTOCK }, /* 93 */
- { 65, 2, 190, 0, 0, 21, 0, 0, 32, CT_GOODS }, /* 94 */
- { 66, 2, 182, 0, 0, 19, 0, 0, 37, CT_GRAIN }, /* 95 */
- { 67, 2, 181, 0, 0, 16, 0, 0, 37, CT_WOOD }, /* 96 */
- { 68, 2, 179, 0, 0, 19, 0, 0, 37, CT_IRON_ORE }, /* 97 */
- { 69, 2, 196, 0, 0, 18, 0, 0, 27, CT_STEEL }, /* 98 */
- { 70, 2, 255, 0, 0, 30, 0, 0, 27, CT_VALUABLES }, /* 99 */
- { 71, 2, 191, 0, 0, 22, 0, 0, 32, CT_FOOD }, /* 100 */
- { 72, 2, 196, 0, 0, 18, 0, 0, 27, CT_PAPER }, /* 101 */
- { 73, 2, 179, 0, 0, 19, 0, 0, 37, CT_COPPER_ORE }, /* 102 */
- { 47, 2, 199, 0, 0, 25, 0, 0, 32, CT_WATER }, /* 103 */
- { 48, 2, 182, 0, 0, 18, 0, 0, 32, CT_FRUIT }, /* 104 */
- { 49, 2, 185, 0, 0, 19, 0, 0, 28, CT_RUBBER }, /* 105 */
- { 50, 2, 176, 0, 0, 19, 0, 0, 37, CT_SUGAR }, /* 106 */
- { 51, 2, 178, 0, 0, 20, 0, 0, 37, CT_COTTON_CANDY }, /* 107 */
- { 52, 2, 192, 0, 0, 20, 0, 0, 37, CT_TOFFEE }, /* 108 */
- { 53, 2, 190, 0, 0, 21, 0, 0, 27, CT_BUBBLES }, /* 109 */
- { 54, 2, 182, 0, 0, 24, 0, 0, 32, CT_COLA }, /* 110 */
- { 55, 2, 181, 0, 0, 21, 0, 0, 32, CT_CANDY }, /* 111 */
- { 56, 2, 183, 0, 0, 21, 0, 0, 27, CT_TOYS }, /* 112 */
- { 57, 2, 196, 0, 0, 18, 0, 0, 29, CT_BATTERIES }, /* 113 */
- { 58, 2, 193, 0, 0, 18, 0, 0, 32, CT_FIZZY_DRINKS }, /* 114 */
- { 59, 2, 191, 0, 0, 18, 0, 0, 37, CT_PLASTIC }, /* 115 */
+ // image_index max_speed (kph) running_cost_base callback bitmask
+ // | flags | power (hp) | running_cost_class |
+ // | | base_cost | weight | capacity |
+ // | | | | | | | | | cargo_type |
+ // | | | | | | | | | | |
+ { 2, 0, 7, 64, 300, 47, 50, 0, 0, 0 , 0 }, /* 0 */
+ { 19, 0, 8, 80, 600, 65, 65, 1, 0, 0 , 0 }, /* 1 */
+ { 2, 0, 10, 72, 400, 85, 90, 0, 0, 0 , 0 }, /* 2 */
+ { 0, 0, 15, 96, 900, 130, 130, 0, 0, 0 , 0 }, /* 3 */
+ { 1, 0, 19, 112, 1000, 140, 145, 0, 0, 0 , 0 }, /* 4 */
+ { 12, 0, 16, 120, 1400, 95, 125, 1, 0, 0 , 0 }, /* 5 */
+ { 14, 0, 20, 152, 2000, 120, 135, 1, 0, 0 , 0 }, /* 6 */
+ { 3, 0, 14, 88, 1100, 145, 130, 0, 0, 0 , 0 }, /* 7 */
+ { 0, 0, 13, 112, 1000, 131, 120, 0, 0, 0 , 0 }, /* 8 */
+ { 1, 0, 19, 128, 1200, 162, 140, 0, 0, 0 , 0 }, /* 9 */
+ { 0, 0, 22, 144, 1600, 170, 130, 0, 0, 0 , 0 }, /* 10 */
+ { 8, 1, 11, 112, 600/2,32/2, 85/2, 1, 38, CT_PASSENGERS , 0 }, /* 11 */
+ { 10, 1, 14, 120, 700/2,38/2, 70/2, 1, 40, CT_PASSENGERS , 0 }, /* 12 */
+ { 4, 0, 15, 128, 1250, 72, 95, 1, 0, 0 , 0 }, /* 13 */
+ { 5, 0, 17, 144, 1750, 101, 120, 1, 0, 0 , 0 }, /* 14 */
+ { 4, 0, 18, 160, 2580, 112, 140, 1, 0, 0 , 0 }, /* 15 */
+ { 14, 0, 23, 96, 4000, 150, 135, 1, 0, 0 , 0 }, /* 16 */
+ { 12, 0, 16, 112, 2400, 120, 105, 1, 0, 0 , 0 }, /* 17 */
+ { 13, 0, 30, 112, 6600, 207, 155, 1, 0, 0 , 0 }, /* 18 */
+ { 15, 0, 18, 104, 1500, 110, 105, 1, 0, 0 , 0 }, /* 19 */
+ { 16, 1, 35, 160, 3500/2,95/2, 205/2, 1, 0, 0 , 0 }, /* 20 */
+ { 18, 0, 21, 104, 2200, 120, 145, 1, 0, 0 , 0 }, /* 21 */
+ { 6, 1, 20, 200, 4500/2,70/2, 190/2, 1, 4, CT_MAIL , 0 }, /* 22 */
+ { 20, 0, 26, 160, 3600, 84, 180, 2, 0, 0 , 0 }, /* 23 */
+ { 20, 0, 30, 176, 5000, 82, 205, 2, 0, 0 , 0 }, /* 24 */
+ { 21, 1, 40, 240, 7000/2,90/2, 240/2, 2, 0, 0 , 0 }, /* 25 */
+ { 23, 1, 43, 264, 8000/2,95/2, 250/2, 2, 0, 0 , 0 }, /* 26 */
+ { 33, 2, 247, 0, 0, 25, 0, 0, 40, CT_PASSENGERS , 0 }, /* 27 */
+ { 35, 2, 228, 0, 0, 21, 0, 0, 30, CT_MAIL , 0 }, /* 28 */
+ { 34, 2, 176, 0, 0, 18, 0, 0, 30, CT_COAL , 0 }, /* 29 */
+ { 36, 2, 200, 0, 0, 24, 0, 0, 30, CT_OIL , 0 }, /* 30 */
+ { 37, 2, 192, 0, 0, 20, 0, 0, 25, CT_LIVESTOCK , 0 }, /* 31 */
+ { 38, 2, 190, 0, 0, 21, 0, 0, 25, CT_GOODS , 0 }, /* 32 */
+ { 39, 2, 182, 0, 0, 19, 0, 0, 30, CT_GRAIN , 0 }, /* 33 */
+ { 40, 2, 181, 0, 0, 16, 0, 0, 30, CT_WOOD , 0 }, /* 34 */
+ { 41, 2, 179, 0, 0, 19, 0, 0, 30, CT_IRON_ORE , 0 }, /* 35 */
+ { 42, 2, 196, 0, 0, 18, 0, 0, 20, CT_STEEL , 0 }, /* 36 */
+ { 43, 2, 255, 0, 0, 30, 0, 0, 20, CT_VALUABLES , 0 }, /* 37 */
+ { 44, 2, 191, 0, 0, 22, 0, 0, 25, CT_FOOD , 0 }, /* 38 */
+ { 45, 2, 196, 0, 0, 18, 0, 0, 20, CT_PAPER , 0 }, /* 39 */
+ { 46, 2, 179, 0, 0, 19, 0, 0, 30, CT_COPPER_ORE , 0 }, /* 40 */
+ { 47, 2, 199, 0, 0, 25, 0, 0, 25, CT_WATER , 0 }, /* 41 */
+ { 48, 2, 182, 0, 0, 18, 0, 0, 25, CT_FRUIT , 0 }, /* 42 */
+ { 49, 2, 185, 0, 0, 19, 0, 0, 21, CT_RUBBER , 0 }, /* 43 */
+ { 50, 2, 176, 0, 0, 19, 0, 0, 30, CT_SUGAR , 0 }, /* 44 */
+ { 51, 2, 178, 0, 0, 20, 0, 0, 30, CT_COTTON_CANDY , 0 }, /* 45 */
+ { 52, 2, 192, 0, 0, 20, 0, 0, 30, CT_TOFFEE , 0 }, /* 46 */
+ { 53, 2, 190, 0, 0, 21, 0, 0, 20, CT_BUBBLES , 0 }, /* 47 */
+ { 54, 2, 182, 0, 0, 24, 0, 0, 25, CT_COLA , 0 }, /* 48 */
+ { 55, 2, 181, 0, 0, 21, 0, 0, 25, CT_CANDY , 0 }, /* 49 */
+ { 56, 2, 183, 0, 0, 21, 0, 0, 20, CT_TOYS , 0 }, /* 50 */
+ { 57, 2, 196, 0, 0, 18, 0, 0, 22, CT_BATTERIES , 0 }, /* 51 */
+ { 58, 2, 193, 0, 0, 18, 0, 0, 25, CT_FIZZY_DRINKS , 0 }, /* 52 */
+ { 59, 2, 191, 0, 0, 18, 0, 0, 30, CT_PLASTIC , 0 }, /* 53 */
+ { 25, 0, 52, 304, 9000, 95, 230, 2, 0, 0 , 0 }, /* 54 */
+ { 26, 1, 60, 336, 10000/2,85/2, 240/2, 2, 25, CT_PASSENGERS , 0 }, /* 55 */
+ { 26, 0, 53, 320, 5000, 95, 230, 2, 0, 0 , 0 }, /* 56 */
+ { 60, 2, 247, 0, 0, 25, 0, 0, 45, CT_PASSENGERS , 0 }, /* 57 */
+ { 62, 2, 228, 0, 0, 21, 0, 0, 35, CT_MAIL , 0 }, /* 58 */
+ { 61, 2, 176, 0, 0, 18, 0, 0, 35, CT_COAL , 0 }, /* 59 */
+ { 63, 2, 200, 0, 0, 24, 0, 0, 35, CT_OIL , 0 }, /* 60 */
+ { 64, 2, 192, 0, 0, 20, 0, 0, 30, CT_LIVESTOCK , 0 }, /* 61 */
+ { 65, 2, 190, 0, 0, 21, 0, 0, 30, CT_GOODS , 0 }, /* 62 */
+ { 66, 2, 182, 0, 0, 19, 0, 0, 35, CT_GRAIN , 0 }, /* 63 */
+ { 67, 2, 181, 0, 0, 16, 0, 0, 35, CT_WOOD , 0 }, /* 64 */
+ { 68, 2, 179, 0, 0, 19, 0, 0, 35, CT_IRON_ORE , 0 }, /* 65 */
+ { 69, 2, 196, 0, 0, 18, 0, 0, 25, CT_STEEL , 0 }, /* 66 */
+ { 70, 2, 255, 0, 0, 30, 0, 0, 25, CT_VALUABLES , 0 }, /* 67 */
+ { 71, 2, 191, 0, 0, 22, 0, 0, 30, CT_FOOD , 0 }, /* 68 */
+ { 72, 2, 196, 0, 0, 18, 0, 0, 25, CT_PAPER , 0 }, /* 69 */
+ { 73, 2, 179, 0, 0, 19, 0, 0, 35, CT_COPPER_ORE , 0 }, /* 70 */
+ { 47, 2, 199, 0, 0, 25, 0, 0, 30, CT_WATER , 0 }, /* 71 */
+ { 48, 2, 182, 0, 0, 18, 0, 0, 30, CT_FRUIT , 0 }, /* 72 */
+ { 49, 2, 185, 0, 0, 19, 0, 0, 26, CT_RUBBER , 0 }, /* 73 */
+ { 50, 2, 176, 0, 0, 19, 0, 0, 35, CT_SUGAR , 0 }, /* 74 */
+ { 51, 2, 178, 0, 0, 20, 0, 0, 35, CT_COTTON_CANDY , 0 }, /* 75 */
+ { 52, 2, 192, 0, 0, 20, 0, 0, 35, CT_TOFFEE , 0 }, /* 76 */
+ { 53, 2, 190, 0, 0, 21, 0, 0, 25, CT_BUBBLES , 0 }, /* 77 */
+ { 54, 2, 182, 0, 0, 24, 0, 0, 30, CT_COLA , 0 }, /* 78 */
+ { 55, 2, 181, 0, 0, 21, 0, 0, 30, CT_CANDY , 0 }, /* 79 */
+ { 56, 2, 183, 0, 0, 21, 0, 0, 25, CT_TOYS , 0 }, /* 80 */
+ { 57, 2, 196, 0, 0, 18, 0, 0, 27, CT_BATTERIES , 0 }, /* 81 */
+ { 58, 2, 193, 0, 0, 18, 0, 0, 30, CT_FIZZY_DRINKS , 0 }, /* 82 */
+ { 59, 2, 191, 0, 0, 18, 0, 0, 35, CT_PLASTIC , 0 }, /* 83 */
+ { 28, 0, 70, 400, 10000, 105, 250, 2, 0, 0 , 0 }, /* 84 */
+ { 29, 0, 74, 448, 12000, 120, 253, 2, 0, 0 , 0 }, /* 85 */
+ { 30, 0, 82, 480, 15000, 130, 254, 2, 0, 0 , 0 }, /* 86 */
+ { 31, 1, 95, 640, 20000/2,150/2,255/2, 2, 0, 0 , 0 }, /* 87 */
+ { 28, 0, 70, 480, 10000, 120, 250, 2, 0, 0 , 0 }, /* 88 */
+ { 60, 2, 247, 0, 0, 25, 0, 0, 47, CT_PASSENGERS , 0 }, /* 89 */
+ { 62, 2, 228, 0, 0, 21, 0, 0, 37, CT_MAIL , 0 }, /* 90 */
+ { 61, 2, 176, 0, 0, 18, 0, 0, 37, CT_COAL , 0 }, /* 91 */
+ { 63, 2, 200, 0, 0, 24, 0, 0, 37, CT_OIL , 0 }, /* 92 */
+ { 64, 2, 192, 0, 0, 20, 0, 0, 32, CT_LIVESTOCK , 0 }, /* 93 */
+ { 65, 2, 190, 0, 0, 21, 0, 0, 32, CT_GOODS , 0 }, /* 94 */
+ { 66, 2, 182, 0, 0, 19, 0, 0, 37, CT_GRAIN , 0 }, /* 95 */
+ { 67, 2, 181, 0, 0, 16, 0, 0, 37, CT_WOOD , 0 }, /* 96 */
+ { 68, 2, 179, 0, 0, 19, 0, 0, 37, CT_IRON_ORE , 0 }, /* 97 */
+ { 69, 2, 196, 0, 0, 18, 0, 0, 27, CT_STEEL , 0 }, /* 98 */
+ { 70, 2, 255, 0, 0, 30, 0, 0, 27, CT_VALUABLES , 0 }, /* 99 */
+ { 71, 2, 191, 0, 0, 22, 0, 0, 32, CT_FOOD , 0 }, /* 100 */
+ { 72, 2, 196, 0, 0, 18, 0, 0, 27, CT_PAPER , 0 }, /* 101 */
+ { 73, 2, 179, 0, 0, 19, 0, 0, 37, CT_COPPER_ORE , 0 }, /* 102 */
+ { 47, 2, 199, 0, 0, 25, 0, 0, 32, CT_WATER , 0 }, /* 103 */
+ { 48, 2, 182, 0, 0, 18, 0, 0, 32, CT_FRUIT , 0 }, /* 104 */
+ { 49, 2, 185, 0, 0, 19, 0, 0, 28, CT_RUBBER , 0 }, /* 105 */
+ { 50, 2, 176, 0, 0, 19, 0, 0, 37, CT_SUGAR , 0 }, /* 106 */
+ { 51, 2, 178, 0, 0, 20, 0, 0, 37, CT_COTTON_CANDY , 0 }, /* 107 */
+ { 52, 2, 192, 0, 0, 20, 0, 0, 37, CT_TOFFEE , 0 }, /* 108 */
+ { 53, 2, 190, 0, 0, 21, 0, 0, 27, CT_BUBBLES , 0 }, /* 109 */
+ { 54, 2, 182, 0, 0, 24, 0, 0, 32, CT_COLA , 0 }, /* 110 */
+ { 55, 2, 181, 0, 0, 21, 0, 0, 32, CT_CANDY , 0 }, /* 111 */
+ { 56, 2, 183, 0, 0, 21, 0, 0, 27, CT_TOYS , 0 }, /* 112 */
+ { 57, 2, 196, 0, 0, 18, 0, 0, 29, CT_BATTERIES , 0 }, /* 113 */
+ { 58, 2, 193, 0, 0, 18, 0, 0, 32, CT_FIZZY_DRINKS , 0 }, /* 114 */
+ { 59, 2, 191, 0, 0, 18, 0, 0, 37, CT_PLASTIC , 0 }, /* 115 */
};
ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES] = {
diff --git a/train_cmd.c b/train_cmd.c
index 185464b6f..a718fd3dd 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -1326,15 +1326,17 @@ int32 CmdRefitRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (v->cargo_cap != 0) {
RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
- uint16 amount;
- CargoID temp_cid = v->cargo_type;
-
- /* Check the 'refit capacity' callback */
- v->cargo_type = new_cid;
- amount = GetCallBackResult(CB_REFIT_CAP, v->engine_type, v);
- v->cargo_type = temp_cid;
+ uint16 amount = CALLBACK_FAILED;
+
+ if (HASBIT(rvi->callbackmask, CBM_REFIT_CAP)) {
+ /* Check the 'refit capacity' callback */
+ CargoID temp_cid = v->cargo_type;
+ v->cargo_type = new_cid;
+ amount = GetCallBackResult(CBID_REFIT_CAP, v->engine_type, v);
+ v->cargo_type = temp_cid;
+ }
- if (amount == CALLBACK_FAILED) { // callback failed, use default
+ if (amount == CALLBACK_FAILED) { // callback failed or not used, use default
CargoID old_cid = rvi->cargo_type;
/* normally, the capacity depends on the cargo type, a rail vehicle
* can carry twice as much mail/goods as normal cargo,