Changeset - r22413:35b65d631e8f
[Not reviewed]
master
0 1 0
frosch - 8 years ago 2016-07-22 21:29:04
frosch@openttd.org
(svn r27620) -Codechange: Inline GetEffectiveTileType (adf88)
1 file changed with 25 insertions and 24 deletions:
0 comments (0 inline, 0 general)
src/smallmap_gui.cpp
Show inline comments
 
@@ -410,58 +410,42 @@ static const byte _tiletype_importance[]
 
	8, // MP_TUNNELBRIDGE
 
	2, // MP_OBJECT
 
	0,
 
};
 

	
 

	
 
static inline TileType GetEffectiveTileType(TileIndex tile)
 
{
 
	TileType t = GetTileType(tile);
 

	
 
	if (t == MP_TUNNELBRIDGE) {
 
		TransportType tt = GetTunnelBridgeTransportType(tile);
 

	
 
		switch (tt) {
 
			case TRANSPORT_RAIL: t = MP_RAILWAY; break;
 
			case TRANSPORT_ROAD: t = MP_ROAD;    break;
 
			default:             t = MP_WATER;   break;
 
		}
 
	}
 
	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).
 
 * @param t    Effective tile type of the tile (see #GetTileColours).
 
 * @return The colour of tile in the small map in mode "Contour"
 
 */
 
static inline uint32 GetSmallMapContoursPixels(TileIndex tile, TileType t)
 
{
 
	const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour];
 
	return ApplyMask(cs->height_colours[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).
 
 * @param t    Effective tile type of the tile (see #GetTileColours).
 
 * @return The colour of tile in the small map in mode "Vehicles"
 
 */
 
static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile, TileType t)
 
{
 
	const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour];
 
	return ApplyMask(cs->default_colour, &_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).
 
 * @param t    Effective tile type of the tile (see #GetTileColours).
 
 * @return The colour of tile in the small map in mode "Industries"
 
 */
 
static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile, TileType t)
 
{
 
	if (t == MP_INDUSTRY) {
 
		/* If industry is allowed to be seen, use its colour on the map */
 
@@ -480,13 +464,13 @@ 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).
 
 * @param t    Effective tile type of the tile (see #GetTileColours).
 
 * @return The colour of tile  in the small map in mode "Routes"
 
 */
 
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile, TileType t)
 
{
 
	if (t == MP_STATION) {
 
		switch (GetStationType(tile)) {
 
@@ -513,13 +497,13 @@ static inline uint32 GetSmallMapRoutesPi
 
}
 

	
 
/**
 
 * Return the colour a tile would be displayed with in the small map in mode "link stats".
 
 *
 
 * @param tile The tile of which we would like to get the colour.
 
 * @param t    Effective tile type of the tile (see #GetEffectiveTileType).
 
 * @param t    Effective tile type of the tile (see #GetTileColours).
 
 * @return The colour of tile in the small map in mode "link stats"
 
 */
 
static inline uint32 GetSmallMapLinkStatsPixels(TileIndex tile, TileType t)
 
{
 
	return _smallmap_show_heightmap ? GetSmallMapContoursPixels(tile, t) : GetSmallMapRoutesPixels(tile, t);
 
}
 
@@ -536,13 +520,13 @@ 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).
 
 * @param t    Effective tile type of the tile (see #GetTileColours).
 
 * @return The colour of tile  in the smallmap in mode "Vegetation"
 
 */
 
static inline uint32 GetSmallMapVegetationPixels(TileIndex tile, TileType t)
 
{
 
	switch (t) {
 
		case MP_CLEAR:
 
@@ -563,13 +547,13 @@ static inline uint32 GetSmallMapVegetati
 
}
 

	
 
/**
 
 * 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).
 
 * @param t    Effective tile type of the tile (see #GetTileColours).
 
 * @return The colour of tile in the small map in mode "Owner"
 
 */
 
static inline uint32 GetSmallMapOwnerPixels(TileIndex tile, TileType t)
 
{
 
	Owner o;
 

	
 
@@ -751,13 +735,30 @@ inline uint32 SmallMapWindow::GetTileCol
 
{
 
	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);
 
		TileType ttype = GetTileType(tile);
 

	
 
		switch (ttype) {
 
			case MP_TUNNELBRIDGE: {
 
				TransportType tt = GetTunnelBridgeTransportType(tile);
 

	
 
				switch (tt) {
 
					case TRANSPORT_RAIL: ttype = MP_RAILWAY; break;
 
					case TRANSPORT_ROAD: ttype = MP_ROAD;    break;
 
					default:             ttype = MP_WATER;   break;
 
				}
 
				break;
 
			}
 

	
 
			default:
 
				break;
 
		}
 

	
 
		if (_tiletype_importance[ttype] > importance) {
 
			importance = _tiletype_importance[ttype];
 
			tile = ti;
 
			et = ttype;
 
		}
 
	}
0 comments (0 inline, 0 general)