Skip to content

Commit

Permalink
Fix land tile recalculation
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Nov 8, 2024
1 parent 4d2cffa commit 343585b
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions CentrED/Map/MapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,24 @@ public MapManager(GraphicsDevice gd)
{
AddTile(staticTile);
}
//Recalculate tiles one and two tiles away from block, to fix corners and normals
var landBlock = block.LandBlock;
ushort minTileX = (ushort)(landBlock.X * 8);
ushort minTileY = (ushort)(landBlock.Y * 8);
for (ushort x = minTileX ; x < minTileX + 8; x++)
var minTileX = landBlock.X * 8;
var maxTileX = minTileX + 7;
var minTileY = landBlock.Y * 8;
var maxTileY = minTileY + 7;
for (var x = minTileX - 2; x <= maxTileX + 2; x++)
{
if(x == 0 || minTileY == 0) continue;
var newZ = landBlock.Tiles[LandBlock.GetTileIndex(x, minTileY)].Z;
LandTiles?[x - 1, minTileY - 1]?.Update();
LandTiles?[x - 1, minTileY - 2]?.Update();
}
for (ushort y = minTileY ; y < minTileY + 8; y++)
{
if(y == 0 || minTileX == 0) continue;
var newZ = landBlock.Tiles[LandBlock.GetTileIndex(minTileX, y)].Z;
LandTiles?[minTileX - 1, y - 1]?.Update();
LandTiles?[minTileX - 2, y - 1]?.Update();
for (var y = minTileY - 2; y <= maxTileY + 2; y++)
{
if(x >= minTileX && x <= maxTileX && y >= minTileY && y <= maxTileY)
continue; //Within block
if(!Client.IsValidX(x) || !Client.IsValidY(y))
continue;
LandTiles?[x, y]?.Update();
}
}
UpdateLights();
};
Client.BlockUnloaded += block =>
Expand Down

0 comments on commit 343585b

Please sign in to comment.