From dbd97081170c97a78027d5ca8c818a874f4f1ee2 Mon Sep 17 00:00:00 2001 From: deskull Date: Thu, 30 Apr 2020 23:21:12 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20item=5Ftester=5Ftval=20=E3=82=92?= =?utf8?q?=E3=82=B0=E3=83=AD=E3=83=BC=E3=83=90=E3=83=AB=E5=A4=89=E6=95=B0?= =?utf8?q?=E3=81=8B=E3=82=89=E6=8E=92=E9=99=A4=EF=BC=8E=20fix=5Finventory(?= =?utf8?q?),fix=5Fequip()=20=E3=81=AE=E3=81=BF=E6=9C=AA=E3=82=B5=E3=83=9D?= =?utf8?q?=E3=83=BC=E3=83=88=E5=8C=96=EF=BC=8E=20/=20Removed=20item=5Ftest?= =?utf8?q?er=5Ftval=20from=20global=20variables.=20Only=20fix=5Finventory?= =?utf8?q?=20()=20and=20fix=5Fequip=20()=20are=20not=20supported.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/cmd/cmd-activate.c | 6 ++--- src/cmd/cmd-read.c | 4 +-- src/cmd/cmd-spell.c | 13 +++++----- src/cmd/cmd-usestaff.c | 4 +-- src/cmd/cmd-zaprod.c | 4 +-- src/market/building.c | 15 +++++------ src/mind.c | 4 +-- src/object-hook.c | 6 ----- src/object.h | 1 - src/player-inventory.c | 58 +++++++++++++++++++++--------------------- src/player-inventory.h | 4 +-- src/racial.c | 6 ++--- src/realm-arcane.c | 2 +- src/realm-craft.c | 2 +- src/realm-death.c | 4 +-- src/realm-hissatsu.c | 4 +-- src/realm-life.c | 4 +-- src/realm-nature.c | 2 +- src/realm-sorcery.c | 4 +-- src/realm-trump.c | 2 +- src/spells-object.c | 7 ++--- src/spells.h | 4 +-- src/spells3.c | 4 +-- src/targeting.c | 4 +-- src/view/display-main-window.c | 8 +++--- src/wizard2.c | 4 +-- 26 files changed, 85 insertions(+), 95 deletions(-) diff --git a/src/cmd/cmd-activate.c b/src/cmd/cmd-activate.c index 75440072d..a4f40e166 100644 --- a/src/cmd/cmd-activate.c +++ b/src/cmd/cmd-activate.c @@ -1455,20 +1455,20 @@ bool activate_artifact(player_type *user_ptr, object_type *o_ptr) msg_print(_("明るく輝いている...", "It glows brightly...")); detect_all(user_ptr, DETECT_RAD_DEFAULT); probing(user_ptr); - identify_fully(user_ptr, FALSE); + identify_fully(user_ptr, FALSE, 0); break; } case ACT_ID_FULL: { msg_print(_("黄色く輝いている...", "It glows yellow...")); - identify_fully(user_ptr, FALSE); + identify_fully(user_ptr, FALSE, 0); break; } case ACT_ID_PLAIN: { - if (!ident_spell(user_ptr, FALSE)) return FALSE; + if (!ident_spell(user_ptr, FALSE, 0)) return FALSE; break; } diff --git a/src/cmd/cmd-read.c b/src/cmd/cmd-read.c index 9a76a8e32..4a645d992 100644 --- a/src/cmd/cmd-read.c +++ b/src/cmd/cmd-read.c @@ -197,14 +197,14 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known) case SV_SCROLL_IDENTIFY: { - if (!ident_spell(creature_ptr, FALSE)) used_up = FALSE; + if (!ident_spell(creature_ptr, FALSE, 0)) used_up = FALSE; ident = TRUE; break; } case SV_SCROLL_STAR_IDENTIFY: { - if (!identify_fully(creature_ptr, FALSE)) used_up = FALSE; + if (!identify_fully(creature_ptr, FALSE, 0)) used_up = FALSE; ident = TRUE; break; } diff --git a/src/cmd/cmd-spell.c b/src/cmd/cmd-spell.c index 343fc4352..0fc6b4cb9 100644 --- a/src/cmd/cmd-spell.c +++ b/src/cmd/cmd-spell.c @@ -597,6 +597,7 @@ void do_cmd_browse(player_type *caster_ptr) object_type *o_ptr; concptr q, s; + OBJECT_TYPE_VALUE tval = 0; /* Warriors are illiterate */ if (!(caster_ptr->realm1 || caster_ptr->realm2) && (caster_ptr->pclass != CLASS_SORCERER) && (caster_ptr->pclass != CLASS_RED_MAGE)) @@ -620,15 +621,14 @@ void do_cmd_browse(player_type *caster_ptr) } /* Restrict choices to "useful" books */ - if (caster_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book; + if (caster_ptr->realm2 == REALM_NONE) tval = mp_ptr->spell_book; else item_tester_hook = item_tester_learn_spell; q = _("どの本を読みますか? ", "Browse which book? "); s = _("読める本がない。", "You have no books that you can read."); - o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | (caster_ptr->pclass == CLASS_FORCETRAINER ? USE_FORCE : 0)), item_tester_tval); + o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR | (caster_ptr->pclass == CLASS_FORCETRAINER ? USE_FORCE : 0)), tval); - item_tester_tval = 0; item_tester_hook = NULL; if (!o_ptr) { @@ -763,6 +763,8 @@ void do_cmd_study(player_type *caster_ptr) concptr p = spell_category_name(mp_ptr->spell_book); object_type *o_ptr; concptr q, s; + OBJECT_TYPE_VALUE tval = 0; + if (!caster_ptr->realm1) { @@ -800,15 +802,14 @@ void do_cmd_study(player_type *caster_ptr) /* Restrict choices to "useful" books */ - if (caster_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book; + if (caster_ptr->realm2 == REALM_NONE) tval = mp_ptr->spell_book; else item_tester_hook = item_tester_learn_spell; q = _("どの本から学びますか? ", "Study which book? "); s = _("読める本がない。", "You have no books that you can read."); - o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), item_tester_tval); + o_ptr = choose_object(caster_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), tval); - item_tester_tval = 0; if (!o_ptr) return; /* Access the item's sval */ diff --git a/src/cmd/cmd-usestaff.c b/src/cmd/cmd-usestaff.c index 7e563812d..51e665351 100644 --- a/src/cmd/cmd-usestaff.c +++ b/src/cmd/cmd-usestaff.c @@ -84,10 +84,10 @@ int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use case SV_STAFF_IDENTIFY: { if (powerful) { - if (!identify_fully(creature_ptr, FALSE)) *use_charge = FALSE; + if (!identify_fully(creature_ptr, FALSE, 0)) *use_charge = FALSE; } else { - if (!ident_spell(creature_ptr, FALSE)) *use_charge = FALSE; + if (!ident_spell(creature_ptr, FALSE, 0)) *use_charge = FALSE; } ident = TRUE; break; diff --git a/src/cmd/cmd-zaprod.c b/src/cmd/cmd-zaprod.c index dff68fdfc..c8addbc71 100644 --- a/src/cmd/cmd-zaprod.c +++ b/src/cmd/cmd-zaprod.c @@ -56,10 +56,10 @@ int rod_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, DIRECTION d case SV_ROD_IDENTIFY: { if (powerful) { - if (!identify_fully(creature_ptr, FALSE)) *use_charge = FALSE; + if (!identify_fully(creature_ptr, FALSE, 0)) *use_charge = FALSE; } else { - if (!ident_spell(creature_ptr, FALSE)) *use_charge = FALSE; + if (!ident_spell(creature_ptr, FALSE, 0)) *use_charge = FALSE; } ident = TRUE; break; diff --git a/src/market/building.c b/src/market/building.c index 5e4fce401..cc8d411af 100644 --- a/src/market/building.c +++ b/src/market/building.c @@ -1846,7 +1846,7 @@ static int repair_broken_weapon(player_type *player_ptr, PRICE bcost) * @param to_ac ACをアップさせる量 * @return 実際に行ったらTRUE */ -static bool enchant_item(player_type *player_ptr, PRICE cost, HIT_PROB to_hit, HIT_POINT to_dam, ARMOUR_CLASS to_ac) +static bool enchant_item(player_type *player_ptr, PRICE cost, HIT_PROB to_hit, HIT_POINT to_dam, ARMOUR_CLASS to_ac, OBJECT_TYPE_VALUE item_tester_tval) { clear_bldg(4, 18); int maxenchant = (player_ptr->lev / 5); @@ -2449,7 +2449,7 @@ static void bldg_process_command(player_type *player_ptr, building_type *bldg, i /* Do nothing */ break; case BACT_RESEARCH_ITEM: - paid = identify_fully(player_ptr, FALSE); + paid = identify_fully(player_ptr, FALSE, 0); break; case BACT_TOWN_HISTORY: town_history(player_ptr); @@ -2492,11 +2492,11 @@ static void bldg_process_command(player_type *player_ptr, building_type *bldg, i break; case BACT_ENCHANT_WEAPON: item_tester_hook = object_allow_enchant_melee_weapon; - enchant_item(player_ptr, bcost, 1, 1, 0); + enchant_item(player_ptr, bcost, 1, 1, 0, 0); break; case BACT_ENCHANT_ARMOR: item_tester_hook = object_is_armour; - enchant_item(player_ptr, bcost, 0, 0, 1); + enchant_item(player_ptr, bcost, 0, 0, 1, 0); break; case BACT_RECHARGE: building_recharge(player_ptr); @@ -2511,7 +2511,7 @@ static void bldg_process_command(player_type *player_ptr, building_type *bldg, i paid = TRUE; break; case BACT_IDENT_ONE: - paid = ident_spell(player_ptr, FALSE); + paid = ident_spell(player_ptr, FALSE, 0); break; case BACT_LEARN: do_cmd_study(player_ptr); @@ -2524,11 +2524,10 @@ static void bldg_process_command(player_type *player_ptr, building_type *bldg, i break; case BACT_ENCHANT_ARROWS: item_tester_hook = item_tester_hook_ammo; - enchant_item(player_ptr, bcost, 1, 1, 0); + enchant_item(player_ptr, bcost, 1, 1, 0, 0); break; case BACT_ENCHANT_BOW: - item_tester_tval = TV_BOW; - enchant_item(player_ptr, bcost, 1, 1, 0); + enchant_item(player_ptr, bcost, 1, 1, 0, TV_BOW); break; case BACT_RECALL: diff --git a/src/mind.c b/src/mind.c index ebbc1b683..3e1654de2 100644 --- a/src/mind.c +++ b/src/mind.c @@ -1116,7 +1116,7 @@ static bool cast_mindcrafter_spell(player_type *caster_ptr, int spell) if (plev < 25) return psychometry(caster_ptr); else - return ident_spell(caster_ptr, FALSE); + return ident_spell(caster_ptr, FALSE, 0); case 8: /* Mindwave */ msg_print(_("精神を捻じ曲げる波動を発生させた!", "Mind-warping forces emanate from your brain!")); @@ -1599,7 +1599,7 @@ static bool cast_ninja_spell(player_type *caster_ptr, int spell) break; } case 7: - return ident_spell(caster_ptr, FALSE); + return ident_spell(caster_ptr, FALSE, 0); case 8: set_tim_levitation(caster_ptr, randint1(20) + 20, FALSE); break; diff --git a/src/object-hook.c b/src/object-hook.c index 90a4317ef..b9b38d3d8 100644 --- a/src/object-hook.c +++ b/src/object-hook.c @@ -964,12 +964,6 @@ bool object_is_quest_target(object_type *o_ptr) */ bool(*item_tester_hook)(object_type*); -/* - * Here is a "pseudo-hook" used during calls to "get_item()" and - * "show_inven()" and "show_equip()", and the choice window routines. - */ -OBJECT_TYPE_VALUE item_tester_tval; - /*! * @brief アイテムがitem_tester_hookグローバル関数ポインタの条件を満たしているかを返す汎用関数 * Check an item against the item tester info diff --git a/src/object.h b/src/object.h index a81a0f721..99d537a30 100644 --- a/src/object.h +++ b/src/object.h @@ -388,7 +388,6 @@ struct object_type }; extern bool(*item_tester_hook)(object_type *o_ptr); -extern OBJECT_TYPE_VALUE item_tester_tval; extern bool(*get_obj_num_hook)(KIND_OBJECT_IDX k_idx); /* object1.c */ diff --git a/src/player-inventory.c b/src/player-inventory.c index 8e9aa6603..cda220b73 100644 --- a/src/player-inventory.c +++ b/src/player-inventory.c @@ -227,7 +227,7 @@ void toggle_inventory_equipment(player_type *owner_ptr) * @param i 選択アイテムID * @return 正規のIDならばTRUEを返す。 */ -bool get_item_okay(player_type *owner_ptr, OBJECT_IDX i) +bool get_item_okay(player_type *owner_ptr, OBJECT_IDX i, OBJECT_TYPE_VALUE item_tester_tval) { /* Illegal items */ if ((i < 0) || (i >= INVEN_TOTAL)) return FALSE; @@ -256,7 +256,7 @@ bool can_get_item(player_type *owner_ptr, OBJECT_TYPE_VALUE tval) return TRUE; OBJECT_IDX floor_list[23]; - ITEM_NUMBER floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03); + ITEM_NUMBER floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03, tval); return floor_num != 0; } @@ -921,7 +921,7 @@ bool get_item(player_type *owner_ptr, OBJECT_IDX *cp, concptr pmt, concptr str, /* Look up the tag and validate the item */ if (!get_tag(owner_ptr, &k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN, tval)) /* Reject */; else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */; - else if (!get_item_okay(owner_ptr, k)) /* Reject */; + else if (!get_item_okay(owner_ptr, k, tval)) /* Reject */; else { /* Accept that choice */ @@ -940,7 +940,7 @@ bool get_item(player_type *owner_ptr, OBJECT_IDX *cp, concptr pmt, concptr str, } /* Verify the item */ - else if (get_item_okay(owner_ptr, *cp)) + else if (get_item_okay(owner_ptr, *cp, tval)) { /* Forget restrictions */ tval = 0; @@ -971,8 +971,8 @@ bool get_item(player_type *owner_ptr, OBJECT_IDX *cp, concptr pmt, concptr str, if (item_tester_okay(owner_ptr, &owner_ptr->inventory_list[j], tval) || (mode & USE_FULL)) max_inven++; } - while ((i1 <= i2) && (!get_item_okay(owner_ptr, i1))) i1++; - while ((i1 <= i2) && (!get_item_okay(owner_ptr, i2))) i2--; + while ((i1 <= i2) && (!get_item_okay(owner_ptr, i1, tval))) i1++; + while ((i1 <= i2) && (!get_item_okay(owner_ptr, i2, tval))) i2--; /* Full equipment */ @@ -989,8 +989,8 @@ bool get_item(player_type *owner_ptr, OBJECT_IDX *cp, concptr pmt, concptr str, } /* Restrict equipment indexes */ - while ((e1 <= e2) && (!get_item_okay(owner_ptr, e1))) e1++; - while ((e1 <= e2) && (!get_item_okay(owner_ptr, e2))) e2--; + while ((e1 <= e2) && (!get_item_okay(owner_ptr, e1, tval))) e1++; + while ((e1 <= e2) && (!get_item_okay(owner_ptr, e2, tval))) e2--; if (equip && owner_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) { @@ -1247,7 +1247,7 @@ bool get_item(player_type *owner_ptr, OBJECT_IDX *cp, concptr pmt, concptr str, else { /* Validate the item */ - if (!get_item_okay(owner_ptr, get_item_label)) + if (!get_item_okay(owner_ptr, get_item_label, tval)) { bell(); break; @@ -1396,7 +1396,7 @@ bool get_item(player_type *owner_ptr, OBJECT_IDX *cp, concptr pmt, concptr str, } /* Validate the item */ - if (!get_item_okay(owner_ptr, k)) + if (!get_item_okay(owner_ptr, k, tval)) { bell(); break; @@ -1446,7 +1446,7 @@ bool get_item(player_type *owner_ptr, OBJECT_IDX *cp, concptr pmt, concptr str, } /* Validate the item */ - else if (!get_item_okay(owner_ptr, k)) + else if (!get_item_okay(owner_ptr, k, tval)) { not_found = TRUE; } @@ -1481,7 +1481,7 @@ bool get_item(player_type *owner_ptr, OBJECT_IDX *cp, concptr pmt, concptr str, } /* Validate the item */ - if (!get_item_okay(owner_ptr, k)) + if (!get_item_okay(owner_ptr, k, tval)) { bell(); break; @@ -1578,7 +1578,7 @@ object_type *choose_object(player_type *owner_ptr, OBJECT_IDX *idx, concptr q, c * mode & 0x02 -- Marked items only * mode & 0x04 -- Stop after first */ -ITEM_NUMBER scan_floor(player_type *owner_ptr, OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode) +ITEM_NUMBER scan_floor(player_type *owner_ptr, OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode, OBJECT_TYPE_VALUE item_tester_tval) { /* Sanity */ floor_type *floor_ptr = owner_ptr->current_floor_ptr; @@ -1623,7 +1623,7 @@ ITEM_NUMBER scan_floor(player_type *owner_ptr, OBJECT_IDX *items, POSITION y, PO * @return 選択したアイテムの添え字 * @details */ -COMMAND_CODE show_floor(player_type *owner_ptr, int target_item, POSITION y, POSITION x, TERM_LEN *min_width) +COMMAND_CODE show_floor(player_type *owner_ptr, int target_item, POSITION y, POSITION x, TERM_LEN *min_width, OBJECT_TYPE_VALUE item_tester_tval) { COMMAND_CODE i, m; int j, k, l; @@ -1651,7 +1651,7 @@ COMMAND_CODE show_floor(player_type *owner_ptr, int target_item, POSITION y, POS int len = MAX((*min_width), 20); /* Scan for objects in the grid, using item_tester_okay() */ - floor_num = scan_floor(owner_ptr, floor_list, y, x, 0x03); + floor_num = scan_floor(owner_ptr, floor_list, y, x, 0x03, item_tester_tval); /* Display the floor objects */ floor_type *floor_ptr = owner_ptr->current_floor_ptr; @@ -1811,7 +1811,7 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp if (prev_tag && command_cmd) { /* Scan all objects in the grid */ - floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03); + floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03, tval); /* Look up the tag */ if (get_tag_floor(owner_ptr->current_floor_ptr, &k, prev_tag, floor_list, floor_num)) @@ -1852,7 +1852,7 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp /* Look up the tag and validate the item */ if (!get_tag(owner_ptr, &k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN, tval)) /* Reject */; else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */; - else if (!get_item_okay(owner_ptr, k)) /* Reject */; + else if (!get_item_okay(owner_ptr, k, tval)) /* Reject */; else { /* Accept that choice */ @@ -1871,7 +1871,7 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp } /* Verify the item */ - else if (get_item_okay(owner_ptr, *cp)) + else if (get_item_okay(owner_ptr, *cp, tval)) { /* Forget restrictions */ tval = 0; @@ -1903,8 +1903,8 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp if (item_tester_okay(owner_ptr, &owner_ptr->inventory_list[j], tval) || (mode & USE_FULL)) max_inven++; } - while ((i1 <= i2) && (!get_item_okay(owner_ptr, i1))) i1++; - while ((i1 <= i2) && (!get_item_okay(owner_ptr, i2))) i2--; + while ((i1 <= i2) && (!get_item_okay(owner_ptr, i1, tval))) i1++; + while ((i1 <= i2) && (!get_item_okay(owner_ptr, i2, tval))) i2--; /* Full equipment */ @@ -1921,8 +1921,8 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp } /* Restrict equipment indexes */ - while ((e1 <= e2) && (!get_item_okay(owner_ptr, e1))) e1++; - while ((e1 <= e2) && (!get_item_okay(owner_ptr, e2))) e2--; + while ((e1 <= e2) && (!get_item_okay(owner_ptr, e1, tval))) e1++; + while ((e1 <= e2) && (!get_item_okay(owner_ptr, e2, tval))) e2--; if (equip && owner_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) { @@ -1940,7 +1940,7 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp if (floor) { /* Scan all objects in the grid */ - floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03); + floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03, tval); } if (i1 <= i2) allow_inven = TRUE; @@ -2069,7 +2069,7 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp n2 = I2A(k - floor_top); /* Redraw if needed */ - if (command_see) get_item_label = show_floor(owner_ptr, menu_line, owner_ptr->y, owner_ptr->x, &min_width); + if (command_see) get_item_label = show_floor(owner_ptr, menu_line, owner_ptr->y, owner_ptr->x, &min_width, tval); } if (command_wrk == (USE_INVEN)) @@ -2382,7 +2382,7 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp else { /* Validate the item */ - if (!get_item_okay(owner_ptr, get_item_label)) + if (!get_item_okay(owner_ptr, get_item_label, tval)) { bell(); break; @@ -2478,7 +2478,7 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp owner_ptr->current_floor_ptr->o_list[i].next_o_idx = o_idx; /* Re-scan floor list */ - floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03); + floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03, tval); /* Hack -- Fix screen */ if (command_see) @@ -2610,7 +2610,7 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp } /* Validate the item */ - if (!get_item_okay(owner_ptr, k)) + if (!get_item_okay(owner_ptr, k, tval)) { bell(); break; @@ -2678,7 +2678,7 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp } /* Validate the item */ - else if (!get_item_okay(owner_ptr, k)) + else if (!get_item_okay(owner_ptr, k, tval)) { not_found = TRUE; } @@ -2746,7 +2746,7 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp } /* Validate the item */ - if ((command_wrk != USE_FLOOR) && !get_item_okay(owner_ptr, k)) + if ((command_wrk != USE_FLOOR) && !get_item_okay(owner_ptr, k, tval)) { bell(); break; diff --git a/src/player-inventory.h b/src/player-inventory.h index f82fba43d..8f24b2c24 100644 --- a/src/player-inventory.h +++ b/src/player-inventory.h @@ -14,7 +14,7 @@ extern void toggle_inventory_equipment(player_type *owner_ptr); extern object_type *choose_object(player_type *owner_ptr, OBJECT_IDX *idx, concptr q, concptr s, BIT_FLAGS option, OBJECT_TYPE_VALUE tval); extern bool can_get_item(player_type *owner_ptr, OBJECT_TYPE_VALUE tval); extern bool get_item(player_type *owner_ptr, OBJECT_IDX *cp, concptr pmt, concptr str, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval); -extern ITEM_NUMBER scan_floor(player_type *owner_ptr, OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode); -extern COMMAND_CODE show_floor(player_type *owner_ptr, int target_item, POSITION y, POSITION x, TERM_LEN *min_width); +extern ITEM_NUMBER scan_floor(player_type *owner_ptr, OBJECT_IDX *items, POSITION y, POSITION x, BIT_FLAGS mode, OBJECT_TYPE_VALUE item_tester_tval); +extern COMMAND_CODE show_floor(player_type *owner_ptr, int target_item, POSITION y, POSITION x, TERM_LEN *min_width, OBJECT_TYPE_VALUE item_tester_tval); extern bool get_item_floor(player_type *creature_ptr, COMMAND_CODE *cp, concptr pmt, concptr str, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval); extern void py_pickup_floor(player_type *creature_ptr, bool pickup); diff --git a/src/racial.c b/src/racial.c index 34090a27f..6d10d2f7f 100644 --- a/src/racial.c +++ b/src/racial.c @@ -496,7 +496,7 @@ static bool exe_racial_power(player_type *creature_ptr, s32b command) } else if (command == -4) { - if (!identify_fully(creature_ptr, FALSE)) return FALSE; + if (!identify_fully(creature_ptr, FALSE, 0)) return FALSE; } break; } @@ -597,11 +597,11 @@ static bool exe_racial_power(player_type *creature_ptr, s32b command) { if (creature_ptr->lev > 29) { - if (!identify_fully(creature_ptr, TRUE)) return FALSE; + if (!identify_fully(creature_ptr, TRUE, 0)) return FALSE; } else { - if (!ident_spell(creature_ptr, TRUE)) return FALSE; + if (!ident_spell(creature_ptr, TRUE, 0)) return FALSE; } break; } diff --git a/src/realm-arcane.c b/src/realm-arcane.c index f7ad583bf..5f844511d 100644 --- a/src/realm-arcane.c +++ b/src/realm-arcane.c @@ -353,7 +353,7 @@ concptr do_arcane_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode { if (cast) { - if (!ident_spell(caster_ptr, FALSE)) return NULL; + if (!ident_spell(caster_ptr, FALSE, 0)) return NULL; } } break; diff --git a/src/realm-craft.c b/src/realm-craft.c index 3d6129a24..0c59abd7f 100644 --- a/src/realm-craft.c +++ b/src/realm-craft.c @@ -439,7 +439,7 @@ concptr do_craft_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode) { if (cast) { - if (!identify_fully(caster_ptr, FALSE)) return NULL; + if (!identify_fully(caster_ptr, FALSE, 0)) return NULL; } } break; diff --git a/src/realm-death.c b/src/realm-death.c index 78577d91c..2d8464036 100644 --- a/src/realm-death.c +++ b/src/realm-death.c @@ -542,11 +542,11 @@ concptr do_death_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode) { if (randint1(50) > plev) { - if (!ident_spell(caster_ptr, FALSE)) return NULL; + if (!ident_spell(caster_ptr, FALSE, 0)) return NULL; } else { - if (!identify_fully(caster_ptr, FALSE)) return NULL; + if (!identify_fully(caster_ptr, FALSE, 0)) return NULL; } } } diff --git a/src/realm-hissatsu.c b/src/realm-hissatsu.c index cad6e44bd..880a4db93 100644 --- a/src/realm-hissatsu.c +++ b/src/realm-hissatsu.c @@ -348,11 +348,11 @@ concptr do_hissatsu_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mo { if (plev > 44) { - if (!identify_fully(caster_ptr, TRUE)) return NULL; + if (!identify_fully(caster_ptr, TRUE, 0)) return NULL; } else { - if (!ident_spell(caster_ptr, TRUE)) return NULL; + if (!ident_spell(caster_ptr, TRUE, 0)) return NULL; } } break; diff --git a/src/realm-life.c b/src/realm-life.c index b96d686b2..6530fa7d0 100644 --- a/src/realm-life.c +++ b/src/realm-life.c @@ -260,7 +260,7 @@ concptr do_life_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode) { if (cast) { - if (!ident_spell(caster_ptr, FALSE)) return NULL; + if (!ident_spell(caster_ptr, FALSE, 0)) return NULL; } } break; @@ -455,7 +455,7 @@ concptr do_life_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode) { if (cast) { - if (!identify_fully(caster_ptr, FALSE)) return NULL; + if (!identify_fully(caster_ptr, FALSE, 0)) return NULL; } } break; diff --git a/src/realm-nature.c b/src/realm-nature.c index 19c8f87b1..ebb582fc9 100644 --- a/src/realm-nature.c +++ b/src/realm-nature.c @@ -402,7 +402,7 @@ concptr do_nature_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode { if (cast) { - if (!identify_fully(caster_ptr, FALSE)) return NULL; + if (!identify_fully(caster_ptr, FALSE, 0)) return NULL; } } break; diff --git a/src/realm-sorcery.c b/src/realm-sorcery.c index 5a547bf5e..260c79e5e 100644 --- a/src/realm-sorcery.c +++ b/src/realm-sorcery.c @@ -189,7 +189,7 @@ concptr do_sorcery_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mod { if (cast) { - if (!ident_spell(caster_ptr, FALSE)) return NULL; + if (!ident_spell(caster_ptr, FALSE, 0)) return NULL; } } break; @@ -287,7 +287,7 @@ concptr do_sorcery_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mod { if (cast) { - if (!identify_fully(caster_ptr, FALSE)) return NULL; + if (!identify_fully(caster_ptr, FALSE, 0)) return NULL; } } break; diff --git a/src/realm-trump.c b/src/realm-trump.c index 38c58279b..d5dd31bcc 100644 --- a/src/realm-trump.c +++ b/src/realm-trump.c @@ -498,7 +498,7 @@ concptr do_trump_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode) { if (cast) { - if (!identify_fully(caster_ptr, FALSE)) return NULL; + if (!identify_fully(caster_ptr, FALSE, 0)) return NULL; } } break; diff --git a/src/spells-object.c b/src/spells-object.c index e58b9097e..084a11d48 100644 --- a/src/spells-object.c +++ b/src/spells-object.c @@ -764,7 +764,7 @@ void brand_bolts(player_type *caster_ptr) bool perilous_secrets(player_type *user_ptr) { - if (!ident_spell(user_ptr, FALSE)) return FALSE; + if (!ident_spell(user_ptr, FALSE, 0)) return FALSE; if (mp_ptr->spell_book) { @@ -1038,15 +1038,12 @@ bool bless_weapon(player_type *caster_ptr) */ bool pulish_shield(player_type *caster_ptr) { - /* Assume enchant weapon */ - item_tester_tval = TV_SHIELD; - concptr q = _("どの盾を磨きますか?", "Pulish which weapon? "); concptr s = _("磨く盾がありません。", "You have weapon to pulish."); OBJECT_IDX item; object_type *o_ptr; - o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), 0); + o_ptr = choose_object(caster_ptr, &item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT), TV_SHIELD); if (!o_ptr) return FALSE; GAME_TEXT o_name[MAX_NLEN]; diff --git a/src/spells.h b/src/spells.h index 4795be33e..e7b77da7b 100644 --- a/src/spells.h +++ b/src/spells.h @@ -312,10 +312,10 @@ extern int remove_all_curse(player_type *caster_ptr); extern bool alchemy(player_type *caster_ptr); extern bool artifact_scroll(player_type *caster_ptr); -extern bool ident_spell(player_type *caster_ptr, bool only_equip); +extern bool ident_spell(player_type *caster_ptr, bool only_equip, OBJECT_TYPE_VALUE item_tester_tval); extern bool mundane_spell(player_type *ownner_ptr, bool only_equip); extern bool identify_item(player_type *owner_ptr, object_type *o_ptr); -extern bool identify_fully(player_type *caster_ptr, bool only_equip); +extern bool identify_fully(player_type *caster_ptr, bool only_equip, OBJECT_TYPE_VALUE item_tester_tval); extern bool recharge(player_type *caster_ptr, int power); extern void display_spell_list(player_type *caster_ptr); extern EXP experience_of_spell(player_type *caster_ptr, SPELL_IDX spell, REALM_IDX use_realm); diff --git a/src/spells3.c b/src/spells3.c index e72e573b8..aefe829fe 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -1532,7 +1532,7 @@ bool identify_item(player_type *owner_ptr, object_type *o_ptr) * This routine does *not* automatically combine objects. * Returns TRUE if something was identified, else FALSE. */ -bool ident_spell(player_type *caster_ptr, bool only_equip) +bool ident_spell(player_type *caster_ptr, bool only_equip, OBJECT_TYPE_VALUE item_tester_tval) { if (only_equip) item_tester_hook = item_tester_hook_identify_weapon_armour; @@ -1639,7 +1639,7 @@ bool mundane_spell(player_type *owner_ptr, bool only_equip) * Fully "identify" an object in the inventory -BEN- * This routine returns TRUE if an item was identified. */ -bool identify_fully(player_type *caster_ptr, bool only_equip) +bool identify_fully(player_type *caster_ptr, bool only_equip, OBJECT_TYPE_VALUE item_tester_tval) { if (only_equip) item_tester_hook = item_tester_hook_identify_fully_weapon_armour; diff --git a/src/targeting.c b/src/targeting.c index a41fc99d2..6a804441d 100644 --- a/src/targeting.c +++ b/src/targeting.c @@ -528,7 +528,7 @@ static char target_set_aux(player_type *subject_ptr, POSITION y, POSITION x, BIT /* Scan all objects in the grid */ if (easy_floor) { - floor_num = scan_floor(subject_ptr, floor_list, y, x, 0x02); + floor_num = scan_floor(subject_ptr, floor_list, y, x, 0x02, 0); if (floor_num) { @@ -767,7 +767,7 @@ static char target_set_aux(player_type *subject_ptr, POSITION y, POSITION x, BIT /* Display */ show_gold_on_floor = TRUE; - (void)show_floor(subject_ptr, 0, y, x, &min_width); + (void)show_floor(subject_ptr, 0, y, x, &min_width, 0); show_gold_on_floor = FALSE; /* Prompt */ diff --git a/src/view/display-main-window.c b/src/view/display-main-window.c index 2295a2fea..15d015163 100644 --- a/src/view/display-main-window.c +++ b/src/view/display-main-window.c @@ -1573,7 +1573,7 @@ static void print_frame_extra(player_type *player_ptr) * @param player_ptr プレーヤーへの参照ポインタ * @return なし */ -static void fix_inventory(player_type *player_ptr) +static void fix_inventory(player_type *player_ptr, OBJECT_TYPE_VALUE item_tester_tval) { /* Scan windows */ for (int j = 0; j < 8; j++) @@ -1760,7 +1760,7 @@ static void fix_monster_list(player_type *player_ptr) * @param player_ptr プレーヤーへの参照ポインタ * @return なし */ -static void fix_equip(player_type *player_ptr) +static void fix_equip(player_type *player_ptr, OBJECT_TYPE_VALUE item_tester_tval) { /* Scan windows */ for (int j = 0; j < 8; j++) @@ -2280,14 +2280,14 @@ void window_stuff(player_type *player_ptr) if (player_ptr->window & (PW_INVEN)) { player_ptr->window &= ~(PW_INVEN); - fix_inventory(player_ptr); + fix_inventory(player_ptr, 0); // TODO:2.2.2 まともなtval参照手段を確保 } /* Display equipment */ if (player_ptr->window & (PW_EQUIP)) { player_ptr->window &= ~(PW_EQUIP); - fix_equip(player_ptr); + fix_equip(player_ptr, 0); // TODO:2.2.2 まともなtval参照手段を確保 } /* Display spell list */ diff --git a/src/wizard2.c b/src/wizard2.c index 16facc64e..f09b0bd91 100644 --- a/src/wizard2.c +++ b/src/wizard2.c @@ -1765,7 +1765,7 @@ void do_cmd_debug(player_type *creature_ptr) /* View item info */ case 'f': - identify_fully(creature_ptr, FALSE); + identify_fully(creature_ptr, FALSE, 0); break; /* Create desired feature */ @@ -1790,7 +1790,7 @@ void do_cmd_debug(player_type *creature_ptr) /* Identify */ case 'i': - (void)ident_spell(creature_ptr, FALSE); + (void)ident_spell(creature_ptr, FALSE, 0); break; /* Go up or down in the dungeon */ -- 2.11.0