summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ai.c10
-rw-r--r--ai_build.c2
-rw-r--r--aircraft_cmd.c4
-rw-r--r--aircraft_gui.c7
-rw-r--r--engine.c6
-rw-r--r--engine.h2
-rw-r--r--engine_gui.c2
-rw-r--r--oldloader.c4
-rw-r--r--roadveh_cmd.c2
-rw-r--r--roadveh_gui.c7
-rw-r--r--ship_cmd.c2
-rw-r--r--ship_gui.c7
-rw-r--r--train_cmd.c12
-rw-r--r--train_gui.c6
-rw-r--r--vehicle.c12
-rw-r--r--vehicle_gui.c28
16 files changed, 59 insertions, 54 deletions
diff --git a/ai.c b/ai.c
index 54814a839..4f0b3ea4f 100644
--- a/ai.c
+++ b/ai.c
@@ -104,7 +104,7 @@ static void AiStateVehLoop(Player *p)
/* not reliable? */
if ((v->age != 0 &&
- _engines[v->engine_type].reliability < 35389) ||
+ GetEngine(v->engine_type)->reliability < 35389) ||
v->age >= v->max_age) {
p->ai.state = AIS_VEH_CHECK_REPLACE_VEHICLE;
p->ai.cur_veh = v;
@@ -126,7 +126,7 @@ static int AiChooseTrainToBuild(byte railtype, int32 money, byte flag, TileIndex
for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
const RailVehicleInfo *rvi = RailVehInfo(i);
- Engine *e = DEREF_ENGINE(i);
+ const Engine* e = GetEngine(i);
if (e->railtype != railtype || rvi->flags & RVI_WAGON
|| !HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D)
@@ -151,7 +151,8 @@ static int AiChooseRoadVehToBuild(byte cargo, int32 money, TileIndex tile)
int i = _cargoc.ai_roadveh_start[cargo];
int end = i + _cargoc.ai_roadveh_count[cargo];
- Engine *e = &_engines[i];
+ const Engine* e = GetEngine(i);
+
do {
if (!HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D)
continue;
@@ -174,7 +175,8 @@ static int AiChooseAircraftToBuild(int32 money, byte flag)
int i = AIRCRAFT_ENGINES_INDEX;
int end = i + NUM_AIRCRAFT_ENGINES;
- Engine *e = &_engines[i];
+ const Engine* e = GetEngine(i);
+
do {
if (!HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D)
continue;
diff --git a/ai_build.c b/ai_build.c
index 32d31331f..84cc80f22 100644
--- a/ai_build.c
+++ b/ai_build.c
@@ -221,7 +221,7 @@ int AiNew_PickVehicle(Player *p) {
for (i=start+count-1;i>=start;i--) {
// Is it availiable?
// Also, check if the reliability of the vehicle is above the AI_VEHICLE_MIN_RELIABILTY
- if (!HASBIT(_engines[i].player_avail, _current_player) || _engines[i].reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue;
+ if (!HASBIT(GetEngine(i)->player_avail, _current_player) || GetEngine(i)->reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue;
// Can we build it?
ret = DoCommandByTile(0, i, 0, DC_QUERY_COST, CMD_BUILD_ROAD_VEH);
if (!CmdFailed(ret)) break;
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 6ca106e3a..f17a36216 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -256,7 +256,7 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
u->subtype = 4;
- e = &_engines[p1];
+ e = GetEngine(p1);
v->reliability = e->reliability;
v->reliability_spd_dec = e->reliability_spd_dec;
v->max_age = e->lifelength * 366;
@@ -1470,7 +1470,7 @@ static void AircraftEventHandler_AtTerminal(Vehicle *v, const AirportFTAClass *A
// an exerpt of ServiceAircraft, without the invisibility stuff
v->date_of_last_service = _date;
v->breakdowns_since_last_service = 0;
- v->reliability = _engines[v->engine_type].reliability;
+ v->reliability = GetEngine(v->engine_type)->reliability;
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
}
}
diff --git a/aircraft_gui.c b/aircraft_gui.c
index e22102482..3515d0c24 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -24,7 +24,7 @@
void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number)
{
const AircraftVehicleInfo *avi = AircraftVehInfo(engine_number);
- Engine *e = &_engines[engine_number];
+ const Engine* e = GetEngine(engine_number);
YearMonthDay ymd;
ConvertDayToYMD(&ymd, e->intro_date);
@@ -97,7 +97,8 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
{
int count = 0;
int num = NUM_AIRCRAFT_ENGINES;
- Engine *e = &_engines[AIRCRAFT_ENGINES_INDEX];
+ const Engine* e = GetEngine(AIRCRAFT_ENGINES_INDEX);
+
do {
if (HASBIT(e->player_avail, _local_player))
count++;
@@ -109,7 +110,7 @@ static void NewAircraftWndProc(Window *w, WindowEvent *e)
{
int num = NUM_AIRCRAFT_ENGINES;
- Engine *e = &_engines[AIRCRAFT_ENGINES_INDEX];
+ const Engine* e = GetEngine(AIRCRAFT_ENGINES_INDEX);
int x = 2;
int y = 15;
int sel = WP(w,buildtrain_d).sel_index;
diff --git a/engine.c b/engine.c
index a055acf60..58a22b21d 100644
--- a/engine.c
+++ b/engine.c
@@ -839,7 +839,7 @@ int32 CmdWantEnginePreview(int x, int y, uint32 flags, uint32 p1, uint32 p2)
Engine *e;
if (!IsEngineIndex(p1)) return CMD_ERROR;
- e = DEREF_ENGINE(p1);
+ e = GetEngine(p1);
if (GetBestPlayer(e->preview_player) != _current_player) return CMD_ERROR;
if (flags & DC_EXEC)
@@ -1028,7 +1028,7 @@ static void Load_ENGN(void)
{
int index;
while ((index = SlIterateArray()) != -1) {
- SlObject(&_engines[index], _engine_desc);
+ SlObject(GetEngine(index), _engine_desc);
}
}
@@ -1057,7 +1057,7 @@ bool IsEngineBuildable(uint engine, byte type)
// check if it's an engine that is in the engine array
if (!IsEngineIndex(engine)) return false;
- e = DEREF_ENGINE(engine);
+ e = GetEngine(engine);
// check if it's an engine of specified type
if (e->type != type) return false;
diff --git a/engine.h b/engine.h
index e5fa8a09b..b87ff7d7b 100644
--- a/engine.h
+++ b/engine.h
@@ -222,7 +222,7 @@ enum {
};
VARDEF Engine _engines[TOTAL_NUM_ENGINES];
#define FOR_ALL_ENGINES(e) for (e = _engines; e != endof(_engines); e++)
-#define DEREF_ENGINE(i) (GetEngine(i))
+
static inline Engine* GetEngine(uint i)
{
assert(i < lengthof(_engines));
diff --git a/engine_gui.c b/engine_gui.c
index 2961c8b98..791d0f046 100644
--- a/engine_gui.c
+++ b/engine_gui.c
@@ -13,7 +13,7 @@
static StringID GetEngineCategoryName(byte engine)
{
if (engine < NUM_TRAIN_ENGINES) {
- switch (_engines[engine].railtype) {
+ switch (GetEngine(engine)->railtype) {
case 0:
return STR_8102_RAILROAD_LOCOMOTIVE;
case 1:
diff --git a/oldloader.c b/oldloader.c
index 141e31e71..df3eb584a 100644
--- a/oldloader.c
+++ b/oldloader.c
@@ -1339,12 +1339,12 @@ static const OldChunks engine_chunk[] = {
};
static bool LoadOldEngine(LoadgameState *ls, int num)
{
- if (!LoadChunk(ls, &_engines[num], engine_chunk))
+ if (!LoadChunk(ls, GetEngine(num), engine_chunk))
return false;
/* Make sure wagons are marked as do-not-age */
if ((num >= 27 && num < 54) || (num >= 57 && num < 84) || (num >= 89 && num < 116))
- _engines[num].age = 0xFFFF;
+ GetEngine(num)->age = 0xFFFF;
return true;
}
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index ba3545e22..8aea4ee4d 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -183,7 +183,7 @@ int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->max_speed = rvi->max_speed;
v->engine_type = (byte)p1;
- e = DEREF_ENGINE(p1);
+ e = GetEngine(p1);
v->reliability = e->reliability;
v->reliability_spd_dec = e->reliability_spd_dec;
v->max_age = e->lifelength * 366;
diff --git a/roadveh_gui.c b/roadveh_gui.c
index fbfa87967..019c87d67 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -23,7 +23,7 @@
void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number)
{
const RoadVehicleInfo *rvi = RoadVehInfo(engine_number);
- Engine *e = &_engines[engine_number];
+ const Engine* e = GetEngine(engine_number);
YearMonthDay ymd;
ConvertDayToYMD(&ymd, e->intro_date);
@@ -370,7 +370,8 @@ static void DrawNewRoadVehWindow(Window *w)
{
int count = 0;
int num = NUM_ROAD_ENGINES;
- Engine *e = &_engines[ROAD_ENGINES_INDEX];
+ const Engine* e = GetEngine(ROAD_ENGINES_INDEX);
+
do {
if (HASBIT(e->player_avail, _local_player))
count++;
@@ -382,7 +383,7 @@ static void DrawNewRoadVehWindow(Window *w)
{
int num = NUM_ROAD_ENGINES;
- Engine *e = &_engines[ROAD_ENGINES_INDEX];
+ const Engine* e = GetEngine(ROAD_ENGINES_INDEX);
int x = 1;
int y = 15;
int sel = WP(w,buildtrain_d).sel_index;
diff --git a/ship_cmd.c b/ship_cmd.c
index 62ec43c38..a1c64a3af 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -912,7 +912,7 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->max_speed = svi->max_speed;
v->engine_type = (byte)p1;
- e = &_engines[p1];
+ e = GetEngine(p1);
v->reliability = e->reliability;
v->reliability_spd_dec = e->reliability_spd_dec;
v->max_age = e->lifelength * 366;
diff --git a/ship_gui.c b/ship_gui.c
index 0f9cba79a..5100d3805 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -44,7 +44,7 @@ void DrawShipPurchaseInfo(int x, int y, EngineID engine_number)
y += 10;
/* Design date - Life length */
- e = &_engines[engine_number];
+ e = GetEngine(engine_number);
ConvertDayToYMD(&ymd, e->intro_date);
SetDParam(0, ymd.year + 1920);
SetDParam(1, e->lifelength);
@@ -326,7 +326,8 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
{
int count = 0;
int num = NUM_SHIP_ENGINES;
- Engine *e = &_engines[SHIP_ENGINES_INDEX];
+ const Engine* e = GetEngine(SHIP_ENGINES_INDEX);
+
do {
if (HASBIT(e->player_avail, _local_player))
count++;
@@ -338,7 +339,7 @@ static void NewShipWndProc(Window *w, WindowEvent *e)
{
int num = NUM_SHIP_ENGINES;
- Engine *e = &_engines[SHIP_ENGINES_INDEX];
+ const Engine* e = GetEngine(SHIP_ENGINES_INDEX);
int x = 2;
int y = 15;
int sel = WP(w,buildtrain_d).sel_index;
diff --git a/train_cmd.c b/train_cmd.c
index b12b49de6..547aedf88 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -481,7 +481,7 @@ static int32 CmdBuildRailWagon(uint engine, uint tile, uint32 flags)
v->value = value;
// v->day_counter = 0;
- e = &_engines[engine];
+ e = GetEngine(engine);
v->u.rail.railtype = e->railtype;
v->build_year = _cur_year;
@@ -650,7 +650,7 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
v->dest_tile = 0;
v->engine_type = (byte)p1;
- e = DEREF_ENGINE(p1);
+ e = GetEngine(p1);
v->reliability = e->reliability;
v->reliability_spd_dec = e->reliability_spd_dec;
@@ -1693,9 +1693,9 @@ static void HandleLocomotiveSmokeCloud(Vehicle *v)
int engtype = v->engine_type;
// no smoke?
- if (RailVehInfo(engtype)->flags & 2
- || _engines[engtype].railtype > 0
- || (v->vehstatus&VS_HIDDEN) || (v->u.rail.track & 0xC0) )
+ if (RailVehInfo(engtype)->flags & 2 ||
+ GetEngine(engtype)->railtype > 0 ||
+ (v->vehstatus & VS_HIDDEN) || (v->u.rail.track & 0xC0))
continue;
switch (RailVehInfo(engtype)->engclass) {
@@ -1738,7 +1738,7 @@ static void TrainPlayLeaveStationSound(Vehicle *v)
int engtype = v->engine_type;
- switch (_engines[engtype].railtype) {
+ switch (GetEngine(engtype)->railtype) {
case 0:
SndPlayVehicleFx(sfx[RailVehInfo(engtype)->engclass], v);
break;
diff --git a/train_gui.c b/train_gui.c
index b8007b007..63641a110 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -26,7 +26,7 @@ int _traininfo_vehicle_pitch = 0;
void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number)
{
const RailVehicleInfo *rvi = RailVehInfo(engine_number);
- Engine *e = &_engines[engine_number];
+ const Engine* e = GetEngine(engine_number);
int multihead = (rvi->flags&RVI_MULTIHEAD?1:0);
YearMonthDay ymd;
ConvertDayToYMD(&ymd, e->intro_date);
@@ -157,7 +157,7 @@ static void engine_drawing_loop(int *x, int *y, int *pos, int *sel,
int i;
for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
- const Engine *e = DEREF_ENGINE(i);
+ const Engine *e = GetEngine(i);
const RailVehicleInfo *rvi = RailVehInfo(i);
if (e->railtype != railtype || !(rvi->flags & RVI_WAGON) != is_engine ||
@@ -191,7 +191,7 @@ static void NewRailVehicleWndProc(Window *w, WindowEvent *e)
int i;
for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
- const Engine *e = DEREF_ENGINE(i);
+ const Engine *e = GetEngine(i);
if (e->railtype == railtype
&& HASBIT(e->player_avail, _local_player))
count++;
diff --git a/vehicle.c b/vehicle.c
index e15d1ddc7..a5d3010b9 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -49,7 +49,7 @@ void VehicleServiceInDepot(Vehicle *v)
{
v->date_of_last_service = _date;
v->breakdowns_since_last_service = 0;
- v->reliability = _engines[v->engine_type].reliability;
+ v->reliability = GetEngine(v->engine_type)->reliability;
}
bool VehicleNeedsService(const Vehicle *v)
@@ -61,7 +61,7 @@ bool VehicleNeedsService(const Vehicle *v)
return false; /* Crashed vehicles don't need service anymore */
return _patches.servint_ispercent ?
- (v->reliability < _engines[v->engine_type].reliability * (100 - v->service_interval) / 100) :
+ (v->reliability < GetEngine(v->engine_type)->reliability * (100 - v->service_interval) / 100) :
(v->date_of_last_service + v->service_interval < _date);
}
@@ -1358,7 +1358,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!IsEngineIndex(new_engine_type)) return CMD_ERROR;
// check that the new vehicle type is the same as the original one
- if (v->type != DEREF_ENGINE(new_engine_type)->type) return CMD_ERROR;
+ if (v->type != GetEngine(new_engine_type)->type) return CMD_ERROR;
// check that it's the vehicle's owner that requested the replace
if (!CheckOwnership(v->owner)) return CMD_ERROR;
@@ -1369,7 +1369,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
// makes sure that the player can actually buy the new engine. Renewing is still allowed to outdated engines
- if (!HASBIT(DEREF_ENGINE(new_engine_type)->player_avail, v->owner) && old_engine_type != new_engine_type) return CMD_ERROR;
+ if (!HASBIT(GetEngine(new_engine_type)->player_avail, v->owner) && old_engine_type != new_engine_type) return CMD_ERROR;
switch (v->type) {
case VEH_Train: build_cost = EstimateTrainCost(RailVehInfo(new_engine_type)); break;
@@ -1438,7 +1438,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) {
/* We do not really buy a new vehicle, we upgrade the old one */
- Engine *e = DEREF_ENGINE(new_engine_type);
+ const Engine* e = GetEngine(new_engine_type);
v->reliability = e->reliability;
v->reliability_spd_dec = e->reliability_spd_dec;
@@ -1620,7 +1620,7 @@ void MaybeReplaceVehicle(Vehicle *v)
the last 8 bit is the engine. The 8 bits in front of the engine is free so it have room for 16 bit engine entries */
new_engine_and_autoreplace_money = ((_patches.autorenew_money / 100000) << 16) + _autoreplace_array[v->engine_type];
- assert(v->type == DEREF_ENGINE(_autoreplace_array[v->engine_type])->type);
+ assert(v->type == GetEngine(_autoreplace_array[v->engine_type])->type);
if ( v->type != VEH_Train ) {
DoCommandP(v->tile, v->index, new_engine_and_autoreplace_money, NULL, CMD_REPLACE_VEHICLE | CMD_SHOW_NO_ERROR);
diff --git a/vehicle_gui.c b/vehicle_gui.c
index cc7ed3ad6..9e44c59b7 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -391,7 +391,7 @@ static void train_engine_drawing_loop(int *x, int *y, int *pos, int *sel, int *s
byte colour;
for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
- const Engine *e = DEREF_ENGINE(i);
+ const Engine *e = GetEngine(i);
const RailVehicleInfo *rvi = RailVehInfo(i);
const EngineInfo *info = &_engine_info[i];
@@ -448,7 +448,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
w->widget[13].color = _player_colors[_local_player]; // sets the colour of that art thing
w->widget[16].color = _player_colors[_local_player]; // sets the colour of that art thing
for (engine_id = 0; engine_id < NUM_TRAIN_ENGINES; engine_id++) {
- const Engine *e = DEREF_ENGINE(engine_id);
+ const Engine *e = GetEngine(engine_id);
const EngineInfo *info = &_engine_info[engine_id];
if (ENGINE_AVAILABLE && RailVehInfo(engine_id)->power && e->railtype == railtype ) {
@@ -468,7 +468,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
}
case VEH_Road: {
int num = NUM_ROAD_ENGINES;
- Engine *e = DEREF_ENGINE(ROAD_ENGINES_INDEX);
+ Engine *e = GetEngine(ROAD_ENGINES_INDEX);
byte cargo;
EngineInfo *info;
engine_id = ROAD_ENGINES_INDEX;
@@ -485,7 +485,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
if ( selected_id[0] != -1 ) { // only draw right array if we have anything in the left one
num = NUM_ROAD_ENGINES;
engine_id = ROAD_ENGINES_INDEX;
- e = DEREF_ENGINE(ROAD_ENGINES_INDEX);
+ e = GetEngine(ROAD_ENGINES_INDEX);
cargo = RoadVehInfo(selected_id[0])->cargo_type;
do {
@@ -501,7 +501,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
case VEH_Ship: {
int num = NUM_SHIP_ENGINES;
- Engine *e = DEREF_ENGINE(SHIP_ENGINES_INDEX);
+ Engine *e = GetEngine(SHIP_ENGINES_INDEX);
byte cargo, refittable;
EngineInfo *info;
engine_id = SHIP_ENGINES_INDEX;
@@ -517,7 +517,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
if ( selected_id[0] != -1 ) {
num = NUM_SHIP_ENGINES;
- e = DEREF_ENGINE(SHIP_ENGINES_INDEX);
+ e = GetEngine(SHIP_ENGINES_INDEX);
engine_id = SHIP_ENGINES_INDEX;
cargo = ShipVehInfo(selected_id[0])->cargo_type;
refittable = ShipVehInfo(selected_id[0])->refittable;
@@ -538,7 +538,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
case VEH_Aircraft:{
int num = NUM_AIRCRAFT_ENGINES;
byte subtype;
- Engine *e = DEREF_ENGINE(AIRCRAFT_ENGINES_INDEX);
+ Engine *e = GetEngine(AIRCRAFT_ENGINES_INDEX);
EngineInfo *info;
engine_id = AIRCRAFT_ENGINES_INDEX;
@@ -553,7 +553,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
if ( selected_id[0] != -1 ) {
num = NUM_AIRCRAFT_ENGINES;
- e = DEREF_ENGINE(AIRCRAFT_ENGINES_INDEX);
+ e = GetEngine(AIRCRAFT_ENGINES_INDEX);
subtype = AircraftVehInfo(selected_id[0])->subtype;
engine_id = AIRCRAFT_ENGINES_INDEX;
do {
@@ -612,7 +612,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
case VEH_Road: {
int num = NUM_ROAD_ENGINES;
- Engine *e = DEREF_ENGINE(ROAD_ENGINES_INDEX);
+ Engine *e = GetEngine(ROAD_ENGINES_INDEX);
int engine_id = ROAD_ENGINES_INDEX;
byte cargo;
EngineInfo *info;
@@ -648,7 +648,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
case VEH_Ship: {
int num = NUM_SHIP_ENGINES;
- Engine *e = DEREF_ENGINE(SHIP_ENGINES_INDEX);
+ Engine *e = GetEngine(SHIP_ENGINES_INDEX);
int engine_id = SHIP_ENGINES_INDEX;
byte cargo, refittable;
EngineInfo *info;
@@ -687,7 +687,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
case VEH_Aircraft: {
if ( selected_id[0] != -1 ) {
int num = NUM_AIRCRAFT_ENGINES;
- Engine *e = DEREF_ENGINE(AIRCRAFT_ENGINES_INDEX);
+ Engine *e = GetEngine(AIRCRAFT_ENGINES_INDEX);
int engine_id = AIRCRAFT_ENGINES_INDEX;
byte subtype = AircraftVehInfo(selected_id[0])->subtype;
EngineInfo *info;
@@ -757,7 +757,7 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
// do not count the vehicles, that contains only 0 in all var
if (vehicle->engine_type == 0 && vehicle->spritenum == 0 ) continue;
- if (vehicle->type != DEREF_ENGINE(vehicle->engine_type)->type) continue;
+ if (vehicle->type != GetEngine(vehicle->engine_type)->type) continue;
_player_num_engines[vehicle->engine_type]++;
}
@@ -892,9 +892,9 @@ static void ReplaceVehicleWndProc(Window *w, WindowEvent *e)
// finds mask for available engines
{
int engine_avail = 0;
- if ( !(HASBIT(DEREF_ENGINE(NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES)->player_avail, _local_player))) {
+ if (!HASBIT(GetEngine(NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES)->player_avail, _local_player)) {
engine_avail = 4;
- if ( !(HASBIT(DEREF_ENGINE(NUM_NORMAL_RAIL_ENGINES)->player_avail, _local_player)))
+ if (!HASBIT(GetEngine(NUM_NORMAL_RAIL_ENGINES)->player_avail, _local_player))
engine_avail = 6;
}
ShowDropDownMenu(w, _rail_types_list, _railtype_selected_in_replace_gui, 15, engine_avail, 1);