summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-01-30 11:53:35 +0000
committerbelugas <belugas@openttd.org>2007-01-30 11:53:35 +0000
commit0c45071bb018aab652f81b594cffa5b2c4ded0d4 (patch)
treed001f734f6111d6fe12abd4a122d09903325335c /src
parente3b63e6d8327b800a2d318d8f30ef72f3b39f33e (diff)
downloadopenttd-0c45071bb018aab652f81b594cffa5b2c4ded0d4.tar.xz
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
-Codechange: Add and use RAILVEH_SINGLEHEAD when railveh_type is set to 0, which was implicit before. -Cleanup: Remove some extraneous parenthesis.
Diffstat (limited to 'src')
-rw-r--r--src/ai/default/default.cpp6
-rw-r--r--src/autoreplace_gui.cpp2
-rw-r--r--src/build_vehicle_gui.cpp24
-rw-r--r--src/engine.cpp2
-rw-r--r--src/engine.h13
-rw-r--r--src/engine_gui.cpp2
-rw-r--r--src/newgrf.cpp19
-rw-r--r--src/players.cpp2
-rw-r--r--src/table/engines.h60
-rw-r--r--src/train_cmd.cpp35
-rw-r--r--src/train_gui.cpp4
-rw-r--r--src/vehicle.cpp6
12 files changed, 89 insertions, 86 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index ed805fb43..0d43ff11f 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -143,8 +143,8 @@ static EngineID AiChooseTrainToBuild(RailType railtype, int32 money, byte flag,
const Engine* e = GetEngine(i);
if (!IsCompatibleRail(rvi->railtype, railtype) ||
- rvi->flags & RVI_WAGON ||
- (rvi->flags & RVI_MULTIHEAD && flag & 1) ||
+ rvi->railveh_type == RAILVEH_WAGON ||
+ (rvi->railveh_type == RAILVEH_MULTIHEAD && flag & 1) ||
!HASBIT(e->player_avail, _current_player) ||
e->reliability < 0x8A3D) {
continue;
@@ -2366,7 +2366,7 @@ static EngineID AiFindBestWagon(CargoID cargo, RailType railtype)
const Engine* e = GetEngine(i);
if (!IsCompatibleRail(rvi->railtype, railtype) ||
- !(rvi->flags & RVI_WAGON) ||
+ rvi->railveh_type != RAILVEH_WAGON ||
!HASBIT(e->player_avail, _current_player)) {
continue;
}
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index 64118e6e9..372052f46 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -63,7 +63,7 @@ static void train_engine_drawing_loop(int *x, int *y, int *pos, int *sel, Engine
if (!(ENGINE_AVAILABLE && show_outdated && RailVehInfo(i)->power && IsCompatibleRail(rvi->railtype, railtype))) {
if ((!IsCompatibleRail(rvi->railtype, railtype) && show_compatible)
|| (rvi->railtype != railtype && !show_compatible)
- || !(rvi->flags & RVI_WAGON) != is_engine ||
+ || (rvi->railveh_type != RAILVEH_WAGON) != is_engine ||
!HASBIT(e->player_avail, _local_player))
continue;
#if 0
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 7be31791b..3cee1a0ef 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -187,8 +187,8 @@ static int CDECL TrainEnginePowerSorter(const void *a, const void *b)
const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a);
const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b);
- int va = rvi_a->power << (rvi_a->flags & RVI_MULTIHEAD ? 1 : 0);
- int vb = rvi_b->power << (rvi_b->flags & RVI_MULTIHEAD ? 1 : 0);
+ int va = rvi_a->power << (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
+ int vb = rvi_b->power << (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
int r = va - vb;
return _internal_sort_order ? -r : r;
@@ -199,8 +199,8 @@ static int CDECL TrainEngineRunningCostSorter(const void *a, const void *b)
const RailVehicleInfo *rvi_a = RailVehInfo(*(const EngineID*)a);
const RailVehicleInfo *rvi_b = RailVehInfo(*(const EngineID*)b);
- int va = rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class] * (rvi_a->flags & RVI_MULTIHEAD ? 2 : 1);
- int vb = rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class] * (rvi_b->flags & RVI_MULTIHEAD ? 2 : 1);
+ int va = rvi_a->running_cost_base * _price.running_rail[rvi_a->running_cost_class] * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
+ int vb = rvi_b->running_cost_base * _price.running_rail[rvi_b->running_cost_class] * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
int r = va - vb;
return _internal_sort_order ? -r : r;
@@ -228,8 +228,8 @@ static int CDECL TrainEnginesThenWagonsSorter(const void *a, const void *b)
{
EngineID va = *(const EngineID*)a;
EngineID vb = *(const EngineID*)b;
- int val_a = ((RailVehInfo(va)->flags & RVI_WAGON) != 0) ? 1 : 0;
- int val_b = ((RailVehInfo(vb)->flags & RVI_WAGON) != 0) ? 1 : 0;
+ int val_a = (RailVehInfo(va)->railveh_type != RAILVEH_WAGON ? 1 : 0);
+ int val_b = (RailVehInfo(vb)->railveh_type != RAILVEH_WAGON ? 1 : 0);
int r = val_a - val_b;
/* Use EngineID to sort instead since we want consistent sorting */
@@ -388,7 +388,7 @@ static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const
/* Draw locomotive specific details */
static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi)
{
- int multihead = (rvi->flags&RVI_MULTIHEAD?1:0);
+ int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
/* Purchase Cost - Engine weight */
SetDParam(0, rvi->base_cost * (_price.build_railvehicle >> 3) >> 5);
@@ -529,7 +529,7 @@ void DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number)
refitable = (EngInfo(engine_number)->refit_mask != 0) && (rvi->capacity > 0);
- if (rvi->flags & RVI_WAGON) {
+ if (rvi->railveh_type == RAILVEH_WAGON) {
y = DrawRailWagonPurchaseInfo(x, y, engine_number, rvi);
} else {
y = DrawRailEnginePurchaseInfo(x, y, engine_number, rvi);
@@ -540,7 +540,7 @@ void DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number)
SetDParam(0, CT_INVALID);
SetDParam(2, STR_EMPTY);
} else {
- int multihead = (rvi->flags & RVI_MULTIHEAD ? 1 : 0);
+ int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
SetDParam(0, rvi->cargo_type);
SetDParam(1, (rvi->capacity * (CountArticulatedParts(engine_number) + 1)) << multihead);
@@ -566,7 +566,7 @@ void DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number)
}
/* Draw details, that applies to all types except rail wagons */
- if (e->type != VEH_Train || !(RailVehInfo(engine_number)->flags & RVI_WAGON)) {
+ if (e->type != VEH_Train || RailVehInfo(engine_number)->railveh_type != RAILVEH_WAGON) {
/* Design date - Life length */
SetDParam(0, ymd.year);
SetDParam(1, e->lifelength);
@@ -607,7 +607,7 @@ static void GenerateBuildTrainList(Window *w)
if (!IsEngineBuildable(eid, VEH_Train, _local_player)) continue;
EngList_Add(&bv->eng_list, eid);
- if ((rvi->flags & RVI_WAGON) == 0) {
+ if (rvi->railveh_type != RAILVEH_WAGON) {
num_engines++;
} else {
num_wagons++;
@@ -826,7 +826,7 @@ static void BuildVehicleClickEvent(Window *w, WindowEvent *e)
if (sel_eng != INVALID_ENGINE) {
switch (bv->vehicle_type) {
case VEH_Train:
- DoCommandP(w->window_number, sel_eng, 0, (RailVehInfo(sel_eng)->flags & RVI_WAGON) ? CcBuildWagon : CcBuildLoco,
+ DoCommandP(w->window_number, sel_eng, 0, (RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? CcBuildWagon : CcBuildLoco,
CMD_BUILD_RAIL_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE));
break;
case VEH_Road:
diff --git a/src/engine.cpp b/src/engine.cpp
index ec4c27ec2..c23909f50 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -285,7 +285,7 @@ int32 CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
// Determine if an engine type is a wagon (and not a loco)
static bool IsWagon(EngineID index)
{
- return index < NUM_TRAIN_ENGINES && RailVehInfo(index)->flags & RVI_WAGON;
+ return index < NUM_TRAIN_ENGINES && RailVehInfo(index)->railveh_type == RAILVEH_WAGON;
}
static void NewVehicleAvailable(Engine *e)
diff --git a/src/engine.h b/src/engine.h
index 375fe1d10..af74bcbab 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -9,9 +9,15 @@
#include "rail.h"
#include "sound.h"
+enum RailVehicleTypes {
+ RAILVEH_SINGLEHEAD,
+ RAILVEH_MULTIHEAD,
+ RAILVEH_WAGON,
+};
+
typedef struct RailVehicleInfo {
byte image_index;
- byte flags; /* 1=multihead engine, 2=wagon */
+ RailVehicleTypes railveh_type;
byte base_cost;
RailTypeByte railtype;
uint16 max_speed;
@@ -118,11 +124,6 @@ enum {
};
enum {
- RVI_MULTIHEAD = 1,
- RVI_WAGON = 2,
-};
-
-enum {
NUM_VEHICLE_TYPES = 6
};
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index 2f8307313..6b15c6541 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -122,7 +122,7 @@ void ShowEnginePreviewWindow(EngineID engine)
static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw)
{
const RailVehicleInfo *rvi = RailVehInfo(engine);
- uint multihead = (rvi->flags & RVI_MULTIHEAD) ? 1 : 0;
+ uint multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD) ? 1 : 0;
SetDParam(0, (_price.build_railvehicle >> 3) * rvi->base_cost >> 5);
SetDParam(2, rvi->max_speed);
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index b8fda928d..b8a5b8073 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -215,10 +215,10 @@ static void dewagonize(int condition, int engine)
if (condition != 0) {
ei->unk2 &= ~0x80;
- rvi->flags &= ~2;
+ rvi->railveh_type = RAILVEH_SINGLEHEAD;
} else {
ei->unk2 |= 0x80;
- rvi->flags |= 2;
+ rvi->railveh_type = RAILVEH_WAGON;
}
}
@@ -265,7 +265,7 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
FOR_EACH_OBJECT {
uint16 power = grf_load_word(&buf);
- if (rvi[i].flags & RVI_MULTIHEAD) power /= 2;
+ if (rvi[i].railveh_type == RAILVEH_MULTIHEAD) power /= 2;
rvi[i].power = power;
dewagonize(power, engine + i);
@@ -276,7 +276,7 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
FOR_EACH_OBJECT {
uint8 runcostfact = grf_load_byte(&buf);
- if (rvi[i].flags & RVI_MULTIHEAD) runcostfact /= 2;
+ if (rvi[i].railveh_type == RAILVEH_MULTIHEAD) runcostfact /= 2;
rvi[i].running_cost_base = runcostfact;
}
@@ -315,19 +315,19 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
uint8 dual = grf_load_byte(&buf);
if (dual != 0) {
- if (!(rvi[i].flags & RVI_MULTIHEAD)) {
+ if (rvi[i].railveh_type != RAILVEH_MULTIHEAD) {
// adjust power and running cost if needed
rvi[i].power /= 2;
rvi[i].running_cost_base /= 2;
}
- rvi[i].flags |= RVI_MULTIHEAD;
+ rvi[i].railveh_type = RAILVEH_MULTIHEAD;
} else {
- if (rvi[i].flags & RVI_MULTIHEAD) {
+ if (rvi[i].railveh_type == RAILVEH_MULTIHEAD) {
// adjust power and running cost if needed
rvi[i].power *= 2;
rvi[i].running_cost_base *= 2;
}
- rvi[i].flags &= ~RVI_MULTIHEAD;
+ rvi[i].railveh_type = RAILVEH_SINGLEHEAD;
}
}
break;
@@ -3588,7 +3588,7 @@ static void CalculateRefitMasks(void)
if (xor_mask == 0 && (
GetEngine(engine)->type != VEH_Train || (
RailVehInfo(engine)->capacity != 0 &&
- !(RailVehInfo(engine)->flags & RVI_WAGON)
+ RailVehInfo(engine)->railveh_type != RAILVEH_WAGON
)
)) {
xor_mask = _default_refitmasks[GetEngine(engine)->type - VEH_Train];
@@ -3801,3 +3801,4 @@ void LoadNewGRF(uint load_index, uint file_index)
+
diff --git a/src/players.cpp b/src/players.cpp
index b306a0632..02d30fee8 100644
--- a/src/players.cpp
+++ b/src/players.cpp
@@ -656,7 +656,7 @@ byte GetPlayerRailtypes(PlayerID p)
(HASBIT(e->player_avail, p) || _date >= e->intro_date + 365)) {
const RailVehicleInfo *rvi = RailVehInfo(i);
- if (!(rvi->flags & RVI_WAGON)) {
+ if (rvi->railveh_type != RAILVEH_WAGON) {
assert(rvi->railtype < RAILTYPE_END);
SETBIT(rt, rvi->railtype);
}
diff --git a/src/table/engines.h b/src/table/engines.h
index 4ca84508a..67ed15d3f 100644
--- a/src/table/engines.h
+++ b/src/table/engines.h
@@ -329,8 +329,9 @@ const EngineInfo orig_engine_info[] = {
* Tractive effort coefficient by default is the same as TTDPatch, 0.30*256=76
*/
#define RVI(a, b, c, d, e, f, g, h, i, j, k, l) { a, b, c, {l}, d, e, f, g, h, h, i, j, k, 0, 0, 0, 0, 76, 0 }
-#define M RVI_MULTIHEAD
-#define W RVI_WAGON
+#define M RAILVEH_MULTIHEAD
+#define W RAILVEH_WAGON
+#define G RAILVEH_SINGLEHEAD
#define S 0
#define D 1
#define E 2
@@ -346,31 +347,31 @@ const RailVehicleInfo orig_rail_vehicle_info[NUM_TRAIN_ENGINES] = {
// | | base_cost | weight | | capacity
// | | | | | | | | | cargo_type
// | | | | | | | | | |
- RVI( 2, 0, 7, 64, 300, 47, 50, S, 0, 0 , 1, R), // 0
- RVI(19, 0, 8, 80, 600, 65, 65, D, 0, 0 , 4, R), // 1
- RVI( 2, 0, 10, 72, 400, 85, 90, S, 0, 0 , 7, R), // 2
- RVI( 0, 0, 15, 96, 900, 130, 130, S, 0, 0 , 19, R), // 3
- RVI( 1, 0, 19, 112, 1000, 140, 145, S, 0, 0 , 20, R), // 4
- RVI(12, 0, 16, 120, 1400, 95, 125, D, 0, 0 , 30, R), // 5
- RVI(14, 0, 20, 152, 2000, 120, 135, D, 0, 0 , 31, R), // 6
- RVI( 3, 0, 14, 88, 1100, 145, 130, S, 0, 0 , 19, R), // 7
- RVI( 0, 0, 13, 112, 1000, 131, 120, S, 0, 0 , 20, R), // 8
- RVI( 1, 0, 19, 128, 1200, 162, 140, S, 0, 0 , 21, R), // 9
- RVI( 0, 0, 22, 144, 1600, 170, 130, S, 0, 0 , 22, R), // 10
+ RVI( 2, G, 7, 64, 300, 47, 50, S, 0, 0 , 1, R), // 0
+ RVI(19, G, 8, 80, 600, 65, 65, D, 0, 0 , 4, R), // 1
+ RVI( 2, G, 10, 72, 400, 85, 90, S, 0, 0 , 7, R), // 2
+ RVI( 0, G, 15, 96, 900, 130, 130, S, 0, 0 , 19, R), // 3
+ RVI( 1, G, 19, 112, 1000, 140, 145, S, 0, 0 , 20, R), // 4
+ RVI(12, G, 16, 120, 1400, 95, 125, D, 0, 0 , 30, R), // 5
+ RVI(14, G, 20, 152, 2000, 120, 135, D, 0, 0 , 31, R), // 6
+ RVI( 3, G, 14, 88, 1100, 145, 130, S, 0, 0 , 19, R), // 7
+ RVI( 0, G, 13, 112, 1000, 131, 120, S, 0, 0 , 20, R), // 8
+ RVI( 1, G, 19, 128, 1200, 162, 140, S, 0, 0 , 21, R), // 9
+ RVI( 0, G, 22, 144, 1600, 170, 130, S, 0, 0 , 22, R), // 10
RVI( 8, M, 11, 112, 600/2,32/2, 85/2, D, 38, CT_PASSENGERS , 10, R), // 11
RVI(10, M, 14, 120, 700/2,38/2, 70/2, D, 40, CT_PASSENGERS , 11, R), // 12
- RVI( 4, 0, 15, 128, 1250, 72, 95, D, 0, 0 , 30, R), // 13
- RVI( 5, 0, 17, 144, 1750, 101, 120, D, 0, 0 , 31, R), // 14
- RVI( 4, 0, 18, 160, 2580, 112, 140, D, 0, 0 , 32, R), // 15
- RVI(14, 0, 23, 96, 4000, 150, 135, D, 0, 0 , 33, R), // 16
- RVI(12, 0, 16, 112, 2400, 120, 105, D, 0, 0 , 34, R), // 17
- RVI(13, 0, 30, 112, 6600, 207, 155, D, 0, 0 , 35, R), // 18
- RVI(15, 0, 18, 104, 1500, 110, 105, D, 0, 0 , 29, R), // 19
+ RVI( 4, G, 15, 128, 1250, 72, 95, D, 0, 0 , 30, R), // 13
+ RVI( 5, G, 17, 144, 1750, 101, 120, D, 0, 0 , 31, R), // 14
+ RVI( 4, G, 18, 160, 2580, 112, 140, D, 0, 0 , 32, R), // 15
+ RVI(14, G, 23, 96, 4000, 150, 135, D, 0, 0 , 33, R), // 16
+ RVI(12, G, 16, 112, 2400, 120, 105, D, 0, 0 , 34, R), // 17
+ RVI(13, G, 30, 112, 6600, 207, 155, D, 0, 0 , 35, R), // 18
+ RVI(15, G, 18, 104, 1500, 110, 105, D, 0, 0 , 29, R), // 19
RVI(16, M, 35, 160, 3500/2,95/2, 205/2, D, 0, 0 , 45, R), // 20
- RVI(18, 0, 21, 104, 2200, 120, 145, D, 0, 0 , 32, R), // 21
+ RVI(18, G, 21, 104, 2200, 120, 145, D, 0, 0 , 32, R), // 21
RVI( 6, M, 20, 200, 4500/2,70/2, 190/2, D, 4, CT_MAIL , 50, R), // 22
- RVI(20, 0, 26, 160, 3600, 84, 180, E, 0, 0 , 40, C), // 23
- RVI(20, 0, 30, 176, 5000, 82, 205, E, 0, 0 , 41, C), // 24
+ RVI(20, G, 26, 160, 3600, 84, 180, E, 0, 0 , 40, C), // 23
+ RVI(20, G, 30, 176, 5000, 82, 205, E, 0, 0 , 41, C), // 24
RVI(21, M, 40, 240, 7000/2,90/2, 240/2, E, 0, 0 , 51, C), // 25
RVI(23, M, 43, 264, 8000/2,95/2, 250/2, E, 0, 0 , 52, C), // 26
RVI(33, W, 247, 0, 0, 25, 0, 0, 40, CT_PASSENGERS , 0, R), // 27
@@ -400,9 +401,9 @@ const RailVehicleInfo orig_rail_vehicle_info[NUM_TRAIN_ENGINES] = {
RVI(57, W, 196, 0, 0, 18, 0, 0, 22, CT_BATTERIES , 0, R), // 51
RVI(58, W, 193, 0, 0, 18, 0, 0, 25, CT_FIZZY_DRINKS, 0, R), // 52
RVI(59, W, 191, 0, 0, 18, 0, 0, 30, CT_PLASTIC , 0, R), // 53
- RVI(25, 0, 52, 304, 9000, 95, 230, E, 0, 0 , 60, O), // 54
+ RVI(25, G, 52, 304, 9000, 95, 230, E, 0, 0 , 60, O), // 54
RVI(26, M, 60, 336, 10000/2,85/2, 240/2, E, 25, CT_PASSENGERS , 62, O), // 55
- RVI(26, 0, 53, 320, 5000, 95, 230, E, 0, 0 , 63, O), // 56
+ RVI(26, G, 53, 320, 5000, 95, 230, E, 0, 0 , 63, O), // 56
RVI(60, W, 247, 0, 0, 25, 0, 0, 45, CT_PASSENGERS , 0, O), // 57
RVI(62, W, 228, 0, 0, 21, 0, 0, 35, CT_MAIL , 0, O), // 58
RVI(61, W, 176, 0, 0, 18, 0, 0, 35, CT_COAL , 0, O), // 59
@@ -430,11 +431,11 @@ const RailVehicleInfo orig_rail_vehicle_info[NUM_TRAIN_ENGINES] = {
RVI(57, W, 196, 0, 0, 18, 0, 0, 27, CT_BATTERIES , 0, O), // 81
RVI(58, W, 193, 0, 0, 18, 0, 0, 30, CT_FIZZY_DRINKS, 0, O), // 82
RVI(59, W, 191, 0, 0, 18, 0, 0, 35, CT_PLASTIC , 0, O), // 83
- RVI(28, 0, 70, 400, 10000, 105, 250, E, 0, 0 , 70, L), // 84
- RVI(29, 0, 74, 448, 12000, 120, 253, E, 0, 0 , 71, L), // 85
- RVI(30, 0, 82, 480, 15000, 130, 254, E, 0, 0 , 72, L), // 86
+ RVI(28, G, 70, 400, 10000, 105, 250, E, 0, 0 , 70, L), // 84
+ RVI(29, G, 74, 448, 12000, 120, 253, E, 0, 0 , 71, L), // 85
+ RVI(30, G, 82, 480, 15000, 130, 254, E, 0, 0 , 72, L), // 86
RVI(31, M, 95, 640, 20000/2,150/2,255/2, E, 0, 0 , 73, L), // 87
- RVI(28, 0, 70, 480, 10000, 120, 250, E, 0, 0 , 74, L), // 88
+ RVI(28, G, 70, 480, 10000, 120, 250, E, 0, 0 , 74, L), // 88
RVI(60, W, 247, 0, 0, 25, 0, 0, 47, CT_PASSENGERS , 0, L), // 89
RVI(62, W, 228, 0, 0, 21, 0, 0, 37, CT_MAIL , 0, L), // 90
RVI(61, W, 176, 0, 0, 18, 0, 0, 37, CT_COAL , 0, L), // 91
@@ -470,6 +471,7 @@ const RailVehicleInfo orig_rail_vehicle_info[NUM_TRAIN_ENGINES] = {
#undef E
#undef D
#undef S
+#undef G
#undef W
#undef M
#undef RVI
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 78481f3a2..1b6c5c80e 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -194,11 +194,10 @@ void TrainConsistChanged(Vehicle* v)
if (callback != CALLBACK_FAILED) u->u.rail.cached_vis_effect = callback;
}
- if ((rvi_v->pow_wag_power != 0) && (rvi_u->flags & RVI_WAGON) && UsesWagonOverride(u)) {
- if (u->u.rail.cached_vis_effect < 0x40) {
- /* wagon is powered */
- SETBIT(u->u.rail.flags, VRF_POWEREDWAGON); // cache 'powered' status
- }
+ if (rvi_v->pow_wag_power != 0 && rvi_u->railveh_type == RAILVEH_WAGON &&
+ UsesWagonOverride(u) && (u->u.rail.cached_vis_effect < 0x40)) {
+ /* wagon is powered */
+ SETBIT(u->u.rail.flags, VRF_POWEREDWAGON); // cache 'powered' status
}
/* Do not count powered wagons for the compatible railtypes, as wagons always
@@ -215,9 +214,9 @@ void TrainConsistChanged(Vehicle* v)
}
// max speed is the minimum of the speed limits of all vehicles in the consist
- if (!(rvi_u->flags & RVI_WAGON) || _patches.wagon_speed_limits)
- if (rvi_u->max_speed != 0 && !UsesWagonOverride(u))
- max_speed = min(rvi_u->max_speed, max_speed);
+ if ((rvi_u->railveh_type != RAILVEH_WAGON || _patches.wagon_speed_limits) &&
+ rvi_u->max_speed != 0 && !UsesWagonOverride(u))
+ max_speed = min(rvi_u->max_speed, max_speed);
}
// check the vehicle length (callback)
@@ -490,7 +489,7 @@ void DrawTrainEngine(int x, int y, EngineID engine, SpriteID pal)
image = (6 & _engine_sprite_and[img]) + _engine_sprite_base[img];
}
- if (rvi->flags & RVI_MULTIHEAD) {
+ if (rvi->railveh_type == RAILVEH_MULTIHEAD) {
DrawSprite(image, pal, x - 14, y);
x += 15;
image = 0;
@@ -765,11 +764,11 @@ int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* We need to see if the engine got power on the tile to avoid eletric engines in non-electric depots */
if (!HasPowerOnRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR;
- if (rvi->flags & RVI_WAGON) return CmdBuildRailWagon(p1, tile, flags);
+ if (rvi->railveh_type == RAILVEH_WAGON) return CmdBuildRailWagon(p1, tile, flags);
value = EstimateTrainCost(rvi);
- num_vehicles = (rvi->flags & RVI_MULTIHEAD) ? 2 : 1;
+ num_vehicles = (rvi->railveh_type == RAILVEH_MULTIHEAD) ? 2 : 1;
num_vehicles += CountArticulatedParts(p1);
if (!(flags & DC_QUERY_COST)) {
@@ -834,7 +833,7 @@ int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
VehiclePositionChanged(v);
- if (rvi->flags & RVI_MULTIHEAD) {
+ if (rvi->railveh_type == RAILVEH_MULTIHEAD) {
SetMultiheaded(v);
AddRearEngineToMultiheadedTrain(vl[0], vl[1], true);
/* Now we need to link the front and rear engines together
@@ -1357,7 +1356,7 @@ int32 CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (v == first && IsFrontEngine(first)) {
DeleteWindowById(WC_VEHICLE_VIEW, first->index);
}
- if (IsLocalPlayer() && (p1 == 1 || !(RailVehInfo(v->engine_type)->flags & RVI_WAGON))) {
+ if (IsLocalPlayer() && (p1 == 1 || RailVehInfo(v->engine_type)->railveh_type != RAILVEH_WAGON)) {
InvalidateWindow(WC_REPLACE_VEHICLE, VEH_Train);
}
InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
@@ -2090,7 +2089,7 @@ static void HandleLocomotiveSmokeCloud(const Vehicle* v)
int x, y;
// no smoke?
- if ((rvi->flags & RVI_WAGON && effect_type == 0) ||
+ if ((rvi->railveh_type == RAILVEH_WAGON && effect_type == 0) ||
disable_effect ||
rvi->railtype > RAILTYPE_ELECTRIC ||
v->vehstatus & VS_HIDDEN) {
@@ -3752,7 +3751,7 @@ void ConvertOldMultiheadToNew(void)
CLRBIT(u->subtype, 7);
switch (u->subtype) {
case 0: /* TS_Front_Engine */
- if (rvi->flags & RVI_MULTIHEAD) SetMultiheaded(u);
+ if (rvi->railveh_type == RAILVEH_MULTIHEAD) SetMultiheaded(u);
SetFrontEngine(u);
SetTrainEngine(u);
break;
@@ -3764,17 +3763,17 @@ void ConvertOldMultiheadToNew(void)
case 2: /* TS_Not_First */
u->subtype = 0;
- if (rvi->flags & RVI_WAGON) {
+ if (rvi->railveh_type == RAILVEH_WAGON) {
// normal wagon
SetTrainWagon(u);
break;
}
- if (rvi->flags & RVI_MULTIHEAD && rvi->image_index == u->spritenum - 1) {
+ if (rvi->railveh_type == RAILVEH_MULTIHEAD && rvi->image_index == u->spritenum - 1) {
// rear end of a multiheaded engine
SetMultiheaded(u);
break;
}
- if (rvi->flags & RVI_MULTIHEAD) SetMultiheaded(u);
+ if (rvi->railveh_type == RAILVEH_MULTIHEAD) SetMultiheaded(u);
SetTrainEngine(u);
break;
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index 874b9cb55..e5ccddd8a 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -158,7 +158,7 @@ static void TrainViewWndProc(Window *w, WindowEvent *e)
/* See if any vehicle can be refitted */
for (u = v; u != NULL; u = u->next) {
if (EngInfo(u->engine_type)->refit_mask != 0 ||
- (!(RailVehInfo(v->engine_type)->flags & RVI_WAGON) && v->cargo_cap != 0)) {
+ (RailVehInfo(v->engine_type)->railveh_type != RAILVEH_WAGON && v->cargo_cap != 0)) {
EnableWindowWidget(w, 12);
/* We have a refittable carriage, bail out */
break;
@@ -341,7 +341,7 @@ static void TrainDetailsCargoTab(const Vehicle *v, int x, int y)
static void TrainDetailsInfoTab(const Vehicle *v, int x, int y)
{
- if (RailVehInfo(v->engine_type)->flags & RVI_WAGON) {
+ if (RailVehInfo(v->engine_type)->railveh_type == RAILVEH_WAGON) {
SetDParam(0, GetCustomEngineName(v->engine_type));
SetDParam(1, v->value);
DrawString(x, y, STR_882D_VALUE, 0x10);
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index ab45f792f..cdaea63aa 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -787,7 +787,7 @@ int32 GetRefitCost(EngineID engine_type)
case VEH_Road: base_cost = _price.roadveh_base; break;
case VEH_Aircraft: base_cost = _price.aircraft_base; break;
case VEH_Train:
- base_cost = 2 * ((RailVehInfo(engine_type)->flags & RVI_WAGON) ?
+ base_cost = 2 * ((RailVehInfo(engine_type)->railveh_type == RAILVEH_WAGON) ?
_price.build_railwagon : _price.build_railvehicle);
break;
default: NOT_REACHED(); break;
@@ -2243,7 +2243,7 @@ static int32 MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs)
while (v->u.rail.cached_total_length > old_total_length) {
// the train is too long. We will remove cars one by one from the start of the train until it's short enough
- while (w != NULL && !(RailVehInfo(w->engine_type)->flags&RVI_WAGON) ) {
+ while (w != NULL && RailVehInfo(w->engine_type)->railveh_type != RAILVEH_WAGON) {
w = GetNextVehicle(w);
}
if (w == NULL) {
@@ -2850,7 +2850,7 @@ static SpriteID GetEngineColourMap(EngineID engine_type, PlayerID player, Engine
case RAILTYPE_ELECTRIC:
{
if (cargo_type == CT_INVALID) cargo_type = rvi->cargo_type;
- if (rvi->flags & RVI_WAGON) {
+ if (rvi->railveh_type == RAILVEH_WAGON) {
if (cargo_type == CT_PASSENGERS || cargo_type == CT_MAIL || cargo_type == CT_VALUABLES) {
if (parent_engine_type == INVALID_ENGINE) {
scheme = LS_PASSENGER_WAGON_STEAM;