OSDN Git Service

[Feature]モンスター一覧に起きているモンスター数を表示するようにした
[hengbandforosx/hengbandosx.git] / src / window / display-sub-windows.cpp
1 #include "window/display-sub-windows.h"
2 #include "core/window-redrawer.h"
3 #include "flavor/flavor-describer.h"
4 #include "floor/cave.h"
5 #include "game-option/option-flags.h"
6 #include "game-option/special-options.h"
7 #include "game-option/text-display-options.h"
8 #include "grid/feature.h"
9 #include "inventory/inventory-describer.h"
10 #include "inventory/inventory-slot-types.h"
11 #include "inventory/inventory-util.h"
12 #include "locale/japanese.h"
13 #include "main/sound-of-music.h"
14 #include "monster-race/monster-race.h"
15 #include "monster-race/race-flags1.h"
16 #include "monster/monster-flag-types.h"
17 #include "monster/monster-info.h"
18 #include "monster/monster-status.h"
19 #include "object/item-tester-hooker.h"
20 #include "object/object-info.h"
21 #include "object/object-mark-types.h"
22 #include "player/player-status-flags.h"
23 #include "player/player-status.h"
24 #include "spell-kind/magic-item-recharger.h"
25 #include "system/baseitem-info.h"
26 #include "system/floor-type-definition.h"
27 #include "system/grid-type-definition.h"
28 #include "system/item-entity.h"
29 #include "system/monster-entity.h"
30 #include "system/monster-race-info.h"
31 #include "system/player-type-definition.h"
32 #include "system/terrain-type-definition.h"
33 #include "target/target-describer.h"
34 #include "target/target-preparation.h"
35 #include "target/target-setter.h"
36 #include "target/target-types.h"
37 #include "term/gameterm.h"
38 #include "term/screen-processor.h"
39 #include "term/term-color-types.h"
40 #include "timed-effect/player-hallucination.h"
41 #include "timed-effect/timed-effects.h"
42 #include "util/bit-flags-calculator.h"
43 #include "view/display-lore.h"
44 #include "view/display-map.h"
45 #include "view/display-messages.h"
46 #include "view/display-player.h"
47 #include "view/object-describer.h"
48 #include "window/main-window-equipments.h"
49 #include "window/main-window-util.h"
50 #include "world/world.h"
51 #include <mutex>
52 #include <sstream>
53 #include <string>
54
55 /*! サブウィンドウ表示用の ItemTester オブジェクト */
56 static std::unique_ptr<ItemTester> fix_item_tester = std::make_unique<AllMatchItemTester>();
57
58 FixItemTesterSetter::FixItemTesterSetter(const ItemTester &item_tester)
59 {
60     fix_item_tester = item_tester.clone();
61 }
62
63 FixItemTesterSetter::~FixItemTesterSetter()
64 {
65     fix_item_tester = std::make_unique<AllMatchItemTester>();
66 }
67
68 /*!
69  * @brief サブウィンドウに所持品一覧を表示する / Hack -- display inventory in sub-windows
70  * @param player_ptr プレイヤーへの参照ポインタ
71  */
72 void fix_inventory(PlayerType *player_ptr)
73 {
74     for (int j = 0; j < 8; j++) {
75         term_type *old = game_term;
76         if (!angband_term[j]) {
77             continue;
78         }
79
80         if (!(window_flag[j] & (PW_INVEN))) {
81             continue;
82         }
83
84         term_activate(angband_term[j]);
85         display_inventory(player_ptr, *fix_item_tester);
86         term_fresh();
87         term_activate(old);
88     }
89 }
90
91 /*!
92  * @brief モンスターの現在数を一行で表現する / Print monster info in line
93  * @param x 表示列
94  * @param y 表示行
95  * @param m_ptr 思い出を表示するモンスター情報の参照ポインタ
96  * @param n_same モンスター数の現在数
97  * @param n_awake 起きている数
98  * @details
99  * <pre>
100  * nnn X LV name
101  *  nnn : number or unique(U) or wanted unique(W)
102  *  X   : symbol of monster
103  *  LV  : monster lv if known
104  *  name: name of monster
105  * </pre>
106  */
107 static void print_monster_line(TERM_LEN x, TERM_LEN y, MonsterEntity *m_ptr, int n_same, int n_awake)
108 {
109     char buf[256];
110     MonsterRaceId r_idx = m_ptr->ap_r_idx;
111     auto *r_ptr = &monraces_info[r_idx];
112
113     term_erase(0, y, 255);
114     term_gotoxy(x, y);
115     if (!r_ptr) {
116         return;
117     }
118     if (r_ptr->kind_flags.has(MonsterKindType::UNIQUE)) {
119         sprintf(buf, _("%3s(覚%2d)", "%3s(%2d)"), MonsterRace(r_idx).is_bounty(true) ? "  W" : "  U", n_awake);
120         term_addstr(-1, TERM_WHITE, buf);
121     } else {
122         sprintf(buf, _("%3d(覚%2d)", "%3d(%2d)"), n_same, n_awake);
123         term_addstr(-1, TERM_WHITE, buf);
124     }
125
126     term_addstr(-1, TERM_WHITE, " ");
127     term_add_bigch(r_ptr->x_attr, r_ptr->x_char);
128
129     if (r_ptr->r_tkills && m_ptr->mflag2.has_not(MonsterConstantFlagType::KAGE)) {
130         sprintf(buf, " %2d", (int)r_ptr->level);
131     } else {
132         strcpy(buf, " ??");
133     }
134
135     term_addstr(-1, TERM_WHITE, buf);
136
137     sprintf(buf, " %s ", r_ptr->name.data());
138     term_addstr(-1, TERM_WHITE, buf);
139 }
140
141 /*!
142  * @brief モンスターの出現リストを表示する / Print monster info in line
143  * @param x 表示列
144  * @param y 表示行
145  * @param max_lines 最大何行描画するか
146  */
147 void print_monster_list(FloorType *floor_ptr, const std::vector<MONSTER_IDX> &monster_list, TERM_LEN x, TERM_LEN y, TERM_LEN max_lines)
148 {
149     TERM_LEN line = y;
150     struct info {
151         MonsterEntity *monster_entity;
152         int visible_count; // 現在数
153         int awake_count; // 起きている数
154     };
155
156     // 出現リスト表示用のデータ
157     std::vector<info> monster_list_info;
158
159     // 描画に必要なデータを集める
160     for (auto monster_index : monster_list) {
161         auto m_ptr = &floor_ptr->m_list[monster_index];
162
163         if (m_ptr->is_pet()) {
164             continue;
165         } // pet
166         if (!MonsterRace(m_ptr->r_idx).is_valid()) {
167             continue;
168         } // dead?
169
170         // ソート済みなので同じモンスターは連続する.これを利用して同じモンスターをカウント,まとめて表示する.
171         if (monster_list_info.empty() || (monster_list_info.back().monster_entity->ap_r_idx != m_ptr->ap_r_idx)) {
172             monster_list_info.push_back({ m_ptr, 0, 0 });
173         }
174
175         // 出現数をカウント
176         monster_list_info.back().visible_count++;
177
178         // 起きているモンスターをカウント
179         if (!m_ptr->is_asleep()) {
180             monster_list_info.back().awake_count++;
181         }
182     }
183
184     // 集めたデータを元にリストを表示する
185     for (const auto &info : monster_list_info) {
186         print_monster_line(x, line++, info.monster_entity, info.visible_count, info.awake_count);
187
188         // 行数が足りなくなったら中断。
189         if (line - y == max_lines) {
190             // 行数が足りなかった場合、最終行にその旨表示。
191             term_addstr(-1, TERM_WHITE, "-- and more --");
192             break;
193         }
194     }
195
196     for (; line < max_lines; line++) {
197         term_erase(0, line, 255);
198     }
199 }
200
201 /*!
202  * @brief 出現中モンスターのリストをサブウィンドウに表示する / Hack -- display monster list in sub-windows
203  * @param player_ptr プレイヤーへの参照ポインタ
204  */
205 void fix_monster_list(PlayerType *player_ptr)
206 {
207     static std::vector<MONSTER_IDX> monster_list;
208     std::once_flag once;
209
210     for (int j = 0; j < 8; j++) {
211         term_type *old = game_term;
212         if (!angband_term[j]) {
213             continue;
214         }
215         if (!(window_flag[j] & PW_MONSTER_LIST)) {
216             continue;
217         }
218         if (angband_term[j]->never_fresh) {
219             continue;
220         }
221
222         term_activate(angband_term[j]);
223         int w, h;
224         term_get_size(&w, &h);
225         std::call_once(once, target_sensing_monsters_prepare, player_ptr, monster_list);
226         print_monster_list(player_ptr->current_floor_ptr, monster_list, 0, 0, h);
227         term_fresh();
228         term_activate(old);
229     }
230
231     if (use_music && has_monster_music) {
232         std::call_once(once, target_sensing_monsters_prepare, player_ptr, monster_list);
233         select_monster_music(player_ptr, monster_list);
234     }
235 }
236
237 /*!
238  * @brief 装備アイテム一覧を表示する /
239  * Choice window "shadow" of the "show_equip()" function
240  */
241 static void display_equipment(PlayerType *player_ptr, const ItemTester &item_tester)
242 {
243     if (!player_ptr || !player_ptr->inventory_list) {
244         return;
245     }
246
247     TERM_LEN wid, hgt;
248     term_get_size(&wid, &hgt);
249
250     TERM_COLOR attr = TERM_WHITE;
251     char tmp_val[80];
252     GAME_TEXT o_name[MAX_NLEN];
253     for (int i = INVEN_MAIN_HAND; i < INVEN_TOTAL; i++) {
254         int cur_row = i - INVEN_MAIN_HAND;
255         if (cur_row >= hgt) {
256             break;
257         }
258
259         auto o_ptr = &player_ptr->inventory_list[i];
260         auto do_disp = player_ptr->select_ring_slot ? is_ring_slot(i) : item_tester.okay(o_ptr);
261         strcpy(tmp_val, "   ");
262
263         if (do_disp) {
264             tmp_val[0] = index_to_label(i);
265             tmp_val[1] = ')';
266         }
267
268         int cur_col = 3;
269         term_erase(cur_col, cur_row, 255);
270         term_putstr(0, cur_row, cur_col, TERM_WHITE, tmp_val);
271
272         if ((((i == INVEN_MAIN_HAND) && can_attack_with_sub_hand(player_ptr)) || ((i == INVEN_SUB_HAND) && can_attack_with_main_hand(player_ptr))) && has_two_handed_weapons(player_ptr)) {
273             strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
274             attr = TERM_WHITE;
275         } else {
276             describe_flavor(player_ptr, o_name, o_ptr, 0);
277             attr = tval_to_attr[enum2i(o_ptr->tval) % 128];
278         }
279
280         int n = strlen(o_name);
281         if (o_ptr->timeout) {
282             attr = TERM_L_DARK;
283         }
284
285         if (show_item_graph) {
286             const auto a = o_ptr->get_color();
287             const auto c = o_ptr->get_symbol();
288             term_queue_bigchar(cur_col, cur_row, a, c, 0, 0);
289             if (use_bigtile) {
290                 cur_col++;
291             }
292
293             cur_col += 2;
294         }
295
296         term_putstr(cur_col, cur_row, n, attr, o_name);
297         if (show_weights) {
298             int wgt = o_ptr->weight * o_ptr->number;
299             sprintf(tmp_val, _("%3d.%1d kg", "%3d.%1d lb"), _(lb_to_kg_integer(wgt), wgt / 10), _(lb_to_kg_fraction(wgt), wgt % 10));
300             prt(tmp_val, cur_row, wid - (show_labels ? 28 : 9));
301         }
302
303         if (show_labels) {
304             term_putstr(wid - 20, cur_row, -1, TERM_WHITE, " <-- ");
305             prt(mention_use(player_ptr, i), cur_row, wid - 15);
306         }
307     }
308
309     for (int i = INVEN_TOTAL - INVEN_MAIN_HAND; i < hgt; i++) {
310         term_erase(0, i, 255);
311     }
312 }
313
314 /*!
315  * @brief 現在の装備品をサブウィンドウに表示する /
316  * Hack -- display equipment in sub-windows
317  * @param player_ptr プレイヤーへの参照ポインタ
318  */
319 void fix_equip(PlayerType *player_ptr)
320 {
321     for (int j = 0; j < 8; j++) {
322         term_type *old = game_term;
323         if (!angband_term[j]) {
324             continue;
325         }
326         if (!(window_flag[j] & (PW_EQUIP))) {
327             continue;
328         }
329
330         term_activate(angband_term[j]);
331         display_equipment(player_ptr, *fix_item_tester);
332         term_fresh();
333         term_activate(old);
334     }
335 }
336
337 /*!
338  * @brief 現在のプレイヤーステータスをサブウィンドウに表示する /
339  * @param player_ptr プレイヤーへの参照ポインタ
340  * Hack -- display character in sub-windows
341  */
342 void fix_player(PlayerType *player_ptr)
343 {
344     for (int j = 0; j < 8; j++) {
345         term_type *old = game_term;
346         if (!angband_term[j]) {
347             continue;
348         }
349
350         if (!(window_flag[j] & (PW_PLAYER))) {
351             continue;
352         }
353
354         term_activate(angband_term[j]);
355         update_playtime();
356         (void)display_player(player_ptr, 0);
357         term_fresh();
358         term_activate(old);
359     }
360 }
361
362 /*!
363  * @brief ゲームメッセージ履歴をサブウィンドウに表示する /
364  * Hack -- display recent messages in sub-windows
365  * Adjust for width and split messages
366  */
367 void fix_message(void)
368 {
369     for (int j = 0; j < 8; j++) {
370         term_type *old = game_term;
371         if (!angband_term[j]) {
372             continue;
373         }
374
375         if (!(window_flag[j] & (PW_MESSAGE))) {
376             continue;
377         }
378
379         term_activate(angband_term[j]);
380         TERM_LEN w, h;
381         term_get_size(&w, &h);
382         for (int i = 0; i < h; i++) {
383             term_putstr(0, (h - 1) - i, -1, (byte)((i < now_message) ? TERM_WHITE : TERM_SLATE), message_str((int16_t)i));
384             TERM_LEN x, y;
385             term_locate(&x, &y);
386             term_erase(x, y, 255);
387         }
388
389         term_fresh();
390         term_activate(old);
391     }
392 }
393
394 /*!
395  * @brief 簡易マップをサブウィンドウに表示する /
396  * Hack -- display overhead view in sub-windows
397  * Adjust for width and split messages
398  * @param player_ptr プレイヤーへの参照ポインタ
399  * @details
400  * Note that the "player" symbol does NOT appear on the map.
401  */
402 void fix_overhead(PlayerType *player_ptr)
403 {
404     for (int j = 0; j < 8; j++) {
405         term_type *old = game_term;
406         TERM_LEN wid, hgt;
407         if (!angband_term[j]) {
408             continue;
409         }
410
411         if (!(window_flag[j] & (PW_OVERHEAD))) {
412             continue;
413         }
414
415         term_activate(angband_term[j]);
416         term_get_size(&wid, &hgt);
417         if (wid > COL_MAP + 2 && hgt > ROW_MAP + 2) {
418             int cy, cx;
419             display_map(player_ptr, &cy, &cx);
420             term_fresh();
421         }
422
423         term_activate(old);
424     }
425 }
426
427 /*!
428  * @brief 自分の周辺の地形をTermに表示する
429  * @param プレイヤー情報への参照ポインタ
430  */
431 static void display_dungeon(PlayerType *player_ptr)
432 {
433     TERM_COLOR ta = 0;
434     auto tc = '\0';
435
436     for (TERM_LEN x = player_ptr->x - game_term->wid / 2 + 1; x <= player_ptr->x + game_term->wid / 2; x++) {
437         for (TERM_LEN y = player_ptr->y - game_term->hgt / 2 + 1; y <= player_ptr->y + game_term->hgt / 2; y++) {
438             TERM_COLOR a;
439             char c;
440             if (!in_bounds2(player_ptr->current_floor_ptr, y, x)) {
441                 auto *f_ptr = &terrains_info[feat_none];
442                 a = f_ptr->x_attr[F_LIT_STANDARD];
443                 c = f_ptr->x_char[F_LIT_STANDARD];
444                 term_queue_char(x - player_ptr->x + game_term->wid / 2 - 1, y - player_ptr->y + game_term->hgt / 2 - 1, a, c, ta, tc);
445                 continue;
446             }
447
448             map_info(player_ptr, y, x, &a, &c, &ta, &tc);
449
450             if (!use_graphics) {
451                 if (w_ptr->timewalk_m_idx) {
452                     a = TERM_DARK;
453                 } else if (is_invuln(player_ptr) || player_ptr->timewalk) {
454                     a = TERM_WHITE;
455                 } else if (player_ptr->wraith_form) {
456                     a = TERM_L_DARK;
457                 }
458             }
459
460             term_queue_char(x - player_ptr->x + game_term->wid / 2 - 1, y - player_ptr->y + game_term->hgt / 2 - 1, a, c, ta, tc);
461         }
462     }
463 }
464
465 /*!
466  * @brief 自分の周辺のダンジョンの地形をサブウィンドウに表示する / display dungeon view around player in a sub window
467  * @param player_ptr プレイヤーへの参照ポインタ
468  */
469 void fix_dungeon(PlayerType *player_ptr)
470 {
471     for (int j = 0; j < 8; j++) {
472         term_type *old = game_term;
473         if (!angband_term[j]) {
474             continue;
475         }
476
477         if (!(window_flag[j] & (PW_DUNGEON))) {
478             continue;
479         }
480
481         term_activate(angband_term[j]);
482         display_dungeon(player_ptr);
483         term_fresh();
484         term_activate(old);
485     }
486 }
487
488 /*!
489  * @brief モンスターの思い出をサブウィンドウに表示する /
490  * Hack -- display dungeon view in sub-windows
491  * @param player_ptr プレイヤーへの参照ポインタ
492  */
493 void fix_monster(PlayerType *player_ptr)
494 {
495     for (int j = 0; j < 8; j++) {
496         term_type *old = game_term;
497         if (!angband_term[j]) {
498             continue;
499         }
500
501         if (!(window_flag[j] & (PW_MONSTER))) {
502             continue;
503         }
504
505         term_activate(angband_term[j]);
506         if (MonsterRace(player_ptr->monster_race_idx).is_valid()) {
507             display_roff(player_ptr);
508         }
509
510         term_fresh();
511         term_activate(old);
512     }
513 }
514
515 /*!
516  * @brief ベースアイテム情報をサブウィンドウに表示する /
517  * Hack -- display object recall in sub-windows
518  * @param player_ptr プレイヤーへの参照ポインタ
519  */
520 void fix_object(PlayerType *player_ptr)
521 {
522     for (int j = 0; j < 8; j++) {
523         term_type *old = game_term;
524         if (!angband_term[j]) {
525             continue;
526         }
527
528         if (!(window_flag[j] & (PW_OBJECT))) {
529             continue;
530         }
531
532         term_activate(angband_term[j]);
533         if (player_ptr->baseitem_info_idx) {
534             display_koff(player_ptr, player_ptr->baseitem_info_idx);
535         }
536
537         term_fresh();
538         term_activate(old);
539     }
540 }
541
542 /*!
543  * @brief 床上のモンスター情報を返す
544  * @param floor_ptr 階の情報への参照ポインタ
545  * @param grid_prt 座標グリッドの情報への参照ポインタ
546  * @return モンスターが見える場合にはモンスター情報への参照ポインタ、それ以外はnullptr
547  * @details
548  * Lookコマンドでカーソルを合わせた場合に合わせてミミックは考慮しない。
549  */
550 static const MonsterEntity *monster_on_floor_items(FloorType *floor_ptr, const grid_type *g_ptr)
551 {
552     if (g_ptr->m_idx == 0) {
553         return nullptr;
554     }
555
556     auto m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
557     if (!m_ptr->is_valid() || !m_ptr->ml) {
558         return nullptr;
559     }
560
561     return m_ptr;
562 }
563
564 /*!
565  * @brief 床上のアイテム一覧を作成し、表示する
566  * @param プレイヤー情報への参照ポインタ
567  * @param y 参照する座標グリッドのy座標
568  * @param x 参照する座標グリッドのx座標
569  */
570 static void display_floor_item_list(PlayerType *player_ptr, const int y, const int x)
571 {
572     // Term の行数を取得。
573     TERM_LEN term_h;
574     {
575         TERM_LEN term_w;
576         term_get_size(&term_w, &term_h);
577     }
578     if (term_h <= 0) {
579         return;
580     }
581
582     term_clear();
583     term_gotoxy(0, 0);
584
585     auto *floor_ptr = player_ptr->current_floor_ptr;
586     const auto *g_ptr = &floor_ptr->grid_array[y][x];
587     char line[1024];
588
589     // 先頭行を書く。
590     auto is_hallucinated = player_ptr->effects()->hallucination()->is_hallucinated();
591     if (player_bold(player_ptr, y, x)) {
592         sprintf(line, _("(X:%03d Y:%03d) あなたの足元のアイテム一覧", "Items at (%03d,%03d) under you"), x, y);
593     } else if (const auto *m_ptr = monster_on_floor_items(floor_ptr, g_ptr); m_ptr != nullptr) {
594         if (is_hallucinated) {
595             sprintf(line, _("(X:%03d Y:%03d) 何か奇妙な物の足元の発見済みアイテム一覧", "Found items at (%03d,%03d) under something strange"), x, y);
596         } else {
597             const MonsterRaceInfo *const r_ptr = &monraces_info[m_ptr->ap_r_idx];
598             sprintf(line, _("(X:%03d Y:%03d) %sの足元の発見済みアイテム一覧", "Found items at (%03d,%03d) under %s"), x, y, r_ptr->name.data());
599         }
600     } else {
601         const TerrainType *const f_ptr = &terrains_info[g_ptr->feat];
602         concptr fn = f_ptr->name.data();
603         char buf[512];
604
605         if (f_ptr->flags.has(TerrainCharacteristics::STORE) || (f_ptr->flags.has(TerrainCharacteristics::BLDG) && !floor_ptr->inside_arena)) {
606             sprintf(buf, _("%sの入口", "on the entrance of %s"), fn);
607         } else if (f_ptr->flags.has(TerrainCharacteristics::WALL)) {
608             sprintf(buf, _("%sの中", "in %s"), fn);
609         } else {
610             sprintf(buf, _("%s", "on %s"), fn);
611         }
612         sprintf(line, _("(X:%03d Y:%03d) %sの上の発見済みアイテム一覧", "Found items at (X:%03d Y:%03d) %s"), x, y, buf);
613     }
614     term_addstr(-1, TERM_WHITE, line);
615
616     // (y,x) のアイテムを1行に1個ずつ書く。
617     TERM_LEN term_y = 1;
618     for (const auto o_idx : g_ptr->o_idx_list) {
619         ItemEntity *const o_ptr = &floor_ptr->o_list[o_idx];
620
621         // 未発見アイテムおよび金は対象外。
622         if (none_bits(o_ptr->marked, OM_FOUND) || o_ptr->tval == ItemKindType::GOLD) {
623             continue;
624         }
625
626         // 途中で行数が足りなくなったら最終行にその旨追記して終了。
627         if (term_y >= term_h) {
628             term_addstr(-1, TERM_WHITE, "-- more --");
629             break;
630         }
631
632         term_gotoxy(0, term_y);
633
634         if (is_hallucinated) {
635             term_addstr(-1, TERM_WHITE, _("何か奇妙な物", "something strange"));
636         } else {
637             describe_flavor(player_ptr, line, o_ptr, 0);
638             TERM_COLOR attr = tval_to_attr[enum2i(o_ptr->tval) % 128];
639             term_addstr(-1, attr, line);
640         }
641
642         ++term_y;
643     }
644 }
645
646 /*!
647  * @brief (y,x) のアイテム一覧をサブウィンドウに表示する / display item at (y,x) in sub-windows
648  */
649 void fix_floor_item_list(PlayerType *player_ptr, const int y, const int x)
650 {
651     for (int j = 0; j < 8; j++) {
652         if (!angband_term[j]) {
653             continue;
654         }
655         if (angband_term[j]->never_fresh) {
656             continue;
657         }
658         if (!(window_flag[j] & PW_FLOOR_ITEM_LIST)) {
659             continue;
660         }
661
662         term_type *old = game_term;
663         term_activate(angband_term[j]);
664
665         display_floor_item_list(player_ptr, y, x);
666         term_fresh();
667
668         term_activate(old);
669     }
670 }
671
672 /*!
673  * @brief サブウィンドウに所持品、装備品リストの表示を行う /
674  * Flip "inven" and "equip" in any sub-windows
675  */
676 void toggle_inventory_equipment(PlayerType *player_ptr)
677 {
678     for (int j = 0; j < 8; j++) {
679         if (!angband_term[j]) {
680             continue;
681         }
682
683         if (window_flag[j] & (PW_INVEN)) {
684             window_flag[j] &= ~(PW_INVEN);
685             window_flag[j] |= (PW_EQUIP);
686             player_ptr->window_flags |= (PW_EQUIP);
687             continue;
688         }
689
690         if (window_flag[j] & PW_EQUIP) {
691             window_flag[j] &= ~(PW_EQUIP);
692             window_flag[j] |= PW_INVEN;
693             player_ptr->window_flags |= PW_INVEN;
694         }
695     }
696 }