diff options
author | rubidium <rubidium@openttd.org> | 2010-08-26 19:29:20 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-08-26 19:29:20 +0000 |
commit | 08a41c6ee5f1500fcd472e953b2341ef996cb901 (patch) | |
tree | 5a6b472d492733b8747c3b02d7421190d6b08bce /src | |
parent | 327451e820fb4429806e4bcfa2ed824ea3858f5a (diff) | |
download | openttd-08a41c6ee5f1500fcd472e953b2341ef996cb901.tar.xz |
(svn r20631) -Codechange: generalise IsIndustryTileOnWater + simplify so related code
Diffstat (limited to 'src')
-rw-r--r-- | src/industry_cmd.cpp | 4 | ||||
-rw-r--r-- | src/industry_map.h | 11 | ||||
-rw-r--r-- | src/newgrf_industrytiles.cpp | 2 | ||||
-rw-r--r-- | src/water_cmd.cpp | 17 | ||||
-rw-r--r-- | src/water_map.h | 13 |
5 files changed, 21 insertions, 26 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 81d84b414..c0558427c 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -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); diff --git a/src/industry_map.h b/src/industry_map.h index 39d8169e6..33f60ff5d 100644 --- a/src/industry_map.h +++ b/src/industry_map.h @@ -157,17 +157,6 @@ static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx) } /** - * 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) diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index c319c44b2..c088a4ea2 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -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))); diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 78d190d69..74483f7ca 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -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; } diff --git a/src/water_map.h b/src/water_map.h index a7f685270..852396e32 100644 --- a/src/water_map.h +++ b/src/water_map.h @@ -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) { @@ -88,6 +90,17 @@ static inline void SetWaterClass(TileIndex t, WaterClass 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. * @return \c true if any type of clear water like ocean, river, or canal. |