From: Pasi Kallinen Date: Tue, 18 Feb 2020 14:53:10 +0000 (+0200) Subject: Split bound_digging function to two X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=49069d6d62dcd3df96e096afe340bd3275095de7;p=nethack Split bound_digging function to two Also remove a DCC 3.0 specific bug define, doubt anyone is using that anymore ... --- diff --git a/src/mkmaze.c b/src/mkmaze.c index d37d1c08c..b46185b6b 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -22,6 +22,7 @@ static void FDECL(check_ransacked, (char *)); static void FDECL(migr_booty_item, (int, const char *)); static void FDECL(migrate_orc, (struct monst *, unsigned long)); static void NDECL(stolen_booty); +static void FDECL(get_level_extends, (int *, int *, int *, int *)); /* adjust a coordinate one step in the specified direction */ #define mz_move(X, Y, dir) \ @@ -1224,18 +1225,9 @@ coord *cc; return; } -/* put a non-diggable boundary around the initial portion of a level map. - * assumes that no level will initially put things beyond the isok() range. - * - * we can't bound unconditionally on the last line with something in it, - * because that something might be a niche which was already reachable, - * so the boundary would be breached - * - * we can't bound unconditionally on one beyond the last line, because - * that provides a window of abuse for wallified special levels - */ -void -bound_digging() +static void +get_level_extends(left, top, right, bottom) +int *left, *top, *right, *bottom; { int x, y; unsigned typ; @@ -1243,9 +1235,6 @@ bound_digging() boolean found, nonwall; int xmin, xmax, ymin, ymax; - if (Is_earthlevel(&u.uz)) - return; /* everything diggable here */ - found = nonwall = FALSE; for (xmin = 0; !found && xmin <= COLNO; xmin++) { lev = &levl[xmin][0]; @@ -1306,16 +1295,37 @@ bound_digging() } ymax += (nonwall || !g.level.flags.is_maze_lev) ? 2 : 1; + *left = xmin; + *right = xmax; + *top = ymin; + *bottom = ymax; +} + +/* put a non-diggable boundary around the initial portion of a level map. + * assumes that no level will initially put things beyond the isok() range. + * + * we can't bound unconditionally on the last line with something in it, + * because that something might be a niche which was already reachable, + * so the boundary would be breached + * + * we can't bound unconditionally on one beyond the last line, because + * that provides a window of abuse for wallified special levels + */ +void +bound_digging() +{ + int x, y; + int xmin, xmax, ymin, ymax; + + if (Is_earthlevel(&u.uz)) + return; /* everything diggable here */ + + get_level_extends(&xmin, &ymin, &xmax, &ymax); + for (x = 0; x < COLNO; x++) for (y = 0; y < ROWNO; y++) - if (y <= ymin || y >= ymax || x <= xmin || x >= xmax) { -#ifdef DCC30_BUG - lev = &levl[x][y]; - lev->wall_info |= W_NONDIGGABLE; -#else + if (y <= ymin || y >= ymax || x <= xmin || x >= xmax) levl[x][y].wall_info |= W_NONDIGGABLE; -#endif - } } void