• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisiónfc162aac46824b01dc9001b93f9c0129a8d22bce (tree)
Tiempo2020-03-08 13:57:41
AutorHourier <hourier@user...>
CommiterHourier

Log Message

[Refactor] #40030 Moved process_monster_movement() to monster-move.c/h

Cambiar Resumen

Diferencia incremental

--- a/src/monster-process.c
+++ b/src/monster-process.c
@@ -15,9 +15,7 @@
1515
1616 #include "angband.h"
1717 #include "util.h"
18-#include "monster/monster-attack.h"
1918 #include "monster/monster-direction.h"
20-#include "monster/monster-object.h"
2119 #include "monster/monster-move.h"
2220 #include "monster/monster-runaway.h"
2321 #include "monster/monster-util.h"
@@ -28,8 +26,6 @@
2826 #include "cmd-pet.h"
2927 #include "creature.h"
3028 #include "melee.h"
31-#include "spells.h"
32-#include "spells-floor.h"
3329 #include "spells-summon.h"
3430 #include "avatar.h"
3531 #include "realm-hex.h"
@@ -39,10 +35,7 @@
3935 #include "monster-status.h"
4036 #include "monster-spell.h"
4137 #include "monster-process.h"
42-#include "monsterrace-hook.h"
43-#include "floor.h"
4438 #include "files.h"
45-#include "view-mainwindow.h"
4639
4740 void decide_drop_from_monster(player_type *target_ptr, MONSTER_IDX m_idx, bool is_riding_mon);
4841 bool process_stealth(player_type *target_ptr, MONSTER_IDX m_idx);
@@ -55,8 +48,6 @@ void process_special(player_type *target_ptr, MONSTER_IDX m_idx);
5548 void process_speak_sound(player_type *target_ptr, MONSTER_IDX m_idx, POSITION oy, POSITION ox, bool aware);
5649 bool cast_spell(player_type *target_ptr, MONSTER_IDX m_idx, bool aware);
5750
58-bool process_monster_movement(player_type *target_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx, DIRECTION *mm, POSITION oy, POSITION ox, int *count);
59-bool process_post_dig_wall(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx);
6051 bool process_monster_fear(player_type *target_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx);
6152
6253 void sweep_monster_process(player_type *target_ptr);
@@ -494,128 +485,6 @@ bool cast_spell(player_type *target_ptr, MONSTER_IDX m_idx, bool aware)
494485
495486
496487 /*!
497- * todo 少し長いが、これといってブロックとしてまとまった部分もないので暫定でこのままとする
498- * @brief モンスターの移動に関するメインルーチン
499- * @param target_ptr プレーヤーへの参照ポインタ
500- * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ
501- * @param m_idx モンスターID
502- * @param mm モンスターの移動方向
503- * @param oy 移動前の、モンスターのY座標
504- * @param ox 移動前の、モンスターのX座標
505- * @param count 移動回数 (のはず todo)
506- * @return 移動が阻害される何か (ドア等)があったらFALSE
507- */
508-bool process_monster_movement(player_type *target_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx, DIRECTION *mm, POSITION oy, POSITION ox, int *count)
509-{
510- for (int i = 0; mm[i]; i++)
511- {
512- int d = mm[i];
513- if (d == 5) d = ddd[randint0(8)];
514-
515- POSITION ny = oy + ddy[d];
516- POSITION nx = ox + ddx[d];
517- if (!in_bounds2(target_ptr->current_floor_ptr, ny, nx)) continue;
518-
519- grid_type *g_ptr;
520- g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx];
521- monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
522- monster_race *r_ptr = &r_info[m_ptr->r_idx];
523- bool can_cross = monster_can_cross_terrain(target_ptr, g_ptr->feat, r_ptr, turn_flags_ptr->is_riding_mon ? CEM_RIDING : 0);
524-
525- if (!process_wall(target_ptr, turn_flags_ptr, m_ptr, ny, nx, can_cross))
526- {
527- if (!process_door(target_ptr, turn_flags_ptr, m_ptr, ny, nx))
528- return FALSE;
529- }
530-
531- if (!process_protection_rune(target_ptr, turn_flags_ptr, m_ptr, ny, nx))
532- {
533- if (!process_explosive_rune(target_ptr, turn_flags_ptr, m_ptr, ny, nx))
534- return FALSE;
535- }
536-
537- exe_monster_attack_to_player(target_ptr, turn_flags_ptr, m_idx, ny, nx);
538- if (process_monster_attack_to_monster(target_ptr, turn_flags_ptr, m_idx, g_ptr, can_cross)) return FALSE;
539-
540- if (turn_flags_ptr->is_riding_mon)
541- {
542- if (!target_ptr->riding_ryoute && !MON_MONFEAR(&target_ptr->current_floor_ptr->m_list[target_ptr->riding])) turn_flags_ptr->do_move = FALSE;
543- }
544-
545- if (!process_post_dig_wall(target_ptr, turn_flags_ptr, m_ptr, ny, nx)) return FALSE;
546-
547- if (turn_flags_ptr->must_alter_to_move && (r_ptr->flags7 & RF7_AQUATIC))
548- {
549- if (!monster_can_cross_terrain(target_ptr, g_ptr->feat, r_ptr, turn_flags_ptr->is_riding_mon ? CEM_RIDING : 0))
550- turn_flags_ptr->do_move = FALSE;
551- }
552-
553- if (turn_flags_ptr->do_move && !can_cross && !turn_flags_ptr->did_kill_wall && !turn_flags_ptr->did_bash_door)
554- turn_flags_ptr->do_move = FALSE;
555-
556- if (turn_flags_ptr->do_move && (r_ptr->flags1 & RF1_NEVER_MOVE))
557- {
558- if (is_original_ap_and_seen(target_ptr, m_ptr))
559- r_ptr->r_flags1 |= (RF1_NEVER_MOVE);
560-
561- turn_flags_ptr->do_move = FALSE;
562- }
563-
564- if (!turn_flags_ptr->do_move)
565- {
566- if (turn_flags_ptr->do_turn) break;
567-
568- continue;
569- }
570-
571- turn_flags_ptr->do_turn = TRUE;
572- feature_type *f_ptr;
573- f_ptr = &f_info[g_ptr->feat];
574- if (have_flag(f_ptr->flags, FF_TREE))
575- {
576- if (!(r_ptr->flags7 & RF7_CAN_FLY) && !(r_ptr->flags8 & RF8_WILD_WOOD))
577- {
578- m_ptr->energy_need += ENERGY_NEED();
579- }
580- }
581-
582- if (!update_riding_monster(target_ptr, turn_flags_ptr, m_idx, oy, ox, ny, nx)) break;
583-
584- monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
585- if (m_ptr->ml &&
586- (disturb_move ||
587- (disturb_near && (m_ptr->mflag & MFLAG_VIEW) && projectable(target_ptr, target_ptr->y, target_ptr->x, m_ptr->fy, m_ptr->fx)) ||
588- (disturb_high && ap_r_ptr->r_tkills && ap_r_ptr->level >= target_ptr->lev)))
589- {
590- if (is_hostile(m_ptr))
591- disturb(target_ptr, FALSE, TRUE);
592- }
593-
594- bool is_takable_or_killable = g_ptr->o_idx > 0;
595- is_takable_or_killable &= (r_ptr->flags2 & (RF2_TAKE_ITEM | RF2_KILL_ITEM)) != 0;
596-
597- bool is_pickup_items = (target_ptr->pet_extra_flags & PF_PICKUP_ITEMS) != 0;
598- is_pickup_items &= (r_ptr->flags2 & RF2_TAKE_ITEM) != 0;
599-
600- is_takable_or_killable &= !is_pet(m_ptr) || is_pickup_items;
601- if (!is_takable_or_killable)
602- {
603- if (turn_flags_ptr->do_turn) break;
604-
605- continue;
606- }
607-
608- update_object_by_monster_movement(target_ptr, turn_flags_ptr, m_idx, ny, nx);
609- if (turn_flags_ptr->do_turn) break;
610-
611- (*count)++;
612- }
613-
614- return TRUE;
615-}
616-
617-
618-/*!
619488 * @brief モンスターの恐怖状態を処理する
620489 * @param target_ptr プレーヤーへの参照ポインタ
621490 * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ
--- a/src/monster/monster-move.c
+++ b/src/monster/monster-move.c
@@ -5,7 +5,11 @@
55 */
66
77 #include "monster/monster-move.h"
8+#include "monster/monster-attack.h"
9+#include "monster/monster-object.h"
10+#include "monster/monster-update.h"
811 #include "cmd/cmd-pet.h"
12+#include "creature.h"
913 #include "monster-status.h"
1014 #include "player-move.h"
1115
@@ -26,7 +30,7 @@ static bool check_hp_for_feat_destruction(feature_type *f_ptr, monster_type *m_p
2630 * @param can_cross モンスターが地形を踏破できるならばTRUE
2731 * @return 透過も破壊もしなかった場合はFALSE、それ以外はTRUE
2832 */
29-bool process_wall(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx, bool can_cross)
33+static bool process_wall(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx, bool can_cross)
3034 {
3135 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3236 grid_type *g_ptr;
@@ -150,7 +154,7 @@ static void bash_glass_door(player_type *target_ptr, turn_flags *turn_flags_ptr,
150154 * @param nx モンスターのX座標
151155 * @return モンスターが死亡した場合のみFALSE
152156 */
153-bool process_door(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx)
157+static bool process_door(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx)
154158 {
155159 monster_race *r_ptr = &r_info[m_ptr->r_idx];
156160 grid_type *g_ptr;
@@ -189,50 +193,6 @@ bool process_door(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_t
189193
190194
191195 /*!
192- * @brief モンスターが壁を掘った後続処理を実行する
193- * @param target_ptr プレーヤーへの参照ポインタ
194- * @turn_flags_ptr ターン経過処理フラグへの参照ポインタ
195- * @param m_ptr モンスターへの参照ポインタ
196- * @param ny モンスターのY座標
197- * @param nx モンスターのX座標
198- * @return モンスターが死亡した場合のみFALSE
199- */
200-bool process_post_dig_wall(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx)
201-{
202- monster_race *r_ptr = &r_info[m_ptr->r_idx];
203- grid_type *g_ptr;
204- g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx];
205- feature_type *f_ptr;
206- f_ptr = &f_info[g_ptr->feat];
207- if (!turn_flags_ptr->did_kill_wall || !turn_flags_ptr->do_move) return TRUE;
208-
209- if (one_in_(GRINDNOISE))
210- {
211- if (have_flag(f_ptr->flags, FF_GLASS))
212- msg_print(_("何かの砕ける音が聞こえる。", "There is a crashing sound."));
213- else
214- msg_print(_("ギシギシいう音が聞こえる。", "There is a grinding sound."));
215- }
216-
217- cave_alter_feat(target_ptr, ny, nx, FF_HURT_DISI);
218-
219- if (!monster_is_valid(m_ptr))
220- {
221- target_ptr->update |= (PU_FLOW);
222- target_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
223- if (is_original_ap_and_seen(target_ptr, m_ptr)) r_ptr->r_flags2 |= (RF2_KILL_WALL);
224-
225- return FALSE;
226- }
227-
228- f_ptr = &f_info[g_ptr->feat];
229- turn_flags_ptr->do_view = TRUE;
230- turn_flags_ptr->do_turn = TRUE;
231- return TRUE;
232-}
233-
234-
235-/*!
236196 * @brief 守りのルーンによるモンスターの移動制限を処理する
237197 * @param target_ptr プレーヤーへの参照ポインタ
238198 * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ
@@ -241,7 +201,7 @@ bool process_post_dig_wall(player_type *target_ptr, turn_flags *turn_flags_ptr,
241201 * @param nx モンスターのX座標
242202 * @return ルーンのある/なし
243203 */
244-bool process_protection_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx)
204+static bool process_protection_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx)
245205 {
246206 grid_type *g_ptr;
247207 g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx];
@@ -277,7 +237,7 @@ bool process_protection_rune(player_type *target_ptr, turn_flags *turn_flags_ptr
277237 * @param nx モンスターのX座標
278238 * @return モンスターが死亡した場合のみFALSE
279239 */
280-bool process_explosive_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx)
240+static bool process_explosive_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx)
281241 {
282242 grid_type *g_ptr;
283243 g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx];
@@ -315,3 +275,169 @@ bool process_explosive_rune(player_type *target_ptr, turn_flags *turn_flags_ptr,
315275 turn_flags_ptr->do_move = TRUE;
316276 return TRUE;
317277 }
278+
279+
280+/*!
281+ * @brief モンスターが壁を掘った後続処理を実行する
282+ * @param target_ptr プレーヤーへの参照ポインタ
283+ * @turn_flags_ptr ターン経過処理フラグへの参照ポインタ
284+ * @param m_ptr モンスターへの参照ポインタ
285+ * @param ny モンスターのY座標
286+ * @param nx モンスターのX座標
287+ * @return モンスターが死亡した場合のみFALSE
288+ */
289+static bool process_post_dig_wall(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx)
290+{
291+ monster_race *r_ptr = &r_info[m_ptr->r_idx];
292+ grid_type *g_ptr;
293+ g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx];
294+ feature_type *f_ptr;
295+ f_ptr = &f_info[g_ptr->feat];
296+ if (!turn_flags_ptr->did_kill_wall || !turn_flags_ptr->do_move) return TRUE;
297+
298+ if (one_in_(GRINDNOISE))
299+ {
300+ if (have_flag(f_ptr->flags, FF_GLASS))
301+ msg_print(_("何かの砕ける音が聞こえる。", "There is a crashing sound."));
302+ else
303+ msg_print(_("ギシギシいう音が聞こえる。", "There is a grinding sound."));
304+ }
305+
306+ cave_alter_feat(target_ptr, ny, nx, FF_HURT_DISI);
307+
308+ if (!monster_is_valid(m_ptr))
309+ {
310+ target_ptr->update |= (PU_FLOW);
311+ target_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
312+ if (is_original_ap_and_seen(target_ptr, m_ptr)) r_ptr->r_flags2 |= (RF2_KILL_WALL);
313+
314+ return FALSE;
315+ }
316+
317+ f_ptr = &f_info[g_ptr->feat];
318+ turn_flags_ptr->do_view = TRUE;
319+ turn_flags_ptr->do_turn = TRUE;
320+ return TRUE;
321+}
322+
323+
324+/*!
325+ * todo 少し長いが、これといってブロックとしてまとまった部分もないので暫定でこのままとする
326+ * @brief モンスターの移動に関するメインルーチン
327+ * @param target_ptr プレーヤーへの参照ポインタ
328+ * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ
329+ * @param m_idx モンスターID
330+ * @param mm モンスターの移動方向
331+ * @param oy 移動前の、モンスターのY座標
332+ * @param ox 移動前の、モンスターのX座標
333+ * @param count 移動回数 (のはず todo)
334+ * @return 移動が阻害される何か (ドア等)があったらFALSE
335+ */
336+bool process_monster_movement(player_type *target_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx, DIRECTION *mm, POSITION oy, POSITION ox, int *count)
337+{
338+ for (int i = 0; mm[i]; i++)
339+ {
340+ int d = mm[i];
341+ if (d == 5) d = ddd[randint0(8)];
342+
343+ POSITION ny = oy + ddy[d];
344+ POSITION nx = ox + ddx[d];
345+ if (!in_bounds2(target_ptr->current_floor_ptr, ny, nx)) continue;
346+
347+ grid_type *g_ptr;
348+ g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx];
349+ monster_type *m_ptr = &target_ptr->current_floor_ptr->m_list[m_idx];
350+ monster_race *r_ptr = &r_info[m_ptr->r_idx];
351+ bool can_cross = monster_can_cross_terrain(target_ptr, g_ptr->feat, r_ptr, turn_flags_ptr->is_riding_mon ? CEM_RIDING : 0);
352+
353+ if (!process_wall(target_ptr, turn_flags_ptr, m_ptr, ny, nx, can_cross))
354+ {
355+ if (!process_door(target_ptr, turn_flags_ptr, m_ptr, ny, nx))
356+ return FALSE;
357+ }
358+
359+ if (!process_protection_rune(target_ptr, turn_flags_ptr, m_ptr, ny, nx))
360+ {
361+ if (!process_explosive_rune(target_ptr, turn_flags_ptr, m_ptr, ny, nx))
362+ return FALSE;
363+ }
364+
365+ exe_monster_attack_to_player(target_ptr, turn_flags_ptr, m_idx, ny, nx);
366+ if (process_monster_attack_to_monster(target_ptr, turn_flags_ptr, m_idx, g_ptr, can_cross)) return FALSE;
367+
368+ if (turn_flags_ptr->is_riding_mon)
369+ {
370+ if (!target_ptr->riding_ryoute && !MON_MONFEAR(&target_ptr->current_floor_ptr->m_list[target_ptr->riding])) turn_flags_ptr->do_move = FALSE;
371+ }
372+
373+ if (!process_post_dig_wall(target_ptr, turn_flags_ptr, m_ptr, ny, nx)) return FALSE;
374+
375+ if (turn_flags_ptr->must_alter_to_move && (r_ptr->flags7 & RF7_AQUATIC))
376+ {
377+ if (!monster_can_cross_terrain(target_ptr, g_ptr->feat, r_ptr, turn_flags_ptr->is_riding_mon ? CEM_RIDING : 0))
378+ turn_flags_ptr->do_move = FALSE;
379+ }
380+
381+ if (turn_flags_ptr->do_move && !can_cross && !turn_flags_ptr->did_kill_wall && !turn_flags_ptr->did_bash_door)
382+ turn_flags_ptr->do_move = FALSE;
383+
384+ if (turn_flags_ptr->do_move && (r_ptr->flags1 & RF1_NEVER_MOVE))
385+ {
386+ if (is_original_ap_and_seen(target_ptr, m_ptr))
387+ r_ptr->r_flags1 |= (RF1_NEVER_MOVE);
388+
389+ turn_flags_ptr->do_move = FALSE;
390+ }
391+
392+ if (!turn_flags_ptr->do_move)
393+ {
394+ if (turn_flags_ptr->do_turn) break;
395+
396+ continue;
397+ }
398+
399+ turn_flags_ptr->do_turn = TRUE;
400+ feature_type *f_ptr;
401+ f_ptr = &f_info[g_ptr->feat];
402+ if (have_flag(f_ptr->flags, FF_TREE))
403+ {
404+ if (!(r_ptr->flags7 & RF7_CAN_FLY) && !(r_ptr->flags8 & RF8_WILD_WOOD))
405+ {
406+ m_ptr->energy_need += ENERGY_NEED();
407+ }
408+ }
409+
410+ if (!update_riding_monster(target_ptr, turn_flags_ptr, m_idx, oy, ox, ny, nx)) break;
411+
412+ monster_race *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
413+ if (m_ptr->ml &&
414+ (disturb_move ||
415+ (disturb_near && (m_ptr->mflag & MFLAG_VIEW) && projectable(target_ptr, target_ptr->y, target_ptr->x, m_ptr->fy, m_ptr->fx)) ||
416+ (disturb_high && ap_r_ptr->r_tkills && ap_r_ptr->level >= target_ptr->lev)))
417+ {
418+ if (is_hostile(m_ptr))
419+ disturb(target_ptr, FALSE, TRUE);
420+ }
421+
422+ bool is_takable_or_killable = g_ptr->o_idx > 0;
423+ is_takable_or_killable &= (r_ptr->flags2 & (RF2_TAKE_ITEM | RF2_KILL_ITEM)) != 0;
424+
425+ bool is_pickup_items = (target_ptr->pet_extra_flags & PF_PICKUP_ITEMS) != 0;
426+ is_pickup_items &= (r_ptr->flags2 & RF2_TAKE_ITEM) != 0;
427+
428+ is_takable_or_killable &= !is_pet(m_ptr) || is_pickup_items;
429+ if (!is_takable_or_killable)
430+ {
431+ if (turn_flags_ptr->do_turn) break;
432+
433+ continue;
434+ }
435+
436+ update_object_by_monster_movement(target_ptr, turn_flags_ptr, m_idx, ny, nx);
437+ if (turn_flags_ptr->do_turn) break;
438+
439+ (*count)++;
440+ }
441+
442+ return TRUE;
443+}
--- a/src/monster/monster-move.h
+++ b/src/monster/monster-move.h
@@ -3,8 +3,4 @@
33 #include "angband.h"
44 #include "monster/monster-util.h"
55
6-bool process_wall(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx, bool can_cross);
7-bool process_door(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx);
8-
9-bool process_protection_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx);
10-bool process_explosive_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx);
6+bool process_monster_movement(player_type *target_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx, DIRECTION *mm, POSITION oy, POSITION ox, int *count);