🐛 Validate tile IDs in static insertion

Sub-4000 filter entries underflowed to huge tile IDs, and placing
on top of statics with corrupt IDs indexed past the tiledata array.
This commit is contained in:
2026-11-15 22:08:32 +01:00
parent 8731ec150c
commit 6df8df9a9b
+13 -7
View File
@@ -340,14 +340,17 @@ procedure TLSInsertStatics.Apply(AMapCell: TMapCell; AStatics: TStaticItemList;
var
staticItem, static: TStaticItem;
topZ, staticTop: ShortInt;
i: Integer;
i, tileID: Integer;
begin
if (Length(FTileIDs) = 0) or (Random(100) >= FProbability) then Exit;
tileID := FTileIDs[Random(Length(FTileIDs))];
if tileID < $4000 then Exit;
staticItem := TStaticItem.Create(nil, nil, 0, 0);
staticItem.X := AMapCell.X;
staticItem.Y := AMapCell.Y;
staticItem.TileID := FTileIDs[Random(Length(FTileIDs))] - $4000;
staticItem.TileID := tileID - $4000;
staticItem.Hue := 0;
case FPlacementType of
@@ -361,10 +364,13 @@ begin
for i := 0 to AStatics.Count - 1 do
begin
static := AStatics[i];
staticTop := EnsureRange(static.Z +
CEDServerInstance.Landscape.TiledataProvider.StaticTiles[static.TileID].Height,
-128, 127);
if staticTop > topZ then topZ := staticTop;
if static.TileID < Integer(CEDServerInstance.Landscape.TiledataProvider.StaticCount) then
begin
staticTop := EnsureRange(static.Z +
CEDServerInstance.Landscape.TiledataProvider.StaticTiles[static.TileID].Height,
-128, 127);
if staticTop > topZ then topZ := staticTop;
end;
end;
end;
spFix: