OSDN Git Service

[Refactor] #37353 型の置換。
[hengband/hengband.git] / src / object2.c
index fca25a6..38228df 100644 (file)
  */
 
 #include "angband.h"
+#include "object-hook.h"
+
+static void one_sustain(object_type *o_ptr);
+
 
 static cptr const kaji_tips[5] =
 {
@@ -31,6 +35,25 @@ static cptr const kaji_tips[5] =
 };
 
 /*!
+ * @brief 対象のオブジェクトにランダムな能力維持を一つ付加する。/ Choose one random sustain
+ * @details 重複の抑止はない。
+ * @param o_ptr 対象のオブジェクト構造体ポインタ
+ * @return なし
+ */
+static void one_sustain(object_type *o_ptr)
+{
+       switch (randint0(6))
+       {
+       case 0: add_flag(o_ptr->art_flags, TR_SUST_STR); break;
+       case 1: add_flag(o_ptr->art_flags, TR_SUST_INT); break;
+       case 2: add_flag(o_ptr->art_flags, TR_SUST_WIS); break;
+       case 3: add_flag(o_ptr->art_flags, TR_SUST_DEX); break;
+       case 4: add_flag(o_ptr->art_flags, TR_SUST_CON); break;
+       case 5: add_flag(o_ptr->art_flags, TR_SUST_CHR); break;
+       }
+}
+
+/*!
  * @brief 床上、モンスター所持でスタックされたアイテムを削除しスタックを補完する / Excise a dungeon object from any stacks
  * @param o_idx 削除対象のオブジェクト構造体ポインタ
  * @return なし
@@ -1967,7 +1990,7 @@ void object_prep(object_type *o_ptr, KIND_OBJECT_IDX k_idx)
        o_ptr->ds = k_ptr->ds;
 
        /* Default activation */
-       if (k_ptr->act_idx > 0) o_ptr->xtra2 = k_ptr->act_idx;
+       if (k_ptr->act_idx > 0) o_ptr->xtra2 = (XTRA8)k_ptr->act_idx;
 
        /* Hack -- worthless items are always "broken" */
        if (k_info[o_ptr->k_idx].cost <= 0) o_ptr->ident |= (IDENT_BROKEN);
@@ -3101,7 +3124,7 @@ static void a_m_aux_2(object_type *o_ptr, int level, int power)
                                        o_ptr->to_d -= 6;
                                        o_ptr->to_h -= 6;
                                        break;
-                                 case EGO_NAZGUL:
+                               case EGO_NAZGUL:
                                        o_ptr->to_d -= 3;
                                        o_ptr->to_h -= 3;
                                        if (one_in_(3)) add_flag(o_ptr->art_flags, TR_COWARDICE);
@@ -4515,7 +4538,7 @@ void apply_magic(object_type *o_ptr, DEPTH lev, BIT_FLAGS mode)
                }
 
                /* Hack -- apply activatin index if needed */
-               if (e_ptr->act_idx) o_ptr->xtra2 = e_ptr->act_idx;
+               if (e_ptr->act_idx) o_ptr->xtra2 = (XTRA8)e_ptr->act_idx;
 
                /* Hack -- apply extra penalties if needed */
                if ((object_is_cursed(o_ptr) || object_is_broken(o_ptr)) && !(e_ptr->gen_flags & (TRG_POWERFUL)))
@@ -4755,7 +4778,6 @@ static bool kind_is_good(KIND_OBJECT_IDX k_idx)
 bool make_object(object_type *j_ptr, BIT_FLAGS mode)
 {
        int prob, base;
-       DEPTH obj_level;
 
 
        /* Chance of "special object" */
@@ -4816,9 +4838,6 @@ bool make_object(object_type *j_ptr, BIT_FLAGS mode)
                }
        }
 
-       obj_level = k_info[j_ptr->k_idx].level;
-       if (object_is_fixed_artifact(j_ptr)) obj_level = a_info[j_ptr->name1].level;
-
        if (cheat_peek) object_mention(j_ptr);
 
        /* Success */
@@ -5414,11 +5433,11 @@ s16b drop_near(object_type *j_ptr, int chance, int y, int x)
  * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
  * @return なし
  */
-void acquirement(int y1, int x1, int num, bool great, bool special, bool known)
+void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bool known)
 {
        object_type *i_ptr;
        object_type object_type_body;
-       u32b mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
+       BIT_FLAGS mode = AM_GOOD | (great || special ? AM_GREAT : 0L) | (special ? AM_SPECIAL : 0L) ;
 
        /* Acquirement */
        while (num--)
@@ -5488,7 +5507,7 @@ amuse_type amuse_info[] =
  * @param known TRUEならばオブジェクトが必ず*鑑定*済になる
  * @return なし
  */
-void amusement(int y1, int x1, int num, bool known)
+void amusement(POSITION y1, POSITION x1, int num, bool known)
 {
        object_type *i_ptr;
        object_type object_type_body;
@@ -5648,7 +5667,7 @@ s16b choose_random_trap(void)
  * @param x 秘匿したいマスのX座標
  * @return なし
  */
-void disclose_grid(int y, int x)
+void disclose_grid(POSITION y, POSITION x)
 {
        cave_type *c_ptr = &cave[y][x];
 
@@ -5680,7 +5699,7 @@ void disclose_grid(int y, int x)
  * when they are "discovered" (by detecting them or setting them off),\n
  * the trap is "instantiated" as a visible, "typed", trap.\n
  */
-void place_trap(int y, int x)
+void place_trap(POSITION y, POSITION x)
 {
        cave_type *c_ptr = &cave[y][x];
 
@@ -6285,9 +6304,9 @@ s16b inven_carry(object_type *o_ptr)
  * to fall to the ground.\n
  * Return the inventory slot into which the item is placed.\n
  */
-s16b inven_takeoff(int item, int amt)
+INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt)
 {
-       int slot;
+       INVENTORY_IDX slot;
 
        object_type forge;
        object_type *q_ptr;
@@ -6374,11 +6393,10 @@ s16b inven_takeoff(int item, int amt)
  * @details
  * The object will be dropped "near" the current location
  */
-void inven_drop(int item, int amt)
+void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt)
 {
        object_type forge;
        object_type *q_ptr;
-
        object_type *o_ptr;
 
        char o_name[MAX_NLEN];
@@ -7208,40 +7226,12 @@ bool process_warning(int xx, int yy)
 }
 
 /*!
- * @brief エッセンスの付加可能な武器や矢弾かを返す
- * @param o_ptr チェックしたいオブジェクトの構造体参照ポインタ
- * @return エッセンスの付加可能な武器か矢弾ならばTRUEを返す。
- */
-static bool item_tester_hook_melee_ammo(object_type *o_ptr)
-{
-       switch (o_ptr->tval)
-       {
-               case TV_HAFTED:
-               case TV_POLEARM:
-               case TV_DIGGING:
-               case TV_BOLT:
-               case TV_ARROW:
-               case TV_SHOT:
-               {
-                       return (TRUE);
-               }
-               case TV_SWORD:
-               {
-                       if (o_ptr->sval != SV_DOKUBARI) return (TRUE);
-               }
-       }
-
-       return (FALSE);
-}
-
-
-/*!
  * エッセンス情報の構造体 / A structure for smithing
  */
 typedef struct {
        int add;       /* TR flag number or special essence id */
        cptr add_name; /* Name of this ability */
-       int type;      /* Menu number */
+       ESSENCE_IDX type;      /* Menu number */
        int essence;   /* Index for carrying essences */
        int value;     /* Needed value to add this ability */
 } essence_type;
@@ -7724,13 +7714,14 @@ static void drain_essence(void)
        bool observe = FALSE;
        int old_ds, old_dd, old_to_h, old_to_d, old_ac, old_to_a, old_pval, old_name2;
        TIME_EFFECT old_timeout;
-       u32b old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
+       BIT_FLAGS old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
        object_type *o_ptr;
        cptr q, s;
        POSITION iy, ix;
        byte_hack marked;
        ITEM_NUMBER number;
-       s16b next_o_idx, weight;
+       OBJECT_IDX next_o_idx;
+       WEIGHT weight;
 
        for (i = 0; i < sizeof(drain_value) / sizeof(int); i++)
                drain_value[i] = 0;
@@ -7958,7 +7949,7 @@ static void drain_essence(void)
  * @brief 付加するエッセンスの大別を選択する
  * @return 選んだエッセンスの大別ID
  */
-static int choose_essence(void)
+static COMMAND_CODE choose_essence(void)
 {
        COMMAND_CODE mode = 0;
        char choice;
@@ -7985,7 +7976,7 @@ static int choose_essence(void)
                "Others"
        };
 #endif
-       const int mode_max = 7;
+       const COMMAND_CODE mode_max = 7;
 
 #ifdef ALLOW_REPEAT
        if (repeat_pull(&mode) && 1 <= mode && mode <= mode_max)
@@ -8073,7 +8064,7 @@ static int choose_essence(void)
  * @param mode エッセンスの大別ID
  * @return なし
  */
-static void add_essence(int mode)
+static void add_essence(ESSENCE_IDX mode)
 {
        OBJECT_IDX item;
        int max_num = 0;
@@ -8088,6 +8079,7 @@ static void add_essence(int mode)
        char o_name[MAX_NLEN];
        int use_essence;
        essence_type *es_ptr;
+       bool able[22] = { 0 };
 
        int menu_line = (use_menu ? 1 : 0);
 
@@ -8120,7 +8112,6 @@ static void add_essence(int mode)
        choice = (always_show_list || use_menu) ? ESCAPE:1;
        while (!flag)
        {
-               bool able[22];
                if( choice==ESCAPE ) choice = ' '; 
                else if( !get_com(out_val, &choice, FALSE) )break; 
 
@@ -8647,10 +8638,10 @@ static void erase_essence(void)
  */
 void do_cmd_kaji(bool only_browse)
 {
-       IDX mode = 0;
+       COMMAND_CODE mode = 0;
        char choice;
 
-       int menu_line = (use_menu ? 1 : 0);
+       COMMAND_CODE menu_line = (use_menu ? 1 : 0);
 
        if (!only_browse)
        {