From: Pasi Kallinen Date: Sun, 23 Feb 2020 13:06:44 +0000 (+0200) Subject: Minor tweaks to level flipping X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=509576a8b7f5a39f3ef326ed50bcf46037ce9782;p=nethack Minor tweaks to level flipping --- diff --git a/include/extern.h b/include/extern.h index 8c9f55946..cae10391d 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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)); diff --git a/src/cmd.c b/src/cmd.c index 6daa3026f..308429412 100644 --- 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; } diff --git a/src/sp_lev.c b/src/sp_lev.c index ef56a6794..9ef7ee1c2 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -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();