Changeset - r15927:e47dbd2576e2
[Not reviewed]
master
0 3 0
rubidium - 14 years ago 2010-08-26 16:53:06
rubidium@openttd.org
(svn r20625) -Add: AirportTileSpec::GetByTile to simplify accessing the AirportTileSpec
3 files changed with 12 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/newgrf_airporttiles.cpp
Show inline comments
 
@@ -39,24 +39,34 @@ AirportTileOverrideManager _airporttile_
 
 * @param gfx index of airport tile
 
 * @return A pointer to the corresponding AirportTileSpec
 
 */
 
/* static */ const AirportTileSpec *AirportTileSpec::Get(StationGfx gfx)
 
{
 
	/* should be assert(gfx < lengthof(tiles)), but that gives compiler warnings
 
	 * since it's always true if the following holds: */
 
	assert_compile(MAX_UVALUE(StationGfx) + 1 == lengthof(tiles));
 
	return &AirportTileSpec::tiles[gfx];
 
}
 

	
 
/**
 
 * Retrieve airport tile spec for the given airport tile.
 
 * @param tile The airport tile.
 
 * @return A pointer to the corresponding AirportTileSpec.
 
 */
 
/* static */ const AirportTileSpec *AirportTileSpec::GetByTile(TileIndex tile)
 
{
 
	return AirportTileSpec::Get(GetAirportGfx(tile));
 
}
 

	
 
/**
 
 * This function initializes the tile array of AirportTileSpec
 
 */
 
void AirportTileSpec::ResetAirportTiles()
 
{
 
	memset(&AirportTileSpec::tiles, 0, sizeof(AirportTileSpec::tiles));
 
	memcpy(&AirportTileSpec::tiles, &_origin_airporttile_specs, sizeof(_origin_airporttile_specs));
 

	
 
	/* Reset any overrides that have been set. */
 
	_airporttile_mngr.ResetOverride();
 
}
 

	
 
void AirportTileOverrideManager::SetEntitySpec(const AirportTileSpec *airpts)
src/newgrf_airporttiles.h
Show inline comments
 
@@ -20,24 +20,25 @@
 
/**
 
 * Defines the data structure of each indivudual tile of an airport.
 
 */
 
struct AirportTileSpec {
 
	AnimationInfo animation;              ///< Information about the animation.
 
	StringID name;                        ///< Tile Subname string, land information on this tile will give you "AirportName (TileSubname)"
 
	uint8 callback_mask;                  ///< Bitmask telling which grf callback is set
 
	uint8 animation_special_flags;        ///< Extra flags to influence the animation
 
	bool enabled;                         ///< entity still available (by default true). newgrf can disable it, though
 
	GRFFileProps grf_prop;                ///< properties related the the grf file
 

	
 
	static const AirportTileSpec *Get(StationGfx gfx);
 
	static const AirportTileSpec *GetByTile(TileIndex tile);
 

	
 
	static void ResetAirportTiles();
 

	
 
private:
 
	static AirportTileSpec tiles[NUM_AIRPORTTILES];
 

	
 
	friend void AirportTileOverrideManager::SetEntitySpec(const AirportTileSpec *airpts);
 
};
 

	
 
StationGfx GetTranslatedAirportTileID(StationGfx gfx);
 
void AnimateAirportTile(TileIndex tile);
 
void AirportTileAnimationTrigger(Station *st, TileIndex tile, AirpAnimationTrigger trigger, CargoID cargo_type = CT_INVALID);
src/station_cmd.cpp
Show inline comments
 
@@ -2798,25 +2798,25 @@ static void GetTileDesc_Station(TileInde
 

	
 
			if (spec->grf_prop.grffile != NULL) {
 
				const GRFConfig *gc = GetGRFConfig(spec->grf_prop.grffile->grfid);
 
				td->grf = gc->GetName();
 
			}
 
		}
 

	
 
		const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(tile));
 
		td->rail_speed = rti->max_speed;
 
	}
 

	
 
	if (IsAirport(tile)) {
 
		const AirportTileSpec *ats = AirportTileSpec::Get(GetAirportGfx(tile));
 
		const AirportTileSpec *ats = AirportTileSpec::GetByTile(tile);
 
		td->airport_tile_name = ats->name;
 

	
 
		if (ats->grf_prop.grffile != NULL) {
 
			const GRFConfig *gc = GetGRFConfig(ats->grf_prop.grffile->grfid);
 
			td->grf = gc->GetName();
 
		}
 
	}
 

	
 
	StringID str;
 
	switch (GetStationType(tile)) {
 
		default: NOT_REACHED();
 
		case STATION_RAIL:     str = STR_LAI_STATION_DESCRIPTION_RAILROAD_STATION; break;
0 comments (0 inline, 0 general)