#define FlipX(val) ((maxx - (val)) + minx)
#define FlipY(val) ((maxy - (val)) + miny)
+#define inFlipArea(x,y) ((x) >= minx && (x) <= maxx && (y) >= miny && (y) <= maxy)
/* transpose top with bottom or left with right or both; sometimes called
for new special levels, or for any level via the #wizlevelflip command */
struct engr *etmp;
struct mkroom *sroom;
timer_element *timer;
+ boolean ball_active = (Punished && uball->where != OBJ_FREE);
+ boolean ball_fliparea;
get_level_extends(&minx, &miny, &maxx, &maxy);
/* get_level_extends() returns -1,-1 to COLNO,ROWNO at max */
if (maxy >= ROWNO)
maxy = (ROWNO - 1);
+ ball_fliparea = Punished
+ && inFlipArea(uball->ox, uball->oy) == inFlipArea(uchain->ox, uchain->oy)
+ && inFlipArea(uball->ox, uball->oy) == inFlipArea(u.ux, u.uy);
+
+ if (ball_active && extras && !ball_fliparea)
+ unplacebc();
+
/* stairs and ladders */
if (flp & 1) {
if (xupstair)
/* traps */
for (ttmp = g.ftrap; ttmp; ttmp = ttmp->ntrap) {
- if (ttmp->tx < minx || ttmp->tx > maxx
- || ttmp->ty < miny || ttmp->ty > maxy)
+ if (!inFlipArea(ttmp->tx, ttmp->ty))
continue;
if (flp & 1) {
ttmp->ty = FlipY(ttmp->ty);
/* objects */
for (otmp = fobj; otmp; otmp = otmp->nobj) {
- if (otmp->ox < minx || otmp->ox > maxx
- || otmp->oy < miny || otmp->oy > maxy)
+ if (!inFlipArea(otmp->ox, otmp->oy))
continue;
if (flp & 1)
otmp->oy = FlipY(otmp->oy);
/* buried objects */
for (otmp = g.level.buriedobjlist; otmp; otmp = otmp->nobj) {
- if (otmp->ox < minx || otmp->ox > maxx
- || otmp->oy < miny || otmp->oy > maxy)
+ if (!inFlipArea(otmp->ox, otmp->oy))
continue;
if (flp & 1)
otmp->oy = FlipY(otmp->oy);
if (mtmp->isgd && mtmp->mx == 0)
continue;
/* skip the occasional earth elemental outside the flip area */
- if (mtmp->mx < minx || mtmp->mx > maxx
- || mtmp->my < miny || mtmp->my > maxy)
+ if (!inFlipArea(mtmp->mx, mtmp->my))
continue;
if (flp & 1) {
mtmp->my = FlipY(mtmp->my);
if (flp & 2)
u.ux = FlipX(u.ux), u.ux0 = FlipX(u.ux0);
}
+ if (ball_active && !ball_fliparea)
+ placebc();
}
fix_wall_spines(1, 0, COLNO - 1, ROWNO - 1);
#undef FlipX
#undef FlipY
+#undef inFlipArea
/* randomly transpose top with bottom or left with right or both;
caller controls which transpositions are allowed */