From b8565578eb84de7420a9dc2423dc0bfd6ffe5281 Mon Sep 17 00:00:00 2001 From: kaczy Date: Thu, 22 Feb 2024 13:40:58 +0100 Subject: [PATCH] Added extra ways of tile validation --- CentrED/Map/LandObject.cs | 1 + CentrED/Map/MapManager.cs | 8 ++++---- CentrED/Map/MapObject.cs | 5 ++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CentrED/Map/LandObject.cs b/CentrED/Map/LandObject.cs index 46486d4..1da6384 100644 --- a/CentrED/Map/LandObject.cs +++ b/CentrED/Map/LandObject.cs @@ -88,6 +88,7 @@ public void UpdateId(ushort newId) if (Texture == null) { Console.WriteLine($"No texture found for land {Tile.X},{Tile.Y},{Tile.Z}:0x{newId:X}, texmap:{useTexMap}"); + Valid = false; return; } diff --git a/CentrED/Map/MapManager.cs b/CentrED/Map/MapManager.cs index 4da8db2..3f2fc37 100644 --- a/CentrED/Map/MapManager.cs +++ b/CentrED/Map/MapManager.cs @@ -885,7 +885,7 @@ private void DrawSelectionBuffer() for (var y = ViewRange.Top; y < ViewRange.Bottom; y++) { var landTile = LandTiles[x, y]; - if (landTile != null && landTile.Visible) + if (landTile != null && landTile.CanDraw) { DrawLand(landTile, landTile.ObjectIdColor); } @@ -894,7 +894,7 @@ private void DrawSelectionBuffer() if(tiles == null) continue; foreach (var tile in tiles) { - if (tile.Visible) + if (tile.CanDraw) { DrawStatic(tile, tile.ObjectIdColor); } @@ -927,7 +927,7 @@ private void DrawLand() for (var y = ViewRange.Top; y < ViewRange.Bottom; y++) { var tile = LandTiles[x, y]; - if (tile != null && tile.Visible) + if (tile != null && tile.CanDraw) { var hueOverride = Vector4.Zero; if (WalkableSurfaces && !TileDataLoader.Instance.LandData[tile.LandTile.Id].IsWet) @@ -971,7 +971,7 @@ private void DrawStatics() if(tiles == null) continue; foreach (var tile in tiles) { - if (tile.Visible) + if (tile.CanDraw) { var hueOverride = Vector4.Zero; if (WalkableSurfaces && TileDataLoader.Instance.StaticData[tile.Tile.Id].IsSurface) diff --git a/CentrED/Map/MapObject.cs b/CentrED/Map/MapObject.cs index 8f7f0b0..d57e267 100644 --- a/CentrED/Map/MapObject.cs +++ b/CentrED/Map/MapObject.cs @@ -28,8 +28,11 @@ public static int GetNextId() public readonly int ObjectId; public readonly Vector4 ObjectIdColor; + - public bool Visible = true; + public bool Valid = true; + public bool Visible; + public bool CanDraw => Valid && Visible; public Texture2D Texture; public Rectangle TextureBounds; public MapVertex[] Vertices = new MapVertex[4];