detect_all(DETECT_RAD_DEFAULT);
probing();
- identify_fully(FALSE, FALSE);
+ identify_fully(FALSE);
o_ptr->timeout = 1000;
break;
}
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;
}
/*
* 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 */
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);
/* 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);
}
*/
else
{
- if (auto_destroy_item((-this_o_idx), idx, FALSE))
+ if (auto_destroy_item((-this_o_idx), idx))
continue;
}
}
/* Do nothing */
break;
case BACT_RESEARCH_ITEM:
- paid = identify_fully(FALSE, FALSE);
+ paid = identify_fully(FALSE);
break;
case BACT_TOWN_HISTORY:
town_history();
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();
}
break;
case 17: /* Perception */
- return ident_spell(FALSE, FALSE);
+ return ident_spell(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, FALSE);
+ return identify_fully(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, FALSE);
+ return ident_spell(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, FALSE);
+ return identify_fully(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, FALSE);
+ return identify_fully(FALSE);
case 22: /* Wall of Stone */
(void)wall_stone();
break;
}
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);
case 25: /* Trump Lore */
if (success)
{
- return identify_fully(FALSE, FALSE);
+ return identify_fully(FALSE);
}
break;
case 26: /* Heal Monster */
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;
}
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);
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;
}
floor_item_describe(0 - item);
floor_item_optimize(0 - item);
}
-
- /* Delayed optimization */
- optimize_inventry_auto_destroy();
}
case SV_STAFF_IDENTIFY:
{
- if (!ident_spell(FALSE, TRUE)) *use_charge = FALSE;
+ if (!ident_spell(FALSE)) *use_charge = FALSE;
ident = TRUE;
break;
}
{
floor_item_charges(0 - item);
}
-
- /* Delayed optimization */
- optimize_inventry_auto_destroy();
}
case SV_ROD_IDENTIFY:
{
+ if (!ident_spell(FALSE)) *use_charge = FALSE;
ident = TRUE;
- if (!ident_spell(FALSE, TRUE)) *use_charge = FALSE;
break;
}
msg_print("Your quarterstaff glows yellow...");
#endif
- if (!ident_spell(FALSE, FALSE)) return;
+ if (!ident_spell(FALSE)) return;
o_ptr->timeout = 10;
break;
}
detect_all(DETECT_RAD_DEFAULT);
probing();
- identify_fully(FALSE, TRUE);
+ identify_fully(FALSE);
o_ptr->timeout = 1000;
break;
}
#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)
{
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:
{
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);
*/
#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 */
/*
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);
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);
/* Place the cursor on the player */
move_cursor_relative(py, px);
- command_cmd = 254;
+ command_cmd = SPECIAL_KEY_BUILDING;
/* Process the command */
process_command();
/* 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);
/* 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();
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);
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);
{
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;
}
if (plev < 25)
return psychometry();
else
- return ident_spell(FALSE, FALSE);
+ return ident_spell(FALSE);
break;
case 8:
/* Mindwave */
break;
}
case 7:
- return ident_spell(FALSE, FALSE);
+ return ident_spell(FALSE);
break;
case 8:
set_tim_ffall(randint1(20) + 20, FALSE);
{
if (racial_aux(25, 20, A_INT, 20))
{
- if (!identify_fully(FALSE, FALSE)) return FALSE;
+ if (!identify_fully(FALSE)) return FALSE;
}
}
break;
{
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;
* 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;
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);
* 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;
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);
/* View item info */
case 'f':
- identify_fully(FALSE, FALSE);
+ identify_fully(FALSE);
break;
/* Good Objects */
/* Identify */
case 'i':
- (void)ident_spell(FALSE, FALSE);
+ (void)ident_spell(FALSE);
break;
/* Go up or down in the dungeon */
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))
{