* @param i1 配列移動元添字
* @param i2 配列移動先添字
*/
-static void compact_monsters_aux(player_type *player_ptr, MONSTER_IDX i1, MONSTER_IDX i2)
+static void compact_monsters_aux(PlayerType *player_ptr, MONSTER_IDX i1, MONSTER_IDX i2)
{
- if (i1 == i2)
+ if (i1 == i2) {
return;
+ }
- floor_type *floor_ptr = player_ptr->current_floor_ptr;
+ auto *floor_ptr = player_ptr->current_floor_ptr;
monster_type *m_ptr;
m_ptr = &floor_ptr->m_list[i1];
g_ptr->m_idx = i2;
for (const auto this_o_idx : m_ptr->hold_o_idx_list) {
- object_type *o_ptr;
+ ObjectType *o_ptr;
o_ptr = &floor_ptr->o_list[this_o_idx];
o_ptr->held_m_idx = i2;
}
- if (target_who == i1)
+ if (target_who == i1) {
target_who = i2;
+ }
- if (player_ptr->pet_t_m_idx == i1)
+ if (player_ptr->pet_t_m_idx == i1) {
player_ptr->pet_t_m_idx = i2;
- if (player_ptr->riding_t_m_idx == i1)
+ }
+ if (player_ptr->riding_t_m_idx == i1) {
player_ptr->riding_t_m_idx = i2;
+ }
- if (player_ptr->riding == i1)
+ if (player_ptr->riding == i1) {
player_ptr->riding = i2;
+ }
- if (player_ptr->health_who == i1)
+ if (player_ptr->health_who == i1) {
health_track(player_ptr, i2);
+ }
- if (is_pet(m_ptr)) {
+ if (m_ptr->is_pet()) {
for (int i = 1; i < floor_ptr->m_max; i++) {
monster_type *m2_ptr = &floor_ptr->m_list[i];
- if (m2_ptr->parent_m_idx == i1)
+ if (m2_ptr->parent_m_idx == i1) {
m2_ptr->parent_m_idx = i2;
+ }
}
}
- (void)COPY(&floor_ptr->m_list[i2], &floor_ptr->m_list[i1], monster_type);
- (void)WIPE(&floor_ptr->m_list[i1], monster_type);
+ floor_ptr->m_list[i2] = floor_ptr->m_list[i1];
+ floor_ptr->m_list[i1] = {};
for (int i = 0; i < MAX_MTIMED; i++) {
int mproc_idx = get_mproc_idx(floor_ptr, i1, i);
- if (mproc_idx >= 0)
+ if (mproc_idx >= 0) {
floor_ptr->mproc_list[i][mproc_idx] = i2;
+ }
}
}
* After "compacting" (if needed), we "reorder" the monsters into a more
* compact order, and we reset the allocation info, and the "live" array.
*/
-void compact_monsters(player_type *player_ptr, int size)
+void compact_monsters(PlayerType *player_ptr, int size)
{
- if (size)
+ if (size) {
msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
+ }
/* Compact at least 'size' objects */
- floor_type *floor_ptr = player_ptr->current_floor_ptr;
+ auto *floor_ptr = player_ptr->current_floor_ptr;
for (int num = 0, cnt = 1; num < size; cnt++) {
int cur_lev = 5 * cnt;
int cur_dis = 5 * (20 - cnt);
for (MONSTER_IDX i = 1; i < floor_ptr->m_max; i++) {
- monster_type *m_ptr = &floor_ptr->m_list[i];
- monster_race *r_ptr = &r_info[m_ptr->r_idx];
- if (!monster_is_valid(m_ptr))
+ auto *m_ptr = &floor_ptr->m_list[i];
+ auto *r_ptr = &r_info[m_ptr->r_idx];
+ if (!m_ptr->is_valid()) {
continue;
- if (r_ptr->level > cur_lev)
+ }
+ if (r_ptr->level > cur_lev) {
continue;
- if (i == player_ptr->riding)
+ }
+ if (i == player_ptr->riding) {
continue;
- if ((cur_dis > 0) && (m_ptr->cdis < cur_dis))
+ }
+ if ((cur_dis > 0) && (m_ptr->cdis < cur_dis)) {
continue;
+ }
int chance = 90;
- if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000))
+ if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000)) {
chance = 100;
+ }
- if (r_ptr->flags1 & (RF1_UNIQUE))
+ if (r_ptr->kind_flags.has(MonsterKindType::UNIQUE)) {
chance = 100;
+ }
- if (randint0(100) < chance)
+ if (randint0(100) < chance) {
continue;
+ }
- if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
+ if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
GAME_TEXT m_name[MAX_NLEN];
monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
/* Excise dead monsters (backwards!) */
for (MONSTER_IDX i = floor_ptr->m_max - 1; i >= 1; i--) {
- monster_type *m_ptr = &floor_ptr->m_list[i];
- if (m_ptr->r_idx)
+ auto *m_ptr = &floor_ptr->m_list[i];
+ if (MonsterRace(m_ptr->r_idx).is_valid()) {
continue;
+ }
compact_monsters_aux(player_ptr, floor_ptr->m_max - 1, i);
floor_ptr->m_max--;
}