Fix TRON being unable to pathfind to the top and left edges of the screen

This commit is contained in:
jacob1 2022-03-18 18:12:50 -04:00
parent 6ff385d92d
commit 14348437a6
No account linked to committer's email address

View File

@ -234,13 +234,13 @@ static int trymovetron(Simulation * sim, int x, int y, int dir, int i, int len)
rx += tron_rx[dir];
ry += tron_ry[dir];
r = sim->pmap[ry][rx];
if (canmovetron(sim, r, k-1) && !sim->bmap[(ry)/CELL][(rx)/CELL] && ry > CELL && rx > CELL && ry < YRES-CELL && rx < XRES-CELL)
if (canmovetron(sim, r, k-1) && !sim->bmap[(ry)/CELL][(rx)/CELL] && ry >= CELL && rx >= CELL && ry < YRES-CELL && rx < XRES-CELL)
{
count++;
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 = sim->pmap[ty][tx];
if (canmovetron(sim, r, j+k-1) && !sim->bmap[(ty)/CELL][(tx)/CELL] && ty > CELL && tx > CELL && ty < YRES-CELL && tx < XRES-CELL)
if (canmovetron(sim, r, j+k-1) && !sim->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
return len+1;
@ -252,7 +252,7 @@ static int trymovetron(Simulation * sim, 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++)
{
r = sim->pmap[ty][tx];
if (canmovetron(sim, r, j+k-1) && !sim->bmap[(ty)/CELL][(tx)/CELL] && ty > CELL && tx > CELL && ty < YRES-CELL && tx < XRES-CELL)
if (canmovetron(sim, r, j+k-1) && !sim->bmap[(ty)/CELL][(tx)/CELL] && ty >= CELL && tx >= CELL && ty < YRES-CELL && tx < XRES-CELL)
{
if (j == (len-k))
return len+1;