Skip to content

Commit

Permalink
Don't crash server when tile with invalid tile is present on the map
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Jan 24, 2025
1 parent 9d20702 commit a6a042e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Client/Map/ClientLandscape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,9 @@ protected override Block LoadBlock(ushort x, ushort y)

return block;
}

public override void LogError(string message)
{
//TODO: Log error
}
}
5 changes: 5 additions & 0 deletions Server/Map/ServerLandscape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,4 +572,9 @@ public void Dispose()
Dispose(true);
GC.SuppressFinalize(this);
}

public override void LogError(string message)
{
_logger.LogError(message);
}
}
2 changes: 2 additions & 0 deletions Shared/BaseLandscape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,6 @@ public void OnStaticTileHued(StaticTile staticTile, ushort newHue)
}

protected abstract Block LoadBlock(ushort x, ushort y);

public abstract void LogError(string message);
}
7 changes: 6 additions & 1 deletion Shared/StaticBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ public void SortTiles(ref StaticTiles[] tiledata)
continue;
foreach (var tile in staticTiles)
{
tile.UpdatePriority(tiledata[tile.Id]);
if(tiledata.Length < tile.Id)
tile.UpdatePriority(tiledata[tile.Id]);
else
{
Landscape.LogError($"StaticTile with invalid Id: {tile.Id}@{tile.X},{tile.Y},{tile.Z}");
}
}
staticTiles.Sort((tile1, tile2) => tile1.PriorityZ.CompareTo(tile2.PriorityZ));
var i = staticTiles.Count;
Expand Down

0 comments on commit a6a042e

Please sign in to comment.