diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index 7d13205d096c4f0e259fb3411d137dab0f01e917..8fa48d2735c4922cbd930d9a9c41b8abf22827dd 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
procedure g_Map_DrawPanelShadowVolumes(lightX: Integer; lightY: Integer; radius: Integer);
// returns wall index in `gWalls` or -1
-function g_Map_traceToNearestWall (x0, y0, x1, y1: Integer; hitx: PInteger=nil; hity: PInteger=nil): Boolean;
+function g_Map_traceToNearestWall (x0, y0, x1, y1: Integer; hitx: PInteger=nil; hity: PInteger=nil; log: Boolean=false): Boolean;
type
TForEachPanelCB = function (pan: TPanel): Boolean; // return `true` to stop
// wall index in `gWalls` or -1
-function g_Map_traceToNearestWall (x0, y0, x1, y1: Integer; hitx: PInteger=nil; hity: PInteger=nil): Boolean;
+function g_Map_traceToNearestWall (x0, y0, x1, y1: Integer; hitx: PInteger=nil; hity: PInteger=nil; log: Boolean=false): Boolean;
var
ex, ey: Integer;
begin
+ mapGrid.dbgShowTraceLog := log;
result := (mapGrid.traceRay(ex, ey, x0, y0, x1, y1, nil, (GridTagWall or GridTagDoor)) <> nil);
+ mapGrid.dbgShowTraceLog := false;
+ if result then
+ begin
+ if (hitx <> nil) then hitx^ := ex;
+ if (hity <> nil) then hity^ := ey;
+ end
+ else
+ begin
+ if (hitx <> nil) then hitx^ := x1;
+ if (hity <> nil) then hity^ := y1;
+ end;
end;