OSDN Git Service

[fix] モンスター一覧表示用に位置リストを用意する
[hengbandforosx/hengbandosx.git] / src / target / target-preparation.c
index 83df2b1..20e2719 100644 (file)
@@ -1,6 +1,5 @@
 #include "target/target-preparation.h"
 #include "floor/cave.h"
-#include "floor/floor.h"
 #include "game-option/input-options.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
@@ -9,6 +8,7 @@
 #include "object/object-mark-types.h"
 #include "system/floor-type-definition.h"
 #include "system/object-type-definition.h"
+#include "target/projection-path-calculator.h"
 #include "target/target-types.h"
 #include "util/bit-flags-calculator.h"
 #include "util/sort.h"
@@ -86,7 +86,7 @@ static bool target_set_accept(player_type *creature_ptr, POSITION y, POSITION x)
         if (g_ptr->info & CAVE_OBJECT)
             return TRUE;
 
-        if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE))
+        if (has_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_NOTICE))
             return TRUE;
     }
 
@@ -134,9 +134,9 @@ void target_set_prepare(player_type *creature_ptr, BIT_FLAGS mode)
     }
 
     if (mode & (TARGET_KILL)) {
-        ang_sort(creature_ptr, tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_distance);
+        ang_sort(creature_ptr, tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_distance, ang_sort_swap_position);
     } else {
-        ang_sort(creature_ptr, tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_importance, ang_sort_swap_distance);
+        ang_sort(creature_ptr, tmp_pos.x, tmp_pos.y, tmp_pos.n, ang_sort_comp_importance, ang_sort_swap_position);
     }
 
     if (creature_ptr->riding == 0 || !target_pet || (tmp_pos.n <= 1) || !(mode & (TARGET_KILL)))
@@ -149,3 +149,24 @@ void target_set_prepare(player_type *creature_ptr, BIT_FLAGS mode)
     tmp_pos.x[0] = tmp_pos.x[1];
     tmp_pos.x[1] = tmp;
 }
+
+void target_sensing_monsters_prepare(player_type *creature_ptr, pos_list* plist)
+{
+    plist->n = 0;
+
+    // 幻覚時は正常に感知できない
+    if (creature_ptr->image)
+        return;
+
+    for (int i = 1; i < creature_ptr->current_floor_ptr->m_max; i++) {
+        monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[i];
+        if (!monster_is_valid(m_ptr) || !m_ptr->ml || is_pet(m_ptr))
+            continue;
+
+        plist->x[plist->n] = m_ptr->fx;
+        plist->y[plist->n] = m_ptr->fy;
+        plist->n++;
+    }
+
+    ang_sort(creature_ptr, plist->x, plist->y, plist->n, ang_sort_comp_importance, ang_sort_swap_position);
+}