🐛 Free the block parts when loading corrupt map data fails

A failed block creation leaked the already constructed halves and
the index.
This commit is contained in:
2026-11-15 22:08:32 +01:00
parent 208ad57777
commit e38a487d56
+10
View File
@@ -538,6 +538,10 @@ var
index: TGenericIndex; index: TGenericIndex;
begin begin
FMap.Position := ((AX * FHeight) + AY) * 196; FMap.Position := ((AX * FHeight) + AY) * 196;
map := nil;
statics := nil;
index := nil;
try
map := TMapBlock.Create(FMap, AX, AY); map := TMapBlock.Create(FMap, AX, AY);
FStaIdx.Position := ((AX * FHeight) + AY) * 12; FStaIdx.Position := ((AX * FHeight) + AY) * 12;
@@ -547,6 +551,12 @@ begin
index.Free; index.Free;
Result := TBlock.Create(map, statics); Result := TBlock.Create(map, statics);
except
map.Free;
statics.Free;
index.Free;
raise;
end;
FBlockCache.StoreID(GetID(AX, AY), Result); FBlockCache.StoreID(GetID(AX, AY), Result);
end; end;