Changeset - r15933:39e6324db57a
[Not reviewed]
master
0 5 0
rubidium - 14 years ago 2010-08-26 19:29:20
rubidium@openttd.org
(svn r20631) -Codechange: generalise IsIndustryTileOnWater + simplify so related code
5 files changed with 21 insertions and 26 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -338,7 +338,7 @@ static void DrawTile_Industry(TileInfo *
 

	
 
	/* If the ground sprite is the default flat water sprite, draw also canal/river borders.
 
	 * Do not do this if the tile's WaterClass is 'land'. */
 
	if (image == SPR_FLAT_WATER_TILE && IsIndustryTileOnWater(ti->tile)) {
 
	if (image == SPR_FLAT_WATER_TILE && IsTileOnWater(ti->tile)) {
 
		DrawWaterClassGround(ti);
 
	} else {
 
		DrawGroundSprite(image, GroundSpritePaletteTransform(image, dits->ground.pal, GENERAL_SPRITE_COLOUR(ind->random_colour)));
 
@@ -791,7 +791,7 @@ static void TileLoopIndustry_BubbleGener
 

	
 
static void TileLoop_Industry(TileIndex tile)
 
{
 
	if (IsIndustryTileOnWater(tile)) TileLoop_Water(tile);
 
	if (IsTileOnWater(tile)) TileLoop_Water(tile);
 

	
 
	TriggerIndustryTile(tile, INDTILE_TRIGGER_TILE_LOOP);
 

	
src/industry_map.h
Show inline comments
 
@@ -157,17 +157,6 @@ static inline void SetIndustryGfx(TileIn
 
}
 

	
 
/**
 
 * Tests if the industry tile was built on water.
 
 * @param t the industry tile
 
 * @return true iff on water
 
 */
 
static inline bool IsIndustryTileOnWater(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_INDUSTRY));
 
	return (GetWaterClass(t) != WATER_CLASS_INVALID);
 
}
 

	
 
/**
 
 * Returns this indutry tile's construction counter value
 
 * @param tile the tile to query
 
 * @pre IsTileType(tile, MP_INDUSTRY)
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -190,7 +190,7 @@ static void IndustryDrawTileLayout(const
 
	if (GB(image, 0, SPRITE_WIDTH) != 0) {
 
		/* If the ground sprite is the default flat water sprite, draw also canal/river borders
 
		 * Do not do this if the tile's WaterClass is 'land'. */
 
		if (image == SPR_FLAT_WATER_TILE && IsIndustryTileOnWater(ti->tile)) {
 
		if (image == SPR_FLAT_WATER_TILE && IsTileOnWater(ti->tile)) {
 
			DrawWaterClassGround(ti);
 
		} else {
 
			DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, GENERAL_SPRITE_COLOUR(rnd_colour)));
src/water_cmd.cpp
Show inline comments
 
@@ -497,7 +497,7 @@ static bool IsWateredTile(TileIndex tile
 
			if ((IsTileType(src_tile, MP_STATION) && IsOilRig(src_tile)) ||
 
			    (IsTileType(src_tile, MP_INDUSTRY) && GetIndustryIndex(src_tile) == GetIndustryIndex(tile))) return true;
 

	
 
			return IsIndustryTileOnWater(tile);
 
			return IsTileOnWater(tile);
 
		}
 

	
 
		case MP_TUNNELBRIDGE: return GetTunnelBridgeTransportType(tile) == TRANSPORT_WATER && ReverseDiagDir(GetTunnelBridgeDirection(tile)) == DirToDiagDir(from);
 
@@ -932,9 +932,11 @@ FloodingBehaviour GetFloodingBehaviour(T
 
			if (IsCoast(tile)) {
 
				Slope tileh = GetTileSlope(tile, NULL);
 
				return (IsSlopeWithOneCornerRaised(tileh) ? FLOOD_ACTIVE : FLOOD_DRYUP);
 
			} else {
 
				return (GetWaterClass(tile) == WATER_CLASS_SEA) ? FLOOD_ACTIVE : FLOOD_NONE;
 
			}
 
			/* FALL THROUGH */
 
		case MP_STATION:
 
		case MP_INDUSTRY:
 
			return (GetWaterClass(tile) == WATER_CLASS_SEA) ? FLOOD_ACTIVE : FLOOD_NONE;
 

	
 
		case MP_RAILWAY:
 
			if (GetRailGroundType(tile) == RAIL_GROUND_WATER) {
 
@@ -945,15 +947,6 @@ FloodingBehaviour GetFloodingBehaviour(T
 
		case MP_TREES:
 
			return (GetTreeGround(tile) == TREE_GROUND_SHORE ? FLOOD_DRYUP : FLOOD_NONE);
 

	
 
		case MP_STATION:
 
			if (IsBuoy(tile) || (IsDock(tile) && GetTileSlope(tile, NULL) == SLOPE_FLAT) || IsOilRig(tile)) {
 
				return (GetWaterClass(tile) == WATER_CLASS_SEA ? FLOOD_ACTIVE : FLOOD_NONE);
 
			}
 
			return FLOOD_NONE;
 

	
 
		case MP_INDUSTRY:
 
			return ((IsIndustryTileOnWater(tile) && GetWaterClass(tile) == WATER_CLASS_SEA) ? FLOOD_ACTIVE : FLOOD_NONE);
 

	
 
		default:
 
			return FLOOD_NONE;
 
	}
src/water_map.h
Show inline comments
 
@@ -68,6 +68,7 @@ static inline WaterTileType GetWaterTile
 
/**
 
 * Get the water class at a tile.
 
 * @param t Water tile to query.
 
 * @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)
 
 * @return Water class at the tile.
 
 */
 
static inline WaterClass GetWaterClass(TileIndex t)
 
@@ -80,6 +81,7 @@ static inline WaterClass GetWaterClass(T
 
 * Set the water class at a tile.
 
 * @param t  Water tile to change.
 
 * @param wc New water class.
 
 * @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)
 
 */
 
static inline void SetWaterClass(TileIndex t, WaterClass wc)
 
{
 
@@ -88,6 +90,17 @@ static inline void SetWaterClass(TileInd
 
}
 

	
 
/**
 
 * Tests if the tile was built on water.
 
 * @param t the tile to check
 
 * @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)
 
 * @return true iff on water
 
 */
 
static inline bool IsTileOnWater(TileIndex t)
 
{
 
	return (GetWaterClass(t) != WATER_CLASS_INVALID);
 
}
 

	
 
/**
 
 * Is it a plain water tile?
 
 * @param t Water tile to query.
 
 * @return \c true if any type of clear water like ocean, river, or canal.
0 comments (0 inline, 0 general)