From 2a80498c1e9e17bec6eec72a15a310daf1d5b4cc Mon Sep 17 00:00:00 2001 From: mogami Date: Thu, 12 Sep 2002 12:30:49 +0000 Subject: [PATCH] =?utf8?q?=E9=91=91=E5=AE=9A=E3=81=AE=E3=83=AD=E3=83=83?= =?utf8?q?=E3=83=89=E3=81=AE=E4=BD=BF=E7=94=A8=E5=BE=8C=E3=81=AB=E8=87=AA?= =?utf8?q?=E5=8B=95=E7=A0=B4=E6=A3=84=E3=81=8C=E3=81=82=E3=81=A3=E3=81=9F?= =?utf8?q?=E3=81=A8=E3=81=8D=E3=81=AE=E3=83=90=E3=82=B0=E4=BF=AE=E6=AD=A3?= =?utf8?q?=E3=80=82=20=E3=81=95=E3=82=89=E3=81=ABp=5Fptr->notice=E3=81=AE?= =?utf8?q?=E6=96=B0=E3=81=97=E3=81=84=E3=83=95=E3=83=A9=E3=82=B0PN=5FAUTOD?= =?utf8?q?ESTROY=E3=82=92=E5=B0=8E=E5=85=A5=E3=81=97=E3=81=A6=20=E3=81=84?= =?utf8?q?=E3=81=A1=E3=81=84=E3=81=A1optimize=E3=82=92=E9=81=85=E3=82=89?= =?utf8?q?=E3=81=9B=E3=82=8BHack=E3=82=92=E3=81=97=E3=81=AA=E3=81=84?= =?utf8?q?=E3=81=A7=E6=B8=88=E3=82=80=E3=82=88=E3=81=86=E3=81=AB=E6=9B=B8?= =?utf8?q?=E3=81=8D=E5=A4=89=E3=81=88=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/artifact.c | 6 ++-- src/autopick.c | 91 +++++++++++++++++++++++++++++++++++++--------------------- src/bldg.c | 4 +-- src/cmd5.c | 20 ++++++------- src/cmd6.c | 25 ++++++---------- src/defines.h | 9 +++--- src/dungeon.c | 19 +++--------- src/externs.h | 8 +++--- src/hissatsu.c | 4 +-- src/mind.c | 4 +-- src/racial.c | 6 ++-- src/spells3.c | 8 +++--- src/wizard2.c | 4 +-- src/xtra1.c | 7 +++++ 14 files changed, 115 insertions(+), 100 deletions(-) diff --git a/src/artifact.c b/src/artifact.c index 85fb5fc7a..0e9ad3718 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -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; } diff --git a/src/autopick.c b/src/autopick.c index a66a3eb5a..11001f5b4 100644 --- a/src/autopick.c +++ b/src/autopick.c @@ -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; } } diff --git a/src/bldg.c b/src/bldg.c index cf2df19b2..5b975d802 100644 --- a/src/bldg.c +++ b/src/bldg.c @@ -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(); diff --git a/src/cmd5.c b/src/cmd5.c index 4f1b775e1..06ec08b86 100644 --- a/src/cmd5.c +++ b/src/cmd5.c @@ -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); diff --git a/src/cmd6.c b/src/cmd6.c index d3c87a330..c41d9041f 100644 --- a/src/cmd6.c +++ b/src/cmd6.c @@ -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); diff --git a/src/defines.h b/src/defines.h index 51e907330..eeebb2c62 100644 --- a/src/defines.h +++ b/src/defines.h @@ -2478,6 +2478,7 @@ */ #define PN_COMBINE 0x00000001L /* Combine the pack */ #define PN_REORDER 0x00000002L /* Reorder the pack */ +#define PN_AUTODESTROY 0x00000004L /* Auto-destroy marked item */ /* xxx (many) */ @@ -2901,10 +2902,10 @@ * 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 */ /* diff --git a/src/dungeon.c b/src/dungeon.c index f9f45a249..a3ce35eee 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -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(); diff --git a/src/externs.h b/src/externs.h index 3342b7dc0..f8ac10a1f 100644 --- a/src/externs.h +++ b/src/externs.h @@ -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); diff --git a/src/hissatsu.c b/src/hissatsu.c index 40c9533b7..76a6b1b3b 100644 --- a/src/hissatsu.c +++ b/src/hissatsu.c @@ -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; } diff --git a/src/mind.c b/src/mind.c index bd435cc68..fd7c08341 100644 --- a/src/mind.c +++ b/src/mind.c @@ -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); diff --git a/src/racial.c b/src/racial.c index c4888681e..4d78a012c 100644 --- a/src/racial.c +++ b/src/racial.c @@ -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; diff --git a/src/spells3.c b/src/spells3.c index 0988e5b0c..7ede2d28b 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -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); diff --git a/src/wizard2.c b/src/wizard2.c index 817f0c33a..98aae29ee 100644 --- a/src/wizard2.c +++ b/src/wizard2.c @@ -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 */ diff --git a/src/xtra1.c b/src/xtra1.c index 147f14ed9..b48112474 100644 --- a/src/xtra1.c +++ b/src/xtra1.c @@ -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)) { -- 2.11.0