summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f25b549)
raw | patch | inline | side by side (parent: f25b549)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 18 Jan 2018 13:10:31 +0000 (15:10 +0200) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Thu, 18 Jan 2018 13:12:03 +0000 (15:12 +0200) |
src/game/g_grid.pas | patch | blob | history | |
src/game/g_map.pas | patch | blob | history |
diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas
index c2d4412ecc73551caad69b4d308dbb5638aaf3b7..30ed8ee0ae9dc062de5a3897a238de1a2e1c6d48 100644 (file)
--- a/src/game/g_grid.pas
+++ b/src/game/g_grid.pas
//WARNING: don't modify grid while any query is in progress (no checks are made!)
// you can set enabled/disabled flag, tho (but iterator can still return objects disabled inside it)
- // cb with `(nil)` will be called before processing new tile
- // no callback: return object of the nearest hit or nil
+ // return object of the nearest hit or nil
// if `inverted` is true, trace will register bodies *exluding* tagmask
- // `cb` is used unconvetionally here: if it returns `false`, tracer will ignore the object
//WARNING: don't change tags in callbacks here!
- function traceRay (const x0, y0, x1, y1: Integer; cb: TGridQueryCB; tagmask: Integer=-1): ITP; overload;
- function traceRay (out ex, ey: Integer; const ax0, ay0, ax1, ay1: Integer; cb: TGridQueryCB; tagmask: Integer=-1): ITP;
+ function traceRay (const x0, y0, x1, y1: Integer; tagmask: Integer=-1): ITP; overload;
+ function traceRay (out ex, ey: Integer; const ax0, ay0, ax1, ay1: Integer; tagmask: Integer=-1): ITP;
// 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
// ////////////////////////////////////////////////////////////////////////// //
-function TBodyGridBase.traceRay (const x0, y0, x1, y1: Integer; cb: TGridQueryCB; tagmask: Integer=-1): ITP;
+function TBodyGridBase.traceRay (const x0, y0, x1, y1: Integer; tagmask: Integer=-1): ITP;
var
ex, ey: Integer;
begin
- result := traceRay(ex, ey, x0, y0, x1, y1, cb, tagmask);
+ result := traceRay(ex, ey, x0, y0, x1, y1, tagmask);
end;
// no callback: return `true` on the nearest hit
// you are not supposed to understand this
-function TBodyGridBase.traceRay (out ex, ey: Integer; const ax0, ay0, ax1, ay1: Integer; cb: TGridQueryCB; tagmask: Integer=-1): ITP;
+function TBodyGridBase.traceRay (out ex, ey: Integer; const ax0, ay0, ax1, ay1: Integer; tagmask: Integer=-1): ITP;
var
lw: TLineWalker;
ccidx: Integer;
if ((ptag and TagDisabled) = 0) and ((ptag and tagmask) <> 0) and (px.mQueryMark <> lq) then
begin
px.mQueryMark := lq; // mark as processed
- if assigned(cb) then
- begin
- if not cb(px.mObj, ptag) then continue;
- end;
// get adjusted proxy coords
px0 := px.mX-minx;
py0 := px.mY-miny;
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index 29ece6fafd845f590715a7502689b9fc1dc2630a..f78ffe11247aca1dae6f8204975a4305f3d92f23 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
var
ex, ey: Integer;
begin
- result := mapGrid.traceRay(ex, ey, x0, y0, x1, y1, nil, (GridTagWall or GridTagDoor));
+ result := mapGrid.traceRay(ex, ey, x0, y0, x1, y1, (GridTagWall or GridTagDoor));
if (result <> nil) then
begin
if (hitx <> nil) then hitx^ := ex;
@@ -580,7 +580,7 @@ function g_Map_traceToNearest (x0, y0, x1, y1: Integer; tag: Integer; hitx: PInt
var
ex, ey: Integer;
begin
- result := mapGrid.traceRay(ex, ey, x0, y0, x1, y1, nil, tag);
+ result := mapGrid.traceRay(ex, ey, x0, y0, x1, y1, tag);
if (result <> nil) then
begin
if (hitx <> nil) then hitx^ := ex;