mirror of https://github.com/OpenTTD/OpenTTD
(svn r7607) -Codechange: remove direct map accesses for snow/desert on tunnels and bridges.
parent
9cb975f7f0
commit
0d459f909c
13
bridge_map.h
13
bridge_map.h
|
@ -81,6 +81,19 @@ static inline TransportType GetBridgeTransportType(TileIndex t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline bool HasBridgeSnowOrDesert(TileIndex t)
|
||||||
|
{
|
||||||
|
assert(IsBridgeTile(t));
|
||||||
|
return HASBIT(_m[t].m4, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline void SetBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
|
||||||
|
{
|
||||||
|
assert(IsBridgeTile(t));
|
||||||
|
SB(_m[t].m4, 7, 1, snow_or_desert);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the end of a bridge in the specified direction starting at a middle tile
|
* Finds the end of a bridge in the specified direction starting at a middle tile
|
||||||
*/
|
*/
|
||||||
|
|
12
tunnel_map.h
12
tunnel_map.h
|
@ -35,6 +35,18 @@ static inline TransportType GetTunnelTransportType(TileIndex t)
|
||||||
return (TransportType)GB(_m[t].m5, 2, 2);
|
return (TransportType)GB(_m[t].m5, 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool HasTunnelSnowOrDesert(TileIndex t)
|
||||||
|
{
|
||||||
|
assert(IsTunnelTile(t));
|
||||||
|
return HASBIT(_m[t].m4, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void SetTunnelSnowOrDesert(TileIndex t, bool snow_or_desert)
|
||||||
|
{
|
||||||
|
assert(IsTunnelTile(t));
|
||||||
|
SB(_m[t].m4, 7, 1, snow_or_desert);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TileIndex GetOtherTunnelEnd(TileIndex);
|
TileIndex GetOtherTunnelEnd(TileIndex);
|
||||||
bool IsTunnelInWay(TileIndex, uint z);
|
bool IsTunnelInWay(TileIndex, uint z);
|
||||||
|
|
|
@ -798,7 +798,6 @@ uint GetBridgeFoundation(Slope tileh, Axis axis)
|
||||||
static void DrawTile_TunnelBridge(TileInfo *ti)
|
static void DrawTile_TunnelBridge(TileInfo *ti)
|
||||||
{
|
{
|
||||||
uint32 image;
|
uint32 image;
|
||||||
bool ice = _m[ti->tile].m4 & 0x80;
|
|
||||||
|
|
||||||
if (IsTunnel(ti->tile)) {
|
if (IsTunnel(ti->tile)) {
|
||||||
if (GetTunnelTransportType(ti->tile) == TRANSPORT_RAIL) {
|
if (GetTunnelTransportType(ti->tile) == TRANSPORT_RAIL) {
|
||||||
|
@ -807,7 +806,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
||||||
image = SPR_TUNNEL_ENTRY_REAR_ROAD;
|
image = SPR_TUNNEL_ENTRY_REAR_ROAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ice) image += 32;
|
if (HasTunnelSnowOrDesert(ti->tile)) image += 32;
|
||||||
|
|
||||||
image += GetTunnelDirection(ti->tile) * 2;
|
image += GetTunnelDirection(ti->tile) * 2;
|
||||||
DrawGroundSprite(image);
|
DrawGroundSprite(image);
|
||||||
|
@ -817,6 +816,7 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
||||||
DrawBridgeMiddle(ti);
|
DrawBridgeMiddle(ti);
|
||||||
} else if (IsBridge(ti->tile)) { // XXX is this necessary?
|
} else if (IsBridge(ti->tile)) { // XXX is this necessary?
|
||||||
int base_offset;
|
int base_offset;
|
||||||
|
bool ice = HasBridgeSnowOrDesert(ti->tile);
|
||||||
|
|
||||||
if (GetBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
|
if (GetBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
|
||||||
base_offset = GetRailTypeInfo(GetRailType(ti->tile))->bridge_offset;
|
base_offset = GetRailTypeInfo(GetRailType(ti->tile))->bridge_offset;
|
||||||
|
@ -1109,17 +1109,26 @@ static void AnimateTile_TunnelBridge(TileIndex tile)
|
||||||
|
|
||||||
static void TileLoop_TunnelBridge(TileIndex tile)
|
static void TileLoop_TunnelBridge(TileIndex tile)
|
||||||
{
|
{
|
||||||
|
bool snow_or_desert = IsTunnelTile(tile) ? HasTunnelSnowOrDesert(tile) : HasBridgeSnowOrDesert(tile);
|
||||||
switch (_opt.landscape) {
|
switch (_opt.landscape) {
|
||||||
case LT_HILLY:
|
case LT_HILLY:
|
||||||
if (HASBIT(_m[tile].m4, 7) != (GetTileZ(tile) > _opt.snow_line)) {
|
if (snow_or_desert != (GetTileZ(tile) > _opt.snow_line)) {
|
||||||
TOGGLEBIT(_m[tile].m4, 7);
|
if (IsTunnelTile(tile)) {
|
||||||
|
SetTunnelSnowOrDesert(tile, !snow_or_desert);
|
||||||
|
} else {
|
||||||
|
SetBridgeSnowOrDesert(tile, !snow_or_desert);
|
||||||
|
}
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LT_DESERT:
|
case LT_DESERT:
|
||||||
if (GetTropicZone(tile) == TROPICZONE_DESERT && !(_m[tile].m4 & 0x80)) {
|
if (GetTropicZone(tile) == TROPICZONE_DESERT && !snow_or_desert) {
|
||||||
_m[tile].m4 |= 0x80;
|
if (IsTunnelTile(tile)) {
|
||||||
|
SetTunnelSnowOrDesert(tile, true);
|
||||||
|
} else {
|
||||||
|
SetBridgeSnowOrDesert(tile, true);
|
||||||
|
}
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue