X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_map.pas;h=2c2a6b5c1a18c16e16c35cd2f4210eb79c5b6662;hb=4caa7355c2a35f38ee6fbd541cfed72751a520a4;hp=bbe1d6c3c7dc535a53ed9b84e1ffd31d84e459c1;hpb=a17222535319cb4089e3f9a92711731c015819b3;p=d2df-sdl.git diff --git a/src/game/g_map.pas b/src/game/g_map.pas index bbe1d6c..2c2a6b5 100644 --- a/src/game/g_map.pas +++ b/src/game/g_map.pas @@ -92,9 +92,14 @@ procedure g_Map_LoadState(Var Mem: TBinMemoryReader); procedure g_Map_DrawPanelShadowVolumes(lightX: Integer; lightY: Integer; radius: Integer); -// returns wall index in `gWalls` or -1 +// returns panel or nil +// sets `ex` and `ey` to `x1` and `y1` when no hit was detected function g_Map_traceToNearestWall (x0, y0, x1, y1: Integer; hitx: PInteger=nil; hity: PInteger=nil): TPanel; +// returns panel or nil +// sets `ex` and `ey` to `x1` and `y1` when no hit was detected +function g_Map_traceToNearest (x0, y0, x1, y1: Integer; tag: Integer; hitx: PInteger=nil; hity: PInteger=nil): TPanel; + type TForEachPanelCB = function (pan: TPanel): Boolean; // return `true` to stop @@ -299,6 +304,24 @@ begin end; end; +// returns panel or nil +function g_Map_traceToNearest (x0, y0, x1, y1: Integer; tag: Integer; hitx: PInteger=nil; hity: PInteger=nil): TPanel; +var + ex, ey: Integer; +begin + result := mapGrid.traceRay(ex, ey, x0, y0, x1, y1, nil, tag); + if (result <> nil) 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; + function g_Map_HasAnyPanelAtPoint (x, y: Integer; panelType: Word): Boolean;