diff options
author | tron <tron@openttd.org> | 2006-05-20 15:13:27 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-05-20 15:13:27 +0000 |
commit | b5f433bf4cbbbb45d8487d04d2492ed7e269823d (patch) | |
tree | ed501eeb08a1ccb519796aec762515649521aa43 | |
parent | d955b49e1b35a154c2c79ee477c6aa61ae2f7c16 (diff) | |
download | openttd-b5f433bf4cbbbb45d8487d04d2492ed7e269823d.tar.xz |
(svn r4918) Move the information about the size of airports from an global array into the struct which describes an airport
-rw-r--r-- | ai/default/default.c | 5 | ||||
-rw-r--r-- | airport.c | 26 | ||||
-rw-r--r-- | airport.h | 2 | ||||
-rw-r--r-- | airport_gui.c | 4 | ||||
-rw-r--r-- | station_cmd.c | 27 | ||||
-rw-r--r-- | variables.h | 6 |
6 files changed, 38 insertions, 32 deletions
diff --git a/ai/default/default.c b/ai/default/default.c index b0915f10a..4b1bcfc92 100644 --- a/ai/default/default.c +++ b/ai/default/default.c @@ -3328,8 +3328,9 @@ static bool AiCheckAirportResources(TileIndex tile, const AiDefaultBlockData *p, for (; p->mode == 0; p++) { TileIndex tile2 = TILE_ADD(tile, ToTileIndexDiff(p->tileoffs)); - uint w = _airport_size_x[p->attr]; - uint h = _airport_size_y[p->attr]; + const AirportFTAClass* airport = GetAirport(p->attr); + uint w = airport->size_x; + uint h = airport->size_y; if (cargo & 0x80) { GetProductionAroundTiles(values, tile2, w, h, rad); @@ -20,7 +20,9 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport, const byte *terminals, const byte *helipads, const byte entry_point, const byte acc_planes, 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 uint16 AirportGetNofElements(const AirportFTAbuildup *FA); @@ -42,7 +44,8 @@ void InitializeAirports(void) ALL, _airport_fta_country, _airport_depots_country, - lengthof(_airport_depots_country) + lengthof(_airport_depots_country), + 4, 3 ); // city airport @@ -56,7 +59,8 @@ void InitializeAirports(void) ALL, _airport_fta_city, _airport_depots_city, - lengthof(_airport_depots_city) + lengthof(_airport_depots_city), + 6, 6 ); // metropolitan airport @@ -70,7 +74,8 @@ void InitializeAirports(void) ALL, _airport_fta_metropolitan, _airport_depots_metropolitan, - lengthof(_airport_depots_metropolitan) + lengthof(_airport_depots_metropolitan), + 6, 6 ); // international airport @@ -84,7 +89,8 @@ void InitializeAirports(void) ALL, _airport_fta_international, _airport_depots_international, - lengthof(_airport_depots_international) + lengthof(_airport_depots_international), + 7, 7 ); // heliport, oilrig @@ -98,7 +104,8 @@ void InitializeAirports(void) HELICOPTERS_ONLY, _airport_fta_heliport_oilrig, NULL, - 0 + 0, + 1, 1 ); 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 entry_point, const byte acc_planes, 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 nofterminalgroups = 0; @@ -126,6 +135,9 @@ static void AirportFTAClass_Constructor(AirportFTAClass *Airport, int i; nofterminals = nofhelipads = 0; + Airport->size_x = size_x; + Airport->size_y = size_y; + //now we read the number of terminals we have if (terminals != NULL) { i = terminals[0]; @@ -105,6 +105,8 @@ typedef struct AirportFTAClass { const TileIndexDiffC *airport_depots; // gives the position of the depots on the airports byte nof_depots; // number of depots this airport has struct AirportFTA *layout; // state machine for airport + byte size_x; + byte size_y; } AirportFTAClass; // internal structure used in openttd - Finite sTate mAchine --> FTA diff --git a/airport_gui.c b/airport_gui.c index e22006e8d..0bf290716 100644 --- a/airport_gui.c +++ b/airport_gui.c @@ -147,6 +147,7 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e) int sel; int rad = 4; // default catchment radious uint32 avail_airports; + const AirportFTAClass* airport; if (WP(w,def_d).close) return; @@ -164,7 +165,8 @@ static void BuildAirportPickerWndProc(Window *w, WindowEvent *e) _selected_airport_type = sel; // select default the coverage area to 'Off' (8) 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) { switch (sel) { diff --git a/station_cmd.c b/station_cmd.c index 636bbe1e9..72dce3c90 100644 --- a/station_cmd.c +++ b/station_cmd.c @@ -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 }; -// 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); extern void UpdateAirplanesOnNewStation(Station *st); @@ -689,12 +684,11 @@ static void UpdateStationAcceptance(Station *st, bool show_msg) } if (st->airport_tile != 0) { + const AirportFTAClass* afc = GetAirport(st->airport_type); + MergePoint(&rect, st->airport_tile); MergePoint(&rect, - st->airport_tile + TileDiffXY( - _airport_size_x[st->airport_type] - 1, - _airport_size_y[st->airport_type] - 1 - ) + st->airport_tile + TileDiffXY(afc->size_x - 1, afc->size_y - 1) ); } @@ -1599,6 +1593,7 @@ int32 CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) int32 ret; int w, h; bool airport_upgrade = true; + const AirportFTAClass* afc; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); @@ -1623,8 +1618,9 @@ int32 CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) } } - w = _airport_size_x[p1]; - h = _airport_size_y[p1]; + afc = GetAirport(p1); + w = afc->size_x; + h = afc->size_y; ret = CheckFlatLandBelow(tile, w, h, flags, 0, NULL); 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; if (flags & DC_EXEC) { - const AirportFTAClass *afc = GetAirport(p1); - st->owner = _current_player; if (IsLocalPlayer() && afc->nof_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; int w,h; int32 cost; + const AirportFTAClass* afc; if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) return CMD_ERROR; tile = st->airport_tile; - w = _airport_size_x[st->airport_type]; - h = _airport_size_y[st->airport_type]; + afc = GetAirport(st->airport_type); + w = afc->size_x; + h = afc->size_y; 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) if (flags & DC_EXEC) { - const AirportFTAClass *afc = GetAirport(st->airport_type); uint i; for (i = 0; i < afc->nof_depots; ++i) { diff --git a/variables.h b/variables.h index 7cf870205..7f4d97e42 100644 --- a/variables.h +++ b/variables.h @@ -403,12 +403,6 @@ extern const byte _inclined_tileh[8]; 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 */ VARDEF char _screenshot_name[128]; VARDEF byte _vehicle_design_names; |