X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_grid.pas;h=c6fe09534a639f958ca7c300f354120d08a9eee7;hb=c185246bfc49a2ae31fc79ef7c73dc6bcc1073e2;hp=925fb80ca042470d6b78acb7cb623952ef2d77cb;hpb=b79ddd98d923ee15f4bfd1db5111e669fc19964a;p=d2df-sdl.git diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas index 925fb80..c6fe095 100644 --- a/src/game/g_grid.pas +++ b/src/game/g_grid.pas @@ -64,6 +64,9 @@ type //mTileSize: Integer; const mTileSize = GridDefaultTileSize; + public + const tileSize = mTileSize; + private mMinX, mMinY: Integer; // so grids can start at any origin mWidth, mHeight: Integer; // in tiles @@ -1316,8 +1319,10 @@ var ptag: Integer; lastWasInGrid: Boolean; tbcross: Boolean; - f, tedist: Integer; + f: Integer; + //tedist: Integer; begin + log := false; result := Default(ITP); tagmask := tagmask and TagFullMask; if (tagmask = 0) or not assigned(cb) then exit; @@ -1331,6 +1336,8 @@ begin if (dx > 0) then incx := 1 else if (dx < 0) then incx := -1 else incx := 0; if (dy > 0) then incy := 1 else if (dy < 0) then incy := -1 else incy := 0; + if (incx = 0) and (incy = 0) then exit; // just incase + dx := abs(dx); dy := abs(dy); @@ -1410,6 +1417,34 @@ begin if (ccidx = -1) then begin // we have nothing interesting here anymore, jump directly to tile edge + (* + if (incx = 0) then + begin + // vertical line + if (incy < 0) then tedist := y-(y and (not tsize)) else tedist := (y or (tsize-1))-y; + if (tedist > 1) then + begin + if (log) then e_WriteLog(Format(' doing vertical jump from tile (%d,%d) - (%d,%d) by %d steps', [(x div tsize), (y div tsize), x, y, tedist]), MSG_NOTIFY); + y += incy*tedist; + Inc(i, tedist); + if (log) then e_WriteLog(Format(' jumped to tile (%d,%d) - (%d,%d) by %d steps', [(x div tsize), (y div tsize), x, y, tedist]), MSG_NOTIFY); + end; + end + else if (incy = 0) then + begin + // horizontal line + if (incx < 0) then tedist := x-(x and (not tsize)) else tedist := (x or (tsize-1))-x; + if (tedist > 1) then + begin + if (log) then e_WriteLog(Format(' doing horizontal jump from tile (%d,%d) - (%d,%d) by %d steps', [(x div tsize), (y div tsize), x, y, tedist]), MSG_NOTIFY); + x += incx*tedist; + Inc(i, tedist); + if (log) then e_WriteLog(Format(' jumped to tile (%d,%d) - (%d,%d) by %d steps', [(x div tsize), (y div tsize), x, y, tedist]), MSG_NOTIFY); + end; + end; + *) + (* + else if ( // get minimal distance to tile edges if (incx < 0) then tedist := x-(x and (not tsize)) else if (incx > 0) then tedist := (x or (tsize+1))-x else tedist := 0; {$IF DEFINED(D2F_DEBUG)} @@ -1431,6 +1466,7 @@ begin Inc(i, tedist); if (log) then e_WriteLog(Format(' jumped to tile (%d,%d) - (%d,%d) by %d steps', [(x div tsize), (y div tsize), x, y, tedist]), MSG_NOTIFY); end; + *) end; end else