(svn r20631) -Codechange: generalise IsIndustryTileOnWater + simplify so related code

This commit is contained in:
rubidium 2010-08-26 19:29:20 +00:00
parent 327451e820
commit 08a41c6ee5
5 changed files with 21 additions and 26 deletions

View File

@ -338,7 +338,7 @@ static void DrawTile_Industry(TileInfo *ti)
/* 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_BubbleGenerator(TileIndex tile)
static void TileLoop_Industry(TileIndex tile)
{
if (IsIndustryTileOnWater(tile)) TileLoop_Water(tile);
if (IsTileOnWater(tile)) TileLoop_Water(tile);
TriggerIndustryTile(tile, INDTILE_TRIGGER_TILE_LOOP);

View File

@ -156,17 +156,6 @@ static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
SB(_m[t].m6, 2, 1, GB(gfx, 8, 1));
}
/**
* 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

View File

@ -190,7 +190,7 @@ static void IndustryDrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGro
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)));

View File

@ -497,7 +497,7 @@ static bool IsWateredTile(TileIndex tile, Direction from)
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(TileIndex tile)
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(TileIndex tile)
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;
}

View File

@ -68,6 +68,7 @@ static inline WaterTileType GetWaterTileType(TileIndex t)
/**
* 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(TileIndex 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)
{
@ -87,6 +89,17 @@ static inline void SetWaterClass(TileIndex t, WaterClass wc)
SB(_m[t].m1, 5, 2, wc);
}
/**
* 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.