From 6df8df9a9b73dd0bf18982ed645df5e4af3e6dc5 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 15 Nov 2026 14:49:43 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Validate=20tile=20IDs=20in=20sta?= =?UTF-8?q?tic=20insertion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sub-4000 filter entries underflowed to huge tile IDs, and placing on top of statics with corrupt IDs indexed past the tiledata array. --- Server/ULargeScaleOperations.pas | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Server/ULargeScaleOperations.pas b/Server/ULargeScaleOperations.pas index cbb3038..3386a58 100644 --- a/Server/ULargeScaleOperations.pas +++ b/Server/ULargeScaleOperations.pas @@ -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: