diff options
author | tron <tron@openttd.org> | 2007-02-10 08:19:39 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2007-02-10 08:19:39 +0000 |
commit | 356e47f1087b56244694a646eb73ee6c9264a229 (patch) | |
tree | e8a4f43e2fa50f6e1637a184752b1ce7c9f43a9c | |
parent | b4592c8a542c06f4509402ebac846a44775740c9 (diff) | |
download | openttd-356e47f1087b56244694a646eb73ee6c9264a229.tar.xz |
(svn r8660) -Fix
-Codechange: Remove _avail_aircraft
Its name is misleading. It is rather _avail_airports, but then only some of them, which leads to inconsistencies when using it.
Further it is unnecessary to store it in savegams.
-rw-r--r-- | src/ai/default/default.cpp | 3 | ||||
-rw-r--r-- | src/airport.cpp | 21 | ||||
-rw-r--r-- | src/engine.cpp | 15 | ||||
-rw-r--r-- | src/misc.cpp | 2 | ||||
-rw-r--r-- | src/oldloader.cpp | 2 | ||||
-rw-r--r-- | src/variables.h | 3 |
6 files changed, 16 insertions, 30 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp index 0d43ff11f..f1e8063bf 100644 --- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -3323,10 +3323,11 @@ static void AiStateAirportStuff(Player *p) static int32 AiDoBuildDefaultAirportBlock(TileIndex tile, const AiDefaultBlockData *p, byte flag) { + uint32 avail_airports = GetValidAirports(); int32 total_cost = 0, ret; for (; p->mode == 0; p++) { - if (!HASBIT(_avail_aircraft, p->attr)) return CMD_ERROR; + if (!HASBIT(avail_airports, p->attr)) return CMD_ERROR; ret = DoCommand(TILE_MASK(tile + ToTileIndexDiff(p->tileoffs)), p->attr,0,flag | DC_AUTO | DC_NO_WATER,CMD_BUILD_AIRPORT); if (CmdFailed(ret)) return CMD_ERROR; total_cost += ret; diff --git a/src/airport.cpp b/src/airport.cpp index 2d118e1cf..c5b375c7f 100644 --- a/src/airport.cpp +++ b/src/airport.cpp @@ -447,13 +447,16 @@ const AirportFTAClass *GetAirport(const byte airport_type) uint32 GetValidAirports(void) { - uint32 bytemask = _avail_aircraft; /// sets the first 3 bytes, 0 - 2, @see AdjustAvailAircraft() - - if (_cur_year >= 1980) SETBIT(bytemask, 3); // metropolitan airport - if (_cur_year >= 1990) SETBIT(bytemask, 4); // international airport - if (_cur_year >= 1983) SETBIT(bytemask, 5); // commuter airport - if (_cur_year >= 1976) SETBIT(bytemask, 6); // helidepot - if (_cur_year >= 2002) SETBIT(bytemask, 7); // intercontinental airport - if (_cur_year >= 1980) SETBIT(bytemask, 8); // helistation - return bytemask; + uint32 mask = 0; + + if (_cur_year < 1960 || _patches.always_small_airport) SETBIT(mask, 0); // small airport + if (_cur_year >= 1955) SETBIT(mask, 1); // city airport + if (_cur_year >= 1963) SETBIT(mask, 2); // heliport + if (_cur_year >= 1980) SETBIT(mask, 3); // metropolitan airport + if (_cur_year >= 1990) SETBIT(mask, 4); // international airport + if (_cur_year >= 1983) SETBIT(mask, 5); // commuter airport + if (_cur_year >= 1976) SETBIT(mask, 6); // helidepot + if (_cur_year >= 2002) SETBIT(mask, 7); // intercontinental airport + if (_cur_year >= 1980) SETBIT(mask, 8); // helistation + return mask; } diff --git a/src/engine.cpp b/src/engine.cpp index 34f8de113..af9794b72 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -69,18 +69,6 @@ static void SetupEngineNames(void) LoadCustomEngineNames(); } -static void AdjustAvailAircraft(void) -{ - byte avail = 0; - if (_cur_year >= 1955) avail |= 2; // big airport - if (_cur_year < 1960 || _patches.always_small_airport) avail |= 1; // small airport - if (_cur_year >= 1963) avail |= 4; // enable heliport - - if (avail != _avail_aircraft) { - _avail_aircraft = avail; - InvalidateWindow(WC_BUILD_STATION, 0); - } -} static void CalcEngineReliability(Engine *e) { @@ -178,8 +166,6 @@ void StartupEngines(void) * but using this, you can ask what type an engine number is * even if it is not a vehicle (yet)*/ } - - AdjustAvailAircraft(); } static void AcceptEnginePreview(EngineID eid, PlayerID player) @@ -371,7 +357,6 @@ void EnginesMonthlyLoop(void) } } } - AdjustAvailAircraft(); } /** Rename an engine. diff --git a/src/misc.cpp b/src/misc.cpp index 242aaff16..7f61191e4 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -310,7 +310,7 @@ static const SaveLoadGlobVarList _date_desc[] = { SLEG_VAR(_tick_counter, SLE_UINT16), SLEG_VAR(_vehicle_id_ctr_day, SLE_UINT16), SLEG_VAR(_age_cargo_skip_counter, SLE_UINT8), - SLEG_VAR(_avail_aircraft, SLE_UINT8), + SLE_CONDNULL(1, 0, 45), SLEG_CONDVAR(_cur_tileloop_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), SLEG_CONDVAR(_cur_tileloop_tile, SLE_UINT32, 6, SL_MAX_VERSION), SLEG_VAR(_disaster_delay, SLE_UINT16), diff --git a/src/oldloader.cpp b/src/oldloader.cpp index 2c9d045f2..e88c37748 100644 --- a/src/oldloader.cpp +++ b/src/oldloader.cpp @@ -1431,7 +1431,7 @@ static const OldChunks main_chunk[] = { OCL_VAR ( OC_UINT8, 1, &_economy.infl_amount ), OCL_VAR ( OC_UINT8, 1, &_economy.infl_amount_pr ), OCL_VAR ( OC_UINT8, 1, &_economy.interest_rate ), - OCL_VAR ( OC_UINT8, 1, &_avail_aircraft ), + OCL_NULL( 1 ), // available airports OCL_VAR ( OC_UINT8, 1, &_opt.road_side ), OCL_VAR ( OC_UINT8, 1, &_opt.town_name ), diff --git a/src/variables.h b/src/variables.h index 420be73ed..89d45dcdd 100644 --- a/src/variables.h +++ b/src/variables.h @@ -50,9 +50,6 @@ VARDEF VehicleID _vehicle_id_ctr_day; // Skip aging of cargo? VARDEF byte _age_cargo_skip_counter; -// Available aircraft types -VARDEF byte _avail_aircraft; - // Position in tile loop VARDEF TileIndex _cur_tileloop_tile; |