X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_weapons.pas;h=725ab6d701a05634adb9baffe2e256e6b94d41ee;hb=ad4f5ec68b851b9b2dba627e3b199b93f529dc86;hp=97d127a46519fbf1a9c9589247cd468047e43b8b;hpb=443705324dafadbc9b3da84365ad68ae7f52d9ba;p=d2df-sdl.git diff --git a/src/game/g_weapons.pas b/src/game/g_weapons.pas index 97d127a..725ab6d 100644 --- a/src/game/g_weapons.pas +++ b/src/game/g_weapons.pas @@ -20,7 +20,7 @@ unit g_weapons; interface uses - SysUtils, Classes, + SysUtils, Classes, mempool, g_textures, g_basic, e_graphics, g_phys, xprofiler; @@ -1440,13 +1440,12 @@ var end; end; - function sqchecker (mon: TMonster; tag: Integer): Boolean; + procedure sqchecker (mon: TMonster); var mx, my, mw, mh: Integer; inx, iny: Integer; distSq: Integer; begin - result := false; // don't stop mon.getMapBox(mx, my, mw, mh); if lineAABBIntersects(x0, y0, x2, y2, mx, my, mw, mh, inx, iny) then begin @@ -1468,6 +1467,9 @@ var {$IF DEFINED(D2F_DEBUG)} stt: UInt64; {$ENDIF} + pmark: PoolMark; + hitcount: Integer; + pmon: PMonster; begin (* if not gwep_debug_fast_trace then @@ -1522,7 +1524,18 @@ begin if playerPossibleHit() then exit; // instant hit // collect monsters - g_Mons_AlongLine(x, y, x2, y2, sqchecker); + //g_Mons_AlongLine(x, y, x2, y2, sqchecker); + + pmark := framePool.mark(); + hitcount := monsGrid.forEachAlongLine(x, y, x2, y2, -1); + pmon := PMonster(framePool.getPtr(pmark)); + while (hitcount > 0) do + begin + sqchecker(pmon^); + Inc(pmon); + Dec(hitcount); + end; + framePool.release(pmark); // here, we collected all monsters and players in `wgunHitHeap` and `wgunHitTime` // also, if `wallWasHit` is `true`, then `wallHitX` and `wallHitY` contains spark coords