mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-04 21:33:51 +00:00
(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.
This commit is contained in:
parent
b4592c8a54
commit
356e47f108
@ -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;
|
||||
|
@ -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()
|
||||
uint32 mask = 0;
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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),
|
||||
|
@ -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 ),
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user