Skip to content

Commit

Permalink
Fix GetTopTiles on land visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Aug 14, 2024
1 parent e5a4963 commit ad95e1f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions CentrED/Map/MapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ public IEnumerable<TileObject> GetTopTiles(TileObject? t1, TileObject? t2)
{
yield return tiles.Last();
}
else if (ShowLand && landTile != null)
else if (landTile != null && CanDrawLand(landTile))
{
yield return landTile;
}
Expand Down Expand Up @@ -838,9 +838,11 @@ public Vector3 Unproject(int x, int y, int z)
);
}

private bool CanDrawLand(ushort id)
private bool CanDrawLand(LandObject lo)
{
return ShowNoDraw | id > 2;
if(lo.Tile.Id <= 2 && !ShowNoDraw)
return false;
return WithinZRange(lo.Tile.Z);
}

public bool CanDrawStatic(StaticObject so)
Expand Down Expand Up @@ -885,7 +887,7 @@ public bool CanDrawStatic(StaticObject so)
return false;
}
var landTile = LandTiles[tile.X, tile.Y];
if (!WithinZRange(tile.Z) || landTile != null && CanDrawLand(landTile.Tile.Id) &&
if (!WithinZRange(tile.Z) || landTile != null && CanDrawLand(landTile) &&
WithinZRange(landTile.Tile.Z) && landTile.AverageZ() >= tile.PriorityZ + 5)
return false;

Expand Down Expand Up @@ -977,11 +979,9 @@ private bool DrawStatic(StaticObject so, Vector4 hueOverride = default)
private void DrawLand(LandObject lo, Vector4 hueOverride = default)
{
var landTile = lo.LandTile;
if (!CanDrawLand(landTile.Id))
return;
if (landTile.Id > TileDataLoader.Instance.LandData.Length)
return;
if (!WithinZRange(landTile.Z))
if (!CanDrawLand(lo))
return;

_mapRenderer.DrawMapObject(lo, hueOverride);
Expand Down

0 comments on commit ad95e1f

Please sign in to comment.