- Fixed/Changed light source evaluation (again) to match the UO client

This commit is contained in:
Andreas Schneider 2009-12-22 13:51:17 +01:00
parent fd8fa39e0d
commit 186527c606
1 changed files with 17 additions and 26 deletions

View File

@ -253,28 +253,23 @@ var
lights: TWorldItemList; lights: TWorldItemList;
i, x, y, tileID: Integer; i, x, y, tileID: Integer;
tileData: TTiledata; tileData: TTiledata;
tileMap: array of array of TWorldItem;
begin begin
//Logger.EnterMethod([lcClient, lcDebug], 'UpdateLightMap'); //Logger.EnterMethod([lcClient, lcDebug], 'UpdateLightMap');
FLightSources.Clear; FLightSources.Clear;
{Logger.Send([lcClient, lcDebug], 'AWidth', AWidth); {Logger.Send([lcClient, lcDebug], 'AWidth', AWidth);
Logger.Send([lcClient, lcDebug], 'AHeight', AHeight);} Logger.Send([lcClient, lcDebug], 'AHeight', AHeight);}
lights := TWorldItemList.Create(False); lights := TWorldItemList.Create(False);
x := -1; SetLength(tileMap, AWidth, AHeight);
y := -1; for x := 0 to AWidth - 1 do
for y := 0 to AHeight - 1 do
tileMap[x,y] := nil;
blockInfo := nil; blockInfo := nil;
while AScreenBuffer.Iterate(blockInfo) do while AScreenBuffer.Iterate(blockInfo) do
begin begin
if blockInfo^.State = ssNormal then if blockInfo^.State = ssNormal then
begin begin
if (x <> blockInfo^.Item.X) or (y <> blockInfo^.Item.Y) then
begin
for i := 0 to lights.Count - 1 do
FLightSources.Add(TLightSource.Create(Self, lights[i]));
lights.Clear;
x := blockInfo^.Item.X;
y := blockInfo^.Item.Y;
end;
if blockInfo^.Item is TStaticItem then if blockInfo^.Item is TStaticItem then
tileID := blockInfo^.Item.TileID + $4000 tileID := blockInfo^.Item.TileID + $4000
else else
@ -282,25 +277,21 @@ begin
tileData := ResMan.Tiledata.TileData[tileID]; tileData := ResMan.Tiledata.TileData[tileID];
if tdfLightSource in tileData.Flags then if tdfLightSource in tileData.Flags then
begin lights.Add(blockInfo^.Item)
lights.Add(blockInfo^.Item); else
end else tileMap[blockInfo^.Item.X - ALeft, blockInfo^.Item.Y - ATop] :=
if (tdfRoof in tileData.Flags) or (blockInfo^.Item is TMapCell) then blockInfo^.Item;
begin
lights.Clear;
end else
if tdfSurface in tileData.Flags then
begin
for i := lights.Count - 1 downto 0 do
if (blockInfo^.Item.Z > lights[i].Z + 3) and
(blockInfo^.Item.Z < lights[i].Z + 30) then
lights.Delete(i);
end;
end; end;
end; end;
for i := 0 to lights.Count - 1 do for i := 0 to lights.Count - 1 do
FLightSources.Add(TLightSource.Create(Self, lights[i])); begin
x := lights[i].X + 1 - ALeft;
y := lights[i].Y + 1 - ATop;
if (x = AWidth) or (y = AHeight) or (tileMap[x,y] = nil) or
(tileMap[x,y].Z < lights[i].Z + 5) then
FLightSources.Add(TLightSource.Create(Self, lights[i]));
end;
lights.Free; lights.Free;