OSDN Git Service

#37287 #37353 (2.2.0.89) 警告修正も兼ねてtypedefの見直し開始 / Start to review typedefs serve as...
authorDeskull <desull@users.sourceforge.jp>
Sun, 17 Sep 2017 12:07:35 +0000 (21:07 +0900)
committerDeskull <desull@users.sourceforge.jp>
Sun, 17 Sep 2017 12:07:35 +0000 (21:07 +0900)
src/birth.c
src/h-type.h
src/melee2.c
src/mind.c
src/monster2.c
src/types.h

index 9dc80b7..0e8c579 100644 (file)
@@ -2682,7 +2682,7 @@ static void get_stats(void)
                for (i = 0; i < 2; i++)
                {
                        s32b tmp = randint0(60*60*60);
-                       int val;
+                       base_status val;
 
                        /* Extract 5 + 1d3 + 1d4 + 1d5 */
                        val = 5 + 3;
@@ -2692,7 +2692,7 @@ static void get_stats(void)
 
                        /* Save that value */
                        sum += val;
-                       p_ptr->stat_cur[3*i] = p_ptr->stat_max[3*i] = (s16b)val;
+                       p_ptr->stat_cur[3*i] = p_ptr->stat_max[3*i] = val;
 
                        /* Extract 5 + 1d3 + 1d4 + 1d5 */
                        val = 5 + 3;
@@ -2702,7 +2702,7 @@ static void get_stats(void)
 
                        /* Save that value */
                        sum += val;
-                       p_ptr->stat_cur[3*i+1] = p_ptr->stat_max[3*i+1] = (s16b)val;
+                       p_ptr->stat_cur[3*i+1] = p_ptr->stat_max[3*i+1] = val;
 
                        /* Extract 5 + 1d3 + 1d4 + 1d5 */
                        val = 5 + 3;
@@ -2712,7 +2712,7 @@ static void get_stats(void)
 
                        /* Save that value */
                        sum += val;
-                       p_ptr->stat_cur[3*i+2] = p_ptr->stat_max[3*i+2] = (s16b)val;
+                       p_ptr->stat_cur[3*i+2] = p_ptr->stat_max[3*i+2] = val;
                }
 
                /* Verify totals */
@@ -2751,14 +2751,14 @@ void get_max_stats(void)
        /* Acquire the stats */
        for (i = 0; i < 6; i++)
        {
-               j = 18 + 60 + dice[i]*10;
+               base_status max_max = 18 + 60 + dice[i]*10;
 
                /* Save that value */
-               p_ptr->stat_max_max[i] = (s16b)j;
-               if (p_ptr->stat_max[i] > j)
-                       p_ptr->stat_max[i] = (s16b)j;
-               if (p_ptr->stat_cur[i] > j)
-                       p_ptr->stat_cur[i] = (s16b)j;
+               p_ptr->stat_max_max[i] = max_max;
+               if (p_ptr->stat_max[i] > max_max)
+                       p_ptr->stat_max[i] = max_max;
+               if (p_ptr->stat_cur[i] > max_max)
+                       p_ptr->stat_cur[i] = max_max;
        }
        p_ptr->knowledge &= ~(KNOW_STAT);
 
index 55e8e5e..a46c90a 100644 (file)
@@ -78,6 +78,7 @@ typedef char bool; /*!< bool型をcharとして定義 / Note that a bool is smal
 typedef int sint; /*!< sint型をintとして定義 / A signed, standard integer (at least 2 bytes) */
 typedef unsigned int uint; /* uint型をintとして定義 /  An unsigned, "standard" integer (often pre-defined) */
 
+
 /* The largest possible signed integer (pre-defined) */
 /* typedef long long; */
 
@@ -103,6 +104,10 @@ typedef unsigned long u32b;
 #endif
 
 
+typedef byte position;         /*!< ゲーム中の座標型を定義 */
+typedef s16b hit_point;                /*!< ゲーム中のHP/ダメージ型を定義 */
+typedef s16b base_status;      /*!< ゲーム中の基礎能力値型を定義 */
+
 
 
 /*** Pointers to all the basic types defined above ***/
index 707e3a2..a8634f3 100644 (file)
@@ -250,7 +250,7 @@ void mon_take_hit_mon(int m_idx, int dam, bool *fear, cptr note, int who)
        }
 
        /* Hurt it */
-       m_ptr->hp -= dam;
+       m_ptr->hp -= (s16b)dam;
 
        /* It is dead now... or is it? */
        if (m_ptr->hp < 0)
@@ -393,7 +393,7 @@ void mon_take_hit_mon(int m_idx, int dam, bool *fear, cptr note, int who)
  * Note that this function is responsible for about one to five percent\n
  * of the processor use in normal conditions...\n
  */
-static int mon_will_run(int m_idx)
+static bool mon_will_run(int m_idx)
 {
        monster_type *m_ptr = &m_list[m_idx];
 
@@ -438,8 +438,8 @@ static int mon_will_run(int m_idx)
        if (m_lev + 4 <= p_lev) return (TRUE);
 
        /* Examine player health */
-       p_chp = p_ptr->chp;
-       p_mhp = p_ptr->mhp;
+       p_chp = (u16b)p_ptr->chp;
+       p_mhp = (u16b)p_ptr->mhp;
 
        /* Examine monster health */
        m_chp = m_ptr->hp;
@@ -2109,7 +2109,8 @@ static void process_monster(int m_idx)
        monster_race    *r_ptr = &r_info[m_ptr->r_idx];
        monster_race    *ap_r_ptr = &r_info[m_ptr->ap_r_idx];
 
-       int             i, d, oy, ox, ny, nx;
+       int             i, d;
+       position        oy, ox, ny, nx;
 
        int             mm[8];
 
@@ -2617,7 +2618,7 @@ static void process_monster(int m_idx)
                                (void)get_moves(m_idx, mm);
 
                                /* Restore the leash */
-                               p_ptr->pet_follow_distance = dis;
+                               p_ptr->pet_follow_distance = (s16b)dis;
                        }
                }
        }
@@ -3090,7 +3091,7 @@ static void process_monster(int m_idx)
                                }
 
                                /* Hack -- Update the new location */
-                               c_ptr->m_idx = m_idx;
+                               c_ptr->m_idx = (s16b)m_idx;
 
                                /* Move the monster */
                                m_ptr->fy = ny;
@@ -3234,7 +3235,7 @@ static void process_monster(int m_idx)
                                                o_ptr->iy = o_ptr->ix = 0;
 
                                                /* Memorize monster */
-                                               o_ptr->held_m_idx = m_idx;
+                                               o_ptr->held_m_idx = (s16b)m_idx;
 
                                                /* Build a stack */
                                                o_ptr->next_o_idx = m_ptr->hold_o_idx;
@@ -3549,7 +3550,7 @@ void process_monsters(void)
 
 
                /* Save global index */
-               hack_m_idx = i;
+               hack_m_idx = (s16b)i;
 
                /* Process the monster */
                process_monster(i);
@@ -3624,7 +3625,7 @@ int get_mproc_idx(int m_idx, int mproc_type)
  */
 static void mproc_add(int m_idx, int mproc_type)
 {
-       if (mproc_max[mproc_type] < max_m_idx) mproc_list[mproc_type][mproc_max[mproc_type]++] = m_idx;
+       if (mproc_max[mproc_type] < max_m_idx) mproc_list[mproc_type][mproc_max[mproc_type]++] = (s16b)m_idx;
 }
 
 
@@ -3706,7 +3707,7 @@ bool set_monster_csleep(int m_idx, int v)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_CSLEEP] = v;
+       m_ptr->mtimed[MTIMED_CSLEEP] = (s16b)v;
 
        if (!notice) return FALSE;
 
@@ -3759,7 +3760,7 @@ bool set_monster_fast(int m_idx, int v)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_FAST] = v;
+       m_ptr->mtimed[MTIMED_FAST] = (s16b)v;
 
        if (!notice) return FALSE;
 
@@ -3801,7 +3802,7 @@ bool set_monster_slow(int m_idx, int v)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_SLOW] = v;
+       m_ptr->mtimed[MTIMED_SLOW] = (s16b)v;
 
        if (!notice) return FALSE;
 
@@ -3847,7 +3848,7 @@ bool set_monster_stunned(int m_idx, int v)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_STUNNED] = v;
+       m_ptr->mtimed[MTIMED_STUNNED] = (s16b)v;
 
        return notice;
 }
@@ -3889,7 +3890,7 @@ bool set_monster_confused(int m_idx, int v)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_CONFUSED] = v;
+       m_ptr->mtimed[MTIMED_CONFUSED] = (s16b)v;
 
        return notice;
 }
@@ -3931,7 +3932,7 @@ bool set_monster_monfear(int m_idx, int v)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_MONFEAR] = v;
+       m_ptr->mtimed[MTIMED_MONFEAR] = (s16b)v;
 
        if (!notice) return FALSE;
 
@@ -3984,7 +3985,7 @@ bool set_monster_invulner(int m_idx, int v, bool energy_need)
        }
 
        /* Use the value */
-       m_ptr->mtimed[MTIMED_INVULNER] = v;
+       m_ptr->mtimed[MTIMED_INVULNER] = (s16b)v;
 
        if (!notice) return FALSE;
 
index 22e2250..1e6709d 100644 (file)
@@ -972,7 +972,7 @@ put_str(format("Lv   %s   Fail Info", ((use_mind == MIND_BERSERKER) || (use_mind
                        ask = isupper(choice);
 
                        /* Lowercase */
-                       if (ask) choice = tolower(choice);
+                       if (ask) choice = (char)tolower(choice);
 
                        /* Extract request */
                        i = (islower(choice) ? A2I(choice) : -1);
@@ -1305,9 +1305,9 @@ static bool cast_force_spell(int spell)
                                {
                                        msg_format(_("%sを吹き飛ばした!", "You blow %s away!"), m_name);
                                        cave[oy][ox].m_idx = 0;
-                                       cave[ty][tx].m_idx = m_idx;
-                                       m_ptr->fy = ty;
-                                       m_ptr->fx = tx;
+                                       cave[ty][tx].m_idx = (s16b)m_idx;
+                                       m_ptr->fy = (byte_hack)ty;
+                                       m_ptr->fx = (byte_hack)tx;
 
                                        update_mon(m_idx, TRUE);
                                        lite_spot(oy, ox);
@@ -1778,11 +1778,11 @@ static bool cast_ninja_spell(int spell)
                cave[target_row][target_col].m_idx = 0;
 
                /* Update the new location */
-               cave[ty][tx].m_idx = m_idx;
+               cave[ty][tx].m_idx = (s16b)m_idx;
 
                /* Move the monster */
-               m_ptr->fy = ty;
-               m_ptr->fx = tx;
+               m_ptr->fy = (byte_hack)ty;
+               m_ptr->fx = (byte_hack)tx;
 
                /* Wake the monster up */
                (void)set_monster_csleep(m_idx, 0);
index 4edae66..79e30c6 100644 (file)
@@ -2929,7 +2929,7 @@ void choose_new_monster(int m_idx, bool born, int r_idx)
        if (ironman_nightmare)
        {
                u32b hp = m_ptr->max_maxhp * 2L;
-               m_ptr->max_maxhp = (s16b)MIN(30000, hp);
+               m_ptr->max_maxhp = (hit_point)MIN(30000, hp);
        }
 
        m_ptr->maxhp = (long)(m_ptr->maxhp * m_ptr->max_maxhp) / oldmaxhp;
@@ -3275,7 +3275,7 @@ static bool place_monster_one(int who, int y, int x, int r_idx, u32b mode)
        {
                u32b hp = m_ptr->max_maxhp * 2L;
 
-               m_ptr->max_maxhp = (s16b)MIN(30000, hp);
+               m_ptr->max_maxhp = (hit_point)MIN(30000, hp);
        }
 
        m_ptr->maxhp = m_ptr->max_maxhp;
index 550076d..3601e6a 100644 (file)
@@ -590,12 +590,12 @@ struct monster_type
        s16b ap_r_idx;          /* Monster race appearance index */
        byte sub_align;         /* Sub-alignment for a neutral monster */
 
-       byte fy;                /* Y location on map */
-       byte fx;                /* X location on map */
+       position fy;            /* Y location on map */
+       position fx;            /* X location on map */
 
-       s16b hp;                /* Current Hit points */
-       s16b maxhp;             /* Max Hit points */
-       s16b max_maxhp;         /* Max Max Hit points */
+       hit_point hp;           /* Current Hit points */
+       hit_point maxhp;                /* Max Hit points */
+       hit_point max_maxhp;            /* Max Max Hit points */
        u32b dealt_damage;              /* Sum of damages dealt by player */
 
        s16b mtimed[MAX_MTIMED];        /* Timed status counter */
@@ -1013,9 +1013,9 @@ struct player_type
 
        s16b max_plv;           /* Max Player Level */
 
-       s16b stat_max[6];       /* Current "maximal" stat values */
-       s16b stat_max_max[6];   /* Maximal "maximal" stat values */
-       s16b stat_cur[6];       /* Current "natural" stat values */
+       base_status stat_max[6];        /* Current "maximal" stat values */
+       base_status stat_max_max[6];    /* Maximal "maximal" stat values */
+       base_status stat_cur[6];        /* Current "natural" stat values */
 
        s16b learned_spells;
        s16b add_spells;