]> granicus.if.org Git - nethack/commitdiff
Minor tweaks to level flipping
authorPasi Kallinen <paxed@alt.org>
Sun, 23 Feb 2020 13:06:44 +0000 (15:06 +0200)
committerPasi Kallinen <paxed@alt.org>
Sun, 23 Feb 2020 13:06:44 +0000 (15:06 +0200)
include/extern.h
src/cmd.c
src/sp_lev.c

index 8c9f559466734fbf41fabf200d2e59aa22799b38..cae10391d4c01e35e3a41d4b168c6332e21cc57e 100644 (file)
@@ -2466,7 +2466,7 @@ E void FDECL(sysopt_seduce_set, (int));
 
 /* ### sp_lev.c ### */
 #if !defined(CROSSCOMPILE) || defined(CROSSCOMPILE_TARGET)
-E void FDECL(flip_level_rnd, (int));
+E void FDECL(flip_level_rnd, (int, BOOLEAN_P));
 E boolean FDECL(check_room, (xchar *, xchar *, xchar *, xchar *, BOOLEAN_P));
 E boolean FDECL(create_room, (XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P,
                               XCHAR_P, XCHAR_P, XCHAR_P));
index 6daa3026fabadf0a5ea8cfa1864715e3396cd94c..30842941238e424f80e0ae75c2328c53f3551175 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1020,13 +1020,13 @@ wiz_level_tele(VOID_ARGS)
 }
 
 /* #wizlevelflip - randomly flip the current level.
-   Does not handle vision, player position, monst mtrack, levregions,
+   Does not handle vision, monst mtrack, levregions,
    as flipping is normally done only during level creation.
  */
 static int
 wiz_level_flip(VOID_ARGS)
 {
-    if (wizard) flip_level_rnd(3);
+    if (wizard) flip_level_rnd(3, TRUE);
     return 0;
 }
 
index ef56a679464ea6e269dac21780d98e31cb65ac16..9ef7ee1c2e5f6a8a1591b194338072ed5db6a0b4 100644 (file)
@@ -27,6 +27,10 @@ static void NDECL(create_des_coder);
 static void NDECL(solidify_map);
 static void FDECL(lvlfill_maze_grid, (int, int, int, int, SCHAR_P));
 static void FDECL(lvlfill_solid, (SCHAR_P, SCHAR_P));
+static void FDECL(flip_drawbridge_horizontal, (struct rm *));
+static void FDECL(flip_drawbridge_vertical, (struct rm *));
+static int FDECL(flip_encoded_direction_bits, (int, int));
+static void FDECL(flip_level, (int, BOOLEAN_P));
 static void FDECL(set_wall_property, (XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P,
                                           int));
 static void NDECL(count_features);
@@ -212,7 +216,7 @@ schar lit;
         }
 }
 
-void
+static void
 flip_drawbridge_horizontal(lev)
 struct rm *lev;
 {
@@ -227,7 +231,7 @@ struct rm *lev;
     }
 }
 
-void
+static void
 flip_drawbridge_vertical(lev)
 struct rm *lev;
 {
@@ -242,7 +246,7 @@ struct rm *lev;
     }
 }
 
-int
+static int
 flip_encoded_direction_bits(int flp, int val)
 {
     /* These depend on xdir[] and ydir[] order */
@@ -263,8 +267,10 @@ flip_encoded_direction_bits(int flp, int val)
 #define FlipX(val) ((maxx - (val)) + minx)
 #define FlipY(val) ((maxy - (val)) + miny)
 
-void
-flip_level(int flp)
+static void
+flip_level(flp, extras)
+int flp;
+boolean extras;
 {
     int x, y, i;
     int minx, miny, maxx, maxy;
@@ -507,6 +513,11 @@ flip_level(int flp)
            }
     }
 
+    if (extras) {
+        if (flp & 1) u.uy = FlipY(u.uy);
+        if (flp & 2) u.ux = FlipX(u.ux);
+    }
+
     fix_wall_spines(1, 0, COLNO-1, ROWNO-1);
 
     vision_reset();
@@ -516,13 +527,15 @@ flip_level(int flp)
 #undef FlipY
 
 void
-flip_level_rnd(int flp)
+flip_level_rnd(flp, extras)
+int flp;
+boolean extras;
 {
     int c = 0;
     if ((flp & 1) && rn2(2)) c |= 1;
     if ((flp & 2) && rn2(2)) c |= 2;
 
-    if (c) flip_level(c);
+    if (c) flip_level(c, extras);
 }
 
 
@@ -5949,7 +5962,7 @@ const char *name;
     if (!g.level.flags.corrmaze)
         wallification(1, 0, COLNO - 1, ROWNO - 1);
 
-    flip_level_rnd(g.coder->allow_flips);
+    flip_level_rnd(g.coder->allow_flips, FALSE);
 
     count_features();