Should fix any border crashes

This commit is contained in:
cracker64 2012-04-18 11:57:27 -03:00
parent 64629df1af
commit c0947d9fea

View File

@ -61,7 +61,7 @@ int trymovetron(int x, int y, int dir, int i, int len)
for (tx = rx - tron_ry[dir] , ty = ry - tron_rx[dir], j=1; abs(tx-rx) < (len-k) && abs(ty-ry) < (len-k); tx-=tron_ry[dir],ty-=tron_rx[dir],j++) for (tx = rx - tron_ry[dir] , ty = ry - tron_rx[dir], j=1; abs(tx-rx) < (len-k) && abs(ty-ry) < (len-k); tx-=tron_ry[dir],ty-=tron_rx[dir],j++)
{ {
r = pmap[ty][tx]; r = pmap[ty][tx];
if (!r && !bmap[(ty)/CELL][(tx)/CELL] && ry > CELL && rx > CELL && ry < YRES-CELL && rx < XRES-CELL) if (!r && !bmap[(ty)/CELL][(tx)/CELL] && ty > CELL && tx > CELL && ty < YRES-CELL && tx < XRES-CELL)
{ {
if (j == (len-k))//there is a safe path, so we can break out if (j == (len-k))//there is a safe path, so we can break out
return len+1; return len+1;
@ -73,7 +73,7 @@ int trymovetron(int x, int y, int dir, int i, int len)
for (tx = rx + tron_ry[dir] , ty = ry + tron_rx[dir], j=1; abs(tx-rx) < (len-k) && abs(ty-ry) < (len-k); tx+=tron_ry[dir],ty+=tron_rx[dir],j++) for (tx = rx + tron_ry[dir] , ty = ry + tron_rx[dir], j=1; abs(tx-rx) < (len-k) && abs(ty-ry) < (len-k); tx+=tron_ry[dir],ty+=tron_rx[dir],j++)
{ {
r = pmap[ty][tx]; r = pmap[ty][tx];
if (!r && !bmap[(ty)/CELL][(tx)/CELL] && ry > CELL && rx > CELL && ry < YRES-CELL && rx < XRES-CELL) if (!r && !bmap[(ty)/CELL][(tx)/CELL] && ty > CELL && tx > CELL && ty < YRES-CELL && tx < XRES-CELL)
{ {
if (j == (len-k)) if (j == (len-k))
return len+1; return len+1;