OSDN Git Service

#37287 #37353 (2.2.0.89) 型の置換を継続中。 / Ongoing type replacement.
[hengband/hengband.git] / src / cmd5.c
index 9ed78fa..11e9b30 100644 (file)
@@ -18,7 +18,7 @@
  * @param tval 魔法書のtval
  * @return 領域魔法の技能名称を保管した文字列ポインタ
  */
-cptr spell_category_name(int tval)
+cptr spell_category_name(OBJECT_TYPE_VALUE tval)
 {
        switch (tval)
        {
@@ -64,19 +64,20 @@ bool select_the_force = FALSE;
  * The "known" should be TRUE for cast/pray, FALSE for study
  * </pre>
  */
-static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm)
+static int get_spell(SPELL_IDX *sn, cptr prompt, OBJECT_SUBTYPE_VALUE sval, bool learned, REALM_IDX use_realm)
 {
        int         i;
-       int         spell = -1;
+       SPELL_IDX   spell = -1;
        int         num = 0;
        int         ask = TRUE;
-       int         need_mana;
-       byte        spells[64];
+       MANA_POINT  need_mana;
+       SPELL_IDX   spells[64];
        bool        flag, redraw, okay;
        char        choice;
        const magic_type  *s_ptr;
        char        out_val[160];
        cptr        p;
+       COMMAND_CODE code;
 #ifdef JP
        char jverb_buf[128];
 #endif
@@ -85,8 +86,9 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
 #ifdef ALLOW_REPEAT /* TNB */
 
        /* Get the spell, if available */
-       if (repeat_pull(sn))
+       if (repeat_pull(&code))
        {
+               *sn = (SPELL_IDX)code;
                /* Verify the spell */
                if (spell_okay(*sn, learned, FALSE, use_realm))
                {
@@ -242,7 +244,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                        ask = (isupper(choice));
 
                        /* Lowercase */
-                       if (ask) choice = tolower(choice);
+                       if (ask) choice = (char)tolower(choice);
 
                        /* Extract request */
                        i = (islower(choice) ? A2I(choice) : -1);
@@ -338,7 +340,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
 
 #ifdef ALLOW_REPEAT /* TNB */
 
-       repeat_push(*sn);
+       repeat_push((COMMAND_CODE)spell);
 
 #endif /* ALLOW_REPEAT -- TNB */
 
@@ -390,7 +392,7 @@ static bool player_has_no_spellbooks(void)
                if (o_ptr->k_idx && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
        }
 
-       for (i = cave[py][px].o_idx; i; i = o_ptr->next_o_idx)
+       for (i = cave[p_ptr->y][p_ptr->x].o_idx; i; i = o_ptr->next_o_idx)
        {
                o_ptr = &o_list[i];
                if (o_ptr->k_idx && (o_ptr->marked & OM_FOUND) && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
@@ -406,14 +408,16 @@ static bool player_has_no_spellbooks(void)
  */
 static void confirm_use_force(bool browse_only)
 {
-       int  item;
+       INVENTORY_IDX item;
        char which;
+       COMMAND_CODE code;
 
 #ifdef ALLOW_REPEAT
 
        /* Get the item index */
-       if (repeat_pull(&item) && (item == INVEN_FORCE))
+       if (repeat_pull(&code) && (code == INVEN_FORCE))
        {
+               item = (INVENTORY_IDX)code;
                browse_only ? do_cmd_mind_browse() : do_cmd_mind();
                return;
        }
@@ -466,12 +470,15 @@ static void confirm_use_force(bool browse_only)
  */
 void do_cmd_browse(void)
 {
-       int             item, sval, use_realm = 0, j, line;
-       int             spell = -1;
-       int             num = 0;
+       OBJECT_IDX item;
+       OBJECT_SUBTYPE_VALUE sval;
+       REALM_IDX use_realm = 0;
+       int j, line;
+       SPELL_IDX spell = -1;
+       int num = 0;
 
-       byte            spells[64];
-       char            temp[62*4];
+       SPELL_IDX spells[64];
+       char temp[62*4];
 
        object_type     *o_ptr;
 
@@ -612,7 +619,7 @@ void do_cmd_browse(void)
  * @param next_realm 変更先の魔法領域ID
  * @return なし
  */
-static void change_realm2(int next_realm)
+static void change_realm2(CHARACTER_IDX next_realm)
 {
        int i, j = 0;
        char tmp[80];
@@ -654,12 +661,14 @@ static void change_realm2(int next_realm)
  */
 void do_cmd_study(void)
 {
-       int     i, item, sval;
+       int     i;
+       OBJECT_IDX item;
+       OBJECT_SUBTYPE_VALUE sval;
        int     increment = 0;
        bool    learned = FALSE;
 
        /* Spells of realm2 will have an increment of +32 */
-       int     spell = -1;
+       SPELL_IDX spell = -1;
 
        cptr p = spell_category_name(mp_ptr->spell_book);
 
@@ -892,7 +901,7 @@ void do_cmd_study(void)
        }
 
        /* Take a turn */
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        switch (mp_ptr->spell_book)
        {
@@ -946,10 +955,10 @@ void do_cmd_study(void)
 static void wild_magic(int spell)
 {
        int counter = 0;
-       int type = SUMMON_BIZARRE1 + randint0(6);
+       int type = SUMMON_MOLD + randint0(6);
 
-       if (type < SUMMON_BIZARRE1) type = SUMMON_BIZARRE1;
-       else if (type > SUMMON_BIZARRE6) type = SUMMON_BIZARRE6;
+       if (type < SUMMON_MOLD) type = SUMMON_MOLD;
+       else if (type > SUMMON_MIMIC) type = SUMMON_MIMIC;
 
        switch (randint1(spell) + randint1(8) + 1)
        {
@@ -987,7 +996,7 @@ static void wild_magic(int spell)
                break;
        case 19:
        case 20:
-               trap_creation(py, px);
+               trap_creation(p_ptr->y, p_ptr->x);
                break;
        case 21:
        case 22:
@@ -999,7 +1008,7 @@ static void wild_magic(int spell)
                aggravate_monsters(0);
                break;
        case 26:
-               earthquake(py, px, 5);
+               earthquake(p_ptr->y, p_ptr->x, 5);
                break;
        case 27:
        case 28:
@@ -1022,15 +1031,15 @@ static void wild_magic(int spell)
        case 35:
                while (counter++ < 8)
                {
-                       (void)summon_specific(0, py, px, (dun_level * 3) / 2, type, (PM_ALLOW_GROUP | PM_NO_PET));
+                       (void)summon_specific(0, p_ptr->y, p_ptr->x, (dun_level * 3) / 2, type, (PM_ALLOW_GROUP | PM_NO_PET));
                }
                break;
        case 36:
        case 37:
-               activate_hi_summon(py, px, FALSE);
+               activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
                break;
        case 38:
-               (void)summon_cyber(-1, py, px);
+               (void)summon_cyber(-1, p_ptr->y, p_ptr->x);
                break;
        default:
                {
@@ -1051,18 +1060,18 @@ static void wild_magic(int spell)
  */
 void do_cmd_cast(void)
 {
-       int     item, sval, spell, realm;
+       OBJECT_IDX item;
+       OBJECT_SUBTYPE_VALUE sval;
+       SPELL_IDX spell;
+       REALM_IDX realm;
        int     chance;
        int     increment = 0;
-       int     use_realm;
-       int     need_mana;
+       REALM_IDX use_realm;
+       MANA_POINT need_mana;
 
        cptr prayer;
-
        object_type     *o_ptr;
-
        const magic_type *s_ptr;
-
        cptr q, s;
 
        bool over_exerted = FALSE;
@@ -1453,7 +1462,7 @@ msg_format("その%sを%sのに十分なマジックポイントがない。",pr
        }
 
        /* Take a turn */
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
 
        /* Over-exert the player */
@@ -1592,7 +1601,7 @@ void check_pets_num_and_align(monster_type *m_ptr, bool inc)
 int calculate_upkeep(void)
 {
        s32b old_friend_align = friend_align;
-       int m_idx;
+       MONSTER_IDX m_idx;
        bool have_a_unique = FALSE;
        s32b total_friend_levels = 0;
 
@@ -1655,13 +1664,14 @@ void do_cmd_pet_dismiss(void)
 {
        monster_type    *m_ptr;
        bool            all_pets = FALSE;
-       int pet_ctr, i;
+       MONSTER_IDX pet_ctr;
+       int i;
        int Dismissed = 0;
 
-       u16b *who;
+       MONSTER_IDX *who;
        u16b dummy_why;
        int max_pet = 0;
-       int cu, cv;
+       bool_hack cu, cv;
 
        cu = Term->scr->cu;
        cv = Term->scr->cv;
@@ -1669,7 +1679,7 @@ void do_cmd_pet_dismiss(void)
        Term->scr->cv = 1;
 
        /* Allocate the "who" array */
-       C_MAKE(who, max_m_idx, u16b);
+       C_MAKE(who, max_m_idx, MONSTER_IDX);
 
        /* Process the monsters (backwards) */
        for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
@@ -1778,7 +1788,7 @@ void do_cmd_pet_dismiss(void)
        Term->scr->cv = cv;
        Term_fresh();
 
-       C_KILL(who, max_m_idx, u16b);
+       C_KILL(who, max_m_idx, MONSTER_IDX);
 
 #ifdef JP
        msg_format("%d 体のペットを放しました。", Dismissed);
@@ -1800,7 +1810,7 @@ static bool player_can_ride_aux(cave_type *c_ptr, bool now_riding)
 {
        bool p_can_enter;
        bool old_character_xtra = character_xtra;
-       int  old_riding = p_ptr->riding;
+       MONSTER_IDX old_riding = p_ptr->riding;
        bool old_riding_ryoute = p_ptr->riding_ryoute;
        bool old_old_riding_ryoute = p_ptr->old_riding_ryoute;
        bool old_pf_ryoute = (p_ptr->pet_extra_flags & PF_RYOUTE) ? TRUE : FALSE;
@@ -1839,7 +1849,7 @@ static bool player_can_ride_aux(cave_type *c_ptr, bool now_riding)
  * @param force TRUEならば強制的に落馬する
  * @return 実際に落馬したらTRUEを返す
  */
-bool rakuba(int dam, bool force)
+bool rakuba(HIT_POINT dam, bool force)
 {
        int i, y, x, oy, ox;
        int sn = 0, sy = 0, sx = 0;
@@ -1892,8 +1902,8 @@ bool rakuba(int dam, bool force)
                        cave_type *c_ptr;
 
                        /* Access the location */
-                       y = py + ddy_ddd[i];
-                       x = px + ddx_ddd[i];
+                       y = p_ptr->y + ddy_ddd[i];
+                       x = p_ptr->x + ddx_ddd[i];
 
                        c_ptr = &cave[y][x];
 
@@ -1929,17 +1939,17 @@ msg_format("%sから振り落とされそうになって、壁にぶつかった
                        return FALSE;
                }
 
-               oy = py;
-               ox = px;
+               oy = p_ptr->y;
+               ox = p_ptr->x;
 
-               py = sy;
-               px = sx;
+               p_ptr->y = sy;
+               p_ptr->x = sx;
 
                /* Redraw the old spot */
                lite_spot(oy, ox);
 
                /* Redraw the new spot */
-               lite_spot(py, px);
+               lite_spot(p_ptr->y, p_ptr->x);
 
                /* Check for new panel */
                verify_panel();
@@ -1977,7 +1987,7 @@ msg_format("%sから振り落とされそうになって、壁にぶつかった
 
        /* Move the player */
        if (sy && !p_ptr->is_dead)
-               (void)move_player_effect(py, px, MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
+               (void)move_player_effect(p_ptr->y, p_ptr->x, MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
 
        return fall_dam;
 }
@@ -1994,8 +2004,8 @@ bool do_riding(bool force)
        monster_type *m_ptr;
 
        if (!get_rep_dir2(&dir)) return FALSE;
-       y = py + ddy[dir];
-       x = px + ddx[dir];
+       y = p_ptr->y + ddy[dir];
+       x = p_ptr->x + ddx[dir];
        c_ptr = &cave[y][x];
 
        if (p_ptr->special_defense & KATA_MUSOU) set_action(ACTION_NONE);
@@ -2009,12 +2019,12 @@ bool do_riding(bool force)
                        return FALSE;
                }
 
-               if (!pattern_seq(py, px, y, x)) return FALSE;
+               if (!pattern_seq(p_ptr->y, p_ptr->x, y, x)) return FALSE;
 
                if (c_ptr->m_idx)
                {
                        /* Take a turn */
-                       energy_use = 100;
+                       p_ptr->energy_use = 100;
 
                        /* Message */
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
@@ -2053,7 +2063,7 @@ bool do_riding(bool force)
                        return FALSE;
                }
 
-               if (!pattern_seq(py, px, y, x)) return FALSE;
+               if (!pattern_seq(p_ptr->y, p_ptr->x, y, x)) return FALSE;
 
                if (!player_can_ride_aux(c_ptr, TRUE))
                {
@@ -2076,7 +2086,7 @@ bool do_riding(bool force)
                if (r_info[m_ptr->r_idx].level > randint1((p_ptr->skill_exp[GINOU_RIDING] / 50 + p_ptr->lev / 2 + 20)))
                {
                        msg_print(_("うまく乗れなかった。", "You failed to ride."));
-                       energy_use = 100;
+                       p_ptr->energy_use = 100;
                        return FALSE;
                }
 
@@ -2096,7 +2106,7 @@ bool do_riding(bool force)
                if (p_ptr->riding == p_ptr->health_who) health_track(0);
        }
 
-       energy_use = 100;
+       p_ptr->energy_use = 100;
 
        /* Mega-Hack -- Forget the view and lite */
        p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
@@ -2176,8 +2186,6 @@ static void do_name_pet(void)
                                m_ptr->nickname = quark_add(out_val);
                                if (record_named_pet)
                                {
-                                       char m_name[80];
-
                                        monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
                                        do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_NAME, m_name);
                                }
@@ -2186,8 +2194,6 @@ static void do_name_pet(void)
                        {
                                if (record_named_pet && old_name)
                                {
-                                       char m_name[80];
-
                                        monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
                                        do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_UNNAME, m_name);
                                }
@@ -2205,7 +2211,7 @@ static void do_name_pet(void)
  */
 void do_cmd_pet(void)
 {
-       int                     i = 0;
+       COMMAND_CODE i = 0;
        int                     num;
        int                     powers[36];
        cptr                    power_desc[36];
@@ -2215,7 +2221,7 @@ void do_cmd_pet(void)
        int                     pet_ctr;
        monster_type    *m_ptr;
 
-       int mode = 0;
+       PET_COMMAND_IDX mode = 0;
 
        char buf[160];
        char target_buf[160];
@@ -2472,7 +2478,7 @@ void do_cmd_pet(void)
                        if (!redraw || use_menu)
                        {
                                byte y = 1, x = 0;
-                               int ctr = 0;
+                               PET_COMMAND_IDX ctr = 0;
 
                                /* Show list */
                                redraw = TRUE;
@@ -2519,7 +2525,7 @@ void do_cmd_pet(void)
                        ask = (isupper(choice));
 
                        /* Lowercase */
-                       if (ask) choice = tolower(choice);
+                       if (ask) choice = (char)tolower(choice);
 
                        /* Extract request */
                        i = (islower(choice) ? A2I(choice) : -1);
@@ -2552,7 +2558,7 @@ void do_cmd_pet(void)
        /* Abort if needed */
        if (!flag)
        {
-               energy_use = 0;
+               p_ptr->energy_use = 0;
                return;
        }