OSDN Git Service

[Refactor] #3950 rooms-fractal.cpp において、変数宣言と代入を同時にするよう差し替えた
authorHourier <66951241+Hourier@users.noreply.github.com>
Sat, 27 Apr 2024 10:50:43 +0000 (19:50 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sun, 28 Apr 2024 05:25:45 +0000 (14:25 +0900)
src/room/rooms-fractal.cpp

index 3a26a58..6a4ed95 100644 (file)
  */
 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;
@@ -41,32 +38,28 @@ bool build_type9(PlayerType *player_ptr, dun_data_type *dd_ptr)
         }
     }
 
-    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;