OSDN Git Service

自動拾いエディタでfreeした領域をアクセスしているバグを修正。
[hengband/hengband.git] / src / cmd3.c
index 688ebf8..e8ce3b1 100644 (file)
@@ -47,12 +47,11 @@ void do_cmd_inven(void)
 #ifdef JP
        sprintf(out_val, "»ý¤Áʪ¡§ ¹ç·× %3d.%1d kg (¸Â³¦¤Î%ld%%) ¥³¥Þ¥ó¥É: ",
            lbtokg1(p_ptr->total_weight) , lbtokg2(p_ptr->total_weight) ,
-           (p_ptr->total_weight * 100) / ((adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) 
-/ 2));
+           (p_ptr->total_weight * 100) / weight_limit());
 #else
        sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
            (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
-           (p_ptr->total_weight * 100) / ((adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) / 2));
+           (p_ptr->total_weight * 100) / weight_limit());
 #endif
 
 
@@ -122,12 +121,11 @@ void do_cmd_equip(void)
 #ifdef JP
        sprintf(out_val, "ÁõÈ÷¡§ ¹ç·× %3d.%1d kg (¸Â³¦¤Î%ld%%) ¥³¥Þ¥ó¥É: ",
            lbtokg1(p_ptr->total_weight) , lbtokg2(p_ptr->total_weight) ,
-           (p_ptr->total_weight * 100) / ((adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) 
-/ 2));
+           (p_ptr->total_weight * 100) / weight_limit());
 #else
        sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
            (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
-           (p_ptr->total_weight * 100) / ((adj_str_wgt[p_ptr->stat_ind[A_STR]] * (p_ptr->pclass == CLASS_BERSERKER ? 150 : 100)) / 2));
+           (p_ptr->total_weight * 100) / weight_limit());
 #endif
 
 
@@ -201,6 +199,8 @@ static bool item_tester_hook_melee_weapon(object_type *o_ptr)
 }
 
 
+bool select_ring_slot = FALSE;
+
 /*
  * Wield or wear a single item from the pack or floor
  */
@@ -351,23 +351,40 @@ void do_cmd_wield(void)
 
        /* Rings */
        case TV_RING:
+               /* Choose a ring slot */
                if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
                {
-                       /* Restrict the choices */
-                       item_tester_tval = TV_RING;
-                       item_tester_no_ryoute = TRUE;
-
-                       /* Choose a ring from the equipment only */
 #ifdef JP
                        q = "¤É¤Á¤é¤Î»ØÎؤȼè¤êÂؤ¨¤Þ¤¹¤«?";
-                       s = "¤ª¤Ã¤È¡£";
 #else
                        q = "Replace which ring? ";
-                       s = "Oops.";
+#endif
+               }
+               else
+               {
+#ifdef JP
+                       q = "¤É¤Á¤é¤Î¼ê¤ËÁõÈ÷¤·¤Þ¤¹¤«?";
+#else
+                       q = "Equip which hand? ";
+#endif
+               }
+
+#ifdef JP
+               s = "¤ª¤Ã¤È¡£";
+#else
+               s = "Oops.";
 #endif
 
-                       if (!get_item(&slot, q, s, (USE_EQUIP))) return;
+               /* Restrict the choices */
+               select_ring_slot = TRUE;
+               item_tester_no_ryoute = TRUE;
+
+               if (!get_item(&slot, q, s, (USE_EQUIP)))
+               {
+                       select_ring_slot = FALSE;
+                       return;
                }
+               select_ring_slot = FALSE;
                break;
        }
 
@@ -390,8 +407,10 @@ void do_cmd_wield(void)
                return;
        }
 
-       if (object_is_cursed(o_ptr) && confirm_wear &&
-           (object_is_known(o_ptr) || (o_ptr->ident & IDENT_SENSE)))
+       if (confirm_wear &&
+               ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) ||
+               ((o_ptr->ident & IDENT_SENSE) &&
+                       (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED))))
        {
                char dummy[MAX_NLEN+80];
 
@@ -513,43 +532,40 @@ msg_print("
        /* Wear the new stuff */
        object_copy(o_ptr, q_ptr);
 
+       /* Player touches it */
+       o_ptr->marked |= OM_TOUCHED;
+
        /* Increase the weight */
        p_ptr->total_weight += q_ptr->weight;
 
        /* Increment the equip counter by hand */
        equip_cnt++;
 
+#ifdef JP
+#define STR_WIELD_RARM "%s(%c)¤ò±¦¼ê¤ËÁõÈ÷¤·¤¿¡£"
+#define STR_WIELD_LARM "%s(%c)¤òº¸¼ê¤ËÁõÈ÷¤·¤¿¡£"
+#define STR_WIELD_ARMS "%s(%c)¤òξ¼ê¤Ç¹½¤¨¤¿¡£"
+#else
+#define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
+#define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
+#define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
+#endif
+
        /* Where is the item now */
        switch (slot)
        {
        case INVEN_RARM:
-               if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE)))
-#ifdef JP
-                       act = "%s(%c)¤òξ¼ê¤Ç¹½¤¨¤¿¡£";
-#else
-                       act = "You are wielding %s (%c) with both hands.";
-#endif
+               if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
+                       act = STR_WIELD_ARMS;
                else
-#ifdef JP
-                       act = (left_hander ? "%s(%c)¤òº¸¼ê¤ËÁõÈ÷¤·¤¿¡£" : "%s(%c)¤ò±¦¼ê¤ËÁõÈ÷¤·¤¿¡£");
-#else
-                       act = (left_hander ? "You are wielding %s (%c) on left hand." : "You are wielding %s (%c) on right hand.");
-#endif
+                       act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
                break;
 
        case INVEN_LARM:
-               if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE)))
-#ifdef JP
-                       act = "%s(%c)¤òξ¼ê¤Ç¹½¤¨¤¿¡£";
-#else
-                       act = "You are wielding %s (%c) with both hands.";
-#endif
+               if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
+                       act = STR_WIELD_ARMS;
                else
-#ifdef JP
-                       act = (left_hander ? "%s(%c)¤ò±¦¼ê¤ËÁõÈ÷¤·¤¿¡£" : "%s(%c)¤òº¸¼ê¤ËÁõÈ÷¤·¤¿¡£");
-#else
-                       act = (left_hander ? "You are wielding %s (%c) on right hand." : "You are wielding %s (%c) on left hand.");
-#endif
+                       act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
                break;
 
        case INVEN_BOW:
@@ -645,7 +661,7 @@ void kamaenaoshi(int item)
                                p_ptr->total_weight += o_ptr->weight;
                                inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
                                inven_item_optimize(INVEN_LARM);
-                               if (object_allow_two_hands_wielding(o_ptr) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE)))
+                               if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
 #ifdef JP
                                        msg_format("%s¤òξ¼ê¤Ç¹½¤¨¤¿¡£", o_name);
 #else
@@ -655,12 +671,12 @@ void kamaenaoshi(int item)
 #ifdef JP
                                        msg_format("%s¤ò%s¤Ç¹½¤¨¤¿¡£", o_name, (left_hander ? "º¸¼ê" : "±¦¼ê"));
 #else
-                                       msg_format("You are wielding %s on %s hand.", o_name, (left_hander ? "left":"right"));
+                                       msg_format("You are wielding %s in your %s hand.", o_name, (left_hander ? "left":"right"));
 #endif
                        }
                        else
                        {
-                               if (object_allow_two_hands_wielding(o_ptr) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE)))
+                               if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
 #ifdef JP
                                        msg_format("%s¤òξ¼ê¤Ç¹½¤¨¤¿¡£", o_name);
 #else
@@ -676,7 +692,7 @@ void kamaenaoshi(int item)
 
                if (buki_motteruka(INVEN_RARM))
                {
-                       if (object_allow_two_hands_wielding(o_ptr) && (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE)))
+                       if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
 #ifdef JP
                                msg_format("%s¤òξ¼ê¤Ç¹½¤¨¤¿¡£", o_name);
 #else
@@ -903,10 +919,11 @@ static bool high_level_book(object_type *o_ptr)
            (o_ptr->tval == TV_CHAOS_BOOK) ||
            (o_ptr->tval == TV_DEATH_BOOK) ||
            (o_ptr->tval == TV_TRUMP_BOOK) ||
-           (o_ptr->tval == TV_ENCHANT_BOOK) ||
+           (o_ptr->tval == TV_CRAFT_BOOK) ||
            (o_ptr->tval == TV_DAEMON_BOOK) ||
            (o_ptr->tval == TV_CRUSADE_BOOK) ||
-           (o_ptr->tval == TV_MUSIC_BOOK))
+           (o_ptr->tval == TV_MUSIC_BOOK) ||
+               (o_ptr->tval == TV_HEX_BOOK))
        {
                if (o_ptr->sval > 1)
                        return TRUE;
@@ -1224,9 +1241,9 @@ void do_cmd_observe(void)
 
        /* Describe it fully */
 #ifdef JP
-       if (!screen_object(o_ptr, TRUE)) msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
+       if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
 #else
-       if (!screen_object(o_ptr, TRUE)) msg_print("You see nothing special.");
+       if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print("You see nothing special.");
 #endif
 
 }