detect_all(DETECT_RAD_DEFAULT);
probing();
- identify_fully(FALSE);
+ identify_fully(FALSE, FALSE);
o_ptr->timeout = 1000;
break;
}
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;
}
/*
* 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];
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) */
/*
+ * 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)
*/
else
{
- if (auto_destroy_item((-this_o_idx), idx))
+ if (auto_destroy_item((-this_o_idx), idx, FALSE))
continue;
}
}
/* Do nothing */
break;
case BACT_RESEARCH_ITEM:
- paid = identify_fully(FALSE);
+ paid = identify_fully(FALSE, FALSE);
break;
case BACT_TOWN_HISTORY:
town_history();
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();
}
break;
case 17: /* Perception */
- return ident_spell(FALSE);
+ return ident_spell(FALSE, FALSE);
case 18: /* Dispel Undead */
(void)dispel_undead(randint1(plev * 5));
break;
(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;
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;
(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);
(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;
}
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);
case 25: /* Trump Lore */
if (success)
{
- return identify_fully(FALSE);
+ return identify_fully(FALSE, FALSE);
}
break;
case 26: /* Heal Monster */
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;
}
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);
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;
}
floor_item_optimize(0 - item);
}
- /* Can save again */
+ /* Delayed optimization */
+ optimize_inventry_auto_destroy();
}
case SV_STAFF_IDENTIFY:
{
- if (!ident_spell(FALSE)) *use_charge = FALSE;
+ if (!ident_spell(FALSE, TRUE)) *use_charge = FALSE;
ident = TRUE;
break;
}
{
floor_item_charges(0 - item);
}
+
+ /* Delayed optimization */
+ optimize_inventry_auto_destroy();
}
case SV_ROD_IDENTIFY:
{
ident = TRUE;
- if (!ident_spell(FALSE)) *use_charge = FALSE;
+ if (!ident_spell(FALSE, FALSE)) *use_charge = FALSE;
break;
}
msg_print("Your quarterstaff glows yellow...");
#endif
- if (!ident_spell(FALSE)) return;
+ if (!ident_spell(FALSE, FALSE)) return;
o_ptr->timeout = 10;
break;
}
detect_all(DETECT_RAD_DEFAULT);
probing();
- identify_fully(FALSE);
+ identify_fully(FALSE, TRUE);
o_ptr->timeout = 1000;
break;
}
#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)
{
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:
{
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);
/* 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);
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);
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);
{
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;
}
if (plev < 25)
return psychometry();
else
- return ident_spell(FALSE);
+ return ident_spell(FALSE, FALSE);
break;
case 8:
/* Mindwave */
break;
}
case 7:
- return ident_spell(FALSE);
+ return ident_spell(FALSE, FALSE);
break;
case 8:
set_tim_ffall(randint1(20) + 20, FALSE);
{
if (racial_aux(25, 20, A_INT, 20))
{
- if (!identify_fully(FALSE)) return FALSE;
+ if (!identify_fully(FALSE, FALSE)) return FALSE;
}
}
break;
{
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;
* 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;
/* 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);
* 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;
/* 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);
/* View item info */
case 'f':
- identify_fully(FALSE);
+ identify_fully(FALSE, FALSE);
break;
/* Good Objects */
/* Identify */
case 'i':
- (void)ident_spell(FALSE);
+ (void)ident_spell(FALSE, FALSE);
break;
/* Go up or down in the dungeon */