mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r5262) Add symbolic names for the aircraft subtypes. not perfect, but better than raw numbers
This commit is contained in:
parent
17c15fab3e
commit
d2f6cb9e2d
|
@ -133,7 +133,8 @@ SpriteID GetRotorImage(const Vehicle *v)
|
||||||
|
|
||||||
void DrawAircraftEngine(int x, int y, EngineID engine, uint32 image_ormod)
|
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]);
|
int sprite = (6 + _aircraft_sprite[spritenum]);
|
||||||
|
|
||||||
if (is_custom_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);
|
DrawSprite(sprite | image_ormod, x, y);
|
||||||
|
|
||||||
if ((AircraftVehInfo(engine)->subtype & 1) == 0) {
|
if (!(avi->subtype & AIR_CTOL)) {
|
||||||
SpriteID rotor_sprite = GetCustomRotorIcon(engine);
|
SpriteID rotor_sprite = GetCustomRotorIcon(engine);
|
||||||
if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
|
if (rotor_sprite == 0) rotor_sprite = SPR_ROTOR_STOPPED;
|
||||||
DrawSprite(rotor_sprite, x, y - 5);
|
DrawSprite(rotor_sprite, x, y - 5);
|
||||||
|
@ -211,7 +212,7 @@ int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
avi = AircraftVehInfo(p1);
|
avi = AircraftVehInfo(p1);
|
||||||
// allocate 2 or 3 vehicle structs, depending on type
|
// 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()) {
|
IsOrderPoolFull()) {
|
||||||
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
|
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->acceleration = avi->acceleration;
|
||||||
v->engine_type = p1;
|
v->engine_type = p1;
|
||||||
|
|
||||||
v->subtype = (avi->subtype & 1) == 0 ? 0 : 2;
|
v->subtype = (avi->subtype & AIR_CTOL ? 2 : 0);
|
||||||
v->value = value;
|
v->value = value;
|
||||||
|
|
||||||
u->subtype = 4;
|
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
|
//FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports
|
||||||
prob = 0x10000 / 1500;
|
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;
|
prob = 0x10000 / 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
engine.h
6
engine.h
|
@ -42,6 +42,12 @@ typedef struct ShipVehicleInfo {
|
||||||
byte refittable;
|
byte refittable;
|
||||||
} ShipVehicleInfo;
|
} ShipVehicleInfo;
|
||||||
|
|
||||||
|
// Aircraft subtypes
|
||||||
|
enum {
|
||||||
|
AIR_CTOL = 1, // Conventional Take Off and Landing, i.e. planes
|
||||||
|
AIR_FAST = 2
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct AircraftVehicleInfo {
|
typedef struct AircraftVehicleInfo {
|
||||||
byte image_index;
|
byte image_index;
|
||||||
byte base_cost;
|
byte base_cost;
|
||||||
|
|
|
@ -850,7 +850,7 @@ SpriteID GetRotorOverrideSprite(EngineID engine, const Vehicle *v)
|
||||||
assert(engine < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES);
|
assert(engine < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES);
|
||||||
|
|
||||||
/* Only valid for helicopters */
|
/* Only valid for helicopters */
|
||||||
assert((AircraftVehInfo(engine)->subtype & 1) == 0);
|
assert(!(AircraftVehInfo(engine)->subtype & AIR_CTOL));
|
||||||
|
|
||||||
NewVehicleResolver(&object, v);
|
NewVehicleResolver(&object, v);
|
||||||
|
|
||||||
|
|
|
@ -738,7 +738,8 @@ int32 CmdReplaceVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
|
||||||
// make sure that we do not replace a plane with a helicopter or vise versa
|
// 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;
|
return CMD_ERROR;
|
||||||
|
|
||||||
// make sure that the player can actually buy the new engine
|
// make sure that the player can actually buy the new engine
|
||||||
|
|
|
@ -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 AVI(a, b, c, d, e, f, g, h, i) { a, b, c, d, e, f, g, h, i }
|
||||||
#define H 0
|
#define H 0
|
||||||
#define P 1
|
#define P AIR_CTOL
|
||||||
#define J 3
|
#define J AIR_CTOL | AIR_FAST
|
||||||
const AircraftVehicleInfo orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES] = {
|
const AircraftVehicleInfo orig_aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES] = {
|
||||||
// image_index sfx acceleration
|
// image_index sfx acceleration
|
||||||
// | base_cost | | max_speed
|
// | base_cost | | max_speed
|
||||||
|
|
|
@ -615,7 +615,7 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
|
||||||
|
|
||||||
for (i = AIRCRAFT_ENGINES_INDEX; i < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; i++) {
|
for (i = AIRCRAFT_ENGINES_INDEX; i < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; i++) {
|
||||||
if (HASBIT(GetEngine(i)->player_avail, _local_player) &&
|
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;
|
if (sel[1] == count2) selected_id[1] = i;
|
||||||
count2++;
|
count2++;
|
||||||
}
|
}
|
||||||
|
@ -760,7 +760,7 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
|
||||||
}
|
}
|
||||||
sel[0]--;
|
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)) {
|
HASBIT(e->player_avail, _local_player)) {
|
||||||
if (sel[1] == 0) selected_id[1] = engine_id;
|
if (sel[1] == 0) selected_id[1] = engine_id;
|
||||||
if (IS_INT_INSIDE(--pos2, -w->vscroll.cap, 0)) {
|
if (IS_INT_INSIDE(--pos2, -w->vscroll.cap, 0)) {
|
||||||
|
|
Loading…
Reference in New Issue