From: Hourier Date: Sat, 18 Jan 2020 04:04:41 +0000 (+0900) Subject: [Refactor] #38997 get_mon_num() にplayer_type * 引数追加 / Added player_type * argument... X-Git-Url: http://git.osdn.net/view?p=hengband%2Fhengband.git;a=commitdiff_plain;h=027427cec7267fca99c7f3a92467d6f26774a9f2 [Refactor] #38997 get_mon_num() にplayer_type * 引数追加 / Added player_type * argument to get_mon_num() --- diff --git a/src/birth.c b/src/birth.c index 58ac5bde1..fb55623cd 100644 --- a/src/birth.c +++ b/src/birth.c @@ -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; diff --git a/src/bldg.c b/src/bldg.c index f7d77610a..5c1b6e1bb 100644 --- a/src/bldg.c +++ b/src/bldg.c @@ -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]]; diff --git a/src/core.c b/src/core.c index 6a5abcaff..c21eec61b 100644 --- a/src/core.c +++ b/src/core.c @@ -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)) { diff --git a/src/monster.h b/src/monster.h index d6b00c8d5..b4d2faf9a 100644 --- a/src/monster.h +++ b/src/monster.h @@ -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); diff --git a/src/monster2.c b/src/monster2.c index 0e49f3566..07917528a 100644 --- a/src/monster2.c +++ b/src/monster2.c @@ -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) diff --git a/src/monsterrace-hook.c b/src/monsterrace-hook.c index 7a9757ad6..289409ade 100644 --- a/src/monsterrace-hook.c +++ b/src/monsterrace-hook.c @@ -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); diff --git a/src/object2.c b/src/object2.c index 71524c3a1..acde32fed 100644 --- a/src/object2.c +++ b/src/object2.c @@ -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]; diff --git a/src/player-status.c b/src/player-status.c index ac5fb4079..09c7040c3 100644 --- a/src/player-status.c +++ b/src/player-status.c @@ -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; diff --git a/src/quest.c b/src/quest.c index 77db2b5ee..662b3db3a 100644 --- a/src/quest.c +++ b/src/quest.c @@ -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]; diff --git a/src/rooms-pitnest.c b/src/rooms-pitnest.c index 4ed6b65b2..be6e7cfb7 100644 --- a/src/rooms-pitnest.c +++ b/src/rooms-pitnest.c @@ -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 */ diff --git a/src/rooms-special.c b/src/rooms-special.c index 693e1201c..7f62db082 100644 --- a/src/rooms-special.c +++ b/src/rooms-special.c @@ -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]; diff --git a/src/spells3.c b/src/spells3.c index be292e1a6..65b23318d 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -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;