Changeset - r14469:32103907ad3a
[Not reviewed]
master
0 1 0
alberth - 15 years ago 2010-02-06 19:24:51
alberth@openttd.org
(svn r19048) -Codechange: Pass the already queried effective tile type to the GetSmallMapPixels routines.
1 file changed with 18 insertions and 19 deletions:
0 comments (0 inline, 0 general)
src/smallmap_gui.cpp
Show inline comments
 
@@ -254,15 +254,16 @@ static const AndOr _smallmap_vehicles_an
 
	{MKCOLOUR(0x00D7D700), MKCOLOUR(0xFF0000FF)},
 
};
 

	
 
/**
 
 * Function signature of the function to retrieve the colour data of a tile for display at the smallmap.
 
 * @param tile Tile that gets displayed.
 
 * @param t    Effective tile type of the tile (see #GetEffectiveTileType).
 
 * @return Colour data to display.
 
 */
 
typedef uint32 GetSmallMapPixels(TileIndex tile);
 
typedef uint32 GetSmallMapPixels(TileIndex tile, TileType t);
 

	
 
/** Mapping of tile type to importance of the tile (higher number means more interesting to show). */
 
static const byte _tiletype_importance[] = {
 
	2, // MP_CLEAR
 
	8, // MP_RAILWAY
 
	7, // MP_ROAD
 
@@ -294,44 +295,41 @@ static inline TileType GetEffectiveTileT
 
	return t;
 
}
 

	
 
/**
 
 * Return the colour a tile would be displayed with in the small map in mode "Contour".
 
 * @param tile The tile of which we would like to get the colour.
 
 * @param t    Effective tile type of the tile (see #GetEffectiveTileType).
 
 * @return The colour of tile in the small map in mode "Contour"
 
 */
 
static inline uint32 GetSmallMapContoursPixels(TileIndex tile)
 
static inline uint32 GetSmallMapContoursPixels(TileIndex tile, TileType t)
 
{
 
	TileType t = GetEffectiveTileType(tile);
 

	
 
	return ApplyMask(_map_height_bits[TileHeight(tile)], &_smallmap_contours_andor[t]);
 
}
 

	
 
/**
 
 * Return the colour a tile would be displayed with in the small map in mode "Vehicles".
 
 *
 
 * @param tile The tile of which we would like to get the colour.
 
 * @param t    Effective tile type of the tile (see #GetEffectiveTileType).
 
 * @return The colour of tile in the small map in mode "Vehicles"
 
 */
 
static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile)
 
static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile, TileType t)
 
{
 
	TileType t = GetEffectiveTileType(tile);
 

	
 
	return ApplyMask(MKCOLOUR(0x54545454), &_smallmap_vehicles_andor[t]);
 
}
 

	
 
/**
 
 * Return the colour a tile would be displayed with in the small map in mode "Industries".
 
 *
 
 * @param tile The tile of which we would like to get the colour.
 
 * @param t    Effective tile type of the tile (see #GetEffectiveTileType).
 
 * @return The colour of tile in the small map in mode "Industries"
 
 */
 
static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile)
 
static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile, TileType t)
 
{
 
	TileType t = GetEffectiveTileType(tile);
 

	
 
	if (t == MP_INDUSTRY) {
 
		/* If industry is allowed to be seen, use its colour on the map */
 
		if (_legend_from_industries[_industry_to_list_pos[Industry::GetByTile(tile)->type]].show_on_map) {
 
			return GetIndustrySpec(Industry::GetByTile(tile)->type)->map_colour * 0x01010101;
 
		} else {
 
			/* Otherwise, return the colour of the clear tiles, which will make it disappear */
 
@@ -343,18 +341,17 @@ static inline uint32 GetSmallMapIndustri
 
}
 

	
 
/**
 
 * Return the colour a tile would be displayed with in the small map in mode "Routes".
 
 *
 
 * @param tile The tile of which we would like to get the colour.
 
 * @param t    Effective tile type of the tile (see #GetEffectiveTileType).
 
 * @return The colour of tile  in the small map in mode "Routes"
 
 */
 
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile)
 
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile, TileType t)
 
{
 
	TileType t = GetEffectiveTileType(tile);
 

	
 
	if (t == MP_STATION) {
 
		switch (GetStationType(tile)) {
 
			case STATION_RAIL:    return MKCOLOUR(0x56565656);
 
			case STATION_AIRPORT: return MKCOLOUR(0xB8B8B8B8);
 
			case STATION_TRUCK:   return MKCOLOUR(0xC2C2C2C2);
 
			case STATION_BUS:     return MKCOLOUR(0xBFBFBFBF);
 
@@ -380,18 +377,17 @@ static const uint32 _vegetation_clear_bi
 
};
 

	
 
/**
 
 * Return the colour a tile would be displayed with in the smallmap in mode "Vegetation".
 
 *
 
 * @param tile The tile of which we would like to get the colour.
 
 * @param t    Effective tile type of the tile (see #GetEffectiveTileType).
 
 * @return The colour of tile  in the smallmap in mode "Vegetation"
 
 */
 
static inline uint32 GetSmallMapVegetationPixels(TileIndex tile)
 
static inline uint32 GetSmallMapVegetationPixels(TileIndex tile, TileType t)
 
{
 
	TileType t = GetEffectiveTileType(tile);
 

	
 
	switch (t) {
 
		case MP_CLEAR:
 
			return (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) < 3) ? MKCOLOUR(0x37373737) : _vegetation_clear_bits[GetClearGround(tile)];
 

	
 
		case MP_INDUSTRY:
 
			return GetIndustrySpec(Industry::GetByTile(tile)->type)->check_proc == CHECK_FOREST ? MKCOLOUR(0xD0D0D0D0) : MKCOLOUR(0xB5B5B5B5);
 
@@ -411,19 +407,20 @@ static inline uint32 GetSmallMapVegetati
 
static uint32 _owner_colours[OWNER_END + 1];
 

	
 
/**
 
 * Return the colour a tile would be displayed with in the small map in mode "Owner".
 
 *
 
 * @param tile The tile of which we would like to get the colour.
 
 * @param t    Effective tile type of the tile (see #GetEffectiveTileType).
 
 * @return The colour of tile in the small map in mode "Owner"
 
 */
 
static inline uint32 GetSmallMapOwnerPixels(TileIndex tile)
 
static inline uint32 GetSmallMapOwnerPixels(TileIndex tile, TileType t)
 
{
 
	Owner o;
 

	
 
	switch (GetEffectiveTileType(tile)) {
 
	switch (t) {
 
		case MP_INDUSTRY: o = OWNER_END;          break;
 
		case MP_HOUSE:    o = OWNER_TOWN;         break;
 
		default:          o = GetTileOwner(tile); break;
 
		/* FIXME: For MP_ROAD there are multiple owners.
 
		 * GetTileOwner returns the rail owner (level crossing) resp. the owner of ROADTYPE_ROAD (normal road),
 
		 * even if there are no ROADTYPE_ROAD bits on the tile.
 
@@ -592,21 +589,23 @@ class SmallMapWindow : public Window {
 
	 * @return Colours to display.
 
	 */
 
	inline uint32 GetTileColours(const TileArea &ta, GetSmallMapPixels *proc) const
 
	{
 
		int importance = 0;
 
		TileIndex tile = INVALID_TILE; // Position of the most important tile.
 
		TileType et = MP_VOID;         // Effective tile type at that position.
 

	
 
		TILE_AREA_LOOP(ti, ta) {
 
			TileType ttype = GetEffectiveTileType(ti);
 
			if (_tiletype_importance[ttype] > importance) {
 
				importance = _tiletype_importance[ttype];
 
				tile = ti;
 
				et = ttype;
 
			}
 
		}
 
		return proc(tile);
 
		return proc(tile, et);
 
	}
 

	
 
	/**
 
	 * Draws one column of tiles of the small map in a certain mode onto the screen buffer, skipping the shifted rows in between.
 
	 *
 
	 * @param dst Pointer to a part of the screen buffer to write to.
0 comments (0 inline, 0 general)