mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r27157) -Fix: Mark bridge middle tiles dirty when building/removing/changing bridges.
This commit is contained in:
parent
ff1f465191
commit
e8e49e5dda
|
@ -1688,13 +1688,11 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
|||
YapfNotifyTrackLayoutChange(tile, track);
|
||||
YapfNotifyTrackLayoutChange(endtile, track);
|
||||
|
||||
MarkTileDirtyByTile(tile);
|
||||
MarkTileDirtyByTile(endtile);
|
||||
|
||||
if (IsBridge(tile)) {
|
||||
TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile));
|
||||
TileIndex t = tile + delta;
|
||||
for (; t != endtile; t += delta) MarkTileDirtyByTile(t); // TODO encapsulate this into a function
|
||||
MarkBridgeDirty(tile);
|
||||
} else {
|
||||
MarkTileDirtyByTile(tile);
|
||||
MarkTileDirtyByTile(endtile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -246,12 +246,11 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
|
|||
}
|
||||
|
||||
/* Mark tiles dirty that have been repaved */
|
||||
MarkTileDirtyByTile(tile);
|
||||
MarkTileDirtyByTile(other_end);
|
||||
if (IsBridge(tile)) {
|
||||
TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile));
|
||||
|
||||
for (TileIndex t = tile + delta; t != other_end; t += delta) MarkTileDirtyByTile(t);
|
||||
MarkBridgeDirty(tile);
|
||||
} else {
|
||||
MarkTileDirtyByTile(tile);
|
||||
MarkTileDirtyByTile(other_end);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -747,12 +746,11 @@ do_clear:;
|
|||
SetRoadOwner(tile, rt, company);
|
||||
|
||||
/* Mark tiles dirty that have been repaved */
|
||||
MarkTileDirtyByTile(other_end);
|
||||
MarkTileDirtyByTile(tile);
|
||||
if (IsBridge(tile)) {
|
||||
TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile));
|
||||
|
||||
for (TileIndex t = tile + delta; t != other_end; t += delta) MarkTileDirtyByTile(t);
|
||||
MarkBridgeDirty(tile);
|
||||
} else {
|
||||
MarkTileDirtyByTile(other_end);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
#include "map_func.h"
|
||||
|
||||
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height);
|
||||
void MarkBridgeDirty(TileIndex tile);
|
||||
|
||||
/**
|
||||
* Calculates the length of a tunnel or a bridge (without end tiles)
|
||||
* @param begin The begin of the tunnel or bridge.
|
||||
|
|
|
@ -52,6 +52,33 @@ TileIndex _build_tunnel_endtile; ///< The end of a tunnel; as hidden return from
|
|||
/** Z position of the bridge sprites relative to bridge height (downwards) */
|
||||
static const int BRIDGE_Z_START = 3;
|
||||
|
||||
|
||||
/**
|
||||
* Mark bridge tiles dirty.
|
||||
* Note: The bridge does not need to exist, everything is passed via parameters.
|
||||
* @param begin Start tile.
|
||||
* @param end End tile.
|
||||
* @param direction Direction from \a begin to \a end.
|
||||
* @param bridge_height Bridge height level.
|
||||
*/
|
||||
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height)
|
||||
{
|
||||
TileIndexDiff delta = TileOffsByDiagDir(direction);
|
||||
for (TileIndex t = begin; t != end; t += delta) {
|
||||
MarkTileDirtyByTile(t, bridge_height - TileHeight(t));
|
||||
}
|
||||
MarkTileDirtyByTile(end);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark bridge tiles dirty.
|
||||
* @param tile Bridge head.
|
||||
*/
|
||||
void MarkBridgeDirty(TileIndex tile)
|
||||
{
|
||||
MarkBridgeDirty(tile, GetOtherTunnelBridgeEnd(tile), GetTunnelBridgeDirection(tile), GetBridgeHeight(tile));
|
||||
}
|
||||
|
||||
/** Reset the data been eventually changed by the grf loaded. */
|
||||
void ResetBridges()
|
||||
{
|
||||
|
@ -506,10 +533,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
|||
}
|
||||
|
||||
/* Mark all tiles dirty */
|
||||
TileIndexDiff delta = (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||
for (TileIndex tile = tile_start; tile <= tile_end; tile += delta) {
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
MarkBridgeDirty(tile_start, tile_end, AxisToDiagDir(direction), z_start);
|
||||
DirtyCompanyInfrastructureWindows(owner);
|
||||
}
|
||||
|
||||
|
@ -926,7 +950,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
|
|||
if (height < minz) SetRoadside(c, ROADSIDE_PAVED);
|
||||
}
|
||||
ClearBridgeMiddle(c);
|
||||
MarkTileDirtyByTile(c);
|
||||
MarkTileDirtyByTile(c, height - TileHeight(c));
|
||||
}
|
||||
|
||||
if (rail) {
|
||||
|
|
|
@ -2232,14 +2232,15 @@ void ConstrainAllViewportsZoom()
|
|||
/**
|
||||
* Mark a tile given by its index dirty for repaint.
|
||||
* @param tile The tile to mark dirty.
|
||||
* @param bridge_level_offset Height of bridge on tile to also mark dirty. (Height level relative to north corner.)
|
||||
* @ingroup dirty
|
||||
*/
|
||||
void MarkTileDirtyByTile(TileIndex tile)
|
||||
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset)
|
||||
{
|
||||
Point pt = RemapCoords(TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE, TilePixelHeight(tile));
|
||||
MarkAllViewportsDirty(
|
||||
pt.x - MAX_TILE_EXTENT_LEFT,
|
||||
pt.y - MAX_TILE_EXTENT_TOP,
|
||||
pt.y - MAX_TILE_EXTENT_TOP - ZOOM_LVL_BASE * TILE_HEIGHT * bridge_level_offset,
|
||||
pt.x + MAX_TILE_EXTENT_RIGHT,
|
||||
pt.y + MAX_TILE_EXTENT_BOTTOM);
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ void UpdateAllVirtCoords();
|
|||
|
||||
extern Point _tile_fract_coords;
|
||||
|
||||
void MarkTileDirtyByTile(TileIndex tile);
|
||||
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset = 0);
|
||||
|
||||
int GetRowAtTile(int viewport_y, Point tile, bool bridge_correct);
|
||||
void MarkTileDirtyByTileOutsideMap(int x, int y);
|
||||
|
|
Loading…
Reference in New Issue