OSDN Git Service

#37353 フラクタル型部屋生成処理を rooms.c から rooms-fractal.c/h へ分離。
authorDeskull <deskull@users.sourceforge.jp>
Sun, 16 Sep 2018 00:00:06 +0000 (09:00 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Sun, 16 Sep 2018 00:00:06 +0000 (09:00 +0900)
Separate generation of fractal room from rooms.c to rooms-fractal.c/h.

Hengband_vcs2015/Hengband/Hengband.vcxproj
Hengband_vcs2015/Hengband/Hengband.vcxproj.filters
src/rooms-fractal.c [new file with mode: 0644]
src/rooms-fractal.h [new file with mode: 0644]
src/rooms.c
src/rooms.h

index 33a1b21..ccadf5a 100644 (file)
     <ClCompile Include="..\..\src\realm-trump.c" />\r
     <ClCompile Include="..\..\src\report.c" />\r
     <ClCompile Include="..\..\src\rooms-city.c" />\r
+    <ClCompile Include="..\..\src\rooms-fractal.c" />\r
     <ClCompile Include="..\..\src\rooms-normal.c" />\r
     <ClCompile Include="..\..\src\rooms-pitnest.c" />\r
     <ClCompile Include="..\..\src\rooms-special.c" />\r
     <ClInclude Include="..\..\src\realm-sorcery.h" />\r
     <ClInclude Include="..\..\src\realm-trump.h" />\r
     <ClInclude Include="..\..\src\rooms-city.h" />\r
+    <ClInclude Include="..\..\src\rooms-fractal.h" />\r
     <ClInclude Include="..\..\src\rooms-normal.h" />\r
     <ClInclude Include="..\..\src\rooms-pitnest.h" />\r
     <ClInclude Include="..\..\src\rooms-special.h" />\r
index 2d09743..5987e19 100644 (file)
     <ClCompile Include="..\..\src\rooms-special.c">\r
       <Filter>Source</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="..\..\src\rooms-fractal.c">\r
+      <Filter>Source</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="..\..\src\angband.h">\r
     <ClInclude Include="..\..\src\rooms-special.h">\r
       <Filter>Header</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="..\..\src\rooms-fractal.h">\r
+      <Filter>Header</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ResourceCompile Include="..\..\src\angband.rc" />\r
diff --git a/src/rooms-fractal.c b/src/rooms-fractal.c
new file mode 100644 (file)
index 0000000..7267f76
--- /dev/null
@@ -0,0 +1,68 @@
+#include "angband.h"\r
+#include "grid.h"\r
+#include "generate.h"\r
+#include "rooms.h"\r
+#include "rooms-normal.h"\r
+\r
+/*!\r
+* @brief \83^\83C\83v9\82Ì\95\94\89®\81c\83t\83\89\83N\83^\83\8b\83J\81[\83u\82É\82æ\82é\93´\8cA\90\90¬ / Type 9 -- Driver routine to create fractal cave system\r
+* @return \82È\82µ\r
+*/\r
+bool build_type9(void)\r
+{\r
+       int grd, roug, cutoff;\r
+       POSITION xsize, ysize, y0, x0;\r
+\r
+       bool done, light, room;\r
+\r
+       /* get size: note 'Evenness'*/\r
+       xsize = randint1(22) * 2 + 6;\r
+       ysize = randint1(15) * 2 + 6;\r
+\r
+       /* Find and reserve some space in the dungeon.  Get center of room. */\r
+       if (!find_space(&y0, &x0, ysize + 1, xsize + 1))\r
+       {\r
+               /* Limit to the minimum room size, and retry */\r
+               xsize = 8;\r
+               ysize = 8;\r
+\r
+               /* Find and reserve some space in the dungeon.  Get center of room. */\r
+               if (!find_space(&y0, &x0, ysize + 1, xsize + 1))\r
+               {\r
+                       /*\r
+                       * Still no space?!\r
+                       * Try normal room\r
+                       */\r
+                       return build_type1();\r
+               }\r
+       }\r
+\r
+       light = done = FALSE;\r
+       room = TRUE;\r
+\r
+       if ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS)) light = TRUE;\r
+\r
+       while (!done)\r
+       {\r
+               /* Note: size must be even or there are rounding problems\r
+               * This causes the tunnels not to connect properly to the room */\r
+\r
+               /* testing values for these parameters feel free to adjust */\r
+               grd = 1 << (randint0(4));\r
+\r
+               /* want average of about 16 */\r
+               roug = randint1(8) * randint1(4);\r
+\r
+               /* about size/2 */\r
+               cutoff = randint1(xsize / 4) + randint1(ysize / 4) +\r
+                       randint1(xsize / 4) + randint1(ysize / 4);\r
+\r
+               /* make it */\r
+               generate_hmap(y0, x0, xsize, ysize, grd, roug, cutoff);\r
+\r
+               /* Convert to normal format + clean up */\r
+               done = generate_fracave(y0, x0, xsize, ysize, cutoff, light, room);\r
+       }\r
+\r
+       return TRUE;\r
+}\r
diff --git a/src/rooms-fractal.h b/src/rooms-fractal.h
new file mode 100644 (file)
index 0000000..97eb400
--- /dev/null
@@ -0,0 +1,2 @@
+\r
+extern bool build_type9(void);\r
index 04d1575..d518bcf 100644 (file)
@@ -42,6 +42,7 @@
 #include "rooms.h"
 
 #include "rooms-city.h"
+#include "rooms-fractal.h"
 #include "rooms-normal.h"
 #include "rooms-pitnest.h"
 #include "rooms-special.h"
@@ -628,7 +629,7 @@ static void store_height(int x, int y, int val)
  *    small values are good for smooth walls.
  *  size=length of the side of the square cave system.
  */
-static void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug, int cutoff)
+void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug, int cutoff)
 {
        int xhsize, yhsize, xsize, ysize, maxsize;
 
@@ -985,7 +986,7 @@ static void cave_fill(POSITION y, POSITION x)
 }
 
 
-static bool generate_fracave(int y0, int x0, int xsize, int ysize, int cutoff, bool light, bool room)
+bool generate_fracave(int y0, int x0, int xsize, int ysize, int cutoff, bool light, bool room)
 {
        int x, y, i, xhsize, yhsize;
 
@@ -1169,69 +1170,6 @@ static bool generate_fracave(int y0, int x0, int xsize, int ysize, int cutoff, b
 }
 
 
-/*!
- * @brief タイプ9の部屋…フラクタルカーブによる洞窟生成 / Type 9 -- Driver routine to create fractal cave system
- * @return なし
- */
-static bool build_type9(void)
-{
-       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;
-
-       /* Find and reserve some space in the dungeon.  Get center of room. */
-       if (!find_space(&y0, &x0, ysize + 1, xsize + 1))
-       {
-               /* Limit to the minimum room size, and retry */
-               xsize = 8;
-               ysize = 8;
-
-               /* Find and reserve some space in the dungeon.  Get center of room. */
-               if (!find_space(&y0, &x0, ysize + 1, xsize + 1))
-               {
-                       /*
-                        * Still no space?!
-                        * Try normal room
-                        */
-                       return build_type1();
-               }
-       }
-
-       light = done = FALSE;
-       room = TRUE;
-
-       if ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS)) light = TRUE;
-
-       while (!done)
-       {
-               /* 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));
-
-               /* want average of about 16 */
-               roug = randint1(8) * randint1(4);
-
-               /* about size/2 */
-               cutoff = randint1(xsize / 4) + randint1(ysize / 4) +
-                        randint1(xsize / 4) + randint1(ysize / 4);
-
-               /* make it */
-               generate_hmap(y0, x0, xsize, ysize, grd, roug, cutoff);
-
-               /* Convert to normal format + clean up */
-               done = generate_fracave(y0, x0, xsize, ysize, cutoff, light, room);
-       }
-
-       return TRUE;
-}
-
 #ifdef ALLOW_CAVERNS_AND_LAKES
 /*
  * Builds a cave system in the center of the dungeon.
index a44acba..5b11f56 100644 (file)
@@ -89,4 +89,6 @@ extern void add_outer_wall(int x, int y, int light, int x1, int y1, int x2, int
 extern int dist2(int x1, int y1, int x2, int y2, int h1, int h2, int h3, int h4);
 extern void generate_room_floor(int y1, int x1, int y2, int x2, int light);
 extern void generate_fill_perm_bold(int y1, int x1, int y2, int x2);
+extern void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug, int cutoff);
+extern bool generate_fracave(int y0, int x0, int xsize, int ysize, int cutoff, bool light, bool room);