OSDN Git Service

[Refactor] #37353 notice_stuff() の直接呼出しを抑止。 / Forbid call of notice_stuff() except...
[hengband/hengband.git] / src / dungeon.c
index 46d5ab0..2f77d8b 100644 (file)
@@ -23,6 +23,8 @@
 #include "cmd-pet.h"
 #include "floor-events.h"
 #include "object-curse.h"
+#include "store.h"
+#include "monsterrace-hook.h"
 
 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
 static int wild_regen = 20; /*!<広域マップ移動時の自然回復処理カウンタ(広域マップ1マス毎に20回処理を基本とする)*/
@@ -701,9 +703,9 @@ static bool pattern_effect(void)
  */
 static void regenhp(int percent)
 {
-       s32b new_chp;
+       HIT_POINT new_chp;
        u32b new_chp_frac;
-       s32b old_chp;
+       HIT_POINT old_chp;
 
        if (p_ptr->special_defense & KATA_KOUKIJIN) return;
        if (p_ptr->action == ACTION_HAYAGAKE) return;
@@ -749,9 +751,9 @@ static void regenhp(int percent)
  * @param regen_amount 回復量
  * @return なし
  */
-static void regenmana(int upkeep_factor, int regen_amount)
+static void regenmana(MANA_POINT upkeep_factor, MANA_POINT regen_amount)
 {
-       s32b old_csp = p_ptr->csp;
+       MANA_POINT old_csp = p_ptr->csp;
        s32b regen_rate = regen_amount * 100 - upkeep_factor * PY_REGEN_NORMAL;
 
        /*
@@ -782,7 +784,7 @@ static void regenmana(int upkeep_factor, int regen_amount)
        else if (regen_rate > 0)
        {
                /* (percent/100) is the Regen factor in unit (1/2^16) */
-               s32b new_mana = 0;
+               MANA_POINT new_mana = 0;
                u32b new_mana_frac = (p_ptr->msp * regen_rate / 100 + PY_REGEN_MNBASE);
 
                /* Convert the unit (1/2^16) to (1/2^32) */
@@ -821,8 +823,6 @@ static void regenmana(int upkeep_factor, int regen_amount)
                }
        }
 
-
-       /* Redraw mana */
        if (old_csp != p_ptr->csp)
        {
                p_ptr->redraw |= (PR_MANA);
@@ -839,7 +839,7 @@ static void regenmana(int upkeep_factor, int regen_amount)
  */
 static void regenmagic(int regen_amount)
 {
-       s32b new_mana;
+       MANA_POINT new_mana;
        int i;
        int dev = 30;
        int mult = (dev + adj_mag_mana[p_ptr->stat_ind[A_INT]]); /* x1 to x2 speed bonus for recharging */
@@ -972,7 +972,6 @@ static void regen_captured_monsters(void)
        {
                /* Combine pack */
                p_ptr->notice |= (PN_COMBINE);
-
                p_ptr->window |= (PW_INVEN);
                p_ptr->window |= (PW_EQUIP);
                wild_regen = 20;
@@ -1162,7 +1161,7 @@ static void check_music(void)
 {
        const magic_type *s_ptr;
        int spell;
-       s32b need_mana;
+       MANA_POINT need_mana;
        u32b need_mana_frac;
 
        /* Music singed by player */
@@ -1206,8 +1205,6 @@ static void check_music(void)
 
                        /* Redraw map and status bar */
                        p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
-
-                       /* Update monsters */
                        p_ptr->update |= (PU_MONSTERS);
 
                        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
@@ -1266,7 +1263,7 @@ static object_type *choose_cursed_obj_name(BIT_FLAGS flag)
                                        (flag == TRC_FAST_DIGEST) || 
                                        (flag == TRC_SLOW_REGEN) )
                {
-                       u32b cf;
+                       u32b cf = 0L;
                        BIT_FLAGS flgs[TR_FLAG_SIZE];
                        object_flags(o_ptr, flgs);
                        switch (flag)
@@ -1518,7 +1515,7 @@ static void process_world_aux_hp_and_sp(void)
 
        if (p_ptr->riding)
        {
-               int damage;
+               HIT_POINT damage;
                if ((r_info[m_list[p_ptr->riding].r_idx].flags2 & RF2_AURA_FIRE) && !p_ptr->immune_fire)
                {
                        damage = r_info[m_list[p_ptr->riding].r_idx].level / 2;
@@ -2553,7 +2550,7 @@ static void process_world_aux_curse(void)
                /* Add light curse (Later) */
                if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000))
                {
-                       u32b new_curse;
+                       BIT_FLAGS new_curse;
                        object_type *o_ptr;
 
                        o_ptr = choose_cursed_obj_name(TRC_ADD_L_CURSE);
@@ -2576,7 +2573,7 @@ static void process_world_aux_curse(void)
                /* Add heavy curse (Later) */
                if ((p_ptr->cursed & TRC_ADD_H_CURSE) && one_in_(2000))
                {
-                       u32b new_curse;
+                       BIT_FLAGS new_curse;
                        object_type *o_ptr;
 
                        o_ptr = choose_cursed_obj_name(TRC_ADD_H_CURSE);
@@ -2696,19 +2693,11 @@ static void process_world_aux_curse(void)
 
                if (o_ptr->name1 == ART_JUDGE)
                {
-#ifdef JP
                        if (object_is_known(o_ptr))
-                               msg_print("『審判の宝石』はあなたの体力を吸収した!");
+                               msg_print(_("『審判の宝石』はあなたの体力を吸収した!", "The Jewel of Judgement drains life from you!"));
                        else
-                               msg_print("なにかがあなたの体力を吸収した!");
-                       take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "審判の宝石", -1);
-#else
-                       if (object_is_known(o_ptr))
-                               msg_print("The Jewel of Judgement drains life from you!");
-                       else
-                               msg_print("Something drains life from you!");
-                       take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), "the Jewel of Judgement", -1);
-#endif
+                               msg_print(_("なにかがあなたの体力を吸収した!", "Something drains life from you!"));
+                       take_hit(DAMAGE_LOSELIFE, MIN(p_ptr->lev, 50), _("審判の宝石", "the Jewel of Judgement"), -1);
                }
        }
 }
@@ -2857,8 +2846,7 @@ static void process_world_aux_movement(void)
                        /* Determine the level */
                        if (dun_level || p_ptr->inside_quest || p_ptr->enter_dungeon)
                        {
-                               msg_print(_("上に引っ張りあげられる感じがする!",
-                                                       "You feel yourself yanked upwards!"));
+                               msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
 
                                if (dungeon_type) p_ptr->recall_dungeon = dungeon_type;
                                if (record_stair)
@@ -2876,8 +2864,7 @@ static void process_world_aux_movement(void)
                        }
                        else
                        {
-                               msg_print(_("下に引きずり降ろされる感じがする!",
-                                                       "You feel yourself yanked downwards!"));
+                               msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
 
                                dungeon_type = p_ptr->recall_dungeon;
 
@@ -3006,8 +2993,8 @@ static void process_world_aux_movement(void)
 static int get_monster_crowd_number(MONSTER_IDX m_idx)
 {
        monster_type *m_ptr = &m_list[m_idx];
-       int my = m_ptr->fy;
-       int mx = m_ptr->fx;
+       POSITION my = m_ptr->fy;
+       POSITION mx = m_ptr->fx;
        int i;
        int count = 0;
 
@@ -3126,7 +3113,7 @@ static byte get_dungeon_feeling(void)
                /* Artifacts */
                if (object_is_artifact(o_ptr))
                {
-                       s32b cost = object_value_real(o_ptr);
+                       PRICE cost = object_value_real(o_ptr);
 
                        delta += 10 * base;
                        if (cost > 10000L) delta += 10 * base;
@@ -3138,27 +3125,16 @@ static byte get_dungeon_feeling(void)
                }
 
                if (o_ptr->tval == TV_DRAG_ARMOR) delta += 30 * base;
-               if (o_ptr->tval == TV_SHIELD &&
-                   o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
-               if (o_ptr->tval == TV_GLOVES &&
-                   o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
-               if (o_ptr->tval == TV_BOOTS &&
-                   o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
-               if (o_ptr->tval == TV_HELM &&
-                   o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
-               if (o_ptr->tval == TV_RING &&
-                   o_ptr->sval == SV_RING_SPEED &&
-                   !object_is_cursed(o_ptr)) delta += 25 * base;
-               if (o_ptr->tval == TV_RING &&
-                   o_ptr->sval == SV_RING_LORDLY &&
-                   !object_is_cursed(o_ptr)) delta += 15 * base;
-               if (o_ptr->tval == TV_AMULET &&
-                   o_ptr->sval == SV_AMULET_THE_MAGI &&
-                   !object_is_cursed(o_ptr)) delta += 15 * base;
+               if (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) delta += 5 * base;
+               if (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) delta += 5 * base;
+               if (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) delta += 5 * base;
+               if (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) delta += 5 * base;
+               if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_SPEED && !object_is_cursed(o_ptr)) delta += 25 * base;
+               if (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY && !object_is_cursed(o_ptr)) delta += 15 * base;
+               if (o_ptr->tval == TV_AMULET && o_ptr->sval == SV_AMULET_THE_MAGI && !object_is_cursed(o_ptr)) delta += 15 * base;
 
                /* Out-of-depth objects */
-               if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) &&
-                   k_ptr->level > dun_level)
+               if (!object_is_cursed(o_ptr) && !object_is_broken(o_ptr) && k_ptr->level > dun_level)
                {
                        /* Rating increase */
                        delta += (k_ptr->level - dun_level) * base;
@@ -3748,8 +3724,6 @@ static void process_command(void)
                                p_ptr->wizard = TRUE;
                                msg_print(_("ウィザードモード突入。", "Wizard mode on."));
                        }
-
-                       /* Update monsters */
                        p_ptr->update |= (PU_MONSTERS);
 
                        /* Redraw "title" */
@@ -4597,7 +4571,7 @@ static void pack_overflow(void)
                object_type *o_ptr;
 
                /* Is auto-destroy done? */
-               notice_stuff();
+               handle_stuff();
                if (!inventory[INVEN_PACK].k_idx) return;
 
                /* Access the slot to be dropped */
@@ -4620,10 +4594,6 @@ static void pack_overflow(void)
                inven_item_describe(INVEN_PACK);
                inven_item_optimize(INVEN_PACK);
 
-               /* Handle "p_ptr->notice" */
-               notice_stuff();
-
-               /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
                handle_stuff();
        }
 }
@@ -4809,8 +4779,6 @@ static void process_player(void)
 
                        /* Recover fully */
                        (void)set_monster_csleep(p_ptr->riding, 0);
-
-                       /* Acquire the monster name */
                        monster_desc(m_name, m_ptr, 0);
                        msg_format(_("%^sを起こした。", "You have waked %s up."), m_name);
                }
@@ -4822,11 +4790,7 @@ static void process_player(void)
                                (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_STUNNED(m_ptr) - 1)))
                        {
                                char m_name[80];
-
-                               /* Acquire the monster name */
                                monster_desc(m_name, m_ptr, 0);
-
-                               /* Dump a message */
                                msg_format(_("%^sを朦朧状態から立ち直らせた。", "%^s is no longer stunned."), m_name);
                        }
                }
@@ -4838,11 +4802,7 @@ static void process_player(void)
                                (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_CONFUSED(m_ptr) - 1)))
                        {
                                char m_name[80];
-
-                               /* Acquire the monster name */
                                monster_desc(m_name, m_ptr, 0);
-
-                               /* Dump a message */
                                msg_format(_("%^sを混乱状態から立ち直らせた。", "%^s is no longer confused."), m_name);
                        }
                }
@@ -4854,11 +4814,7 @@ static void process_player(void)
                                (randint0(r_ptr->level) < p_ptr->skill_exp[GINOU_RIDING]) ? 0 : (MON_MONFEAR(m_ptr) - 1)))
                        {
                                char m_name[80];
-
-                               /* Acquire the monster name */
                                monster_desc(m_name, m_ptr, 0);
-
-                               /* Dump a message */
                                msg_format(_("%^sを恐怖から立ち直らせた。", "%^s is no longer fear."), m_name);
                        }
                }
@@ -4929,10 +4885,6 @@ static void process_player(void)
                p_ptr->counter = FALSE;
                now_damaged = FALSE;
 
-               /* Handle "p_ptr->notice" */
-               notice_stuff();
-
-               /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
                handle_stuff();
 
                /* Place the cursor on the player */
@@ -5013,11 +4965,8 @@ static void process_player(void)
                        /* Count this execution */
                        command_rep--;
 
-                       /* Redraw the state */
                        p_ptr->redraw |= (PR_STATE);
-
-                       /* Redraw stuff */
-                       redraw_stuff();
+                       handle_stuff();
 
                        /* Hack -- Assume messages were seen */
                        msg_flag = FALSE;
@@ -5187,8 +5136,6 @@ static void process_player(void)
                        {
 
                                p_ptr->redraw |= (PR_MAP);
-
-                               /* Update monsters */
                                p_ptr->update |= (PU_MONSTERS);
 
                                p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
@@ -5327,8 +5274,6 @@ static void dungeon(bool load_game)
 
        /* Update lite/view */
        p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH);
-
-       /* Update monsters */
        p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
 
        /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
@@ -5338,14 +5283,7 @@ static void dungeon(bool load_game)
        character_xtra = FALSE;
 
        p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
-
-       /* Combine / Reorder the pack */
        p_ptr->notice |= (PN_COMBINE | PN_REORDER);
-
-       /* Handle "p_ptr->notice" */
-       notice_stuff();
-
-       /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
        handle_stuff();
 
        /* Refresh */
@@ -5433,15 +5371,10 @@ static void dungeon(bool load_game)
                /* Hack -- Compress the object list occasionally */
                if (o_cnt + 32 < o_max) compact_objects(0);
 
-               
                /* Process the player */
                process_player();
-               
                process_upkeep_with_speed();
 
-               /* Handle "p_ptr->notice" */
-               notice_stuff();
-
                /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
                handle_stuff();
 
@@ -5457,10 +5390,6 @@ static void dungeon(bool load_game)
                /* Process all of the monsters */
                process_monsters();
 
-               /* Handle "p_ptr->notice" */
-               notice_stuff();
-
-               /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
                handle_stuff();
 
                /* Hack -- Hilite the player */
@@ -5472,14 +5401,9 @@ static void dungeon(bool load_game)
                /* Hack -- Notice death or departure */
                if (!p_ptr->playing || p_ptr->is_dead) break;
 
-
                /* Process the world */
                process_world();
 
-               /* Handle "p_ptr->notice" */
-               notice_stuff();
-
-               /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
                handle_stuff();
 
                /* Hack -- Hilite the player */
@@ -5803,7 +5727,7 @@ void play_game(bool new_game)
 
                p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
 
-               update_stuff();
+               handle_stuff();
 
                p_ptr->is_dead = TRUE;
 
@@ -6081,11 +6005,8 @@ void play_game(bool new_game)
        Term_xtra(TERM_XTRA_REACT, 0);
 
        p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
-
        p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
-
-       window_stuff();
-
+       handle_stuff();
 
        /* Set or clear "rogue_like_commands" if requested */
        if (arg_force_original) rogue_like_commands = FALSE;
@@ -6123,13 +6044,10 @@ void play_game(bool new_game)
                /* Process the level */
                dungeon(load_game);
 
-               /* Handle "p_ptr->notice" */
-               notice_stuff();
 
                /* Hack -- prevent "icky" message */
                character_xtra = TRUE;
 
-               /* Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window" */
                handle_stuff();
 
                character_xtra = FALSE;