X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_grid.pas;h=c1a5f0777cd25a2416e92da03da53834e744a571;hb=f0d4e199f20938613340c53ff24e1eb7a6cc2481;hp=579e5f8dbe90e0b2ba781707e90a54727c58555c;hpb=00d3260470d072699ceb1fe9bf655cbb4880160f;p=d2df-sdl.git diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas index 579e5f8..c1a5f07 100644 --- a/src/game/g_grid.pas +++ b/src/game/g_grid.pas @@ -187,7 +187,7 @@ var 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; @@ -277,7 +277,7 @@ begin xd := x0; yd := y0; e := 2*dsy-dsx; - term := x1; + //!term := x1; xfixed := false; if (y0 < wy0) then @@ -308,6 +308,7 @@ begin if (rem >= dsx) then begin Inc(yd); e -= dx2; end; end; + (* if (y1 > wy1) then begin // clip at bottom @@ -321,10 +322,11 @@ begin 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^; @@ -1147,7 +1149,9 @@ begin // 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); @@ -1172,7 +1176,9 @@ begin 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 @@ -1359,11 +1365,15 @@ begin 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