Changeset - r4023:2a2ec18b6c65
[Not reviewed]
master
0 6 0
tron - 18 years ago 2006-06-14 11:05:30
tron@openttd.org
(svn r5262) Add symbolic names for the aircraft subtypes. not perfect, but better than raw numbers
6 files changed with 19 insertions and 11 deletions:
0 comments (0 inline, 0 general)
aircraft_cmd.c
Show inline comments
 
@@ -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, En
 

	
 
	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, u
 

	
 
	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, u
 
		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 *
 

	
 
	//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;
 
	}
 

	
engine.h
Show inline comments
 
@@ -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;
newgrf_engine.c
Show inline comments
 
@@ -850,7 +850,7 @@ SpriteID GetRotorOverrideSprite(EngineID
 
	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);
 

	
players.c
Show inline comments
 
@@ -738,7 +738,8 @@ int32 CmdReplaceVehicle(TileIndex tile, 
 
					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
table/engines.h
Show inline comments
 
@@ -505,8 +505,8 @@ const ShipVehicleInfo orig_ship_vehicle_
 
 */
 
#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
vehicle_gui.c
Show inline comments
 
@@ -615,7 +615,7 @@ static void SetupScrollStuffForReplaceWi
 

	
 
				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 DrawEngineArrayInReplaceWind
 
						}
 
						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)) {
0 comments (0 inline, 0 general)