diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas
index 579e5f8dbe90e0b2ba781707e90a54727c58555c..c1a5f0777cd25a2416e92da03da53834e744a571 100644 (file)
--- a/src/game/g_grid.pas
+++ b/src/game/g_grid.pas
xd, yd: Integer; // current coord
e: Integer; // "error" (as in bresenham algo)
rem: Integer;
- term: Integer;
+ //!term: Integer;
d0, d1: PInteger;
xfixed: Boolean;
temp: Integer;
xd := x0;
yd := y0;
e := 2*dsy-dsx;
- term := x1;
+ //!term := x1;
xfixed := false;
if (y0 < wy0) then
if (rem >= dsx) then begin Inc(yd); e -= dx2; end;
end;
+ (*
if (y1 > wy1) then
begin
// clip at bottom
Inc(term); // draw last point
//if (term = xd) then exit; // this is the only point, get out of here
+ *)
if (sty = -1) then yd := -yd;
- if (stx = -1) then begin xd := -xd; term := -term; end;
- dx2 -= dy2;
+ if (stx = -1) then begin xd := -xd; {!term := -term;} end;
+ //!dx2 -= dy2;
inx := d0^;
iny := d1^;
// done?
if (xd = term) then exit;
+ {$IF DEFINED(D2F_DEBUG)}
if (xptr^ < 0) or (yptr^ < 0) or (xptr^ >= gw*tsize) and (yptr^ > mHeight*tsize) then raise Exception.Create('raycaster internal error (0)');
+ {$ENDIF}
//if (dbgShowTraceLog) then e_WriteLog(Format('raycast start: (%d,%d)-(%d,%d); xptr^=%d; yptr^=%d', [ax0, ay0, ax1, ay1, xptr^, yptr^]), MSG_NOTIFY);
while (xd <> term) do
begin
// check cell(s)
+ {$IF DEFINED(D2F_DEBUG)}
if (xptr^ < 0) or (yptr^ < 0) or (xptr^ >= gw*tsize) and (yptr^ > mHeight*tsize) then raise Exception.Create('raycaster internal error (0)');
+ {$ENDIF}
// new tile?
ga := (yptr^ div tsize)*gw+(xptr^ div tsize);
if (ga <> lastGA) then
xerr += dx;
yerr += dy;
// invariant: one of those always changed
+ {$IF DEFINED(D2F_DEBUG)}
if (xerr < 0) and (yerr < 0) then raise Exception.Create('internal bug in grid raycaster (0)');
+ {$ENDIF}
if (xerr >= 0) then begin xerr -= d; x += incx; stepx := incx; end else stepx := 0;
if (yerr >= 0) then begin yerr -= d; y += incy; stepy := incy; end else stepy := 0;
// invariant: we always doing a step
+ {$IF DEFINED(D2F_DEBUG)}
if ((stepx or stepy) = 0) then raise Exception.Create('internal bug in grid raycaster (1)');
+ {$ENDIF}
begin
// check for crossing tile/grid boundary
if (x >= 0) and (y >= 0) and (x <= maxx) and (y <= maxy) then