From 043a5a1ccfc24c44117984856105f9b4860430df Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 15 Nov 2026 09:27:50 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Free=20the=20light=20collection?= =?UTF-8?q?=20when=20the=20light=20map=20update=20fails?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Client/ULightManager.pas | 64 +++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/Client/ULightManager.pas b/Client/ULightManager.pas index fe2c5ba..2560928 100644 --- a/Client/ULightManager.pas +++ b/Client/ULightManager.pas @@ -285,44 +285,46 @@ begin {Logger.Send([lcClient, lcDebug], 'AWidth', AWidth); Logger.Send([lcClient, lcDebug], 'AHeight', AHeight);} lights := TWorldItemList.Create(False); - SetLength(tileMap, AWidth, AHeight); - for x := 0 to AWidth - 1 do - for y := 0 to AHeight - 1 do - tileMap[x,y] := nil; + try + SetLength(tileMap, AWidth, AHeight); + for x := 0 to AWidth - 1 do + for y := 0 to AHeight - 1 do + tileMap[x,y] := nil; - blockInfo := nil; - while AScreenBuffer.Iterate(blockInfo) do - begin - if blockInfo^.State = ssNormal then + blockInfo := nil; + while AScreenBuffer.Iterate(blockInfo) do begin - if blockInfo^.Item is TStaticItem then - tileID := blockInfo^.Item.TileID + $4000 - else - tileID := blockInfo^.Item.TileID; - tileData := ResMan.Tiledata.TileData[tileID]; + if blockInfo^.State = ssNormal then + begin + if blockInfo^.Item is TStaticItem then + tileID := blockInfo^.Item.TileID + $4000 + else + tileID := blockInfo^.Item.TileID; + tileData := ResMan.Tiledata.TileData[tileID]; - if tdfLightSource in tileData.Flags then - lights.Add(blockInfo^.Item) - else - x := blockInfo^.Item.X - ALeft; - y := blockInfo^.Item.Y - ATop; - if InRange(x, 0, AWidth - 1) and InRange(y, 0, AHeight - 1) then - tileMap[x, y] := blockInfo^.Item; + if tdfLightSource in tileData.Flags then + lights.Add(blockInfo^.Item) + else + x := blockInfo^.Item.X - ALeft; + y := blockInfo^.Item.Y - ATop; + if InRange(x, 0, AWidth - 1) and InRange(y, 0, AHeight - 1) then + tileMap[x, y] := blockInfo^.Item; + end; end; - end; - for i := 0 to lights.Count - 1 do - begin - x := lights[i].X + 1 - ALeft; - y := lights[i].Y + 1 - ATop; - if (x = AWidth) or (y = AHeight) or - (InRange(x, 0, AWidth - 1) and InRange(y, 0, AHeight - 1) and - ((tileMap[x,y] = nil) or (tileMap[x,y].Z < lights[i].Z + 5))) then - FLightSources.Add(TLightSource.Create(Self, lights[i])); + for i := 0 to lights.Count - 1 do + begin + x := lights[i].X + 1 - ALeft; + y := lights[i].Y + 1 - ATop; + if (x = AWidth) or (y = AHeight) or + (InRange(x, 0, AWidth - 1) and InRange(y, 0, AHeight - 1) and + ((tileMap[x,y] = nil) or (tileMap[x,y].Z < lights[i].Z + 5))) then + FLightSources.Add(TLightSource.Create(Self, lights[i])); + end; + finally + lights.Free; end; - lights.Free; - FValid := False; //Logger.ExitMethod([lcClient, lcDebug], 'UpdateLightMap'); end;