- Fixed more range violations (fixes #82)
This commit is contained in:
parent
abe62e13b8
commit
5c3a8740c1
|
@ -21,7 +21,7 @@
|
||||||
* CDDL HEADER END
|
* CDDL HEADER END
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Portions Copyright 2009 Andreas Schneider
|
* Portions Copyright 2011 Andreas Schneider
|
||||||
*)
|
*)
|
||||||
unit ULightManager;
|
unit ULightManager;
|
||||||
|
|
||||||
|
@ -31,7 +31,8 @@ interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Imaging, ImagingTypes, ImagingClasses, ImagingCanvases,
|
Classes, SysUtils, Imaging, ImagingTypes, ImagingClasses, ImagingCanvases,
|
||||||
ImagingOpenGL, GL, GLu, GLext, fgl, ULandscape, UWorldItem, UCacheManager;
|
ImagingOpenGL, GL, GLu, GLext, fgl, ULandscape, UWorldItem, UCacheManager,
|
||||||
|
Math;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
@ -279,8 +280,10 @@ begin
|
||||||
if tdfLightSource in tileData.Flags then
|
if tdfLightSource in tileData.Flags then
|
||||||
lights.Add(blockInfo^.Item)
|
lights.Add(blockInfo^.Item)
|
||||||
else
|
else
|
||||||
tileMap[blockInfo^.Item.X - ALeft, blockInfo^.Item.Y - ATop] :=
|
x := blockInfo^.Item.X - ALeft;
|
||||||
blockInfo^.Item;
|
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;
|
end;
|
||||||
|
|
||||||
|
@ -288,8 +291,9 @@ begin
|
||||||
begin
|
begin
|
||||||
x := lights[i].X + 1 - ALeft;
|
x := lights[i].X + 1 - ALeft;
|
||||||
y := lights[i].Y + 1 - ATop;
|
y := lights[i].Y + 1 - ATop;
|
||||||
if (x = AWidth) or (y = AHeight) or (tileMap[x,y] = nil) or
|
if (x = AWidth) or (y = AHeight) or
|
||||||
(tileMap[x,y].Z < lights[i].Z + 5) then
|
(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]));
|
FLightSources.Add(TLightSource.Create(Self, lights[i]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* CDDL HEADER END
|
* CDDL HEADER END
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Portions Copyright 2009 Andreas Schneider
|
* Portions Copyright 2011 Andreas Schneider
|
||||||
*)
|
*)
|
||||||
unit ULight;
|
unit ULight;
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ begin
|
||||||
for y := 0 to Height - 1 do
|
for y := 0 to Height - 1 do
|
||||||
for x := 0 to Width - 1 do
|
for x := 0 to Width - 1 do
|
||||||
begin
|
begin
|
||||||
buffer.Read(color, SizeOf(byte));
|
buffer.Read(color, SizeOf(Byte));
|
||||||
color32.R := color * 8;
|
color32.R := Byte(color * 8);
|
||||||
color32.G := color32.R;
|
color32.G := color32.R;
|
||||||
color32.B := color32.R;
|
color32.B := color32.R;
|
||||||
if color > 0 then
|
if color > 0 then
|
||||||
|
|
Loading…
Reference in New Issue