diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas
index 049868c7821e7784afa08dbe18e68ab97c0d6a31..d7263f36e0c244dedd9a8424e113e41e397e1981 100644 (file)
--- a/src/game/g_grid.pas
+++ b/src/game/g_grid.pas
{.$DEFINE D2F_DEBUG_XXQ}
{.$DEFINE D2F_DEBUG_MOVER}
{$ENDIF}
-{$DEFINE GRID_USE_ORTHO_ACCEL}
+{.$DEFINE GRID_USE_ORTHO_ACCEL}
unit g_grid;
interface
// return `false` if we're still inside at the end
// line should be either strict horizontal, or strict vertical, otherwise an exception will be thrown
+ // `true`: endpoint will point at the last "inside" pixel
+ // `false`: endpoint will be (ax1, ay1)
function traceOrthoRayWhileIn (out ex, ey: Integer; ax0, ay0, ax1, ay1: Integer; tagmask: Integer=-1): Boolean;
//WARNING: don't modify grid while any query is in progress (no checks are made!)
// ////////////////////////////////////////////////////////////////////////// //
function TBodyGridBase.getProxyEnabled (pid: TBodyProxyId): Boolean; inline;
begin
- if (pid >= 0) then result := ((mProxies[pid].mTag and TagDisabled) = 0) else result := false;
+ if (pid >= 0) and (pid < Length(mProxies)) then result := ((mProxies[pid].mTag and TagDisabled) = 0) else result := false;
end;
procedure TBodyGridBase.setProxyEnabled (pid: TBodyProxyId; val: Boolean); inline;
begin
- if (pid >= 0) then
+ if (pid >= 0) and (pid < Length(mProxies)) then
begin
if val then
begin
function TBodyGridBase.getProxyById (idx: TBodyProxyId): PBodyProxyRec; inline;
begin
- if (idx >= 0) and (idx < High(mProxies)) then result := @mProxies[idx] else result := nil;
+ if (idx >= 0) and (idx < Length(mProxies)) then result := @mProxies[idx] else result := nil;
end;
else
begin
// down
- while (y0 <= celly1) and (filled[y1-celly0] <> 0) do begin Inc(y0); Inc(ay0); end;
+ while (y0 <= celly1) and (filled[y0-celly0] <> 0) do begin Inc(y0); Inc(ay0); end;
if (ay0 >= ay1) then begin ey := ay1; result := false; exit; end;
if (y0 <= celly1) then begin ey := ay0-1; result := true; exit; end;
end;