summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--aircraft_cmd.c11
-rw-r--r--engine.h6
-rw-r--r--newgrf_engine.c2
-rw-r--r--players.c3
-rw-r--r--table/engines.h4
-rw-r--r--vehicle_gui.c4
6 files changed, 19 insertions, 11 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 28b7eecdc..53502a983 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -133,7 +133,8 @@ SpriteID GetRotorImage(const Vehicle *v)
void DrawAircraftEngine(int x, int y, EngineID engine, uint32 image_ormod)
{
- int spritenum = AircraftVehInfo(engine)->image_index;
+ const AircraftVehicleInfo* avi = AircraftVehInfo(engine);
+ int spritenum = avi->image_index;
int sprite = (6 + _aircraft_sprite[spritenum]);
if (is_custom_sprite(spritenum)) {
@@ -144,7 +145,7 @@ void DrawAircraftEngine(int x, int y, EngineID engine, uint32 image_ormod)
DrawSprite(sprite | image_ormod, x, y);
- if ((AircraftVehInfo(engine)->subtype & 1) == 0) {
+ if (!(avi->subtype & AIR_CTOL)) {
SpriteID rotor_sprite = GetCustomRotorIcon(engine);
if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
DrawSprite(rotor_sprite, x, y - 5);
@@ -211,7 +212,7 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
avi = AircraftVehInfo(p1);
// allocate 2 or 3 vehicle structs, depending on type
- if (!AllocateVehicles(vl, (avi->subtype & 1) == 0 ? 3 : 2) ||
+ if (!AllocateVehicles(vl, avi->subtype & AIR_CTOL ? 2 : 3) ||
IsOrderPoolFull()) {
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
}
@@ -281,7 +282,7 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->acceleration = avi->acceleration;
v->engine_type = p1;
- v->subtype = (avi->subtype & 1) == 0 ? 0 : 2;
+ v->subtype = (avi->subtype & AIR_CTOL ? 2 : 0);
v->value = value;
u->subtype = 4;
@@ -1271,7 +1272,7 @@ static void MaybeCrashAirplane(Vehicle *v)
//FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports
prob = 0x10000 / 1500;
- if (st->airport_type == AT_SMALL && (AircraftVehInfo(v->engine_type)->subtype & 2) && !_cheats.no_jetcrash.value) {
+ if (st->airport_type == AT_SMALL && AircraftVehInfo(v->engine_type)->subtype & AIR_FAST && !_cheats.no_jetcrash.value) {
prob = 0x10000 / 20;
}
diff --git a/engine.h b/engine.h
index 465011f2c..67886ffcd 100644
--- a/engine.h
+++ b/engine.h
@@ -42,6 +42,12 @@ typedef struct ShipVehicleInfo {
byte refittable;
} ShipVehicleInfo;
+// Aircraft subtypes
+enum {
+ AIR_CTOL = 1, // Conventional Take Off and Landing, i.e. planes
+ AIR_FAST = 2
+};
+
typedef struct AircraftVehicleInfo {
byte image_index;
byte base_cost;
diff --git a/newgrf_engine.c b/newgrf_engine.c
index feb037f67..0c46cd548 100644
--- a/newgrf_engine.c
+++ b/newgrf_engine.c
@@ -850,7 +850,7 @@ SpriteID GetRotorOverrideSprite(EngineID engine, const Vehicle *v)
assert(engine < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES);
/* Only valid for helicopters */
- assert((AircraftVehInfo(engine)->subtype & 1) == 0);
+ assert(!(AircraftVehInfo(engine)->subtype & AIR_CTOL));
NewVehicleResolver(&object, v);
diff --git a/players.c b/players.c
index 865688f5d..6a72c8c95 100644
--- a/players.c
+++ b/players.c
@@ -738,7 +738,8 @@ int32 CmdReplaceVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
return CMD_ERROR;
// make sure that we do not replace a plane with a helicopter or vise versa
- if (GetEngine(new_engine_type)->type == VEH_Aircraft && HASBIT(AircraftVehInfo(old_engine_type)->subtype, 0) != HASBIT(AircraftVehInfo(new_engine_type)->subtype, 0))
+ if (GetEngine(new_engine_type)->type == VEH_Aircraft &&
+ (AircraftVehInfo(old_engine_type)->subtype & AIR_CTOL) != (AircraftVehInfo(new_engine_type)->subtype & AIR_CTOL))
return CMD_ERROR;
// make sure that the player can actually buy the new engine
diff --git a/table/engines.h b/table/engines.h
index efa2b5836..c59ce94cf 100644
--- a/table/engines.h
+++ b/table/engines.h
@@ -505,8 +505,8 @@ const ShipVehicleInfo orig_ship_vehicle_info[NUM_SHIP_ENGINES] = {
*/
#define AVI(a, b, c, d, e, f, g, h, i) { a, b, c, d, e, f, g, h, i }
#define H 0
-#define P 1
-#define J 3
+#define P AIR_CTOL
+#define J AIR_CTOL | AIR_FAST
const AircraftVehicleInfo orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES] = {
// image_index sfx acceleration
// | base_cost | | max_speed
diff --git a/vehicle_gui.c b/vehicle_gui.c
index 3ed835f2e..2d3edfd34 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -615,7 +615,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
for (i = AIRCRAFT_ENGINES_INDEX; i < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; i++) {
if (HASBIT(GetEngine(i)->player_avail, _local_player) &&
- HASBIT(subtype, 0) == HASBIT(AircraftVehInfo(i)->subtype, 0)) {
+ (subtype & AIR_CTOL) == (AircraftVehInfo(i)->subtype & AIR_CTOL)) {
if (sel[1] == count2) selected_id[1] = i;
count2++;
}
@@ -760,7 +760,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
}
sel[0]--;
}
- if (HASBIT(subtype, 0) == HASBIT(AircraftVehInfo(engine_id)->subtype, 0) &&
+ if ((subtype & AIR_CTOL) == (AircraftVehInfo(engine_id)->subtype & AIR_CTOL) &&
HASBIT(e->player_avail, _local_player)) {
if (sel[1] == 0) selected_id[1] = engine_id;
if (IS_INT_INSIDE(--pos2, -w->vscroll.cap, 0)) {