mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r20631) -Codechange: generalise IsIndustryTileOnWater + simplify so related code
This commit is contained in:
parent
327451e820
commit
08a41c6ee5
|
@ -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.
|
/* 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'. */
|
* 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);
|
DrawWaterClassGround(ti);
|
||||||
} else {
|
} else {
|
||||||
DrawGroundSprite(image, GroundSpritePaletteTransform(image, dits->ground.pal, GENERAL_SPRITE_COLOUR(ind->random_colour)));
|
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)
|
static void TileLoop_Industry(TileIndex tile)
|
||||||
{
|
{
|
||||||
if (IsIndustryTileOnWater(tile)) TileLoop_Water(tile);
|
if (IsTileOnWater(tile)) TileLoop_Water(tile);
|
||||||
|
|
||||||
TriggerIndustryTile(tile, INDTILE_TRIGGER_TILE_LOOP);
|
TriggerIndustryTile(tile, INDTILE_TRIGGER_TILE_LOOP);
|
||||||
|
|
||||||
|
|
|
@ -156,17 +156,6 @@ static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
|
||||||
SB(_m[t].m6, 2, 1, GB(gfx, 8, 1));
|
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
|
* Returns this indutry tile's construction counter value
|
||||||
* @param tile the tile to query
|
* @param tile the tile to query
|
||||||
|
|
|
@ -190,7 +190,7 @@ static void IndustryDrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGro
|
||||||
if (GB(image, 0, SPRITE_WIDTH) != 0) {
|
if (GB(image, 0, SPRITE_WIDTH) != 0) {
|
||||||
/* If the ground sprite is the default flat water sprite, draw also canal/river borders
|
/* 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'. */
|
* 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);
|
DrawWaterClassGround(ti);
|
||||||
} else {
|
} else {
|
||||||
DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, GENERAL_SPRITE_COLOUR(rnd_colour)));
|
DrawGroundSprite(image, GroundSpritePaletteTransform(image, pal, GENERAL_SPRITE_COLOUR(rnd_colour)));
|
||||||
|
|
|
@ -497,7 +497,7 @@ static bool IsWateredTile(TileIndex tile, Direction from)
|
||||||
if ((IsTileType(src_tile, MP_STATION) && IsOilRig(src_tile)) ||
|
if ((IsTileType(src_tile, MP_STATION) && IsOilRig(src_tile)) ||
|
||||||
(IsTileType(src_tile, MP_INDUSTRY) && GetIndustryIndex(src_tile) == GetIndustryIndex(tile))) return true;
|
(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);
|
case MP_TUNNELBRIDGE: return GetTunnelBridgeTransportType(tile) == TRANSPORT_WATER && ReverseDiagDir(GetTunnelBridgeDirection(tile)) == DirToDiagDir(from);
|
||||||
|
@ -932,9 +932,11 @@ FloodingBehaviour GetFloodingBehaviour(TileIndex tile)
|
||||||
if (IsCoast(tile)) {
|
if (IsCoast(tile)) {
|
||||||
Slope tileh = GetTileSlope(tile, NULL);
|
Slope tileh = GetTileSlope(tile, NULL);
|
||||||
return (IsSlopeWithOneCornerRaised(tileh) ? FLOOD_ACTIVE : FLOOD_DRYUP);
|
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:
|
case MP_RAILWAY:
|
||||||
if (GetRailGroundType(tile) == RAIL_GROUND_WATER) {
|
if (GetRailGroundType(tile) == RAIL_GROUND_WATER) {
|
||||||
|
@ -945,15 +947,6 @@ FloodingBehaviour GetFloodingBehaviour(TileIndex tile)
|
||||||
case MP_TREES:
|
case MP_TREES:
|
||||||
return (GetTreeGround(tile) == TREE_GROUND_SHORE ? FLOOD_DRYUP : FLOOD_NONE);
|
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:
|
default:
|
||||||
return FLOOD_NONE;
|
return FLOOD_NONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,7 @@ static inline WaterTileType GetWaterTileType(TileIndex t)
|
||||||
/**
|
/**
|
||||||
* Get the water class at a tile.
|
* Get the water class at a tile.
|
||||||
* @param t Water tile to query.
|
* @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.
|
* @return Water class at the tile.
|
||||||
*/
|
*/
|
||||||
static inline WaterClass GetWaterClass(TileIndex t)
|
static inline WaterClass GetWaterClass(TileIndex t)
|
||||||
|
@ -80,6 +81,7 @@ static inline WaterClass GetWaterClass(TileIndex t)
|
||||||
* Set the water class at a tile.
|
* Set the water class at a tile.
|
||||||
* @param t Water tile to change.
|
* @param t Water tile to change.
|
||||||
* @param wc New water class.
|
* @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)
|
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);
|
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?
|
* Is it a plain water tile?
|
||||||
* @param t Water tile to query.
|
* @param t Water tile to query.
|
||||||
|
|
Loading…
Reference in New Issue