From e1104a707f46b1bc56c1780c8ace0addd5e0da77 Mon Sep 17 00:00:00 2001 From: Hourier <66951241+Hourier@users.noreply.github.com> Date: Sun, 30 Oct 2022 22:04:04 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#2680=20monster-generator.cpp=20?= =?utf8?q?=E3=81=A7=E3=81=97=E3=81=8B=E5=8F=82=E7=85=A7=E3=81=95=E3=82=8C?= =?utf8?q?=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E5=AE=9A?= =?utf8?q?=E6=95=B0=E3=82=92gamevalue.h=20=E3=81=8B=E3=82=89=E7=A7=BB?= =?utf8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/monster-floor/monster-generator.cpp | 18 ++++++++++-------- src/system/gamevalue.h | 2 -- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/monster-floor/monster-generator.cpp b/src/monster-floor/monster-generator.cpp index ab6e35953..5cd309204 100644 --- a/src/monster-floor/monster-generator.cpp +++ b/src/monster-floor/monster-generator.cpp @@ -178,10 +178,10 @@ bool multiply_monster(PlayerType *player_ptr, MONSTER_IDX m_idx, bool clone, BIT static bool place_monster_group(PlayerType *player_ptr, MONSTER_IDX who, POSITION y, POSITION x, MonsterRaceId r_idx, BIT_FLAGS mode) { auto *r_ptr = &monraces_info[r_idx]; - int total = randint1(10); + auto total = randint1(10); auto *floor_ptr = player_ptr->current_floor_ptr; - int extra = 0; + auto extra = 0; if (r_ptr->level > floor_ptr->dun_level) { extra = r_ptr->level - floor_ptr->dun_level; extra = 0 - randint1(extra); @@ -199,17 +199,19 @@ static bool place_monster_group(PlayerType *player_ptr, MONSTER_IDX who, POSITIO if (total < 1) { total = 1; } - if (total > GROUP_MAX) { - total = GROUP_MAX; + + constexpr auto max_monsters_count = 32; + if (total > max_monsters_count) { + total = max_monsters_count; } - int hack_n = 1; - POSITION hack_x[GROUP_MAX]; + auto hack_n = 1; + POSITION hack_x[max_monsters_count]{}; hack_x[0] = x; - POSITION hack_y[GROUP_MAX]; + POSITION hack_y[max_monsters_count]{}; hack_y[0] = y; - for (int n = 0; (n < hack_n) && (hack_n < total); n++) { + for (auto n = 0; (n < hack_n) && (hack_n < total); n++) { POSITION hx = hack_x[n]; POSITION hy = hack_y[n]; for (int i = 0; (i < 8) && (hack_n < total); i++) { diff --git a/src/system/gamevalue.h b/src/system/gamevalue.h index 14040b729..d5c262d05 100644 --- a/src/system/gamevalue.h +++ b/src/system/gamevalue.h @@ -59,8 +59,6 @@ #define GRINDNOISE 20 #define CYBERNOISE 20 -#define GROUP_MAX 32 /*!< place_monster_group() 関数によるモンスターのGROUP生成時の配置最大数 / Maximum size of a group of monsters */ - /* ToDo: Make this global */ #define HURT_CHANCE 16 /*!< 属性攻撃を受けた際に能力値低下を起こす確率(1/X) / 1/x chance of reducing stats (for elemental attacks) */ -- 2.11.0