OSDN Git Service

[Refactor] #37353 snipe_type をグローバル変数から、引数へ置換 / Replace snipe_type from global to...
authordeskull <deskull@users.sourceforge.jp>
Thu, 7 Mar 2019 04:42:59 +0000 (13:42 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Thu, 7 Mar 2019 04:42:59 +0000 (13:42 +0900)
src/cmd-item.c
src/cmd2.c
src/dungeon.c
src/externs.h
src/object1.c
src/shoot.c
src/snipe.c
src/variable.c

index 0f770c5..32ea8c6 100644 (file)
@@ -1704,7 +1704,7 @@ void do_cmd_use(void)
                case TV_ARROW:
                case TV_BOLT:
                {
-                       exe_fire(item, &inventory[INVEN_BOW]);
+                       exe_fire(item, &inventory[INVEN_BOW], SP_NONE);
                        break;
                }
 
index e59243b..0988b76 100644 (file)
@@ -2232,7 +2232,7 @@ void do_cmd_rest(void)
  * @brief 射撃処理のメインルーチン
  * @return なし
  */
-void do_cmd_fire(void)
+void do_cmd_fire(SPELL_IDX snipe_type)
 {
        OBJECT_IDX item;
        object_type *j_ptr, *ammo_ptr;
@@ -2288,7 +2288,7 @@ void do_cmd_fire(void)
        }
 
        /* Fire the item */
-       exe_fire(item, j_ptr);
+       exe_fire(item, j_ptr, snipe_type);
 
        if (!is_fired || p_ptr->pclass != CLASS_SNIPER) return;
 
@@ -2691,7 +2691,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
        if (hit_body) torch_lost_fuel(q_ptr);
 
        /* Chance of breakage (during attacks) */
-       j = (hit_body ? breakage_chance(q_ptr) : 0);
+       j = (hit_body ? breakage_chance(q_ptr, 0) : 0);
 
        /* Figurines transform */
        if ((q_ptr->tval == TV_FIGURINE) && !(p_ptr->inside_arena))
index 0ad8256..eaa5e3b 100644 (file)
@@ -4195,7 +4195,7 @@ static void process_command(void)
                /* Fire an item */
                case 'f':
                {
-                       do_cmd_fire();
+                       do_cmd_fire(SP_NONE);
                        break;
                }
 
index 68185bf..8c9d3c9 100644 (file)
@@ -507,8 +507,8 @@ extern void do_cmd_walk(bool pickup);
 extern void do_cmd_stay(bool pickup);
 extern void do_cmd_run(void);
 extern void do_cmd_rest(void);
-extern void do_cmd_fire(void);
-extern void exe_fire(INVENTORY_IDX item, object_type *j_ptr);
+extern void do_cmd_fire(SPELL_IDX snipe_type);
+extern void exe_fire(INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type);
 extern bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken);
 #ifdef TRAVEL
 extern void do_cmd_travel(void);
@@ -732,7 +732,7 @@ extern void toggle_inven_equip(void);
 extern bool can_get_item(void);
 extern bool get_item(OBJECT_IDX *cp, concptr pmt, concptr str, BIT_FLAGS mode);
 extern object_type *choose_object(OBJECT_IDX *idx, concptr q, concptr s, BIT_FLAGS option);
-PERCENTAGE breakage_chance(object_type *o_ptr);
+PERCENTAGE breakage_chance(object_type *o_ptr, SPELL_IDX snipe_type);
 
 /* object2.c */
 extern void excise_object_idx(OBJECT_IDX o_idx);
@@ -1363,14 +1363,13 @@ extern travel_type travel;
 #endif
 
 /* variable.c (for snipers) */
-extern int snipe_type;
 extern bool reset_concent;   /* Concentration reset flag */
 extern bool is_fired;
 
 /* snipe.c */
 extern void reset_concentration(bool msg);
 extern void display_snipe_list(void);
-extern MULTIPLY tot_dam_aux_snipe (MULTIPLY mult, monster_type *m_ptr);
+extern MULTIPLY tot_dam_aux_snipe (MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_type);
 extern void do_cmd_snipe(void);
 extern void do_cmd_snipe_browse(void);
 extern int boost_concentration_damage(int tdam);
index e769902..f90a0d0 100644 (file)
@@ -5040,7 +5040,7 @@ void py_pickup_floor(bool pickup)
  * @details
  * Note that artifacts never break, see the "drop_near()" function.
  */
-PERCENTAGE breakage_chance(object_type *o_ptr)
+PERCENTAGE breakage_chance(object_type *o_ptr, SPELL_IDX snipe_type)
 {
        PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev - 1) / 7 + 4 : 0);
 
index 0139e93..3de0388 100644 (file)
@@ -15,7 +15,7 @@
  * @param m_ptr 目標モンスターの構造体参照ポインタ
  * @return スレイ倍率をかけたダメージ量
  */
-static MULTIPLY tot_dam_aux_shot(object_type *o_ptr, HIT_POINT tdam, monster_type *m_ptr)
+static MULTIPLY tot_dam_aux_shot(object_type *o_ptr, HIT_POINT tdam, monster_type *m_ptr, SPELL_IDX snipe_type)
 {
        MULTIPLY mult = 10;
 
@@ -307,7 +307,7 @@ static MULTIPLY tot_dam_aux_shot(object_type *o_ptr, HIT_POINT tdam, monster_typ
        }
 
        /* Sniper */
-       if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr);
+       if (snipe_type) mult = tot_dam_aux_snipe(mult, m_ptr, snipe_type);
 
        /* Return the total damage */
        return (tdam * mult / 10);
@@ -338,7 +338,7 @@ static MULTIPLY tot_dam_aux_shot(object_type *o_ptr, HIT_POINT tdam, monster_typ
  * Note that Bows of "Extra Shots" give an extra shot.
  * </pre>
  */
-void exe_fire(INVENTORY_IDX item, object_type *j_ptr)
+void exe_fire(INVENTORY_IDX item, object_type *j_ptr, SPELL_IDX snipe_type)
 {
        DIRECTION dir;
        int i;
@@ -692,7 +692,7 @@ void exe_fire(INVENTORY_IDX item, object_type *j_ptr)
                                        else
                                        {
                                                /* Apply special damage */
-                                               tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr);
+                                               tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr, snipe_type);
                                                tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam);
 
                                                /* No negative damage */
@@ -822,7 +822,7 @@ void exe_fire(INVENTORY_IDX item, object_type *j_ptr)
                }
 
                /* Chance of breakage (during attacks) */
-               j = (hit_body ? breakage_chance(q_ptr) : 0);
+               j = (hit_body ? breakage_chance(q_ptr, snipe_type) : 0);
 
                if (stick_to)
                {
index 623263e..9372b88 100644 (file)
@@ -391,7 +391,7 @@ static int get_snipe_power(COMMAND_CODE *sn, bool only_browse)
  * @param m_ptr 目標となるモンスターの構造体参照ポインタ
  * @return スレイの倍率(/10倍)
  */
-MULTIPLY tot_dam_aux_snipe(MULTIPLY mult, monster_type *m_ptr)
+MULTIPLY tot_dam_aux_snipe(MULTIPLY mult, monster_type *m_ptr, SPELL_IDX snipe_type)
 {
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        bool seen = is_seen(m_ptr);
@@ -492,6 +492,7 @@ MULTIPLY tot_dam_aux_snipe(MULTIPLY mult, monster_type *m_ptr)
 static bool cast_sniper_spell(int spell)
 {
        object_type *o_ptr = &inventory[INVEN_BOW];
+       SPELL_IDX snipe_type = SP_NONE;
 
        if (o_ptr->tval != TV_BOW)
        {
@@ -526,8 +527,7 @@ static bool cast_sniper_spell(int spell)
        }
 
        command_cmd = 'f';
-       do_cmd_fire();
-       snipe_type = 0;
+       do_cmd_fire(snipe_type);
 
        return (is_fired);
 }
index 7b850bf..56a3ed2 100644 (file)
@@ -904,7 +904,6 @@ travel_type travel;
 #endif
 
 /* for snipers */
-int snipe_type = SP_NONE;
 bool reset_concent = FALSE;   /* Concentration reset flag */
 bool is_fired = FALSE;