OSDN Git Service

鑑定のロッドの使用後に自動破棄があったときのバグ修正。
authormogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 12 Sep 2002 12:30:49 +0000 (12:30 +0000)
committermogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 12 Sep 2002 12:30:49 +0000 (12:30 +0000)
さらにp_ptr->noticeの新しいフラグPN_AUTODESTROYを導入して
いちいちoptimizeを遅らせるHackをしないで済むように書き変えた。

14 files changed:
src/artifact.c
src/autopick.c
src/bldg.c
src/cmd5.c
src/cmd6.c
src/defines.h
src/dungeon.c
src/externs.h
src/hissatsu.c
src/mind.c
src/racial.c
src/spells3.c
src/wizard2.c
src/xtra1.c

index 85fb5fc..0e9ad37 100644 (file)
@@ -2863,7 +2863,7 @@ bool activate_random_artifact(object_type * o_ptr)
 
                        detect_all(DETECT_RAD_DEFAULT);
                        probing();
-                       identify_fully(FALSE, FALSE);
+                       identify_fully(FALSE);
                        o_ptr->timeout = 1000;
                        break;
                }
@@ -2876,14 +2876,14 @@ bool activate_random_artifact(object_type * o_ptr)
                        msg_print("It glows yellow...");
 #endif
 
-                       identify_fully(FALSE, FALSE);
+                       identify_fully(FALSE);
                        o_ptr->timeout = 750;
                        break;
                }
 
                case ACT_ID_PLAIN:
                {
-                       if (!ident_spell(FALSE, FALSE)) return FALSE;
+                       if (!ident_spell(FALSE)) return FALSE;
                        o_ptr->timeout = 10;
                        break;
                }
index a66a3eb..11001f5 100644 (file)
@@ -981,10 +981,9 @@ void auto_inscribe_item(int item, int idx)
 /*
  * Automatically destroy an item if it is to be destroyed
  */
-bool auto_destroy_item(int item, int autopick_idx, bool wait_optimize)
+bool auto_destroy_item(int item, int autopick_idx)
 {
        bool destroy = FALSE;
-       char o_name[MAX_NLEN];
        object_type *o_ptr;
 
        /* Don't destroy equipped items */
@@ -1019,12 +1018,14 @@ bool auto_destroy_item(int item, int autopick_idx, bool wait_optimize)
 
        disturb(0,0);
 
-       /* Describe the object (with {terrible/special}) */
-       object_desc(o_name, o_ptr, TRUE, 3);
-
        /* Artifact? */
        if (!can_player_destroy_object(o_ptr))
        {
+                char o_name[MAX_NLEN];
+
+                /* Describe the object (with {terrible/special}) */
+                object_desc(o_name, o_ptr, TRUE, 3);
+
                /* Message */
 #ifdef JP
                msg_format("%s¤ÏÇ˲õÉÔǽ¤À¡£", o_name);
@@ -1039,45 +1040,71 @@ bool auto_destroy_item(int item, int autopick_idx, bool wait_optimize)
        /* Record name of destroyed item */
         COPY(&autopick_last_destroyed_object, o_ptr, object_type);
 
-       /* Eliminate the item (from the pack) */
-       if (item >= 0)
-       {
-               inven_item_increase(item, -(o_ptr->number));
+        /* Destroy Later */
+        o_ptr->marked |= OM_AUTODESTROY;
+        p_ptr->notice |= PN_AUTODESTROY;
 
-               /*
-                * always optimize equipment.
-                * optimize inventry only when wait_optimize is FALSE.
-                */
-               if (!wait_optimize || item > INVEN_PACK)
-                       inven_item_optimize(item);
-       }
+       return TRUE;
+}
 
-       /* Eliminate the item (from the floor) */
-       else
-       {
-               delete_object_idx(0 - item);
-       }
 
-       /* Print a message */
+/*
+ *  Auto-destroy marked item
+ */
+static void delayed_auto_destroy_aux(int item)
+{
+        object_type *o_ptr;
+
+       /* Get the item (in the pack) */
+       if (item >= 0) o_ptr = &inventory[item];
+
+       /* Get the item (on the floor) */
+       else o_ptr = &o_list[0 - item];
+
+        if (o_ptr->k_idx && o_ptr->marked & OM_AUTODESTROY)
+        {
+                char o_name[MAX_NLEN];
+
+                /* Describe the object (with {terrible/special}) */
+                object_desc(o_name, o_ptr, TRUE, 3);
+
+                /* Eliminate the item (from the pack) */
+                if (item >= 0)
+                {
+                        inven_item_increase(item, -(o_ptr->number));
+                        inven_item_optimize(item);
+                }
+
+                /* Eliminate the item (from the floor) */
+                else
+                {
+                        delete_object_idx(0 - item);
+                }
+
+                /* Print a message */
 #ifdef JP
-       msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
+                msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
 #else
-       msg_format("Auto-destroying %s.", o_name);
+                msg_format("Auto-destroying %s.", o_name);
 #endif
-                       
-       return TRUE;
+        }
 }
 
 
 /*
- * Optimize all inventry items after consumption of staves or scrolls.
+ *  Auto-destroy marked item in inventry and on floor
  */
-void optimize_inventry_auto_destroy(void)
+void delayed_auto_destroy(void)
 {
-       int i;
+       int item;
 
-       for (i = 0; i <= INVEN_PACK; i++)
-               inven_item_optimize(i);
+       /* Scan inventry */
+       for (item = 0; item <= INVEN_TOTAL; item++)
+                delayed_auto_destroy_aux(item);
+
+       /* Scan the pile of objects */
+        for (item = cave[py][px].o_idx; item; item = o_list[item].next_o_idx)
+                delayed_auto_destroy_aux(-item);
 }
 
 
@@ -1168,7 +1195,7 @@ void auto_pickup_items(cave_type *c_ptr)
                 */
                else
                {
-                       if (auto_destroy_item((-this_o_idx), idx, FALSE))
+                       if (auto_destroy_item((-this_o_idx), idx))
                                continue;
                }
        }
index cf2df19..5b975d8 100644 (file)
@@ -4098,7 +4098,7 @@ msg_print("
                                /* Do nothing */
                break;
        case BACT_RESEARCH_ITEM:
-               paid = identify_fully(FALSE, FALSE);
+               paid = identify_fully(FALSE);
                break;
        case BACT_TOWN_HISTORY:
                town_history();
@@ -4166,7 +4166,7 @@ msg_print("
                paid = TRUE;
                break;
        case BACT_IDENT_ONE: /* needs work */
-               paid = ident_spell(FALSE, FALSE);
+               paid = ident_spell(FALSE);
                break;
        case BACT_LEARN:
                do_cmd_study();
index 4f1b775..06ec08b 100644 (file)
@@ -1121,7 +1121,7 @@ static bool cast_life_spell(int spell)
                }
                break;
        case 17: /* Perception */
-               return ident_spell(FALSE, FALSE);
+               return ident_spell(FALSE);
        case 18: /* Dispel Undead */
                (void)dispel_undead(randint1(plev * 5));
                break;
@@ -1169,7 +1169,7 @@ static bool cast_life_spell(int spell)
                (void)set_cut(0);
                break;
        case 30: /* Holy Vision */
-               return identify_fully(FALSE, FALSE);
+               return identify_fully(FALSE);
        case 31: /* Ultimate resistance */
        {
                int v = randint1(plev/2)+plev/2;
@@ -1237,7 +1237,7 @@ static bool cast_sorcery_spell(int spell)
                map_area(DETECT_RAD_MAP);
                break;
        case 9: /* Identify */
-               return ident_spell(FALSE, FALSE);
+               return ident_spell(FALSE);
        case 10: /* Slow Monster */
                if (!get_aim_dir(&dir)) return FALSE;
 
@@ -1258,7 +1258,7 @@ static bool cast_sorcery_spell(int spell)
                (void)detect_all(DETECT_RAD_DEFAULT);
                break;
        case 15: /* Identify True */
-               return identify_fully(FALSE, FALSE);
+               return identify_fully(FALSE);
        case 16: /* Detect Objects and Treasure*/
                (void)detect_objects_normal(DETECT_RAD_DEFAULT);
                (void)detect_treasure(DETECT_RAD_DEFAULT);
@@ -1472,7 +1472,7 @@ msg_print("
                (void)charm_animals(plev * 2);
                break;
        case 21: /* Stone Tell */
-               return identify_fully(FALSE, FALSE);
+               return identify_fully(FALSE);
        case 22: /* Wall of Stone */
                (void)wall_stone();
                break;
@@ -2270,9 +2270,9 @@ msg_print("
                }
        case 26: /* Esoteria */
                if (randint1(50) > plev)
-                       return ident_spell(FALSE, FALSE);
+                       return ident_spell(FALSE);
                else
-                       return identify_fully(FALSE, FALSE);
+                       return identify_fully(FALSE);
                break;
        case 27: /* Mimic vampire */
                (void)set_mimic(10+plev/2 + randint1(10+plev/2), MIMIC_VAMPIRE, FALSE);
@@ -3076,7 +3076,7 @@ msg_print("
                case 25: /* Trump Lore */
                        if (success)
                        {
-                               return identify_fully(FALSE, FALSE);
+                               return identify_fully(FALSE);
                        }
                        break;
                case 26: /* Heal Monster */
@@ -3379,7 +3379,7 @@ static bool cast_arcane_spell(int spell)
                teleport_player(plev * 5);
                break;
        case 20: /* Identify */
-               return ident_spell(FALSE, FALSE);
+               return ident_spell(FALSE);
        case 21: /* Stone to Mud */
                if (!get_aim_dir(&dir)) return FALSE;
 
@@ -3585,7 +3585,7 @@ msg_print("
                }
                break;
        case 26: /* Total Knowledge */
-               return identify_fully(FALSE, FALSE);
+               return identify_fully(FALSE);
                break;
        case 27: /* Enchant Weapon */
                return enchant_spell(randint0(4) + 1, randint0(4) + 1, 0);
index d3c87a3..c41d904 100644 (file)
@@ -1650,15 +1650,15 @@ static void do_cmd_read_scroll_aux(int item, bool known)
 
                case SV_SCROLL_IDENTIFY:
                {
+                       if (!ident_spell(FALSE)) used_up = FALSE;
                        ident = TRUE;
-                       if (!ident_spell(FALSE, TRUE)) used_up = FALSE;
                        break;
                }
 
                case SV_SCROLL_STAR_IDENTIFY:
                {
+                       if (!identify_fully(FALSE)) used_up = FALSE;
                        ident = TRUE;
-                       if (!identify_fully(FALSE, TRUE)) used_up = FALSE;
                        break;
                }
 
@@ -2139,9 +2139,6 @@ msg_print("
                floor_item_describe(0 - item);
                floor_item_optimize(0 - item);
        }
-
-       /* Delayed optimization */
-       optimize_inventry_auto_destroy();
 }
 
 
@@ -2283,7 +2280,7 @@ static int staff_effect(int sval, bool *use_charge, bool magic, bool known)
 
                case SV_STAFF_IDENTIFY:
                {
-                       if (!ident_spell(FALSE, TRUE)) *use_charge = FALSE;
+                       if (!ident_spell(FALSE)) *use_charge = FALSE;
                        ident = TRUE;
                        break;
                }
@@ -2754,9 +2751,6 @@ static void do_cmd_use_staff_aux(int item)
        {
                floor_item_charges(0 - item);
        }
-
-       /* Delayed optimization */
-       optimize_inventry_auto_destroy();
 }
 
 
@@ -3308,8 +3302,8 @@ static int rod_effect(int sval, int dir, bool *use_charge, bool magic)
 
                case SV_ROD_IDENTIFY:
                {
+                       if (!ident_spell(FALSE)) *use_charge = FALSE;
                        ident = TRUE;
-                       if (!ident_spell(FALSE, TRUE)) *use_charge = FALSE;
                        break;
                }
 
@@ -4974,7 +4968,7 @@ msg_print("
                                msg_print("Your quarterstaff glows yellow...");
 #endif
 
-                               if (!ident_spell(FALSE, FALSE)) return;
+                               if (!ident_spell(FALSE)) return;
                                o_ptr->timeout = 10;
                                break;
                        }
@@ -4989,7 +4983,7 @@ msg_print("
 
                                detect_all(DETECT_RAD_DEFAULT);
                                probing();
-                               identify_fully(FALSE, TRUE);
+                               identify_fully(FALSE);
                                o_ptr->timeout = 1000;
                                break;
                        }
@@ -5105,7 +5099,7 @@ msg_print("
 #else
                                msg_print("The stone reveals hidden mysteries...");
 #endif
-                               if (!ident_spell(FALSE, FALSE)) return;
+                               if (!ident_spell(FALSE)) return;
 
                                if (mp_ptr->spell_book)
                                {
@@ -6124,7 +6118,7 @@ msg_print("
                        switch (o_ptr->name2)
                        {
                        case EGO_AMU_IDENT:
-                               if (!ident_spell(FALSE, FALSE)) return;
+                               if (!ident_spell(FALSE)) return;
                                o_ptr->timeout = 10;
                                break;
                        case EGO_AMU_CHARM:
@@ -7168,9 +7162,6 @@ msg_print("
                {
                        staff_effect(sval, &use_charge, TRUE, TRUE);
                        if (!use_charge) return;
-
-                       /* Delayed optimization */
-                       optimize_inventry_auto_destroy();
                }
                if (randint1(100) < chance)
                        chg_virtue(V_CHANCE,1);
index 51e9073..eeebb2c 100644 (file)
  */
 #define PN_COMBINE      0x00000001L     /* Combine the pack */
 #define PN_REORDER      0x00000002L     /* Reorder the pack */
+#define PN_AUTODESTROY  0x00000004L     /* Auto-destroy marked item */
 /* xxx (many) */
 
 
  * OM_NOMSG --- temporary flag to suppress messages which were
  *              already printed in auto_pickup_items().
  */
-#define OM_FOUND        0x01
-#define OM_NOMSG        0x02
-#define OM_NO_QUERY     0x04
-
+#define OM_FOUND        0x01    /* original boolean flag */
+#define OM_NOMSG        0x02    /* temporary flag to suppress messages */
+#define OM_NO_QUERY     0x04    /* Query for auto-pick was already answered as 'No' */
+#define OM_AUTODESTROY  0x08    /* Destroy later to avoid illegal inventry shift */
 
 
 /*
index f9f45a2..a3ce35e 100644 (file)
@@ -199,7 +199,7 @@ o_name, index_to_label(slot),game_inscriptions[feel]);
        idx = is_autopick(o_ptr);
        auto_inscribe_item(slot, idx);
         if (destroy_feeling)
-                auto_destroy_item(slot, idx, FALSE);
+                auto_destroy_item(slot, idx);
 
        /* Combine / Reorder the pack (later) */
        p_ptr->notice |= (PN_COMBINE | PN_REORDER);
@@ -1287,7 +1287,7 @@ msg_format("%s
        idx = is_autopick(o_ptr);
        auto_inscribe_item(item, idx);
        if (okay && destroy_feeling)
-                auto_destroy_item(item, idx, FALSE);
+                auto_destroy_item(item, idx);
 
        /* Something happened */
        return (TRUE);
@@ -5438,7 +5438,7 @@ msg_format("%s(%c)
                        /* Place the cursor on the player */
                        move_cursor_relative(py, px);
 
-                       command_cmd = 254;
+                       command_cmd = SPECIAL_KEY_BUILDING;
 
                        /* Process the command */
                        process_command();
@@ -5930,7 +5930,7 @@ msg_print("
        /* Main loop */
        while (TRUE)
        {
-               int i, correct_inven_cnt = 0;
+               int i;
 
                /* Hack -- Compact the monster list occasionally */
                if ((m_cnt + 32 > max_m_idx) && !p_ptr->inside_battle) compact_monsters(64);
@@ -5952,17 +5952,6 @@ msg_print("
                /* Notice stuff */
                if (p_ptr->notice) notice_stuff();
 
-               /* Similar slot? */
-               for (i = 0; i < INVEN_PACK; i++)
-               {
-                       object_type *j_ptr = &inventory[i];
-
-                       /* Skip non-objects */
-                       if (!j_ptr->k_idx) continue;
-
-                       correct_inven_cnt++;
-               }
-
                /* Update stuff */
                if (p_ptr->update) update_stuff();
 
index 3342b7d..f8ac10a 100644 (file)
@@ -520,8 +520,8 @@ extern bool autopick_new_entry(autopick_type *entry, cptr str);
 extern void autopick_free_entry(autopick_type *entry);
 extern int is_autopick(object_type *o_ptr);
 extern void auto_inscribe_item(int item, int idx);
-extern bool auto_destroy_item(int item, int autopick_idx, bool wait_optimize);
-extern void optimize_inventry_auto_destroy(void);
+extern bool auto_destroy_item(int item, int autopick_idx);
+extern void delayed_auto_destroy(void);
 extern void auto_pickup_items(cave_type *c_ptr);
 extern void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr);
 extern void init_autopicker(void);
@@ -1070,10 +1070,10 @@ extern bool item_tester_hook_weapon_armour(object_type *o_ptr);
 extern bool enchant(object_type *o_ptr, int n, int eflag);
 extern bool enchant_spell(int num_hit, int num_dam, int num_ac);
 extern bool artifact_scroll(void);
-extern bool ident_spell(bool only_equip, bool wait_optimize);
+extern bool ident_spell(bool only_equip);
 extern bool mundane_spell(bool only_equip);
 extern bool identify_item(object_type *o_ptr);
-extern bool identify_fully(bool only_equip, bool wait_optimize);
+extern bool identify_fully(bool only_equip);
 extern bool recharge(int num);
 extern bool bless_weapon(void);
 extern bool pulish_shield(void);
index 40c9533..76a6b1b 100644 (file)
@@ -645,11 +645,11 @@ static bool cast_hissatsu_spell(int spell)
        {
                if (p_ptr->lev > 44)
                {
-                       if (!identify_fully(TRUE, FALSE)) return FALSE;
+                       if (!identify_fully(TRUE)) return FALSE;
                }
                else
                {
-                       if (!ident_spell(TRUE, FALSE)) return FALSE;
+                       if (!ident_spell(TRUE)) return FALSE;
                }
                break;
        }
index bd435cc..fd7c083 100644 (file)
@@ -931,7 +931,7 @@ if (!b) msg_print("
                if (plev < 25)
                        return psychometry();
                else
-                       return ident_spell(FALSE, FALSE);
+                       return ident_spell(FALSE);
                break;
        case 8:
                /* Mindwave */
@@ -1675,7 +1675,7 @@ msg_print("
                break;
        }
        case 7:
-               return ident_spell(FALSE, FALSE);
+               return ident_spell(FALSE);
                break;
        case 8:
                set_tim_ffall(randint1(20) + 20, FALSE);
index c488868..4d78a01 100644 (file)
@@ -1138,7 +1138,7 @@ msg_print("
                        {
                                if (racial_aux(25, 20, A_INT, 20))
                                {
-                                       if (!identify_fully(FALSE, FALSE)) return FALSE;
+                                       if (!identify_fully(FALSE)) return FALSE;
                                }
                        }
                        break;
@@ -1362,11 +1362,11 @@ msg_print("
                        {
                                if (p_ptr->lev > 29)
                                {
-                                       if (!identify_fully(TRUE, FALSE)) return FALSE;
+                                       if (!identify_fully(TRUE)) return FALSE;
                                }
                                else
                                {
-                                       if (!ident_spell(TRUE, FALSE)) return FALSE;
+                                       if (!ident_spell(TRUE)) return FALSE;
                                }
                        }
                        break;
index 0988e5b..7ede2d2 100644 (file)
@@ -2631,7 +2631,7 @@ static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
  * This routine does *not* automatically combine objects.
  * Returns TRUE if something was identified, else FALSE.
  */
-bool ident_spell(bool only_equip, bool wait_optimize)
+bool ident_spell(bool only_equip)
 {
        int             item;
        object_type     *o_ptr;
@@ -2718,7 +2718,7 @@ s = "
        idx = is_autopick(o_ptr);
        auto_inscribe_item(item, idx);
        if (destroy_identify && !old_known)
-                auto_destroy_item(item, idx, wait_optimize);
+                auto_destroy_item(item, idx);
 
        /* Something happened */
        return (TRUE);
@@ -2808,7 +2808,7 @@ static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
  * Fully "identify" an object in the inventory  -BEN-
  * This routine returns TRUE if an item was identified.
  */
-bool identify_fully(bool only_equip, bool wait_optimize)
+bool identify_fully(bool only_equip)
 {
        int             item;
        object_type     *o_ptr;
@@ -2901,7 +2901,7 @@ s = "
        idx = is_autopick(o_ptr);
        auto_inscribe_item(item, idx);
        if (destroy_identify && !old_known)
-                auto_destroy_item(item, idx, wait_optimize);
+                auto_destroy_item(item, idx);
 
        /* Success */
        return (TRUE);
index 817f0c3..98aae29 100644 (file)
@@ -1750,7 +1750,7 @@ void do_cmd_debug(void)
 
                /* View item info */
                case 'f':
-               identify_fully(FALSE, FALSE);
+               identify_fully(FALSE);
                break;
 
                /* Good Objects */
@@ -1770,7 +1770,7 @@ void do_cmd_debug(void)
 
                /* Identify */
                case 'i':
-               (void)ident_spell(FALSE, FALSE);
+               (void)ident_spell(FALSE);
                break;
 
                /* Go up or down in the dungeon */
index 147f14e..b481124 100644 (file)
@@ -5534,6 +5534,13 @@ void notice_stuff(void)
        if (!p_ptr->notice) return;
 
 
+       /* Actually do auto-destroy */
+       if (p_ptr->notice & (PN_AUTODESTROY))
+       {
+               p_ptr->notice &= ~(PN_AUTODESTROY);
+               delayed_auto_destroy();
+       }
+
        /* Combine the pack */
        if (p_ptr->notice & (PN_COMBINE))
        {