mirror of https://github.com/OpenTTD/OpenTTD
(svn r4918) Move the information about the size of airports from an global array into the struct which describes an airport
parent
910aa90bd3
commit
edb5e87e0c
|
@ -3328,8 +3328,9 @@ static bool AiCheckAirportResources(TileIndex tile, const AiDefaultBlockData *p,
|
||||||
|
|
||||||
for (; p->mode == 0; p++) {
|
for (; p->mode == 0; p++) {
|
||||||
TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
|
TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs));
|
||||||
uint w = _airport_size_x[p->attr];
|
const AirportFTAClass* airport = GetAirport(p->attr);
|
||||||
uint h = _airport_size_y[p->attr];
|
uint w = airport->size_x;
|
||||||
|
uint h = airport->size_y;
|
||||||
|
|
||||||
if (cargo & 0x80) {
|
if (cargo & 0x80) {
|
||||||
GetProductionAroundTiles(values, tile2, w, h, rad);
|
GetProductionAroundTiles(values, tile2, w, h, rad);
|
||||||
|
|
26
airport.c
26
airport.c
|
@ -20,7 +20,9 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
|
||||||
const byte *terminals, const byte *helipads,
|
const byte *terminals, const byte *helipads,
|
||||||
const byte entry_point, const byte acc_planes,
|
const byte entry_point, const byte acc_planes,
|
||||||
const AirportFTAbuildup *FA,
|
const AirportFTAbuildup *FA,
|
||||||
const TileIndexDiffC *depots, const byte nof_depots);
|
const TileIndexDiffC *depots, const byte nof_depots,
|
||||||
|
uint size_x, uint size_y
|
||||||
|
);
|
||||||
static void AirportFTAClass_Destructor(AirportFTAClass *Airport);
|
static void AirportFTAClass_Destructor(AirportFTAClass *Airport);
|
||||||
|
|
||||||
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA);
|
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA);
|
||||||
|
@ -42,7 +44,8 @@ void InitializeAirports(void)
|
||||||
ALL,
|
ALL,
|
||||||
_airport_fta_country,
|
_airport_fta_country,
|
||||||
_airport_depots_country,
|
_airport_depots_country,
|
||||||
lengthof(_airport_depots_country)
|
lengthof(_airport_depots_country),
|
||||||
|
4, 3
|
||||||
);
|
);
|
||||||
|
|
||||||
// city airport
|
// city airport
|
||||||
|
@ -56,7 +59,8 @@ void InitializeAirports(void)
|
||||||
ALL,
|
ALL,
|
||||||
_airport_fta_city,
|
_airport_fta_city,
|
||||||
_airport_depots_city,
|
_airport_depots_city,
|
||||||
lengthof(_airport_depots_city)
|
lengthof(_airport_depots_city),
|
||||||
|
6, 6
|
||||||
);
|
);
|
||||||
|
|
||||||
// metropolitan airport
|
// metropolitan airport
|
||||||
|
@ -70,7 +74,8 @@ void InitializeAirports(void)
|
||||||
ALL,
|
ALL,
|
||||||
_airport_fta_metropolitan,
|
_airport_fta_metropolitan,
|
||||||
_airport_depots_metropolitan,
|
_airport_depots_metropolitan,
|
||||||
lengthof(_airport_depots_metropolitan)
|
lengthof(_airport_depots_metropolitan),
|
||||||
|
6, 6
|
||||||
);
|
);
|
||||||
|
|
||||||
// international airport
|
// international airport
|
||||||
|
@ -84,7 +89,8 @@ void InitializeAirports(void)
|
||||||
ALL,
|
ALL,
|
||||||
_airport_fta_international,
|
_airport_fta_international,
|
||||||
_airport_depots_international,
|
_airport_depots_international,
|
||||||
lengthof(_airport_depots_international)
|
lengthof(_airport_depots_international),
|
||||||
|
7, 7
|
||||||
);
|
);
|
||||||
|
|
||||||
// heliport, oilrig
|
// heliport, oilrig
|
||||||
|
@ -98,7 +104,8 @@ void InitializeAirports(void)
|
||||||
HELICOPTERS_ONLY,
|
HELICOPTERS_ONLY,
|
||||||
_airport_fta_heliport_oilrig,
|
_airport_fta_heliport_oilrig,
|
||||||
NULL,
|
NULL,
|
||||||
0
|
0,
|
||||||
|
1, 1
|
||||||
);
|
);
|
||||||
|
|
||||||
Oilrig = Heliport; // exactly the same structure for heliport/oilrig, so share state machine
|
Oilrig = Heliport; // exactly the same structure for heliport/oilrig, so share state machine
|
||||||
|
@ -117,7 +124,9 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
|
||||||
const byte *terminals, const byte *helipads,
|
const byte *terminals, const byte *helipads,
|
||||||
const byte entry_point, const byte acc_planes,
|
const byte entry_point, const byte acc_planes,
|
||||||
const AirportFTAbuildup *FA,
|
const AirportFTAbuildup *FA,
|
||||||
const TileIndexDiffC *depots, const byte nof_depots)
|
const TileIndexDiffC *depots, const byte nof_depots,
|
||||||
|
uint size_x, uint size_y
|
||||||
|
)
|
||||||
{
|
{
|
||||||
byte nofterminals, nofhelipads;
|
byte nofterminals, nofhelipads;
|
||||||
byte nofterminalgroups = 0;
|
byte nofterminalgroups = 0;
|
||||||
|
@ -126,6 +135,9 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
|
||||||
int i;
|
int i;
|
||||||
nofterminals = nofhelipads = 0;
|
nofterminals = nofhelipads = 0;
|
||||||
|
|
||||||
|
Airport->size_x = size_x;
|
||||||
|
Airport->size_y = size_y;
|
||||||
|
|
||||||
//now we read the number of terminals we have
|
//now we read the number of terminals we have
|
||||||
if (terminals != NULL) {
|
if (terminals != NULL) {
|
||||||
i = terminals[0];
|
i = terminals[0];
|
||||||
|
|
|
@ -105,6 +105,8 @@ typedef struct AirportFTAClass {
|
||||||
const TileIndexDiffC *airport_depots; // gives the position of the depots on the airports
|
const TileIndexDiffC *airport_depots; // gives the position of the depots on the airports
|
||||||
byte nof_depots; // number of depots this airport has
|
byte nof_depots; // number of depots this airport has
|
||||||
struct AirportFTA *layout; // state machine for airport
|
struct AirportFTA *layout; // state machine for airport
|
||||||
|
byte size_x;
|
||||||
|
byte size_y;
|
||||||
} AirportFTAClass;
|
} AirportFTAClass;
|
||||||
|
|
||||||
// internal structure used in openttd - Finite sTate mAchine --> FTA
|
// internal structure used in openttd - Finite sTate mAchine --> FTA
|
||||||
|
|
|
@ -147,6 +147,7 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
|
||||||
int sel;
|
int sel;
|
||||||
int rad = 4; // default catchment radious
|
int rad = 4; // default catchment radious
|
||||||
uint32 avail_airports;
|
uint32 avail_airports;
|
||||||
|
const AirportFTAClass* airport;
|
||||||
|
|
||||||
if (WP(w,def_d).close) return;
|
if (WP(w,def_d).close) return;
|
||||||
|
|
||||||
|
@ -164,7 +165,8 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e)
|
||||||
_selected_airport_type = sel;
|
_selected_airport_type = sel;
|
||||||
// select default the coverage area to 'Off' (8)
|
// select default the coverage area to 'Off' (8)
|
||||||
w->click_state = ((1<<3) << sel) | ((1<<8) << _station_show_coverage);
|
w->click_state = ((1<<3) << sel) | ((1<<8) << _station_show_coverage);
|
||||||
SetTileSelectSize(_airport_size_x[sel],_airport_size_y[sel]);
|
airport = GetAirport(sel);
|
||||||
|
SetTileSelectSize(airport->size_x, airport->size_y);
|
||||||
|
|
||||||
if (_patches.modified_catchment) {
|
if (_patches.modified_catchment) {
|
||||||
switch (sel) {
|
switch (sel) {
|
||||||
|
|
|
@ -78,11 +78,6 @@ MemoryPool _station_pool = { "Stations", STATION_POOL_MAX_BLOCKS, STATION_POOL_B
|
||||||
MemoryPool _roadstop_pool = { "RoadStop", ROADSTOP_POOL_MAX_BLOCKS, ROADSTOP_POOL_BLOCK_SIZE_BITS, sizeof(RoadStop), &RoadStopPoolNewBlock, NULL, 0, 0, NULL };
|
MemoryPool _roadstop_pool = { "RoadStop", ROADSTOP_POOL_MAX_BLOCKS, ROADSTOP_POOL_BLOCK_SIZE_BITS, sizeof(RoadStop), &RoadStopPoolNewBlock, NULL, 0, 0, NULL };
|
||||||
|
|
||||||
|
|
||||||
// FIXME -- need to be embedded into Airport variable. Is dynamically
|
|
||||||
// deducteable from graphics-tile array, so will not be needed
|
|
||||||
const byte _airport_size_x[] = {4, 6, 1, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
|
|
||||||
const byte _airport_size_y[] = {3, 6, 1, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
|
|
||||||
|
|
||||||
void ShowAircraftDepotWindow(TileIndex tile);
|
void ShowAircraftDepotWindow(TileIndex tile);
|
||||||
extern void UpdateAirplanesOnNewStation(Station *st);
|
extern void UpdateAirplanesOnNewStation(Station *st);
|
||||||
|
|
||||||
|
@ -689,12 +684,11 @@ static void UpdateStationAcceptance(Station *st, bool show_msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st->airport_tile != 0) {
|
if (st->airport_tile != 0) {
|
||||||
|
const AirportFTAClass* afc = GetAirport(st->airport_type);
|
||||||
|
|
||||||
MergePoint(&rect, st->airport_tile);
|
MergePoint(&rect, st->airport_tile);
|
||||||
MergePoint(&rect,
|
MergePoint(&rect,
|
||||||
st->airport_tile + TileDiffXY(
|
st->airport_tile + TileDiffXY(afc->size_x - 1, afc->size_y - 1)
|
||||||
_airport_size_x[st->airport_type] - 1,
|
|
||||||
_airport_size_y[st->airport_type] - 1
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1599,6 +1593,7 @@ int32 CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
int32 ret;
|
int32 ret;
|
||||||
int w, h;
|
int w, h;
|
||||||
bool airport_upgrade = true;
|
bool airport_upgrade = true;
|
||||||
|
const AirportFTAClass* afc;
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
|
@ -1623,8 +1618,9 @@ int32 CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w = _airport_size_x[p1];
|
afc = GetAirport(p1);
|
||||||
h = _airport_size_y[p1];
|
w = afc->size_x;
|
||||||
|
h = afc->size_y;
|
||||||
|
|
||||||
ret = CheckFlatLandBelow(tile, w, h, flags, 0, NULL);
|
ret = CheckFlatLandBelow(tile, w, h, flags, 0, NULL);
|
||||||
if (CmdFailed(ret)) return ret;
|
if (CmdFailed(ret)) return ret;
|
||||||
|
@ -1672,8 +1668,6 @@ int32 CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
cost += _price.build_airport * w * h;
|
cost += _price.build_airport * w * h;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
const AirportFTAClass *afc = GetAirport(p1);
|
|
||||||
|
|
||||||
st->owner = _current_player;
|
st->owner = _current_player;
|
||||||
if (IsLocalPlayer() && afc->nof_depots != 0)
|
if (IsLocalPlayer() && afc->nof_depots != 0)
|
||||||
_last_built_aircraft_depot_tile = tile + ToTileIndexDiff(afc->airport_depots[0]);
|
_last_built_aircraft_depot_tile = tile + ToTileIndexDiff(afc->airport_depots[0]);
|
||||||
|
@ -1717,14 +1711,16 @@ static int32 RemoveAirport(Station *st, uint32 flags)
|
||||||
TileIndex tile;
|
TileIndex tile;
|
||||||
int w,h;
|
int w,h;
|
||||||
int32 cost;
|
int32 cost;
|
||||||
|
const AirportFTAClass* afc;
|
||||||
|
|
||||||
if (_current_player != OWNER_WATER && !CheckOwnership(st->owner))
|
if (_current_player != OWNER_WATER && !CheckOwnership(st->owner))
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
|
||||||
tile = st->airport_tile;
|
tile = st->airport_tile;
|
||||||
|
|
||||||
w = _airport_size_x[st->airport_type];
|
afc = GetAirport(st->airport_type);
|
||||||
h = _airport_size_y[st->airport_type];
|
w = afc->size_x;
|
||||||
|
h = afc->size_y;
|
||||||
|
|
||||||
cost = w * h * _price.remove_airport;
|
cost = w * h * _price.remove_airport;
|
||||||
|
|
||||||
|
@ -1738,7 +1734,6 @@ static int32 RemoveAirport(Station *st, uint32 flags)
|
||||||
} END_TILE_LOOP(tile_cur, w,h,tile)
|
} END_TILE_LOOP(tile_cur, w,h,tile)
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
const AirportFTAClass *afc = GetAirport(st->airport_type);
|
|
||||||
uint i;
|
uint i;
|
||||||
|
|
||||||
for (i = 0; i < afc->nof_depots; ++i) {
|
for (i = 0; i < afc->nof_depots; ++i) {
|
||||||
|
|
|
@ -403,12 +403,6 @@ extern const byte _inclined_tileh[8];
|
||||||
|
|
||||||
extern const TileTypeProcs * const _tile_type_procs[16];
|
extern const TileTypeProcs * const _tile_type_procs[16];
|
||||||
|
|
||||||
/* station_cmd.c */
|
|
||||||
// there are 5 types of airport (Country (3x4) , City(6x6), Metropolitan(6x6), International(7x7), Heliport(1x1)
|
|
||||||
// will become obsolete once airports are loaded from seperate file
|
|
||||||
extern const byte _airport_size_x[];
|
|
||||||
extern const byte _airport_size_y[];
|
|
||||||
|
|
||||||
/* misc */
|
/* misc */
|
||||||
VARDEF char _screenshot_name[128];
|
VARDEF char _screenshot_name[128];
|
||||||
VARDEF byte _vehicle_design_names;
|
VARDEF byte _vehicle_design_names;
|
||||||
|
|
Loading…
Reference in New Issue