OSDN Git Service

[Refactor] #40570 Separated treasure-deployment.c/h from rooms.c/h
authorHourier <hourier@users.sourceforge.jp>
Fri, 24 Jul 2020 03:24:45 +0000 (12:24 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 26 Jul 2020 08:04:20 +0000 (17:04 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/room/rooms-vault.c
src/room/rooms.c
src/room/rooms.h
src/room/treasure-deployment.c [new file with mode: 0644]
src/room/treasure-deployment.h [new file with mode: 0644]

index dd319cc..720eee5 100644 (file)
     <ClCompile Include="..\..\src\room\cave-filler.c" />\r
     <ClCompile Include="..\..\src\room\room-generator.c" />\r
     <ClCompile Include="..\..\src\room\room-info-table.c" />\r
+    <ClCompile Include="..\..\src\room\treasure-deployment.c" />\r
     <ClCompile Include="..\..\src\save\floor-writer.c" />\r
     <ClCompile Include="..\..\src\save\info-writer.c" />\r
     <ClCompile Include="..\..\src\save\item-writer.c" />\r
     <ClInclude Include="..\..\src\room\room-generator.h" />\r
     <ClInclude Include="..\..\src\room\room-info-table.h" />\r
     <ClInclude Include="..\..\src\room\room-types.h" />\r
+    <ClInclude Include="..\..\src\room\treasure-deployment.h" />\r
     <ClInclude Include="..\..\src\save\floor-writer.h" />\r
     <ClInclude Include="..\..\src\save\info-writer.h" />\r
     <ClInclude Include="..\..\src\save\item-writer.h" />\r
index bcaca37..7eca52f 100644 (file)
     <ClCompile Include="..\..\src\system\dungeon-data-definition.c">
       <Filter>system</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\room\treasure-deployment.c">
+      <Filter>room</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\combat\shoot.h">
     <ClInclude Include="..\..\src\system\dungeon-data-definition.h">
       <Filter>system</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\room\treasure-deployment.h">
+      <Filter>room</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index a3a7565..250f86f 100644 (file)
@@ -615,6 +615,7 @@ hengband_SOURCES = \
        room/rooms-vault.c room/rooms-vault.h \
        room/rooms-pit-nest.c room/rooms-pit-nest.h \
        room/pit-nest-kinds-table.c room/pit-nest-kinds-table.h \
+       room/treasure-deployment.c room/treasure-deployment.h \
        \
        save/floor-writer.c save/floor-writer.h \
        save/info-writer.c save/info-writer.h \
index 54f074c..78555b2 100644 (file)
@@ -21,6 +21,7 @@
 #include "room/cave-filler.h"
 #include "room/lake-types.h"
 #include "room/rooms.h"
+#include "room/treasure-deployment.h"
 #include "store/store-util.h"
 #include "store/store.h"
 #include "system/dungeon-data-definition.h"
index d17d39d..9f69d13 100644 (file)
@@ -60,6 +60,7 @@
 #include "room/rooms-special.h"
 #include "room/rooms-trap.h"
 #include "room/rooms-vault.h"
+#include "room/treasure-deployment.h"
 #include "system/dungeon-data-definition.h"
 #include "system/floor-type-definition.h"
 #include "util/bit-flags-calculator.h"
@@ -358,81 +359,6 @@ void build_lake(player_type *player_ptr, int type)
 }
 
 /*
- * Routine that fills the empty areas of a room with treasure and monsters.
- */
-void fill_treasure(player_type *player_ptr, POSITION x1, POSITION x2, POSITION y1, POSITION y2, int difficulty)
-{
-    POSITION cx = (x1 + x2) / 2;
-    POSITION cy = (y1 + y2) / 2;
-    POSITION size = abs(x2 - x1) + abs(y2 - y1);
-    floor_type *floor_ptr = player_ptr->current_floor_ptr;
-    for (POSITION x = x1; x <= x2; x++) {
-        for (POSITION y = y1; y <= y2; y++) {
-            s32b value = ((((s32b)(distance(cx, cy, x, y))) * 100) / size) + randint1(10) - difficulty;
-            if ((randint1(100) - difficulty * 3) > 50)
-                value = 20;
-
-            if (!is_floor_bold(floor_ptr, y, x) && (!cave_have_flag_bold(floor_ptr, y, x, FF_PLACE) || !cave_have_flag_bold(floor_ptr, y, x, FF_DROP)))
-                continue;
-
-            if (value < 0) {
-                floor_ptr->monster_level = floor_ptr->base_level + 40;
-                place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
-                floor_ptr->monster_level = floor_ptr->base_level;
-                floor_ptr->object_level = floor_ptr->base_level + 20;
-                place_object(player_ptr, y, x, AM_GOOD);
-                floor_ptr->object_level = floor_ptr->base_level;
-            } else if (value < 5) {
-                floor_ptr->monster_level = floor_ptr->base_level + 20;
-                place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
-                floor_ptr->monster_level = floor_ptr->base_level;
-                floor_ptr->object_level = floor_ptr->base_level + 10;
-                place_object(player_ptr, y, x, AM_GOOD);
-                floor_ptr->object_level = floor_ptr->base_level;
-            } else if (value < 10) {
-                floor_ptr->monster_level = floor_ptr->base_level + 9;
-                place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
-                floor_ptr->monster_level = floor_ptr->base_level;
-            } else if (value < 17) {
-            } else if (value < 23) {
-                if (randint0(100) < 25) {
-                    place_object(player_ptr, y, x, 0L);
-                } else {
-                    place_trap(player_ptr, y, x);
-                }
-            } else if (value < 30) {
-                floor_ptr->monster_level = floor_ptr->base_level + 5;
-                place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
-                floor_ptr->monster_level = floor_ptr->base_level;
-                place_trap(player_ptr, y, x);
-            } else if (value < 40) {
-                if (randint0(100) < 50) {
-                    floor_ptr->monster_level = floor_ptr->base_level + 3;
-                    place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
-                    floor_ptr->monster_level = floor_ptr->base_level;
-                }
-
-                if (randint0(100) < 50) {
-                    floor_ptr->object_level = floor_ptr->base_level + 7;
-                    place_object(player_ptr, y, x, 0L);
-                    floor_ptr->object_level = floor_ptr->base_level;
-                }
-            } else if (value < 50) {
-                place_trap(player_ptr, y, x);
-            } else {
-                if (randint0(100) < 20) {
-                    place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
-                } else if (randint0(100) < 50) {
-                    place_trap(player_ptr, y, x);
-                } else if (randint0(100) < 50) {
-                    place_object(player_ptr, y, x, 0L);
-                }
-            }
-        }
-    }
-}
-
-/*
  * Overlay a rectangular room given its bounds
  * This routine is used by build_room_vault
  * The area inside the walls is not touched:
index 0c21929..393e99d 100644 (file)
@@ -29,7 +29,6 @@ bool find_space(player_type *player_ptr, POSITION *y, POSITION *x, POSITION heig
 void build_small_room(player_type *player_ptr, POSITION x0, POSITION y0);
 void add_outer_wall(player_type *player_ptr, POSITION x, POSITION y, int light, POSITION x1, POSITION y1, POSITION x2, POSITION y2);
 POSITION dist2(POSITION x1, POSITION y1, POSITION x2, POSITION y2, POSITION h1, POSITION h2, POSITION h3, POSITION h4);
-void fill_treasure(player_type *player_ptr, POSITION x1, POSITION x2, POSITION y1, POSITION y2, int difficulty);
 void build_recursive_room(player_type *player_ptr, POSITION x1, POSITION y1, POSITION x2, POSITION y2, int power);
 void build_room(player_type *player_ptr, POSITION x1, POSITION x2, POSITION y1, POSITION y2);
 void r_visit(player_type *player_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2, int node, DIRECTION dir, int *visited);
diff --git a/src/room/treasure-deployment.c b/src/room/treasure-deployment.c
new file mode 100644 (file)
index 0000000..8af5f9d
--- /dev/null
@@ -0,0 +1,91 @@
+/*!
+ * @brief 部屋にアイテム・モンスター・罠を配置する処理
+ * @date 2020/07/24
+ * @author Hourier
+ */
+
+#include "room/treasure-deployment.h"
+#include "floor/cave.h"
+#include "floor/floor.h"
+#include "grid/feature-flag-types.h"
+#include "grid/grid.h"
+#include "grid/trap.h"
+#include "monster-floor/monster-generator.h"
+#include "monster-floor/place-monster-types.h"
+#include "object-enchant/item-apply-magic.h"
+#include "system/floor-type-definition.h"
+
+/*
+ * Routine that fills the empty areas of a room with treasure and monsters.
+ */
+void fill_treasure(player_type *player_ptr, POSITION x1, POSITION x2, POSITION y1, POSITION y2, int difficulty)
+{
+    POSITION cx = (x1 + x2) / 2;
+    POSITION cy = (y1 + y2) / 2;
+    POSITION size = abs(x2 - x1) + abs(y2 - y1);
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    for (POSITION x = x1; x <= x2; x++) {
+        for (POSITION y = y1; y <= y2; y++) {
+            s32b value = ((((s32b)(distance(cx, cy, x, y))) * 100) / size) + randint1(10) - difficulty;
+            if ((randint1(100) - difficulty * 3) > 50)
+                value = 20;
+
+            if (!is_floor_bold(floor_ptr, y, x) && (!cave_have_flag_bold(floor_ptr, y, x, FF_PLACE) || !cave_have_flag_bold(floor_ptr, y, x, FF_DROP)))
+                continue;
+
+            if (value < 0) {
+                floor_ptr->monster_level = floor_ptr->base_level + 40;
+                place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
+                floor_ptr->monster_level = floor_ptr->base_level;
+                floor_ptr->object_level = floor_ptr->base_level + 20;
+                place_object(player_ptr, y, x, AM_GOOD);
+                floor_ptr->object_level = floor_ptr->base_level;
+            } else if (value < 5) {
+                floor_ptr->monster_level = floor_ptr->base_level + 20;
+                place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
+                floor_ptr->monster_level = floor_ptr->base_level;
+                floor_ptr->object_level = floor_ptr->base_level + 10;
+                place_object(player_ptr, y, x, AM_GOOD);
+                floor_ptr->object_level = floor_ptr->base_level;
+            } else if (value < 10) {
+                floor_ptr->monster_level = floor_ptr->base_level + 9;
+                place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
+                floor_ptr->monster_level = floor_ptr->base_level;
+            } else if (value < 17) {
+            } else if (value < 23) {
+                if (randint0(100) < 25) {
+                    place_object(player_ptr, y, x, 0L);
+                } else {
+                    place_trap(player_ptr, y, x);
+                }
+            } else if (value < 30) {
+                floor_ptr->monster_level = floor_ptr->base_level + 5;
+                place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
+                floor_ptr->monster_level = floor_ptr->base_level;
+                place_trap(player_ptr, y, x);
+            } else if (value < 40) {
+                if (randint0(100) < 50) {
+                    floor_ptr->monster_level = floor_ptr->base_level + 3;
+                    place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
+                    floor_ptr->monster_level = floor_ptr->base_level;
+                }
+
+                if (randint0(100) < 50) {
+                    floor_ptr->object_level = floor_ptr->base_level + 7;
+                    place_object(player_ptr, y, x, 0L);
+                    floor_ptr->object_level = floor_ptr->base_level;
+                }
+            } else if (value < 50) {
+                place_trap(player_ptr, y, x);
+            } else {
+                if (randint0(100) < 20) {
+                    place_monster(player_ptr, y, x, PM_ALLOW_SLEEP | PM_ALLOW_GROUP);
+                } else if (randint0(100) < 50) {
+                    place_trap(player_ptr, y, x);
+                } else if (randint0(100) < 50) {
+                    place_object(player_ptr, y, x, 0L);
+                }
+            }
+        }
+    }
+}
diff --git a/src/room/treasure-deployment.h b/src/room/treasure-deployment.h
new file mode 100644 (file)
index 0000000..bd68310
--- /dev/null
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "system/angband.h"
+
+void fill_treasure(player_type *player_ptr, POSITION x1, POSITION x2, POSITION y1, POSITION y2, int difficulty);