Changeset - r5971:454a15e95a02
[Not reviewed]
master
0 6 0
tron - 18 years ago 2007-02-10 08:19:39
tron@openttd.org
(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.
6 files changed with 15 insertions and 29 deletions:
0 comments (0 inline, 0 general)
src/ai/default/default.cpp
Show inline comments
 
@@ -3323,10 +3323,11 @@ static void AiStateAirportStuff(Player *
 

	
 
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;
src/airport.cpp
Show inline comments
 
@@ -447,13 +447,16 @@ const AirportFTAClass *GetAirport(const 
 

	
 
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;
 
}
src/engine.cpp
Show inline comments
 
@@ -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.
src/misc.cpp
Show inline comments
 
@@ -310,7 +310,7 @@ static const SaveLoadGlobVarList _date_d
 
	    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),
src/oldloader.cpp
Show inline comments
 
@@ -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 ),
 

	
src/variables.h
Show inline comments
 
@@ -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;
 

	
0 comments (0 inline, 0 general)