🚨 Free the block index when a landscape update fails mid-packet
This commit is contained in:
+22
-19
@@ -770,30 +770,33 @@ var
|
|||||||
block: TBlock;
|
block: TBlock;
|
||||||
begin
|
begin
|
||||||
index := TGenericIndex.Create(nil);
|
index := TGenericIndex.Create(nil);
|
||||||
while ABuffer.Position < ABuffer.Size do
|
try
|
||||||
begin
|
while ABuffer.Position < ABuffer.Size do
|
||||||
ABuffer.Read(coords, SizeOf(TBlockCoords));
|
begin
|
||||||
id := GetID(coords.X, coords.Y);
|
ABuffer.Read(coords, SizeOf(TBlockCoords));
|
||||||
|
id := GetID(coords.X, coords.Y);
|
||||||
|
|
||||||
map := TMapBlock.Create(ABuffer, coords.X, coords.Y);
|
map := TMapBlock.Create(ABuffer, coords.X, coords.Y);
|
||||||
count := ABuffer.ReadWord;
|
count := ABuffer.ReadWord;
|
||||||
if count > 0 then
|
if count > 0 then
|
||||||
index.Lookup := ABuffer.Position
|
index.Lookup := ABuffer.Position
|
||||||
else
|
else
|
||||||
index.Lookup := -1;
|
index.Lookup := -1;
|
||||||
index.Size := count * 7;
|
index.Size := count * 7;
|
||||||
statics := TSeperatedStaticBlock.Create(ABuffer, index, coords.X, coords.Y);
|
statics := TSeperatedStaticBlock.Create(ABuffer, index, coords.X, coords.Y);
|
||||||
|
|
||||||
FBlockCache.RemoveID(id);
|
FBlockCache.RemoveID(id);
|
||||||
block := TBlock.Create(map, statics);
|
block := TBlock.Create(map, statics);
|
||||||
block.UpdateBlockAcess(Self);
|
block.UpdateBlockAcess(Self);
|
||||||
FBlockCache.StoreID(id, block);
|
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;
|
end;
|
||||||
index.Free;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TLandscape.OnDrawMapPacket(ABuffer: TEnhancedMemoryStream);
|
procedure TLandscape.OnDrawMapPacket(ABuffer: TEnhancedMemoryStream);
|
||||||
|
|||||||
Reference in New Issue
Block a user