<ClCompile Include="..\..\src\info-reader\race-reader.c" />\r
<ClCompile Include="..\..\src\info-reader\skill-reader.c" />\r
<ClCompile Include="..\..\src\info-reader\vault-reader.c" />\r
+ <ClCompile Include="..\..\src\monster\monster-compaction.c" />\r
<ClCompile Include="..\..\src\monster\monster-death.c" />\r
<ClCompile Include="..\..\src\monster-lore\lore-store.c" />\r
<ClCompile Include="..\..\src\monster-lore\monster-lore.c" />\r
<ClInclude Include="..\..\src\info-reader\vault-reader.h" />\r
<ClInclude Include="..\..\src\mind\drs-types.h" />\r
<ClInclude Include="..\..\src\mind\snipe-types.h" />\r
+ <ClInclude Include="..\..\src\monster\monster-compaction.h" />\r
<ClInclude Include="..\..\src\monster\monster-death.h" />\r
<ClInclude Include="..\..\src\monster-lore\lore-store.h" />\r
<ClInclude Include="..\..\src\monster-lore\monster-lore.h" />\r
<ClCompile Include="..\..\src\monster\monster-remover.c">
<Filter>monster</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\monster\monster-compaction.c">
+ <Filter>monster</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\cmd\cmd-basic.h">
<ClInclude Include="..\..\src\monster\monster-remover.h">
<Filter>monster</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\monster\monster-compaction.h">
+ <Filter>monster</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\wall.bmp" />
monster/horror-descriptions.c monster/horror-descriptions.h \
monster/monster2.c monster/monster2.h \
monster/monster-attack.c monster/monster-attack.h \
+ monster/monster-compaction.c monster/monster-compaction.h \
monster/monster-death.c monster/monster-death.h \
monster/monster-describer.c monster/monster-describer.h \
monster/monster-description-types.h \
#include "io/write-diary.h"
#include "market/arena.h"
#include "monster-race/race-flags1.h"
+#include "monster/monster-compaction.h"
#include "monster/monster-processor.h"
#include "monster/monster-status.h"
#include "monster/monster-util.h"
-#include "monster/monster2.h"
#include "player/player-effects.h"
#include "player/player-move.h"
#include "realm/realm-song-numbers.h"
#include "io/report.h"
#include "io/uid-checker.h"
#include "monster-race/monster-race.h"
+#include "monster/monster-compaction.h"
#include "monster/monster-info.h"
#include "monster/monster-status.h"
-#include "monster/monster2.h"
#include "object-enchant/artifact.h"
#include "object/object-kind.h"
#include "store/store-util.h"
--- /dev/null
+#include "monster/monster-compaction.h"
+#include "floor/floor.h"
+#include "io/targeting.h"
+#include "io/write-diary.h"
+#include "monster-race/race-flags1.h"
+#include "monster/monster-describer.h"
+#include "monster/monster-description-types.h"
+#include "monster/monster-info.h"
+#include "monster/monster-remover.h"
+#include "monster/monster-status.h"
+#include "system/monster-type-definition.h"
+#include "view/display-main-window.h"
+
+/*!
+ * @brief モンスター情報を配列内移動する / Move an object from index i1 to index i2 in the object list
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param i1 配列移動元添字
+ * @param i2 配列移動先添字
+ * @return なし
+ */
+static void compact_monsters_aux(player_type *player_ptr, MONSTER_IDX i1, MONSTER_IDX i2)
+{
+ if (i1 == i2)
+ return;
+
+ floor_type *floor_ptr = player_ptr->current_floor_ptr;
+ monster_type *m_ptr;
+ m_ptr = &floor_ptr->m_list[i1];
+
+ POSITION y = m_ptr->fy;
+ POSITION x = m_ptr->fx;
+ grid_type *g_ptr;
+ g_ptr = &floor_ptr->grid_array[y][x];
+ g_ptr->m_idx = i2;
+
+ OBJECT_IDX next_o_idx = 0;
+ for (OBJECT_IDX this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx) {
+ object_type *o_ptr;
+ o_ptr = &floor_ptr->o_list[this_o_idx];
+ next_o_idx = o_ptr->next_o_idx;
+ o_ptr->held_m_idx = i2;
+ }
+
+ if (target_who == i1)
+ target_who = i2;
+
+ if (player_ptr->pet_t_m_idx == i1)
+ player_ptr->pet_t_m_idx = i2;
+ if (player_ptr->riding_t_m_idx == i1)
+ player_ptr->riding_t_m_idx = i2;
+
+ if (player_ptr->riding == i1)
+ player_ptr->riding = i2;
+
+ if (player_ptr->health_who == i1)
+ health_track(player_ptr, i2);
+
+ if (is_pet(m_ptr)) {
+ 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)
+ 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);
+
+ for (int i = 0; i < MAX_MTIMED; i++) {
+ int mproc_idx = get_mproc_idx(floor_ptr, i1, i);
+ if (mproc_idx >= 0)
+ floor_ptr->mproc_list[i][mproc_idx] = i2;
+ }
+}
+
+/*!
+ * @brief モンスター情報配列を圧縮する / Compact and Reorder the monster list
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @param size 圧縮後のモンスター件数目標
+ * @return なし
+ * @details
+ * This function can be very dangerous, use with caution!
+ *
+ * When actually "compacting" monsters, we base the saving throw
+ * on a combination of monster level, distance from player, and
+ * current "desperation".
+ *
+ * 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)
+{
+ if (size)
+ msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
+
+ /* Compact at least 'size' objects */
+ floor_type *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))
+ continue;
+ if (r_ptr->level > cur_lev)
+ continue;
+ if (i == player_ptr->riding)
+ continue;
+ if ((cur_dis > 0) && (m_ptr->cdis < cur_dis))
+ continue;
+
+ int chance = 90;
+ if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000))
+ chance = 100;
+
+ if (r_ptr->flags1 & (RF1_UNIQUE))
+ chance = 100;
+
+ if (randint0(100) < chance)
+ continue;
+
+ if (record_named_pet && is_pet(m_ptr) && 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);
+ }
+
+ delete_monster_idx(player_ptr, i);
+ num++;
+ }
+ }
+
+ /* 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)
+ continue;
+ compact_monsters_aux(player_ptr, floor_ptr->m_max - 1, i);
+ floor_ptr->m_max--;
+ }
+}
--- /dev/null
+#pragma once
+
+#include "system/angband.h"
+
+void compact_monsters(player_type *player_ptr, int size);
#include "floor/floor-object.h"
#include "floor/wild.h"
#include "io/files-util.h"
-#include "io/targeting.h"
-#include "io/write-diary.h"
#include "main/sound-definitions-table.h"
#include "mind/drs-types.h"
#include "monster-race/monster-race-hook.h"
#include "monster-race/race-flags7.h"
#include "monster-race/race-indice-types.h"
#include "monster/monster-describer.h" // todo 相互参照している.
-#include "monster/monster-description-types.h"
#include "monster/monster-flag-types.h"
#include "monster/monster-generator.h"
#include "monster/monster-info.h"
-#include "monster/monster-remover.h"
-#include "monster/monster-status.h"
#include "monster/monster-update.h"
#include "monster/monster-util.h"
#include "monster/place-monster-types.h"
#include "spell/process-effect.h"
#include "spell/spells-summon.h"
#include "spell/spells-type.h"
-#include "view/display-main-window.h"
#include "world/world.h"
#define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
void reset_target(monster_type *m_ptr) { set_target(m_ptr, 0, 0); }
/*!
- * @brief モンスター情報を配列内移動する / Move an object from index i1 to index i2 in the object list
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param i1 配列移動元添字
- * @param i2 配列移動先添字
- * @return なし
- */
-static void compact_monsters_aux(player_type *player_ptr, MONSTER_IDX i1, MONSTER_IDX i2)
-{
- if (i1 == i2)
- return;
-
- floor_type *floor_ptr = player_ptr->current_floor_ptr;
- monster_type *m_ptr;
- m_ptr = &floor_ptr->m_list[i1];
-
- POSITION y = m_ptr->fy;
- POSITION x = m_ptr->fx;
- grid_type *g_ptr;
- g_ptr = &floor_ptr->grid_array[y][x];
- g_ptr->m_idx = i2;
-
- OBJECT_IDX next_o_idx = 0;
- for (OBJECT_IDX this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx) {
- object_type *o_ptr;
- o_ptr = &floor_ptr->o_list[this_o_idx];
- next_o_idx = o_ptr->next_o_idx;
- o_ptr->held_m_idx = i2;
- }
-
- if (target_who == i1)
- target_who = i2;
-
- if (player_ptr->pet_t_m_idx == i1)
- player_ptr->pet_t_m_idx = i2;
- if (player_ptr->riding_t_m_idx == i1)
- player_ptr->riding_t_m_idx = i2;
-
- if (player_ptr->riding == i1)
- player_ptr->riding = i2;
-
- if (player_ptr->health_who == i1)
- health_track(player_ptr, i2);
-
- if (is_pet(m_ptr)) {
- 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)
- 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);
-
- for (int i = 0; i < MAX_MTIMED; i++) {
- int mproc_idx = get_mproc_idx(floor_ptr, i1, i);
- if (mproc_idx >= 0)
- floor_ptr->mproc_list[i][mproc_idx] = i2;
- }
-}
-
-/*!
- * @brief モンスター情報配列を圧縮する / Compact and Reorder the monster list
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param size 圧縮後のモンスター件数目標
- * @return なし
- * @details
- * This function can be very dangerous, use with caution!
- *
- * When actually "compacting" monsters, we base the saving throw
- * on a combination of monster level, distance from player, and
- * current "desperation".
- *
- * 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)
-{
- if (size)
- msg_print(_("モンスター情報を圧縮しています...", "Compacting monsters..."));
-
- /* Compact at least 'size' objects */
- floor_type *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))
- continue;
- if (r_ptr->level > cur_lev)
- continue;
- if (i == player_ptr->riding)
- continue;
- if ((cur_dis > 0) && (m_ptr->cdis < cur_dis))
- continue;
-
- int chance = 90;
- if ((r_ptr->flags1 & (RF1_QUESTOR)) && (cnt < 1000))
- chance = 100;
-
- if (r_ptr->flags1 & (RF1_UNIQUE))
- chance = 100;
-
- if (randint0(100) < chance)
- continue;
-
- if (record_named_pet && is_pet(m_ptr) && 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);
- }
-
- delete_monster_idx(player_ptr, i);
- num++;
- }
- }
-
- /* 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)
- continue;
- compact_monsters_aux(player_ptr, floor_ptr->m_max - 1, i);
- floor_ptr->m_max--;
- }
-}
-
-/*!
* todo ここには本来floor_type*を追加したいが、monster.hにfloor.hの参照を追加するとコンパイルエラーが出るので保留
* @brief モンスター配列の空きを探す / Acquires and returns the index of a "free" monster.
* @return 利用可能なモンスター配列の添字
void set_target(monster_type *m_ptr, POSITION y, POSITION x);
void reset_target(monster_type *m_ptr);
-void compact_monsters(player_type *player_ptr, int size);
MONSTER_IDX m_pop(player_type *player_ptr);
#define GMN_ARENA 0x00000001 //!< 賭け闘技場向け生成