OSDN Git Service

[Refactor] #37353 chest_traps を trap.c へ移動。
[hengband/hengband.git] / src / flavor.c
index 1e3b53a..f7f4f92 100644 (file)
  */
 
 #include "angband.h"
+#include "player-status.h"
+#include "shoot.h"
+#include "object-hook.h"
+#include "trap.h"
 
 /*!
  * @brief 最初から簡易な名称が明らかになるベースアイテムの判定。 /  Certain items, if aware, are known instantly 
@@ -65,7 +69,6 @@ static bool object_easy_know(int i)
                }
        }
 
-       /* Nope */
        return (FALSE);
 }
 
@@ -87,7 +90,7 @@ void get_table_name_aux(char *out_string)
 #else
 #define MAX_SYLLABLES 164       /* Used with scrolls (see below) */
 
-       static cptr syllables[MAX_SYLLABLES] = {
+       static concptr syllables[MAX_SYLLABLES] = {
                "a", "ab", "ag", "aks", "ala", "an", "ankh", "app",
                "arg", "arze", "ash", "aus", "ban", "bar", "bat", "bek",
                "bie", "bin", "bit", "bjor", "blu", "bot", "bu",
@@ -199,14 +202,14 @@ void get_table_sindarin(char *out_string)
  * @return なし
  * @details 巻物、各種魔道具などに利用される。
  */
-static void shuffle_flavors(byte tval)
+static void shuffle_flavors(OBJECT_TYPE_VALUE tval)
 {
-       s16b *k_idx_list;
-       int k_idx_list_num = 0;
-       int i;
+       KIND_OBJECT_IDX *k_idx_list;
+       KIND_OBJECT_IDX k_idx_list_num = 0;
+       KIND_OBJECT_IDX i;
 
        /* Allocate an array for a list of k_idx */
-       C_MAKE(k_idx_list, max_k_idx, s16b);
+       C_MAKE(k_idx_list, max_k_idx, KIND_OBJECT_IDX);
 
        /* Search objects with given tval for shuffle */
        for (i = 0; i < max_k_idx; i++)
@@ -281,7 +284,7 @@ static void shuffle_flavors(byte tval)
  */
 void flavor_init(void)
 {
-       int i;
+       KIND_OBJECT_IDX i;
        u32b state_backup[4];
 
        /* Hack -- Backup the RNG state */
@@ -367,8 +370,6 @@ static char *object_desc_chr(char *t, char c)
 
        /* Terminate */
        *t = '\0';
-
-       /* Result */
        return (t);
 }
 
@@ -381,15 +382,13 @@ static char *object_desc_chr(char *t, char c)
  * Print a string "s" into a string "t", as if by strcpy(t, s),
  * and return a pointer to the terminator.
  */
-static char *object_desc_str(char *t, cptr s)
+static char *object_desc_str(char *t, concptr s)
 {
        /* Copy the string */
        while (*s) *t++ = *s++;
 
        /* Terminate */
        *t = '\0';
-
-       /* Result */
        return (t);
 }
 
@@ -424,8 +423,6 @@ static char *object_desc_num(char *t, uint n)
 
        /* Terminate */
        *t = '\0';
-
-       /* Result */
        return (t);
 }
 
@@ -588,8 +585,6 @@ static char *object_desc_int(char *t, sint v)
 
        /* Terminate */
        *t = '\0';
-
-       /* Result */
        return (t);
 }
 
@@ -600,9 +595,9 @@ static char *object_desc_int(char *t, sint v)
 typedef struct flag_insc_table
 {
 #ifdef JP
-       cptr japanese;
+       concptr japanese;
 #endif
-       cptr english;
+       concptr english;
        int flag;
        int except_flag;
 } flag_insc_table;
@@ -966,7 +961,7 @@ static flag_insc_table flag_insc_sust[] =
  * sprintf(t, "%+d", n), and return a pointer to the terminator.
  * Note that we always print a sign, either "+" or "-".
  */
-static char *inscribe_flags_aux(flag_insc_table *fi_ptr, u32b flgs[TR_FLAG_SIZE], bool kanji, char *ptr)
+static char *inscribe_flags_aux(flag_insc_table *fi_ptr, BIT_FLAGS flgs[TR_FLAG_SIZE], bool kanji, char *ptr)
 {
 #ifndef JP
        (void)kanji;
@@ -994,7 +989,7 @@ static char *inscribe_flags_aux(flag_insc_table *fi_ptr, u32b flgs[TR_FLAG_SIZE]
  * @param flgs 対応するオブジェクトのフラグ文字列
  * @return 1つでも該当の特性があったらTRUEを返す。
  */
-static bool have_flag_of(flag_insc_table *fi_ptr, u32b flgs[TR_FLAG_SIZE])
+static bool have_flag_of(flag_insc_table *fi_ptr, BIT_FLAGS flgs[TR_FLAG_SIZE])
 {
        while (fi_ptr->english)
        {
@@ -1018,9 +1013,7 @@ static bool have_flag_of(flag_insc_table *fi_ptr, u32b flgs[TR_FLAG_SIZE])
 static char *get_ability_abbreviation(char *ptr, object_type *o_ptr, bool kanji, bool all)
 {
        char *prev_ptr = ptr;
-       u32b flgs[TR_FLAG_SIZE];
-
-       /* Extract the flags */
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
        object_flags(o_ptr, flgs);
 
        /* Remove obvious flags */
@@ -1170,7 +1163,7 @@ static char *get_ability_abbreviation(char *ptr, object_type *o_ptr, bool kanji,
  */
 static void get_inscription(char *buff, object_type *o_ptr)
 {
-       cptr insc = quark_str(o_ptr->inscription);
+       concptr insc = quark_str(o_ptr->inscription);
        char *ptr = buff;
 
        /* Not fully identified */
@@ -1201,7 +1194,7 @@ static void get_inscription(char *buff, object_type *o_ptr)
                {
                        bool kanji = FALSE;
                        bool all;
-                       cptr start = ptr;
+                       concptr start = ptr;
 
                        /* check for too long inscription */
                        if (ptr >= buff + MAX_NLEN) continue;
@@ -1240,31 +1233,6 @@ static void get_inscription(char *buff, object_type *o_ptr)
        *ptr = '\0';
 }
 
-/*!
- * @brief オブジェクトがクエストの達成目的か否かを返す。
- * @param o_ptr 特性短縮表記を得たいオブジェクト構造体の参照ポインタ
- * @return 現在クエスト達成目的のアイテムならばTRUEを返す。
- */
-bool object_is_quest_target(object_type *o_ptr)
-{
-       if (p_ptr->inside_quest)
-       {
-               int a_idx = quest[p_ptr->inside_quest].k_idx;
-               if (a_idx)
-               {
-                       artifact_type *a_ptr = &a_info[a_idx];
-                       if (!(a_ptr->gen_flags & TRG_INSTA_ART))
-                       {
-                               if((o_ptr->tval == a_ptr->tval) && (o_ptr->sval == a_ptr->sval))
-                               {
-                                       return TRUE;
-                               }
-                       }
-               }
-       }
-       return FALSE;
-}
-
 
 /*!
  * @brief オブジェクトの各表記を返すメイン関数 / Creates a description of the item "o_ptr", and stores it in "out_val".
@@ -1316,19 +1284,19 @@ bool object_is_quest_target(object_type *o_ptr)
  *   OD_NO_FLAVOR        : Allow to hidden flavor\n
  *   OD_FORCE_FLAVOR     : Get un-shuffled flavor name\n
  */
-void object_desc(char *buf, object_type *o_ptr, u32b mode)
+void object_desc(char *buf, object_type *o_ptr, BIT_FLAGS mode)
 {
        /* Extract object kind name */
-       cptr            kindname = k_name + k_info[o_ptr->k_idx].name;
+       concptr            kindname = k_name + k_info[o_ptr->k_idx].name;
 
        /* Extract default "base" string */
-       cptr            basenm = kindname;
+       concptr            basenm = kindname;
 
        /* Assume no "modifier" string */
-       cptr            modstr = "";
+       concptr            modstr = "";
 
-       int             power;
-       int                             fire_rate;
+       int power;
+       int fire_rate;
 
        bool            aware = FALSE;
        bool            known = FALSE;
@@ -1337,7 +1305,7 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
        bool            show_weapon = FALSE;
        bool            show_armour = FALSE;
 
-       cptr            s, s0;
+       concptr            s, s0;
        char            *t;
 
        char            p1 = '(', p2 = ')';
@@ -1348,7 +1316,7 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
        char            tmp_val2[MAX_NLEN+10];
        char            fake_insc_buf[30];
 
-       u32b flgs[TR_FLAG_SIZE];
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
 
        object_type *bow_ptr;
 
@@ -1420,7 +1388,7 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
                                        sprintf(tmp_val2, " (%s)",r_name + r_ptr->name);
                                        modstr = tmp_val2;
 #else
-                                       cptr t = r_name + r_ptr->name;
+                                       concptr t = r_name + r_ptr->name;
 
                                        if (!(r_ptr->flags1 & RF1_UNIQUE))
                                        {
@@ -1449,7 +1417,7 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
 #ifdef JP
                        modstr = r_name + r_ptr->name;
 #else
-                       cptr t = r_name + r_ptr->name;
+                       concptr t = r_name + r_ptr->name;
 
                        if (!(r_ptr->flags1 & RF1_UNIQUE))
                        {
@@ -2020,7 +1988,7 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
 #ifdef JP
        if (object_is_smith(o_ptr))
        {
-               t = object_desc_str(t, format("鍛冶師%sの", player_name));
+               t = object_desc_str(t, format("鍛冶師%sの", p_ptr->name));
        }
 
        /* 伝説のアイテム、名のあるアイテムの名前を付加する */
@@ -2029,7 +1997,7 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
                /* ランダム・アーティファクト */
                if (o_ptr->art_name)
                {
-                       cptr temp = quark_str(o_ptr->art_name);
+                       concptr temp = quark_str(o_ptr->art_name);
 
                        /* '『' から始まらない伝説のアイテムの名前は最初に付加する */
                        /* 英語版のセーブファイルから来た 'of XXX' は,「XXXの」と表示する */
@@ -2101,7 +2069,7 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
                        {
                                char k = t[-1];
 
-                               /* XXX XXX XXX Mega-Hack */
+                               /* Mega-Hack */
 
                                /* Hack -- "Cutlass-es" and "Torch-es" */
                                if ((k == 's') || (k == 'h')) *t++ = 'e';
@@ -2159,7 +2127,7 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
                }
                else if (o_ptr->inscription)
                {
-                       cptr str = quark_str(o_ptr->inscription);
+                       concptr str = quark_str(o_ptr->inscription);
 
                        while(*str)
                        {
@@ -2174,11 +2142,11 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
                        if (*str)
                        {
                                /* Find the '#' */
-                               cptr str = my_strchr(quark_str(o_ptr->inscription), '#');
+                               concptr str_aux = my_strchr(quark_str(o_ptr->inscription), '#');
 
                                /* Add the false name */
                                t = object_desc_str(t,"『");
-                               t = object_desc_str(t, &str[1]);
+                               t = object_desc_str(t, &str_aux[1]);
                                t = object_desc_str(t,"』");
                        }
                }
@@ -2186,7 +2154,7 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
 #else
        if (object_is_smith(o_ptr))
        {
-               t = object_desc_str(t,format(" of %s the Smith",player_name));
+               t = object_desc_str(t,format(" of %s the Smith",p_ptr->name));
        }
 
        /* Hack -- Append "Artifact" or "Special" names */
@@ -2222,7 +2190,7 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
                        if (o_ptr->inscription && my_strchr(quark_str(o_ptr->inscription), '#'))
                        {
                                /* Find the '#' */
-                               cptr str = my_strchr(quark_str(o_ptr->inscription), '#');
+                               concptr str = my_strchr(quark_str(o_ptr->inscription), '#');
 
                                /* Add the false name */
                                t = object_desc_chr(t, ' ');
@@ -2448,7 +2416,7 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
        {
                int avgdam = o_ptr->dd * (o_ptr->ds + 1) * 10 / 2;
                int tmul = bow_tmul(bow_ptr->sval);
-               s16b energy_fire = bow_energy(bow_ptr->sval);
+               ENERGY energy_fire = bow_energy(bow_ptr->sval);
 
                /* See if the bow is "known" - then set damage bonus */
                if (object_is_known(bow_ptr)) avgdam += (bow_ptr->to_d * 10);
@@ -2498,13 +2466,11 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
                        avgdam *= (p_ptr->num_fire * 100);
                        avgdam /= energy_fire;
                        t = object_desc_num(t, avgdam);
-                       t = object_desc_str(t, show_ammo_detail ? "/turn" : "");
+                       t = object_desc_str(t, show_ammo_detail ? "/current_world_ptr->game_turn" : "");
                        
                        if(show_ammo_crit_ratio)
                        {
-                               int percent = calc_crit_ratio_shot(o_ptr->weight, 
-                                               known ? o_ptr->to_h : 0, 
-                                               object_is_known(bow_ptr) ? bow_ptr->to_h : 0,  avgdam);
+                               int percent = calc_crit_ratio_shot(known ? o_ptr->to_h : 0, known ? bow_ptr->to_h : 0);
                                
                                t = object_desc_chr(t, '/');
                                t = object_desc_num(t, percent / 100);
@@ -2658,7 +2624,6 @@ void object_desc(char *buf, object_type *o_ptr, u32b mode)
                                /* Nothing */
                        }
 
-                       /* Speed */
                        else if (have_flag(flgs, TR_SPEED))
                        {
                                /* Dump " to speed" */