From: nothere Date: Fri, 13 Aug 2004 20:21:02 +0000 (+0000) Subject: アイテムを繰り返しコマンドで使っていて, 鑑定による自動破壊等でザック X-Git-Tag: v2.1.2~354 X-Git-Url: http://git.osdn.net/view?p=hengband%2Fhengband.git;a=commitdiff_plain;h=eb61554d78ce2135af9a25785e10ecfc3e74daf0 アイテムを繰り返しコマンドで使っていて, 鑑定による自動破壊等でザック の中が並べ替えられた際, コマンドを実行していた位置にそのコマンドで使 用可能な別のアイテムが来た時に{!*}などの銘を無視してアイテムを使って しまう問題があった. これに対処するため, 新しくその位置に入ったアイテ ムに{!*}などの銘があれば繰り返しコマンドでも初回のみ実行確認を取るよ うに修正. --- diff --git a/src/object1.c b/src/object1.c index d9769675e..3b2cb5076 100644 --- a/src/object1.c +++ b/src/object1.c @@ -5443,6 +5443,12 @@ bool get_item(int *cp, cptr pmt, cptr str, int mode) int max_inven = 0; int max_equip = 0; +#ifdef ALLOW_REPEAT + + static s16b prev_k_idx = 0; + +#endif /* ALLOW_REPEAT */ + #ifdef ALLOW_EASY_FLOOR /* TNB */ if (easy_floor || use_menu) return get_item_floor(cp, pmt, str, mode); @@ -5482,6 +5488,14 @@ bool get_item(int *cp, cptr pmt, cptr str, int mode) /* Validate the item */ if (item_tester_okay(o_ptr)) { + bool allowed = !command_cmd || (prev_k_idx == o_ptr->k_idx); + + if (!allowed) + { + allowed = get_item_allow(*cp); + if (allowed) prev_k_idx = o_ptr->k_idx; + } + /* Forget the item_tester_tval restriction */ item_tester_tval = 0; @@ -5490,8 +5504,8 @@ bool get_item(int *cp, cptr pmt, cptr str, int mode) command_cmd = 0; /* Hack -- command_cmd is no longer effective */ - /* Success */ - return (TRUE); + /* Success or aborted */ + return allowed; } } @@ -5501,6 +5515,14 @@ bool get_item(int *cp, cptr pmt, cptr str, int mode) /* Verify the item */ if (get_item_okay(*cp)) { + bool allowed = !command_cmd || (prev_k_idx == inventory[*cp].k_idx); + + if (!allowed) + { + allowed = get_item_allow(*cp); + if (allowed) prev_k_idx = inventory[*cp].k_idx; + } + /* Forget the item_tester_tval restriction */ item_tester_tval = 0; @@ -5509,8 +5531,8 @@ bool get_item(int *cp, cptr pmt, cptr str, int mode) command_cmd = 0; /* Hack -- command_cmd is no longer effective */ - /* Success */ - return (TRUE); + /* Success or aborted */ + return allowed; } } } @@ -6248,6 +6270,13 @@ if (ver && !verify(" { #ifdef ALLOW_REPEAT repeat_push(*cp); + + if (command_cmd) + { + if (*cp == INVEN_FORCE) prev_k_idx = 0; + else if (*cp < 0) prev_k_idx = o_list[0 - (*cp)].k_idx; + else prev_k_idx = inventory[*cp].k_idx; + } #endif /* ALLOW_REPEAT */ command_cmd = 0; /* Hack -- command_cmd is no longer effective */ @@ -6485,6 +6514,8 @@ bool get_item_floor(int *cp, cptr pmt, cptr str, int mode) #ifdef ALLOW_REPEAT + static s16b prev_k_idx = 0; + /* Get the item index */ if (repeat_pull(cp)) { @@ -6511,6 +6542,14 @@ bool get_item_floor(int *cp, cptr pmt, cptr str, int mode) /* Validate the item */ if (item_tester_okay(o_ptr)) { + bool allowed = !command_cmd || (prev_k_idx == o_ptr->k_idx); + + if (!allowed) + { + allowed = get_item_allow(*cp); + if (allowed) prev_k_idx = o_ptr->k_idx; + } + /* Forget the item_tester_tval restriction */ item_tester_tval = 0; @@ -6519,8 +6558,8 @@ bool get_item_floor(int *cp, cptr pmt, cptr str, int mode) command_cmd = 0; /* Hack -- command_cmd is no longer effective */ - /* Success */ - return (TRUE); + /* Success or aborted */ + return allowed; } } @@ -6530,6 +6569,14 @@ bool get_item_floor(int *cp, cptr pmt, cptr str, int mode) /* Verify the item */ if (get_item_okay(*cp)) { + bool allowed = !command_cmd || (prev_k_idx == inventory[*cp].k_idx); + + if (!allowed) + { + allowed = get_item_allow(*cp); + if (allowed) prev_k_idx = inventory[*cp].k_idx; + } + /* Forget the item_tester_tval restriction */ item_tester_tval = 0; @@ -6538,8 +6585,8 @@ bool get_item_floor(int *cp, cptr pmt, cptr str, int mode) command_cmd = 0; /* Hack -- command_cmd is no longer effective */ - /* Success */ - return (TRUE); + /* Success or aborted */ + return allowed; } } } @@ -7680,6 +7727,13 @@ if (ver && !verify(" { #ifdef ALLOW_REPEAT repeat_push(*cp); + + if (command_cmd) + { + if (*cp == INVEN_FORCE) prev_k_idx = 0; + else if (*cp < 0) prev_k_idx = o_list[0 - (*cp)].k_idx; + else prev_k_idx = inventory[*cp].k_idx; + } #endif /* ALLOW_REPEAT */ command_cmd = 0; /* Hack -- command_cmd is no longer effective */