# HG changeset patch # User tron # Date 1103372344 0 # Node ID 604af534c65d649e80742b63eef887d72022c832 # Parent 9c116656baa594795086077fc42d4be4ce6767e3 (svn r1149) Fix hack which abuses first TileIndex of airport depot array as number of depots (similar change as in map branch) diff -r 9c116656baa5 -r 604af534c65d aircraft_cmd.c --- a/aircraft_cmd.c Fri Dec 17 23:32:54 2004 +0000 +++ b/aircraft_cmd.c Sat Dec 18 12:19:04 2004 +0000 @@ -218,8 +218,7 @@ byte i = 0; st = DEREF_STATION(_map2[tile]); Airport = GetAirport(st->airport_type); - // first element of depot array contains #of depots on the airport - for (cur_depot=&Airport->airport_depots[1]; i != Airport->airport_depots[0]; cur_depot++) { + for (cur_depot = Airport->airport_depots; i != Airport->nof_depots; cur_depot++) { if ((uint)(st->airport_tile + *cur_depot) == tile) { assert(Airport->layout[i].heading == HANGAR); v->u.air.pos = Airport->layout[i].position; diff -r 9c116656baa5 -r 604af534c65d airport.c --- a/airport.c Fri Dec 17 23:32:54 2004 +0000 +++ b/airport.c Sat Dec 18 12:19:04 2004 +0000 @@ -14,7 +14,7 @@ const byte nofhelipads, const byte nofhelipadgroups, const byte entry_point, const byte acc_planes, const AirportFTAbuildup *FA, - const TileIndex *depots); + const TileIndex *depots, const byte nof_depots); static void AirportFTAClass_Destructor(AirportFTAClass *Airport); static uint16 AirportGetNofElements(const AirportFTAbuildup *FA); @@ -27,23 +27,23 @@ { // country airport CountryAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass)); - AirportFTAClass_Constructor(CountryAirport, 2, 1, 0, 0, 16, ALL, _airport_fta_country, _airport_depots_country); + AirportFTAClass_Constructor(CountryAirport, 2, 1, 0, 0, 16, ALL, _airport_fta_country, _airport_depots_country, lengthof(_airport_depots_country)); // city airport CityAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass)); - AirportFTAClass_Constructor(CityAirport, 3, 1, 0, 0, 19, ALL, _airport_fta_city, _airport_depots_city); + AirportFTAClass_Constructor(CityAirport, 3, 1, 0, 0, 19, ALL, _airport_fta_city, _airport_depots_city, lengthof(_airport_depots_city)); // metropolitan airport MetropolitanAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass)); - AirportFTAClass_Constructor(MetropolitanAirport, 3, 1, 0, 0, 20, ALL, _airport_fta_metropolitan, _airport_depots_metropolitan); + AirportFTAClass_Constructor(MetropolitanAirport, 3, 1, 0, 0, 20, ALL, _airport_fta_metropolitan, _airport_depots_metropolitan, lengthof(_airport_depots_metropolitan)); // international airport InternationalAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass)); - AirportFTAClass_Constructor(InternationalAirport, 6, 2, 2, 1, 37, ALL, _airport_fta_international, _airport_depots_international); + AirportFTAClass_Constructor(InternationalAirport, 6, 2, 2, 1, 37, ALL, _airport_fta_international, _airport_depots_international, lengthof(_airport_depots_international)); // heliport, oilrig Heliport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass)); - AirportFTAClass_Constructor(Heliport, 0, 0, 1, 1, 7, HELICOPTERS_ONLY, _airport_fta_heliport_oilrig, _airport_depots_heliport_oilrig); + AirportFTAClass_Constructor(Heliport, 0, 0, 1, 1, 7, HELICOPTERS_ONLY, _airport_fta_heliport_oilrig, NULL, 0); Oilrig = Heliport; // exactly the same structure for heliport/oilrig, so share state machine } @@ -61,7 +61,7 @@ const byte nofhelipads, const byte nofhelipadgroups, const byte entry_point, const byte acc_planes, const AirportFTAbuildup *FA, - const TileIndex *depots) + const TileIndex *depots, const byte nof_depots) { // if there are more terminals than 6, internal variables have to be changed, so don't allow that // same goes for helipads @@ -89,7 +89,8 @@ Airport->nofhelipadgroups = nofhelipadgroups; Airport->acc_planes = acc_planes; Airport->entry_point = entry_point; - Airport->airport_depots = (const uint16*)depots; + Airport->airport_depots = depots; + Airport->nof_depots = nof_depots; // build the state machine diff -r 9c116656baa5 -r 604af534c65d airport.h --- a/airport.h Fri Dec 17 23:32:54 2004 +0000 +++ b/airport.h Sat Dec 18 12:19:04 2004 +0000 @@ -32,7 +32,8 @@ byte nofhelipadgroups; // helipads belong to so many groups (MAX is the nofhelipads) byte entry_point; // when an airplane arrives at this airport, enter it at position entry_point byte acc_planes; // accept airplanes or helicopters or both - const uint16 *airport_depots; // gives the position of the depots on the airports + const TileIndex *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 } AirportFTAClass; diff -r 9c116656baa5 -r 604af534c65d airport_movement.h --- a/airport_movement.h Fri Dec 17 23:32:54 2004 +0000 +++ b/airport_movement.h Sat Dec 18 12:19:04 2004 +0000 @@ -4,10 +4,6 @@ #include "stdafx.h" #include "macros.h" -// don't forget to change the airport_depots too for larger mapsizes. TILE_X_BITS 16 -// won't fit in uint16 for example and overflow will occur in the checking code! -// TrueLight -- So make it a TileIndex.. - typedef struct AirportMovingData { int x,y; byte flag; @@ -267,7 +263,7 @@ /////**********Movement Machine on Airports*********************/////// // first element of depots array tells us how many depots there are (to know size of array) // this may be changed later when airports are moved to external file -static const TileIndex _airport_depots_country[] = {1, TILE_XY(3,0)}; +static const TileIndex _airport_depots_country[] = {TILE_XY(3,0)}; static const AirportFTAbuildup _airport_fta_country[] = { { 0,HANGAR,NOTHING_block,1}, { 1,255,AIRPORT_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM1,TERM1_block,2}, {1,TERM2,0,4}, {1,HELITAKEOFF,0,19}, {1,0,0,6}, @@ -297,7 +293,7 @@ {MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE }; -static const TileIndex _airport_depots_city[] = {1, TILE_XY(5,0)}; +static const TileIndex _airport_depots_city[] = {TILE_XY(5,0)}; static const AirportFTAbuildup _airport_fta_city[] = { { 0,HANGAR,NOTHING_block,1}, {0,TAKEOFF,OUT_WAY_block,1}, {0,0,0,1}, { 1,255,TAXIWAY_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM2,0,6}, {1,TERM3,0,6}, {1,0,0,7}, // for all else, go to 7 @@ -331,7 +327,7 @@ {MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE }; -static const TileIndex _airport_depots_metropolitan[] = {1, TILE_XY(5,0)}; +static const TileIndex _airport_depots_metropolitan[] = {TILE_XY(5,0)}; static const AirportFTAbuildup _airport_fta_metropolitan[] = { { 0,HANGAR,NOTHING_block,1}, { 1,255,TAXIWAY_BUSY_block,0}, {1,HANGAR,0,0}, {1,TERM2,0,6}, {1,TERM3,0,6}, {1,0,0,7}, // for all else, go to 7 @@ -367,7 +363,7 @@ {MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE }; -static const TileIndex _airport_depots_international[] = {2, TILE_XY(0,3), TILE_XY(6,1)}; +static const TileIndex _airport_depots_international[] = {TILE_XY(0,3), TILE_XY(6,1)}; static const AirportFTAbuildup _airport_fta_international[] = { { 0,HANGAR,NOTHING_block,2}, {0,255,TERM_GROUP1_block,0}, {0,255,TERM_GROUP2_ENTER1_block,1}, {0,HELITAKEOFF,HELIPAD1_block,2}, {0,0,0,2}, { 1,HANGAR,NOTHING_block,3}, {1,255,HANGAR2_AREA_block,1}, {1,HELITAKEOFF,HELIPAD2_block,3}, {1,0,0,3}, @@ -429,7 +425,7 @@ {MAX_ELEMENTS,0,0,0} // end marker. DO NOT REMOVE }; -static const TileIndex _airport_depots_heliport_oilrig[] = {0}; +// heliports, oilrigs don't have depots static const AirportFTAbuildup _airport_fta_heliport_oilrig[] = { {0,HELIPAD1,HELIPAD1_block,1}, {1,HELITAKEOFF,NOTHING_block,0}, // takeoff