Clean up set_apparxy()
This commit removes the gotos from set_apparxy, making it easier to read. It also cuts out at 1-2 variable assignments on certain calls, so technically it is an efficiency win as well.
This commit is contained in:
committed by
Pasi Kallinen
parent
f83eaade32
commit
a2a79a1250
+17
-11
@@ -1828,13 +1828,14 @@ set_apparxy(register struct monst* mtmp)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* pet knows your smell; grabber still has hold of you */
|
/* pet knows your smell; grabber still has hold of you */
|
||||||
if (mtmp->mtame || mtmp == u.ustuck)
|
if (mtmp->mtame || mtmp == u.ustuck ||
|
||||||
goto found_you;
|
/* monsters which know where you are don't suddenly forget,
|
||||||
|
|
||||||
/* monsters which know where you are don't suddenly forget,
|
|
||||||
if you haven't moved away */
|
if you haven't moved away */
|
||||||
if (u_at(mx, my))
|
u_at(mx,my)) {
|
||||||
goto found_you;
|
mtmp->mux = u.ux;
|
||||||
|
mtmp->muy = u.uy;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
notseen = (!mtmp->mcansee || (Invis && !perceives(mtmp->data)));
|
notseen = (!mtmp->mcansee || (Invis && !perceives(mtmp->data)));
|
||||||
notthere = (Displaced && mtmp->data != &mons[PM_DISPLACER_BEAST]);
|
notthere = (Displaced && mtmp->data != &mons[PM_DISPLACER_BEAST]);
|
||||||
@@ -1850,8 +1851,11 @@ set_apparxy(register struct monst* mtmp)
|
|||||||
} else {
|
} else {
|
||||||
disp = 0;
|
disp = 0;
|
||||||
}
|
}
|
||||||
if (!disp)
|
if (!disp) {
|
||||||
goto found_you;
|
mtmp->mux = u.ux;
|
||||||
|
mtmp->muy = u.uy;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* without something like the following, invisibility and displacement
|
/* without something like the following, invisibility and displacement
|
||||||
are too powerful */
|
are too powerful */
|
||||||
@@ -1861,8 +1865,11 @@ set_apparxy(register struct monst* mtmp)
|
|||||||
register int try_cnt = 0;
|
register int try_cnt = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (++try_cnt > 200)
|
if (++try_cnt > 200) {
|
||||||
goto found_you; /* punt */
|
mx = u.ux;
|
||||||
|
my = u.uy;
|
||||||
|
break; /* punt */
|
||||||
|
}
|
||||||
mx = u.ux - disp + rn2(2 * disp + 1);
|
mx = u.ux - disp + rn2(2 * disp + 1);
|
||||||
my = u.uy - disp + rn2(2 * disp + 1);
|
my = u.uy - disp + rn2(2 * disp + 1);
|
||||||
} while (!isok(mx, my)
|
} while (!isok(mx, my)
|
||||||
@@ -1873,7 +1880,6 @@ set_apparxy(register struct monst* mtmp)
|
|||||||
&& (can_ooze(mtmp) || can_fog(mtmp)))))
|
&& (can_ooze(mtmp) || can_fog(mtmp)))))
|
||||||
|| !couldsee(mx, my));
|
|| !couldsee(mx, my));
|
||||||
} else {
|
} else {
|
||||||
found_you:
|
|
||||||
mx = u.ux;
|
mx = u.ux;
|
||||||
my = u.uy;
|
my = u.uy;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user