From 1dc371ed27a187b19519537d0012638da5c9c8b4 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 15 Nov 2026 09:08:58 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Free=20the=20block=20index=20whe?= =?UTF-8?q?n=20a=20landscape=20update=20fails=20mid-packet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Client/ULandscape.pas | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/Client/ULandscape.pas b/Client/ULandscape.pas index 3a8f852..2cf76fa 100644 --- a/Client/ULandscape.pas +++ b/Client/ULandscape.pas @@ -770,30 +770,33 @@ var block: TBlock; begin index := TGenericIndex.Create(nil); - while ABuffer.Position < ABuffer.Size do - begin - ABuffer.Read(coords, SizeOf(TBlockCoords)); - id := GetID(coords.X, coords.Y); + try + while ABuffer.Position < ABuffer.Size do + begin + ABuffer.Read(coords, SizeOf(TBlockCoords)); + id := GetID(coords.X, coords.Y); - map := TMapBlock.Create(ABuffer, coords.X, coords.Y); - count := ABuffer.ReadWord; - if count > 0 then - index.Lookup := ABuffer.Position - else - index.Lookup := -1; - index.Size := count * 7; - statics := TSeperatedStaticBlock.Create(ABuffer, index, coords.X, coords.Y); + map := TMapBlock.Create(ABuffer, coords.X, coords.Y); + count := ABuffer.ReadWord; + if count > 0 then + index.Lookup := ABuffer.Position + else + index.Lookup := -1; + index.Size := count * 7; + statics := TSeperatedStaticBlock.Create(ABuffer, index, coords.X, coords.Y); - FBlockCache.RemoveID(id); - block := TBlock.Create(map, statics); - block.UpdateBlockAcess(Self); - FBlockCache.StoreID(id, block); + FBlockCache.RemoveID(id); + block := TBlock.Create(map, statics); + block.UpdateBlockAcess(Self); + FBlockCache.StoreID(id, block); - FOpenRequests[coords.Y * FWidth + coords.X] := False; + FOpenRequests[coords.Y * FWidth + coords.X] := False; - if Assigned(FOnNewBlock) then FOnNewBlock(block); + if Assigned(FOnNewBlock) then FOnNewBlock(block); + end; + finally + index.Free; end; - index.Free; end; procedure TLandscape.OnDrawMapPacket(ABuffer: TEnhancedMemoryStream);