$NetBSD: patch-ac,v 1.1 2004/09/08 12:48:32 sketch Exp $ --- xroads.c.orig 2004-09-08 13:39:59.000000000 +0100 +++ xroads.c 2004-09-08 13:41:00.000000000 +0100 @@ -288,7 +288,7 @@ } /*************************************************************************************************/ -int round( float num ) { /* Round a float to an int */ +int roundup( float num ) { /* Round a float to an int */ return (int)(num+0.5); } @@ -394,11 +394,11 @@ /* VacAttack */ /* if(data[amonst->type].attack1==VACCUUM && (amonst->x==monst[targ].x - || amonst->y==monst[targ].y) && (round(amonst->x) == - trunc(amonst->x) && round(amonst->y) == trunc(amonst->y))) { + || amonst->y==monst[targ].y) && (roundup(amonst->x) == + trunc(amonst->x) && roundup(amonst->y) == trunc(amonst->y))) { */ - if(data[amonst->type].attack1==VACCUUM && (round(amonst->x) == - trunc(amonst->x) && round(amonst->y) == trunc(amonst->y)) && + if(data[amonst->type].attack1==VACCUUM && (roundup(amonst->x) == + trunc(amonst->x) && roundup(amonst->y) == trunc(amonst->y)) && clearshot(amonst, &monst[targ])) { watchentity(amonst, &monst[targ]); vacattack(amonst, &monst[targ]); @@ -423,9 +423,9 @@ else amonst->frame++; if(data[amonst->type].etype!=EFFECT) { - maze[round(oldy)][round(oldx)]=-2; /* Blank out old space */ + maze[roundup(oldy)][roundup(oldx)]=-2; /* Blank out old space */ maze[trunc(oldy)][trunc(oldx)]=-2; - maze[round(amonst->y)][round(amonst->x)]=number; + maze[roundup(amonst->y)][roundup(amonst->x)]=number; maze[trunc(amonst->y)][trunc(amonst->x)]=number; } /* If there was something underneath the effect, redraw it */ @@ -434,8 +434,8 @@ draw_tilex2(mainwindow, data[bmonst->type].tile[bmonst->frame], (bmonst->x)*GRIDSIZE, (bmonst->y)*GRIDSIZE, bmonst->color, bmonst->dir); } - if(maze[round(amonst->y)][round(amonst->x)]!=-2) { - bmonst=&monst[maze[round(amonst->y)][round(amonst->x)]]; + if(maze[roundup(amonst->y)][roundup(amonst->x)]!=-2) { + bmonst=&monst[maze[roundup(amonst->y)][roundup(amonst->x)]]; draw_tilex2(mainwindow, data[bmonst->type].tile[bmonst->frame], (bmonst->x)*GRIDSIZE, (bmonst->y)*GRIDSIZE, bmonst->color, bmonst->dir); } @@ -558,7 +558,7 @@ else if(player->attr & PULL_R) { newx+=1; player->attr &= ~PULL_R; } /* Only one half-step at a time */ - if(round(newx)!=trunc(newx) && round(newy)!=trunc(newy)) { + if(roundup(newx)!=trunc(newx) && roundup(newy)!=trunc(newy)) { #ifdef DEBUG printf("Damn, in two half-steps at a time...\n"); #endif @@ -574,17 +574,17 @@ /* If we're in a half-step, eqx and eqy are the space we're moving into */ - if(round(newx)!=trunc(newx)) { + if(roundup(newx)!=trunc(newx)) { eqy = trunc(newy); if(newx > player->x) - eqx = round(newx); + eqx = roundup(newx); else if(newx < player->x) eqx = trunc(newx); } - else if(round(newy)!=trunc(newy)) { + else if(roundup(newy)!=trunc(newy)) { eqx = trunc(newx); if(newy > player->y) - eqy = round(newy); + eqy = roundup(newy); else if(newy < player->y) eqy = trunc(newy); } @@ -595,9 +595,9 @@ /* switch(player->dir) { case LEFT: eqx = trunc(newx); break; - case RIGHT: eqx = round(newx); break; + case RIGHT: eqx = roundup(newx); break; case UP: eqy = trunc(newy); break; - case DOWN: eqy = round(newy); break; + case DOWN: eqy = roundup(newy); break; default: } */ @@ -610,8 +610,8 @@ printf("Destination (%0.2f, %0.2f)...\n", newx, newy); printf("Equiv (%d, %d)\n", eqx, eqy); printf("@ %d, %d : %d\n", eqx, eqy, maze[eqy][eqx]); - printf("newx: %0.2f: round %d, trunc %d\n", newx, round(newx), trunc(newx)); - printf("newy: %0.2f: round %d, trunc %d\n", newy, round(newy), trunc(newy)); + printf("newx: %0.2f: round %d, trunc %d\n", newx, roundup(newx), trunc(newx)); + printf("newy: %0.2f: round %d, trunc %d\n", newy, roundup(newy), trunc(newy)); printf("Checkdest: %d\n", checkdest(eqx, eqy)); printf("-----\n"); } @@ -647,7 +647,7 @@ #ifdef DEBUG printf("something in the way. (%d or %d)\n", maze[trunc(newy)][trunc(newx)], - maze[round(newy)][round(newy)]); + maze[roundup(newy)][roundup(newy)]); #endif newx=player->x; newy=player->y; @@ -658,14 +658,14 @@ #endif /* Destination has been set, now all we have to do is move there */ - maze[round(player->y)][round(player->x)]=-2; + maze[roundup(player->y)][roundup(player->x)]=-2; maze[trunc(player->y)][trunc(player->x)]=-2; draw_tilex2(mainwindow, blank, player->x*GRIDSIZE, player->y*GRIDSIZE, BLACK, RIGHT); /* Draw player */ player->x=newx; player->y=newy; - maze[round(player->y)][round(player->x)]=player->ind; + maze[roundup(player->y)][roundup(player->x)]=player->ind; maze[trunc(player->y)][trunc(player->x)]=player->ind; draw_tilex2(mainwindow, data[datapos].tile[player->frame], player->x*GRIDSIZE, player->y*GRIDSIZE, @@ -1279,7 +1279,7 @@ player[i]->health = 0; if(player[i]->attr & ACTIVE) { player[i]->attr ^= ACTIVE; - maze[round(player[i]->y)][round(player[i]->x)] = -2; + maze[roundup(player[i]->y)][roundup(player[i]->x)] = -2; maze[trunc(player[i]->y)][trunc(player[i]->x)] = -2; draw_tilex2(mainwindow, blank, player[i]->x*GRIDSIZE, player[i]->y*GRIDSIZE, BLACK, RIGHT);