*/
bool build_type9(PlayerType *player_ptr, dun_data_type *dd_ptr)
{
- int grd, roug, cutoff;
- POSITION xsize, ysize, y0, x0;
-
- bool done, light, room;
-
/* get size: note 'Evenness'*/
- xsize = randint1(22) * 2 + 6;
- ysize = randint1(15) * 2 + 6;
+ auto xsize = randint1(22) * 2 + 6;
+ auto ysize = randint1(15) * 2 + 6;
/* Find and reserve some space in the dungeon. Get center of room. */
- auto *floor_ptr = player_ptr->current_floor_ptr;
+ auto &floor = *player_ptr->current_floor_ptr;
+ int y0;
+ int x0;
if (!find_space(player_ptr, dd_ptr, &y0, &x0, ysize + 1, xsize + 1)) {
/* Limit to the minimum room size, and retry */
xsize = 8;
}
}
- light = done = false;
- room = true;
-
- if ((floor_ptr->dun_level <= randint1(25)) && floor_ptr->get_dungeon_definition().flags.has_not(DungeonFeatureType::DARKNESS)) {
- light = true;
- }
-
- while (!done) {
+ const auto should_brighten = (floor.dun_level <= randint1(25)) && floor.get_dungeon_definition().flags.has_not(DungeonFeatureType::DARKNESS);
+ while (true) {
/* Note: size must be even or there are rounding problems
* This causes the tunnels not to connect properly to the room */
/* testing values for these parameters feel free to adjust */
- grd = 1 << (randint0(4));
+ const auto grd = 1 << (randint0(4));
/* want average of about 16 */
- roug = randint1(8) * randint1(4);
+ const auto roug = randint1(8) * randint1(4);
/* about size/2 */
- cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
- randint1(xsize / 4) + randint1(ysize / 4);
+ const auto cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
+ randint1(xsize / 4) + randint1(ysize / 4);
/* make it */
- generate_hmap(floor_ptr, y0, x0, xsize, ysize, grd, roug, cutoff);
+ generate_hmap(&floor, y0, x0, xsize, ysize, grd, roug, cutoff);
/* Convert to normal format + clean up */
- done = generate_fracave(player_ptr, y0, x0, xsize, ysize, cutoff, light, room);
+ if (generate_fracave(player_ptr, y0, x0, xsize, ysize, cutoff, should_brighten, true)) {
+ break;
+ }
}
return true;