OSDN Git Service

鑑定した瞬間の自動破壊に根本的なバグがあった。
authormogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 3 Jun 2002 17:12:04 +0000 (17:12 +0000)
committermogami <mogami@0568b783-4c39-0410-ac80-bf13821ea2a2>
Mon, 3 Jun 2002 17:12:04 +0000 (17:12 +0000)
鑑定手段(巻物や杖)を消費する前に自動破壊によってスロットの位置が変わって
別のアイテムを消費(数を減らしたり、pvalを減らしたりしていた。
スロットのoptimizeを遅らせる事によって解決。

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

index e4d7f7b..95877e0 100644 (file)
@@ -2745,7 +2745,7 @@ bool activate_random_artifact(object_type * o_ptr)
 
                        detect_all(DETECT_RAD_DEFAULT);
                        probing();
-                       identify_fully(FALSE);
+                       identify_fully(FALSE, FALSE);
                        o_ptr->timeout = 1000;
                        break;
                }
@@ -2758,14 +2758,14 @@ bool activate_random_artifact(object_type * o_ptr)
                        msg_print("It glows yellow...");
 #endif
 
-                       identify_fully(FALSE);
+                       identify_fully(FALSE, FALSE);
                        o_ptr->timeout = 750;
                        break;
                }
 
                case ACT_ID_PLAIN:
                {
-                       if (!ident_spell(FALSE)) return FALSE;
+                       if (!ident_spell(FALSE, FALSE)) return FALSE;
                        o_ptr->timeout = 10;
                        break;
                }
index e9bf264..b2fbaf0 100644 (file)
@@ -898,9 +898,8 @@ 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 auto_destroy_item(int item, int autopick_idx, bool wait_optimize)
 {
        bool destroy = FALSE;
        char o_name[MAX_NLEN];
@@ -963,7 +962,13 @@ bool auto_destroy_item(int item, int autopick_idx)
        if (item >= 0)
        {
                inven_item_increase(item, -(o_ptr->number));
-               inven_item_optimize(item);
+
+               /*
+                * Optimize only equipment now.
+                * Optimize inventry later.
+                */
+               if (wait_optimize && item > INVEN_PACK)
+                       inven_item_optimize(item);
        }
 
        /* Eliminate the item (from the floor) */
@@ -984,6 +989,18 @@ bool auto_destroy_item(int item, int autopick_idx)
 
 
 /*
+ * Optimize all inventry items after consumption of staves or scrolls.
+ */
+void optimize_inventry_auto_destroy(void)
+{
+       int i;
+
+       for (i = 0; i <= INVEN_PACK; i++)
+               inven_item_optimize(i);
+}
+
+
+/*
  * Automatically pickup/destroy items in this grid.
  */
 void auto_pickup_items(cave_type *c_ptr)
@@ -1038,7 +1055,7 @@ void auto_pickup_items(cave_type *c_ptr)
                 */
                else
                {
-                       if (auto_destroy_item((-this_o_idx), idx))
+                       if (auto_destroy_item((-this_o_idx), idx, FALSE))
                                continue;
                }
        }
index 590b698..df0c4bc 100644 (file)
@@ -4081,7 +4081,7 @@ msg_print("
                                /* Do nothing */
                break;
        case BACT_RESEARCH_ITEM:
-               paid = identify_fully(FALSE);
+               paid = identify_fully(FALSE, FALSE);
                break;
        case BACT_TOWN_HISTORY:
                town_history();
@@ -4149,7 +4149,7 @@ msg_print("
                paid = TRUE;
                break;
        case BACT_IDENT_ONE: /* needs work */
-               paid = ident_spell(FALSE);
+               paid = ident_spell(FALSE, FALSE);
                break;
        case BACT_LEARN:
                do_cmd_study();
index 9cc09c0..59e9e2b 100644 (file)
@@ -1122,7 +1122,7 @@ static bool cast_life_spell(int spell)
                }
                break;
        case 17: /* Perception */
-               return ident_spell(FALSE);
+               return ident_spell(FALSE, FALSE);
        case 18: /* Dispel Undead */
                (void)dispel_undead(randint1(plev * 5));
                break;
@@ -1170,7 +1170,7 @@ static bool cast_life_spell(int spell)
                (void)set_cut(0);
                break;
        case 30: /* Holy Vision */
-               return identify_fully(FALSE);
+               return identify_fully(FALSE, FALSE);
        case 31: /* Ultimate resistance */
        {
                int v = randint1(plev/2)+plev/2;
@@ -1238,7 +1238,7 @@ static bool cast_sorcery_spell(int spell)
                map_area(DETECT_RAD_MAP);
                break;
        case 9: /* Identify */
-               return ident_spell(FALSE);
+               return ident_spell(FALSE, FALSE);
        case 10: /* Slow Monster */
                if (!get_aim_dir(&dir)) return FALSE;
 
@@ -1259,7 +1259,7 @@ static bool cast_sorcery_spell(int spell)
                (void)detect_all(DETECT_RAD_DEFAULT);
                break;
        case 15: /* Identify True */
-               return identify_fully(FALSE);
+               return identify_fully(FALSE, FALSE);
        case 16: /* Detect Objects and Treasure*/
                (void)detect_objects_normal(DETECT_RAD_DEFAULT);
                (void)detect_treasure(DETECT_RAD_DEFAULT);
@@ -1473,7 +1473,7 @@ msg_print("
                (void)charm_animals(plev * 2);
                break;
        case 21: /* Stone Tell */
-               return identify_fully(FALSE);
+               return identify_fully(FALSE, FALSE);
        case 22: /* Wall of Stone */
                (void)wall_stone();
                break;
@@ -2271,9 +2271,9 @@ msg_print("
                }
        case 26: /* Esoteria */
                if (randint1(50) > plev)
-                       return ident_spell(FALSE);
+                       return ident_spell(FALSE, FALSE);
                else
-                       return identify_fully(FALSE);
+                       return identify_fully(FALSE, FALSE);
                break;
        case 27: /* Mimic vampire */
                (void)set_mimic(10+plev/2 + randint1(10+plev/2), MIMIC_VAMPIRE, FALSE);
@@ -3077,7 +3077,7 @@ msg_print("
                case 25: /* Trump Lore */
                        if (success)
                        {
-                               return identify_fully(FALSE);
+                               return identify_fully(FALSE, FALSE);
                        }
                        break;
                case 26: /* Heal Monster */
@@ -3380,7 +3380,7 @@ static bool cast_arcane_spell(int spell)
                teleport_player(plev * 5);
                break;
        case 20: /* Identify */
-               return ident_spell(FALSE);
+               return ident_spell(FALSE, FALSE);
        case 21: /* Stone to Mud */
                if (!get_aim_dir(&dir)) return FALSE;
 
@@ -3586,7 +3586,7 @@ msg_print("
                }
                break;
        case 26: /* Total Knowledge */
-               return identify_fully(FALSE);
+               return identify_fully(FALSE, FALSE);
                break;
        case 27: /* Enchant Weapon */
                return enchant_spell(randint0(4) + 1, randint0(4) + 1, 0);
index 8c1e7bc..0bc166e 100644 (file)
@@ -1651,14 +1651,14 @@ static void do_cmd_read_scroll_aux(int item)
                case SV_SCROLL_IDENTIFY:
                {
                        ident = TRUE;
-                       if (!ident_spell(FALSE)) used_up = FALSE;
+                       if (!ident_spell(FALSE, TRUE)) used_up = FALSE;
                        break;
                }
 
                case SV_SCROLL_STAR_IDENTIFY:
                {
                        ident = TRUE;
-                       if (!identify_fully(FALSE)) used_up = FALSE;
+                       if (!identify_fully(FALSE, TRUE)) used_up = FALSE;
                        break;
                }
 
@@ -2140,7 +2140,8 @@ msg_print("
                floor_item_optimize(0 - item);
        }
 
-       /* Can save again */
+       /* Delayed optimization */
+       optimize_inventry_auto_destroy();
 }
 
 
@@ -2269,7 +2270,7 @@ static int staff_effect(int sval, bool *use_charge, bool magic)
 
                case SV_STAFF_IDENTIFY:
                {
-                       if (!ident_spell(FALSE)) *use_charge = FALSE;
+                       if (!ident_spell(FALSE, TRUE)) *use_charge = FALSE;
                        ident = TRUE;
                        break;
                }
@@ -2739,6 +2740,9 @@ static void do_cmd_use_staff_aux(int item)
        {
                floor_item_charges(0 - item);
        }
+
+       /* Delayed optimization */
+       optimize_inventry_auto_destroy();
 }
 
 
@@ -3290,7 +3294,7 @@ static int rod_effect(int sval, int dir, bool *use_charge, bool magic)
                case SV_ROD_IDENTIFY:
                {
                        ident = TRUE;
-                       if (!ident_spell(FALSE)) *use_charge = FALSE;
+                       if (!ident_spell(FALSE, FALSE)) *use_charge = FALSE;
                        break;
                }
 
@@ -4965,7 +4969,7 @@ msg_print("
                                msg_print("Your quarterstaff glows yellow...");
 #endif
 
-                               if (!ident_spell(FALSE)) return;
+                               if (!ident_spell(FALSE, FALSE)) return;
                                o_ptr->timeout = 10;
                                break;
                        }
@@ -4980,7 +4984,7 @@ msg_print("
 
                                detect_all(DETECT_RAD_DEFAULT);
                                probing();
-                               identify_fully(FALSE);
+                               identify_fully(FALSE, TRUE);
                                o_ptr->timeout = 1000;
                                break;
                        }
@@ -5096,7 +5100,7 @@ msg_print("
 #else
                                msg_print("The stone reveals hidden mysteries...");
 #endif
-                               if (!ident_spell(FALSE)) return;
+                               if (!ident_spell(FALSE, FALSE)) return;
 
                                if (mp_ptr->spell_book)
                                {
@@ -6118,7 +6122,7 @@ msg_print("
                        switch (o_ptr->name2)
                        {
                        case EGO_AMU_IDENT:
-                               if (!ident_spell(FALSE)) return;
+                               if (!ident_spell(FALSE, FALSE)) return;
                                o_ptr->timeout = 10;
                                break;
                        case EGO_AMU_CHARM:
@@ -7128,6 +7132,9 @@ msg_print("
                {
                        staff_effect(sval, &use_charge, TRUE);
                        if (!use_charge) return;
+
+                       /* Delayed optimization */
+                       optimize_inventry_auto_destroy();
                }
                if (randint1(100) < chance)
                        chg_virtue(V_CHANCE,1);
index 19b7194..3cd03a5 100644 (file)
@@ -198,7 +198,7 @@ o_name, index_to_label(slot),game_inscriptions[feel]);
        /* Auto-inscription/destroy */
        idx = is_autopick(o_ptr);
        auto_inscribe_item(slot, idx);
-       auto_destroy_item(slot, idx);
+       auto_destroy_item(slot, idx, FALSE);
 
        /* Combine / Reorder the pack (later) */
        p_ptr->notice |= (PN_COMBINE | PN_REORDER);
index 4a91f14..af97b3c 100644 (file)
@@ -547,7 +547,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);
+extern bool auto_destroy_item(int item, int autopick_idx, bool wait_optimize);
+extern void optimize_inventry_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);
@@ -1085,10 +1086,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);
+extern bool ident_spell(bool only_equip, bool wait_optimize);
 extern bool mundane_spell(bool only_equip);
 extern bool identify_item(object_type *o_ptr);
-extern bool identify_fully(bool only_equip);
+extern bool identify_fully(bool only_equip, bool wait_optimize);
 extern bool recharge(int num);
 extern bool bless_weapon(void);
 extern bool pulish_shield(void);
index 4672095..a63abba 100644 (file)
@@ -645,11 +645,11 @@ static bool cast_hissatsu_spell(int spell)
        {
                if (p_ptr->lev > 44)
                {
-                       if (!identify_fully(TRUE)) return FALSE;
+                       if (!identify_fully(TRUE, FALSE)) return FALSE;
                }
                else
                {
-                       if (!ident_spell(TRUE)) return FALSE;
+                       if (!ident_spell(TRUE, FALSE)) return FALSE;
                }
                break;
        }
index e53af3b..a29bec0 100644 (file)
@@ -931,7 +931,7 @@ if (!b) msg_print("
                if (plev < 25)
                        return psychometry();
                else
-                       return ident_spell(FALSE);
+                       return ident_spell(FALSE, FALSE);
                break;
        case 8:
                /* Mindwave */
@@ -1675,7 +1675,7 @@ msg_print("
                break;
        }
        case 7:
-               return ident_spell(FALSE);
+               return ident_spell(FALSE, FALSE);
                break;
        case 8:
                set_tim_ffall(randint1(20) + 20, FALSE);
index 478f7cc..c25fe84 100644 (file)
@@ -1138,7 +1138,7 @@ msg_print("
                        {
                                if (racial_aux(25, 20, A_INT, 20))
                                {
-                                       if (!identify_fully(FALSE)) return FALSE;
+                                       if (!identify_fully(FALSE, FALSE)) return FALSE;
                                }
                        }
                        break;
@@ -1362,11 +1362,11 @@ msg_print("
                        {
                                if (p_ptr->lev > 29)
                                {
-                                       if (!identify_fully(TRUE)) return FALSE;
+                                       if (!identify_fully(TRUE, FALSE)) return FALSE;
                                }
                                else
                                {
-                                       if (!ident_spell(TRUE)) return FALSE;
+                                       if (!ident_spell(TRUE, FALSE)) return FALSE;
                                }
                        }
                        break;
index 41dcb9b..ebf3310 100644 (file)
@@ -2609,7 +2609,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 ident_spell(bool only_equip, bool wait_optimize)
 {
        int             item;
        object_type     *o_ptr;
@@ -2695,7 +2695,7 @@ s = "
        /* Auto-inscription/destroy */
        idx = is_autopick(o_ptr);
        auto_inscribe_item(item, idx);
-       if (!old_known) auto_destroy_item(item, idx);
+       if (!old_known) auto_destroy_item(item, idx, wait_optimize);
 
        /* Something happened */
        return (TRUE);
@@ -2785,7 +2785,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 identify_fully(bool only_equip, bool wait_optimize)
 {
        int             item;
        object_type     *o_ptr;
@@ -2877,7 +2877,7 @@ s = "
        /* Auto-inscription/destroy */
        idx = is_autopick(o_ptr);
        auto_inscribe_item(item, idx);
-       if (!old_known) auto_destroy_item(item, idx);
+       if (!old_known) auto_destroy_item(item, idx, wait_optimize);
 
        /* Success */
        return (TRUE);
index c40c14c..767d966 100644 (file)
@@ -1740,7 +1740,7 @@ void do_cmd_debug(void)
 
                /* View item info */
                case 'f':
-               identify_fully(FALSE);
+               identify_fully(FALSE, FALSE);
                break;
 
                /* Good Objects */
@@ -1760,7 +1760,7 @@ void do_cmd_debug(void)
 
                /* Identify */
                case 'i':
-               (void)ident_spell(FALSE);
+               (void)ident_spell(FALSE, FALSE);
                break;
 
                /* Go up or down in the dungeon */