X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_grid.pas;h=d7263f36e0c244dedd9a8424e113e41e397e1981;hb=66d9ad247935e99fe7161849b71ed952cbb85508;hp=049868c7821e7784afa08dbe18e68ab97c0d6a31;hpb=8115b77d3af1120651be9e452acced03ac8aaa9c;p=d2df-sdl.git diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas index 049868c..d7263f3 100644 --- a/src/game/g_grid.pas +++ b/src/game/g_grid.pas @@ -20,7 +20,7 @@ {.$DEFINE D2F_DEBUG_XXQ} {.$DEFINE D2F_DEBUG_MOVER} {$ENDIF} -{$DEFINE GRID_USE_ORTHO_ACCEL} +{.$DEFINE GRID_USE_ORTHO_ACCEL} unit g_grid; interface @@ -199,6 +199,8 @@ type // 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!) @@ -685,13 +687,13 @@ end; // ////////////////////////////////////////////////////////////////////////// // 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 @@ -707,7 +709,7 @@ end; 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; @@ -2559,7 +2561,7 @@ begin 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;