diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas
index b4b0e32795cddfaa38864fa8154c2f260e903328..346770246cfd96eb4bb196e9471360ef95763d13 100644 (file)
--- a/src/game/g_grid.pas
+++ b/src/game/g_grid.pas
mProxyFree: TBodyProxyId; // free
mProxyCount: Integer; // currently used
mProxyMaxCount: Integer;
+ mInQuery: Boolean;
public
dbgShowTraceLog: Boolean;
if (x+w <= 0) or (y+h <= 0) then exit;
if (x >= gw*tsize) or (y >= mHeight*tsize) then exit;
+ if mInQuery then raise Exception.Create('recursive queries aren''t supported');
+ mInQuery := true;
+
// increase query counter
Inc(mLastQuery);
if (mLastQuery = 0) then
if (x0+w <= px.mX) or (y0+h <= px.mY) then continue;
if assigned(cb) then
begin
- if cb(px.mObj, ptag) then begin result := px.mObj; exit; end;
+ if cb(px.mObj, ptag) then begin result := px.mObj; mInQuery := false; exit; end;
end
else
begin
result := px.mObj;
+ mInQuery := false;
exit;
end;
end;
end;
end;
end;
+
+ mInQuery := false;
end;
//if (dbgShowTraceLog) then e_WriteLog(Format('raycast start: (%d,%d)-(%d,%d); xptr^=%d; yptr^=%d', [ax0, ay0, ax1, ay1, xptr^, yptr^]), MSG_NOTIFY);
+ if mInQuery then raise Exception.Create('recursive queries aren''t supported');
+ mInQuery := true;
+
// increase query counter
Inc(mLastQuery);
if (mLastQuery = 0) then
result := px.mObj;
ex := x;
ey := y;
+ mInQuery := false;
exit;
end;
end
ex := x;
ey := y;
result := px.mObj;
+ mInQuery := false;
exit;
end;
end;
result := px.mObj;
ex := prevx;
ey := prevy;
+ mInQuery := false;
exit;
end;
end
// next cell
ccidx := cc.next;
end;
- if wasHit and not assigned(cb) then begin result := lastObj; exit; end;
- if assigned(cb) and cb(nil, 0, x, y, x, y) then begin result := lastObj; exit; end;
+ if wasHit and not assigned(cb) then begin result := lastObj; mInQuery := false; exit; end;
+ if assigned(cb) and cb(nil, 0, x, y, x, y) then begin result := lastObj; mInQuery := false; exit; end;
end;
// skip to next tile
if hopt then
end;
// we can travel less than one cell
if wasHit and not assigned(cb) then result := lastObj else begin ex := ax1; ey := ay1; end;
+ mInQuery := false;
exit;
end;
{$ENDIF}
// signal cell completion
if assigned(cb) then
begin
- if cb(nil, 0, xptr^+minx, yptr^+miny, prevx, prevy) then begin result := lastObj; exit; end;
+ if cb(nil, 0, xptr^+minx, yptr^+miny, prevx, prevy) then begin result := lastObj; mInQuery := false; exit; end;
end
else if wasHit then
begin
result := lastObj;
+ mInQuery := false;
exit;
end;
end;
result := px.mObj;
ex := prevx;
ey := prevy;
+ mInQuery := false;
exit;
end;
end
ccidx := -1;
if assigned(cb) then
begin
- if cb(nil, 0, x, y, prevx, prevy) then begin result := lastObj; exit; end;
+ if cb(nil, 0, x, y, prevx, prevy) then begin result := lastObj; mInQuery := false; exit; end;
end
else if wasHit then
begin
result := lastObj;
+ mInQuery := false;
exit;
end;
end;
ex := ax1; // why not?
ey := ay1; // why not?
end;
+
+ mInQuery := false;
end;
//lastGA := (yptr^ div tsize)*gw+(xptr^ div tsize);
//ccidx := mGrid[lastGA];
+ if mInQuery then raise Exception.Create('recursive queries aren''t supported');
+ mInQuery := true;
+
// increase query counter
Inc(mLastQuery);
if (mLastQuery = 0) then
px.mQueryMark := lq; // mark as processed
if assigned(cb) then
begin
- if cb(px.mObj, ptag) then begin result := px.mObj; exit; end;
+ if cb(px.mObj, ptag) then begin result := px.mObj; mInQuery := false; exit; end;
end
else
begin
result := px.mObj;
+ mInQuery := false;
exit;
end;
end;
end;
Dec(wklen, wkstep);
end;
+ mInQuery := false;
exit;
end;
{$ENDIF}
px.mQueryMark := lq; // mark as processed
if assigned(cb) then
begin
- if cb(px.mObj, ptag) then begin result := px.mObj; exit; end;
+ if cb(px.mObj, ptag) then begin result := px.mObj; mInQuery := false; exit; end;
end
else
begin
result := px.mObj;
+ mInQuery := false;
exit;
end;
end;
if (e >= 0) then begin yd += sty; e -= dx2; end else e += dy2;
xd += stx;
end;
+
+ mInQuery := false;
end;