• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisionbcdc635917996cc5c63df7cf3512306cd69f2011 (tree)
Time2019-06-15 16:27:04
Authordeskull <deskull@user...>
Commiterdeskull

Log Message

[Refactor] #39068 prepare_label_string() の item_tester_tval グローバル参照をローカル引数に収める.

Change Summary

Incremental Difference

--- a/src/player-inventory.c
+++ b/src/player-inventory.c
@@ -122,191 +122,6 @@ void display_equip(void)
122122 }
123123 }
124124
125-
126-/*!
127- * @brief 装備アイテムの表示を行う /
128- * Display the equipment.
129- * @param target_item アイテムの選択処理を行うか否か。
130- * @return 選択したアイテムのタグ
131- */
132-COMMAND_CODE show_equip(int target_item, BIT_FLAGS mode)
133-{
134- COMMAND_CODE i;
135- int j, k, l;
136- int col, cur_col, len;
137- object_type *o_ptr;
138- char tmp_val[80];
139- GAME_TEXT o_name[MAX_NLEN];
140- COMMAND_CODE out_index[23];
141- TERM_COLOR out_color[23];
142- char out_desc[23][MAX_NLEN];
143- COMMAND_CODE target_item_label = 0;
144- TERM_LEN wid, hgt;
145- char equip_label[52 + 1];
146-
147- /* Starting column */
148- col = command_gap;
149-
150- Term_get_size(&wid, &hgt);
151-
152- /* Maximal length */
153- len = wid - col - 1;
154-
155-
156- /* Scan the equipment list */
157- for (k = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
158- {
159- o_ptr = &p_ptr->inventory_list[i];
160-
161- /* Is this item acceptable? */
162- if (!(select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr, item_tester_tval) || (mode & USE_FULL)) &&
163- (!((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute) ||
164- (mode & IGNORE_BOTHHAND_SLOT))) continue;
165-
166- object_desc(o_name, o_ptr, 0);
167-
168- if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
169- {
170- (void)strcpy(out_desc[k], _("(武器を両手持ち)", "(wielding with two-hands)"));
171- out_color[k] = TERM_WHITE;
172- }
173- else
174- {
175- (void)strcpy(out_desc[k], o_name);
176- out_color[k] = tval_to_attr[o_ptr->tval % 128];
177- }
178-
179- out_index[k] = i;
180- /* Grey out charging items */
181- if (o_ptr->timeout)
182- {
183- out_color[k] = TERM_L_DARK;
184- }
185-
186- /* Extract the maximal length (see below) */
187-#ifdef JP
188- l = strlen(out_desc[k]) + (2 + 1);
189-#else
190- l = strlen(out_desc[k]) + (2 + 3);
191-#endif
192-
193-
194- /* Increase length for labels (if needed) */
195-#ifdef JP
196- if (show_labels) l += (7 + 2);
197-#else
198- if (show_labels) l += (14 + 2);
199-#endif
200-
201-
202- /* Increase length for weight (if needed) */
203- if (show_weights) l += 9;
204-
205- if (show_item_graph) l += 2;
206-
207- /* Maintain the max-length */
208- if (l > len) len = l;
209-
210- /* Advance the entry */
211- k++;
212- }
213-
214- /* Hack -- Find a column to start in */
215-#ifdef JP
216- col = (len > wid - 6) ? 0 : (wid - len - 1);
217-#else
218- col = (len > wid - 4) ? 0 : (wid - len - 1);
219-#endif
220-
221- prepare_label_string(equip_label, USE_EQUIP);
222-
223- /* Output each entry */
224- for (j = 0; j < k; j++)
225- {
226- i = out_index[j];
227- o_ptr = &p_ptr->inventory_list[i];
228-
229- /* Clear the line */
230- prt("", j + 1, col ? col - 2 : col);
231-
232- if (use_menu && target_item)
233- {
234- if (j == (target_item - 1))
235- {
236- strcpy(tmp_val, _("》", "> "));
237- target_item_label = i;
238- }
239- else strcpy(tmp_val, " ");
240- }
241- else if (i >= INVEN_RARM)
242- {
243- /* Prepare an index --(-- */
244- sprintf(tmp_val, "%c)", equip_label[i - INVEN_RARM]);
245- }
246- else
247- {
248- /* Prepare an index --(-- */
249- sprintf(tmp_val, "%c)", index_to_label(i));
250- }
251-
252- /* Clear the line with the (possibly indented) index */
253- put_str(tmp_val, j + 1, col);
254-
255- cur_col = col + 3;
256-
257- /* Display graphics for object, if desired */
258- if (show_item_graph)
259- {
260- TERM_COLOR a = object_attr(o_ptr);
261- SYMBOL_CODE c = object_char(o_ptr);
262- Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
263- if (use_bigtile) cur_col++;
264-
265- cur_col += 2;
266- }
267-
268- /* Use labels */
269- if (show_labels)
270- {
271- /* Mention the use */
272- (void)sprintf(tmp_val, _("%-7s: ", "%-14s: "), mention_use(i));
273-
274- put_str(tmp_val, j + 1, cur_col);
275-
276- /* Display the entry itself */
277- c_put_str(out_color[j], out_desc[j], j + 1, _(cur_col + 9, cur_col + 16));
278- }
279-
280- /* No labels */
281- else
282- {
283- /* Display the entry itself */
284- c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
285- }
286-
287- /* Display the weight if needed */
288- if (show_weights)
289- {
290- int wgt = o_ptr->weight * o_ptr->number;
291-#ifdef JP
292- (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
293-#else
294- (void)sprintf(tmp_val, "%3d.%d lb", wgt / 10, wgt % 10);
295-#endif
296-
297- prt(tmp_val, j + 1, wid - 9);
298- }
299- }
300-
301- /* Make a "shadow" below the list (only if needed) */
302- if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
303-
304- /* Save the new column */
305- command_gap = col;
306-
307- return target_item_label;
308-}
309-
310125 /*!
311126 * @brief サブウィンドウに所持品、装備品リストの表示を行う /
312127 * Flip "inven" and "equip" in any sub-windows
@@ -612,7 +427,7 @@ static bool get_tag(COMMAND_CODE *cp, char tag, BIT_FLAGS mode, OBJECT_TYPE_VALU
612427 * @param mode 所持品リストか装備品リストかの切り替え
613428 * @return なし
614429 */
615-void prepare_label_string(char *label, BIT_FLAGS mode)
430+void prepare_label_string(char *label, BIT_FLAGS mode, OBJECT_TYPE_VALUE tval)
616431 {
617432 concptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
618433 int offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
@@ -628,7 +443,7 @@ void prepare_label_string(char *label, BIT_FLAGS mode)
628443 SYMBOL_CODE c = alphabet_chars[i];
629444
630445 /* Find a tag with this label */
631- if (get_tag(&index, c, mode, item_tester_tval))
446+ if (get_tag(&index, c, mode, tval))
632447 {
633448 /* Delete the overwritten label */
634449 if (label[i] == c) label[i] = ' ';
@@ -718,7 +533,7 @@ COMMAND_CODE show_inven(int target_item, BIT_FLAGS mode)
718533 z = i + 1;
719534 }
720535
721- prepare_label_string(inven_label, USE_INVEN);
536+ prepare_label_string(inven_label, USE_INVEN, item_tester_tval);
722537
723538 /* Display the p_ptr->inventory_list */
724539 for (k = 0, i = 0; i < z; i++)
@@ -3400,3 +3215,188 @@ void display_inven(void)
34003215 Term_erase(0, i, 255);
34013216 }
34023217 }
3218+
3219+
3220+/*!
3221+ * @brief 装備アイテムの表示を行う /
3222+ * Display the equipment.
3223+ * @param target_item アイテムの選択処理を行うか否か。
3224+ * @return 選択したアイテムのタグ
3225+ */
3226+COMMAND_CODE show_equip(int target_item, BIT_FLAGS mode)
3227+{
3228+ COMMAND_CODE i;
3229+ int j, k, l;
3230+ int col, cur_col, len;
3231+ object_type *o_ptr;
3232+ char tmp_val[80];
3233+ GAME_TEXT o_name[MAX_NLEN];
3234+ COMMAND_CODE out_index[23];
3235+ TERM_COLOR out_color[23];
3236+ char out_desc[23][MAX_NLEN];
3237+ COMMAND_CODE target_item_label = 0;
3238+ TERM_LEN wid, hgt;
3239+ char equip_label[52 + 1];
3240+
3241+ /* Starting column */
3242+ col = command_gap;
3243+
3244+ Term_get_size(&wid, &hgt);
3245+
3246+ /* Maximal length */
3247+ len = wid - col - 1;
3248+
3249+
3250+ /* Scan the equipment list */
3251+ for (k = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
3252+ {
3253+ o_ptr = &p_ptr->inventory_list[i];
3254+
3255+ /* Is this item acceptable? */
3256+ if (!(select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr, item_tester_tval) || (mode & USE_FULL)) &&
3257+ (!((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute) ||
3258+ (mode & IGNORE_BOTHHAND_SLOT))) continue;
3259+
3260+ object_desc(o_name, o_ptr, 0);
3261+
3262+ if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
3263+ {
3264+ (void)strcpy(out_desc[k], _("(武器を両手持ち)", "(wielding with two-hands)"));
3265+ out_color[k] = TERM_WHITE;
3266+ }
3267+ else
3268+ {
3269+ (void)strcpy(out_desc[k], o_name);
3270+ out_color[k] = tval_to_attr[o_ptr->tval % 128];
3271+ }
3272+
3273+ out_index[k] = i;
3274+ /* Grey out charging items */
3275+ if (o_ptr->timeout)
3276+ {
3277+ out_color[k] = TERM_L_DARK;
3278+ }
3279+
3280+ /* Extract the maximal length (see below) */
3281+#ifdef JP
3282+ l = strlen(out_desc[k]) + (2 + 1);
3283+#else
3284+ l = strlen(out_desc[k]) + (2 + 3);
3285+#endif
3286+
3287+
3288+ /* Increase length for labels (if needed) */
3289+#ifdef JP
3290+ if (show_labels) l += (7 + 2);
3291+#else
3292+ if (show_labels) l += (14 + 2);
3293+#endif
3294+
3295+
3296+ /* Increase length for weight (if needed) */
3297+ if (show_weights) l += 9;
3298+
3299+ if (show_item_graph) l += 2;
3300+
3301+ /* Maintain the max-length */
3302+ if (l > len) len = l;
3303+
3304+ /* Advance the entry */
3305+ k++;
3306+ }
3307+
3308+ /* Hack -- Find a column to start in */
3309+#ifdef JP
3310+ col = (len > wid - 6) ? 0 : (wid - len - 1);
3311+#else
3312+ col = (len > wid - 4) ? 0 : (wid - len - 1);
3313+#endif
3314+
3315+ prepare_label_string(equip_label, USE_EQUIP, item_tester_tval);
3316+
3317+ /* Output each entry */
3318+ for (j = 0; j < k; j++)
3319+ {
3320+ i = out_index[j];
3321+ o_ptr = &p_ptr->inventory_list[i];
3322+
3323+ /* Clear the line */
3324+ prt("", j + 1, col ? col - 2 : col);
3325+
3326+ if (use_menu && target_item)
3327+ {
3328+ if (j == (target_item - 1))
3329+ {
3330+ strcpy(tmp_val, _("》", "> "));
3331+ target_item_label = i;
3332+ }
3333+ else strcpy(tmp_val, " ");
3334+ }
3335+ else if (i >= INVEN_RARM)
3336+ {
3337+ /* Prepare an index --(-- */
3338+ sprintf(tmp_val, "%c)", equip_label[i - INVEN_RARM]);
3339+ }
3340+ else
3341+ {
3342+ /* Prepare an index --(-- */
3343+ sprintf(tmp_val, "%c)", index_to_label(i));
3344+ }
3345+
3346+ /* Clear the line with the (possibly indented) index */
3347+ put_str(tmp_val, j + 1, col);
3348+
3349+ cur_col = col + 3;
3350+
3351+ /* Display graphics for object, if desired */
3352+ if (show_item_graph)
3353+ {
3354+ TERM_COLOR a = object_attr(o_ptr);
3355+ SYMBOL_CODE c = object_char(o_ptr);
3356+ Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
3357+ if (use_bigtile) cur_col++;
3358+
3359+ cur_col += 2;
3360+ }
3361+
3362+ /* Use labels */
3363+ if (show_labels)
3364+ {
3365+ /* Mention the use */
3366+ (void)sprintf(tmp_val, _("%-7s: ", "%-14s: "), mention_use(i));
3367+
3368+ put_str(tmp_val, j + 1, cur_col);
3369+
3370+ /* Display the entry itself */
3371+ c_put_str(out_color[j], out_desc[j], j + 1, _(cur_col + 9, cur_col + 16));
3372+ }
3373+
3374+ /* No labels */
3375+ else
3376+ {
3377+ /* Display the entry itself */
3378+ c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
3379+ }
3380+
3381+ /* Display the weight if needed */
3382+ if (show_weights)
3383+ {
3384+ int wgt = o_ptr->weight * o_ptr->number;
3385+#ifdef JP
3386+ (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt), lbtokg2(wgt));
3387+#else
3388+ (void)sprintf(tmp_val, "%3d.%d lb", wgt / 10, wgt % 10);
3389+#endif
3390+
3391+ prt(tmp_val, j + 1, wid - 9);
3392+ }
3393+ }
3394+
3395+ /* Make a "shadow" below the list (only if needed) */
3396+ if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
3397+
3398+ /* Save the new column */
3399+ command_gap = col;
3400+
3401+ return target_item_label;
3402+}
Show on old repository browser