From ac7fcb2f2873d4bee7aa34507dfe348e82ffe757 Mon Sep 17 00:00:00 2001 From: Deskull Date: Sat, 15 Sep 2018 17:05:54 +0900 Subject: [PATCH] =?utf8?q?#37353=E3=80=80=E3=83=88=E3=83=A9=E3=83=83?= =?utf8?q?=E3=83=97=E9=83=A8=E5=B1=8B=E7=94=9F=E6=88=90=E5=87=A6=E7=90=86?= =?utf8?q?=E3=82=92=20rooms.c=20=E3=81=8B=E3=82=89=20rooms-trap.c/h=20?= =?utf8?q?=E3=81=B8=E5=88=86=E9=9B=A2=E3=80=82=20Separate=20generation=20o?= =?utf8?q?f=20trap=20room=20from=20rooms.c=20to=20rooms-trap.c/h.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Hengband_vcs2015/Hengband/Hengband.vcxproj | 2 + Hengband_vcs2015/Hengband/Hengband.vcxproj.filters | 6 ++ src/rooms-trap.c | 88 +++++++++++++++++++++ src/rooms-trap.h | 1 + src/rooms.c | 89 +--------------------- 5 files changed, 99 insertions(+), 87 deletions(-) create mode 100644 src/rooms-trap.c create mode 100644 src/rooms-trap.h diff --git a/Hengband_vcs2015/Hengband/Hengband.vcxproj b/Hengband_vcs2015/Hengband/Hengband.vcxproj index 84720dfb6..c3e627132 100644 --- a/Hengband_vcs2015/Hengband/Hengband.vcxproj +++ b/Hengband_vcs2015/Hengband/Hengband.vcxproj @@ -212,6 +212,7 @@ + @@ -277,6 +278,7 @@ + diff --git a/Hengband_vcs2015/Hengband/Hengband.vcxproj.filters b/Hengband_vcs2015/Hengband/Hengband.vcxproj.filters index 0bc7d49b3..a6eadac29 100644 --- a/Hengband_vcs2015/Hengband/Hengband.vcxproj.filters +++ b/Hengband_vcs2015/Hengband/Hengband.vcxproj.filters @@ -295,6 +295,9 @@ Source + + Source + @@ -466,6 +469,9 @@ Header + + Header + diff --git a/src/rooms-trap.c b/src/rooms-trap.c new file mode 100644 index 000000000..c19c16359 --- /dev/null +++ b/src/rooms-trap.c @@ -0,0 +1,88 @@ +#include "angband.h" +#include "grid.h" +#include "generate.h" +#include "rooms.h" + + +/*! +* @brief ƒ^ƒCƒv14‚Ì•”‰®c“ÁŽêƒgƒ‰ƒbƒv•”‰®‚̐¶¬ / Type 14 -- trapped rooms +* @return ‚È‚µ +* @details +* A special trap is placed at center of the room +*/ +bool build_type14(void) +{ + POSITION y, x, y2, x2, yval, xval; + POSITION y1, x1, xsize, ysize; + + bool light; + + cave_type *c_ptr; + s16b trap; + + /* Pick a room size */ + y1 = randint1(4); + x1 = randint1(11); + y2 = randint1(3); + x2 = randint1(11); + + xsize = x1 + x2 + 1; + ysize = y1 + y2 + 1; + + /* Find and reserve some space in the dungeon. Get center of room. */ + if (!find_space(&yval, &xval, ysize + 2, xsize + 2)) return FALSE; + + /* Choose lite or dark */ + light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS)); + + + /* Get corner values */ + y1 = yval - ysize / 2; + x1 = xval - xsize / 2; + y2 = yval + (ysize - 1) / 2; + x2 = xval + (xsize - 1) / 2; + + + /* Place a full floor under the room */ + for (y = y1 - 1; y <= y2 + 1; y++) + { + for (x = x1 - 1; x <= x2 + 1; x++) + { + c_ptr = &cave[y][x]; + place_floor_grid(c_ptr); + c_ptr->info |= (CAVE_ROOM); + if (light) c_ptr->info |= (CAVE_GLOW); + } + } + + /* Walls around the room */ + for (y = y1 - 1; y <= y2 + 1; y++) + { + c_ptr = &cave[y][x1 - 1]; + place_outer_grid(c_ptr); + c_ptr = &cave[y][x2 + 1]; + place_outer_grid(c_ptr); + } + for (x = x1 - 1; x <= x2 + 1; x++) + { + c_ptr = &cave[y1 - 1][x]; + place_outer_grid(c_ptr); + c_ptr = &cave[y2 + 1][x]; + place_outer_grid(c_ptr); + } + + if (dun_level < 30 + randint1(30)) + trap = feat_trap_piranha; + else + trap = feat_trap_armageddon; + + /* Place a special trap */ + c_ptr = &cave[rand_spread(yval, ysize / 4)][rand_spread(xval, xsize / 4)]; + c_ptr->mimic = c_ptr->feat; + c_ptr->feat = trap; + + msg_format_wizard(CHEAT_DUNGEON, _("%s‚Ì•”‰®‚ª¶¬‚³‚ê‚Ü‚µ‚½B", "Room of %s was generated."), f_name + f_info[trap].name); + + return TRUE; +} + diff --git a/src/rooms-trap.h b/src/rooms-trap.h new file mode 100644 index 000000000..d03ed2621 --- /dev/null +++ b/src/rooms-trap.h @@ -0,0 +1 @@ +extern bool build_type14(void); diff --git a/src/rooms.c b/src/rooms.c index 8d49cf691..4079e6957 100644 --- a/src/rooms.c +++ b/src/rooms.c @@ -41,10 +41,11 @@ #include "grid.h" #include "rooms.h" +#include "rooms-city.h" #include "rooms-normal.h" #include "rooms-pitnest.h" +#include "rooms-trap.h" #include "rooms-vault.h" -#include "rooms-city.h" /*! @@ -522,9 +523,6 @@ bool find_space(POSITION *y, POSITION *x, POSITION height, POSITION width) - - - /* * Structure to hold all "fill" data */ @@ -2866,89 +2864,6 @@ static bool build_type10(void) -/*! - * @brief タイプ14の部屋…特殊トラップ部屋の生成 / Type 14 -- trapped rooms - * @return なし - * @details - * A special trap is placed at center of the room - */ -static bool build_type14(void) -{ - POSITION y, x, y2, x2, yval, xval; - POSITION y1, x1, xsize, ysize; - - bool light; - - cave_type *c_ptr; - s16b trap; - - /* Pick a room size */ - y1 = randint1(4); - x1 = randint1(11); - y2 = randint1(3); - x2 = randint1(11); - - xsize = x1 + x2 + 1; - ysize = y1 + y2 + 1; - - /* Find and reserve some space in the dungeon. Get center of room. */ - if (!find_space(&yval, &xval, ysize + 2, xsize + 2)) return FALSE; - - /* Choose lite or dark */ - light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS)); - - - /* Get corner values */ - y1 = yval - ysize / 2; - x1 = xval - xsize / 2; - y2 = yval + (ysize - 1) / 2; - x2 = xval + (xsize - 1) / 2; - - - /* Place a full floor under the room */ - for (y = y1 - 1; y <= y2 + 1; y++) - { - for (x = x1 - 1; x <= x2 + 1; x++) - { - c_ptr = &cave[y][x]; - place_floor_grid(c_ptr); - c_ptr->info |= (CAVE_ROOM); - if (light) c_ptr->info |= (CAVE_GLOW); - } - } - - /* Walls around the room */ - for (y = y1 - 1; y <= y2 + 1; y++) - { - c_ptr = &cave[y][x1 - 1]; - place_outer_grid(c_ptr); - c_ptr = &cave[y][x2 + 1]; - place_outer_grid(c_ptr); - } - for (x = x1 - 1; x <= x2 + 1; x++) - { - c_ptr = &cave[y1 - 1][x]; - place_outer_grid(c_ptr); - c_ptr = &cave[y2 + 1][x]; - place_outer_grid(c_ptr); - } - - if (dun_level < 30 + randint1(30)) - trap = feat_trap_piranha; - else - trap = feat_trap_armageddon; - - /* Place a special trap */ - c_ptr = &cave[rand_spread(yval, ysize/4)][rand_spread(xval, xsize/4)]; - c_ptr->mimic = c_ptr->feat; - c_ptr->feat = trap; - - msg_format_wizard(CHEAT_DUNGEON, _("%sの部屋が生成されました。", "Room of %s was generated."), f_name + f_info[trap].name); - - return TRUE; -} - - /* * Helper function for "glass room" */ -- 2.11.0