OSDN Git Service

[Refactor] #38997 get_mon_num() にplayer_type * 引数追加 / Added player_type * argument...
authorHourier <hourier@users.sourceforge.jp>
Sat, 18 Jan 2020 04:04:41 +0000 (13:04 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 18 Jan 2020 14:01:52 +0000 (23:01 +0900)
12 files changed:
src/birth.c
src/bldg.c
src/core.c
src/monster.h
src/monster2.c
src/monsterrace-hook.c
src/object2.c
src/player-status.c
src/quest.c
src/rooms-pitnest.c
src/rooms-special.c
src/spells3.c

index 58ac5bd..fb55623 100644 (file)
@@ -2261,7 +2261,7 @@ void player_outfit(player_type *creature_ptr)
                for (i = rand_range(3, 4); i > 0; i--)
                {
                        object_prep(q_ptr, lookup_kind(TV_CORPSE, SV_CORPSE));
-                       q_ptr->pval = get_mon_num(2);
+                       q_ptr->pval = get_mon_num(creature_ptr, 2);
                        if (q_ptr->pval)
                        {
                                q_ptr->number = 1;
index f7d7761..5c1b6e1 100644 (file)
@@ -1586,7 +1586,7 @@ void update_gambling_monsters(player_type *player_ptr)
                        {
                                get_mon_num_prep(player_ptr, monster_can_entry_arena, NULL);
                                player_ptr->phase_out = TRUE;
-                               r_idx = get_mon_num(mon_level);
+                               r_idx = get_mon_num(player_ptr, mon_level);
                                player_ptr->phase_out = old_inside_battle;
                                if (!r_idx) continue;
 
@@ -2291,7 +2291,7 @@ static void castle_quest(player_type *player_ptr)
        if (q_ptr->r_idx == 0)
        {
                /* Random monster at least 5 - 10 levels out of deep */
-               q_ptr->r_idx = get_mon_num(q_ptr->level + 4 + randint1(6));
+               q_ptr->r_idx = get_mon_num(player_ptr, q_ptr->level + 4 + randint1(6));
        }
 
        monster_race *r_ptr;
@@ -2299,7 +2299,7 @@ static void castle_quest(player_type *player_ptr)
 
        while ((r_ptr->flags1 & RF1_UNIQUE) || (r_ptr->rarity != 1))
        {
-               q_ptr->r_idx = get_mon_num(q_ptr->level) + 4 + randint1(6);
+               q_ptr->r_idx = get_mon_num(player_ptr, q_ptr->level) + 4 + randint1(6);
                r_ptr = &r_info[q_ptr->r_idx];
        }
 
@@ -4239,7 +4239,7 @@ void determine_daily_bounty(player_type *player_ptr, bool conv_old)
 
        while (TRUE)
        {
-               today_mon = get_mon_num(max_dl);
+               today_mon = get_mon_num(player_ptr, max_dl);
                monster_race *r_ptr;
                r_ptr = &r_info[today_mon];
 
@@ -4270,7 +4270,7 @@ void determine_bounty_uniques(player_type *player_ptr)
        {
                while (TRUE)
                {
-                       current_world_ptr->bounty_r_idx[i] = get_mon_num(MAX_DEPTH - 1);
+                       current_world_ptr->bounty_r_idx[i] = get_mon_num(player_ptr, MAX_DEPTH - 1);
                        monster_race *r_ptr;
                        r_ptr = &r_info[current_world_ptr->bounty_r_idx[i]];
 
index 6a5abca..c21eec6 100644 (file)
@@ -4375,7 +4375,7 @@ static void process_fishing(player_type *creature_ptr)
                MONRACE_IDX r_idx;
                bool success = FALSE;
                get_mon_num_prep(creature_ptr, monster_is_fishing_target, NULL);
-               r_idx = get_mon_num(creature_ptr->current_floor_ptr->dun_level ? creature_ptr->current_floor_ptr->dun_level : wilderness[creature_ptr->wilderness_y][creature_ptr->wilderness_x].level);
+               r_idx = get_mon_num(creature_ptr, creature_ptr->current_floor_ptr->dun_level ? creature_ptr->current_floor_ptr->dun_level : wilderness[creature_ptr->wilderness_y][creature_ptr->wilderness_x].level);
                msg_print(NULL);
                if (r_idx && one_in_(2))
                {
index d6b00c8..b4d2faf 100644 (file)
@@ -473,7 +473,7 @@ extern void compact_monsters(player_type *player_ptr, int size);
 extern void wipe_monsters_list(player_type *player_ptr);
 extern MONSTER_IDX m_pop(player_type *player_ptr);
 extern errr get_mon_num_prep(player_type *player_ptr, monsterrace_hook_type monster_hook, monsterrace_hook_type monster_hook2);
-extern MONRACE_IDX get_mon_num(DEPTH level);
+extern MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level);
 extern int lore_do_probe(MONRACE_IDX r_idx);
 extern void lore_treasure(MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold);
 extern void update_monster(player_type *subject_ptr, MONSTER_IDX m_idx, bool full);
index 0e49f35..0791752 100644 (file)
@@ -1097,6 +1097,7 @@ errr get_mon_num_prep(player_type *player_ptr, monsterrace_hook_type monster_hoo
 
 /*!
  * @brief 生成モンスター種族を1種生成テーブルから選択する
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param level 生成階
  * @return 選択されたモンスター生成種族
  * @details
@@ -1121,7 +1122,7 @@ errr get_mon_num_prep(player_type *player_ptr, monsterrace_hook_type monster_hoo
  * Note that if no monsters are "appropriate", then this function will
  * fail, and return zero, but this should *almost* never happen.
  */
-MONRACE_IDX get_mon_num(DEPTH level)
+MONRACE_IDX get_mon_num(player_type *player_ptr, DEPTH level)
 {
        int i, j, p;
        MONRACE_IDX r_idx;
@@ -1135,7 +1136,7 @@ MONRACE_IDX get_mon_num(DEPTH level)
        pls_kakuritu = MAX(NASTY_MON_MAX, NASTY_MON_BASE - ((current_world_ptr->dungeon_turn / (TURNS_PER_TICK * 5000L) - delay / 10)));
        pls_level = MIN(NASTY_MON_PLUS_MAX, 3 + current_world_ptr->dungeon_turn / (TURNS_PER_TICK * 40000L) - delay / 40 + MIN(5, level / 10));
 
-       if (d_info[p_ptr->dungeon_idx].flags1 & DF1_MAZE)
+       if (d_info[player_ptr->dungeon_idx].flags1 & DF1_MAZE)
        {
                pls_kakuritu = MIN(pls_kakuritu / 2, pls_kakuritu - 10);
                if (pls_kakuritu < 2) pls_kakuritu = 2;
@@ -1144,7 +1145,7 @@ MONRACE_IDX get_mon_num(DEPTH level)
        }
 
        /* Boost the level */
-       if (!p_ptr->phase_out && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
+       if (!player_ptr->phase_out && !(d_info[player_ptr->dungeon_idx].flags1 & DF1_BEGINNER))
        {
                /* Nightmare mode allows more out-of depth monsters */
                if (ironman_nightmare && !randint0(pls_kakuritu))
@@ -1184,7 +1185,7 @@ MONRACE_IDX get_mon_num(DEPTH level)
                /* Access the actual race */
                r_ptr = &r_info[r_idx];
 
-               if (!p_ptr->phase_out && !chameleon_change_m_idx)
+               if (!player_ptr->phase_out && !chameleon_change_m_idx)
                {
                        /* Hack -- "unique" monsters must be "unique" */
                        if (((r_ptr->flags1 & (RF1_UNIQUE)) ||
@@ -2340,7 +2341,7 @@ void choose_new_monster(player_type *player_ptr, MONSTER_IDX m_idx, bool born, M
 
                if (d_info[player_ptr->dungeon_idx].flags1 & DF1_CHAMELEON) level += 2 + randint1(3);
 
-               r_idx = get_mon_num(level);
+               r_idx = get_mon_num(player_ptr, level);
                r_ptr = &r_info[r_idx];
 
                chameleon_change_m_idx = 0;
@@ -2455,7 +2456,7 @@ static MONRACE_IDX initial_r_appearance(player_type *player_ptr, MONRACE_IDX r_i
 
        while (--attempts)
        {
-               ap_r_idx = get_mon_num(floor_ptr->base_level + 10);
+               ap_r_idx = get_mon_num(player_ptr, floor_ptr->base_level + 10);
                if (r_info[ap_r_idx].level >= min) return ap_r_idx;
        }
 
@@ -3193,7 +3194,7 @@ bool place_monster_aux(player_type *player_ptr, MONSTER_IDX who, POSITION y, POS
                        get_mon_num_prep(player_ptr, place_monster_can_escort, get_monster_hook2(player_ptr, ny, nx));
 
                        /* Pick a random race */
-                       z = get_mon_num(r_ptr->level);
+                       z = get_mon_num(player_ptr, r_ptr->level);
 
                        /* Handle failure */
                        if (!z) break;
@@ -3229,7 +3230,7 @@ bool place_monster(player_type *player_ptr, POSITION y, POSITION x, BIT_FLAGS mo
        get_mon_num_prep(player_ptr, get_monster_hook(player_ptr), get_monster_hook2(player_ptr, y, x));
 
        /* Pick a monster */
-       r_idx = get_mon_num(player_ptr->current_floor_ptr->monster_level);
+       r_idx = get_mon_num(player_ptr, player_ptr->current_floor_ptr->monster_level);
 
        /* Handle failure */
        if (!r_idx) return FALSE;
@@ -3261,7 +3262,7 @@ bool alloc_horde(player_type *player_ptr, POSITION y, POSITION x)
        while (--attempts)
        {
                /* Pick a monster */
-               r_idx = get_mon_num(floor_ptr->monster_level);
+               r_idx = get_mon_num(player_ptr, floor_ptr->monster_level);
 
                /* Handle failure */
                if (!r_idx) return FALSE;
@@ -3513,7 +3514,7 @@ bool summon_specific(player_type *player_ptr, MONSTER_IDX who, POSITION y1, POSI
        get_mon_num_prep(player_ptr, summon_specific_okay, get_monster_hook2(player_ptr, y, x));
 
        /* Pick a monster, using the level calculation */
-       r_idx = get_mon_num((floor_ptr->dun_level + lev) / 2 + 5);
+       r_idx = get_mon_num(player_ptr, (floor_ptr->dun_level + lev) / 2 + 5);
 
        /* Handle failure */
        if (!r_idx)
index 7a9757a..289409a 100644 (file)
@@ -30,7 +30,7 @@ void vault_prep_clone(player_type *player_ptr)
        get_mon_num_prep(player_ptr, vault_aux_simple, NULL);
 
        /* Pick a race to clone */
-       vault_aux_race = get_mon_num(p_ptr->current_floor_ptr->dun_level + 10);
+       vault_aux_race = get_mon_num(player_ptr, player_ptr->current_floor_ptr->dun_level + 10);
 
        /* Remove the monster restriction */
        get_mon_num_prep(player_ptr, NULL, NULL);
@@ -50,7 +50,7 @@ void vault_prep_symbol(player_type *player_ptr)
        get_mon_num_prep(player_ptr, vault_aux_simple, NULL);
 
        /* Pick a race to clone */
-       r_idx = get_mon_num(p_ptr->current_floor_ptr->dun_level + 10);
+       r_idx = get_mon_num(player_ptr, player_ptr->current_floor_ptr->dun_level + 10);
 
        /* Remove the monster restriction */
        get_mon_num_prep(player_ptr, NULL, NULL);
index 71524c3..acde32f 100644 (file)
@@ -3521,7 +3521,7 @@ static void a_m_aux_4(player_type *owner_ptr, object_type *o_ptr, DEPTH level, i
                /* Pick a random non-unique monster race */
                while (TRUE)
                {
-                       i = get_mon_num(floor_ptr->dun_level);
+                       i = get_mon_num(owner_ptr, floor_ptr->dun_level);
 
                        r_ptr = &r_info[i];
 
index ac5fb40..09c7040 100644 (file)
@@ -5195,7 +5195,7 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro)
 
                get_mon_num_prep(creature_ptr, get_nightmare, NULL);
 
-               r_ptr = &r_info[get_mon_num(MAX_DEPTH)];
+               r_ptr = &r_info[get_mon_num(creature_ptr, MAX_DEPTH)];
                power = r_ptr->level + 10;
                desc = r_name + r_ptr->name;
 
index 77db2b5..662b3db 100644 (file)
@@ -54,7 +54,7 @@ void determine_random_questor(player_type *player_ptr, quest_type *q_ptr)
                 * Random monster 5 - 10 levels out of depth
                 * (depending on level)
                 */
-               r_idx = get_mon_num(q_ptr->level + 5 + randint1(q_ptr->level / 10));
+               r_idx = get_mon_num(player_ptr, q_ptr->level + 5 + randint1(q_ptr->level / 10));
                monster_race *r_ptr;
                r_ptr = &r_info[r_idx];
 
index 4ed6b65..be6e7cf 100644 (file)
@@ -319,7 +319,7 @@ bool build_type5(player_type *player_ptr)
                while (attempts--)
                {
                        /* Get a (hard) monster type */
-                       r_idx = get_mon_num(floor_ptr->dun_level + 11);
+                       r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11);
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
@@ -529,7 +529,7 @@ bool build_type6(player_type *player_ptr)
                while (attempts--)
                {
                        /* Get a (hard) monster type */
-                       r_idx = get_mon_num(floor_ptr->dun_level + 11);
+                       r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11);
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
@@ -838,7 +838,7 @@ bool build_type13(player_type *player_ptr)
                while (attempts--)
                {
                        /* Get a (hard) monster type */
-                       r_idx = get_mon_num(floor_ptr->dun_level + 0);
+                       r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 0);
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
index 693e120..7f62db0 100644 (file)
@@ -86,7 +86,7 @@ bool build_type15(player_type *player_ptr)
                /* Place fixed lite berathers */
                for (dir1 = 4; dir1 < 8; dir1++)
                {
-                       MONRACE_IDX r_idx = get_mon_num(floor_ptr->dun_level);
+                       MONRACE_IDX r_idx = get_mon_num(player_ptr, floor_ptr->dun_level);
 
                        y = yval + 2 * ddy_ddd[dir1];
                        x = xval + 2 * ddx_ddd[dir1];
@@ -150,7 +150,7 @@ bool build_type15(player_type *player_ptr)
                g_ptr->feat = feat_glass_wall;
                get_mon_num_prep(player_ptr, vault_aux_lite, NULL);
 
-               r_idx = get_mon_num(floor_ptr->dun_level);
+               r_idx = get_mon_num(player_ptr, floor_ptr->dun_level);
                if (r_idx) place_monster_aux(player_ptr, 0, yval, xval, r_idx, 0L);
 
                /* Walls around the breather */
@@ -217,7 +217,7 @@ bool build_type15(player_type *player_ptr)
                /* Place shard berathers */
                for (dir1 = 4; dir1 < 8; dir1++)
                {
-                       MONRACE_IDX r_idx = get_mon_num(floor_ptr->dun_level);
+                       MONRACE_IDX r_idx = get_mon_num(player_ptr, floor_ptr->dun_level);
 
                        y = yval + ddy_ddd[dir1];
                        x = xval + ddx_ddd[dir1];
index be292e1..65b2331 100644 (file)
@@ -2691,7 +2691,7 @@ static MONRACE_IDX poly_r_idx(player_type *caster_ptr, MONRACE_IDX r_idx)
        for (int i = 0; i < 1000; i++)
        {
                /* Pick a new race, using a level calculation */
-               r = get_mon_num((caster_ptr->current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
+               r = get_mon_num(caster_ptr, (caster_ptr->current_floor_ptr->dun_level + r_ptr->level) / 2 + 5);
 
                /* Handle failure */
                if (!r) break;