OSDN Git Service

[fix] #41503 超能力者でゲームを開始しようとするとクラッシュ
[hengband/hengband.git] / src / cmd-io / cmd-floor.c
1 #include "cmd-io/cmd-floor.h"
2 #include "core/asking-player.h"
3 #include "core/player-redraw-types.h"
4 #include "core/player-update-types.h"
5 #include "core/stuff-handler.h"
6 #include "core/window-redrawer.h"
7 #include "floor/geometry.h"
8 #include "game-option/keymap-directory-getter.h"
9 #include "io/cursor.h"
10 #include "io/screen-util.h"
11 #include "main/sound-of-music.h"
12 #include "target/target-checker.h"
13 #include "target/target-setter.h"
14 #include "target/target-types.h"
15 #include "view/display-messages.h"
16 #include "window/main-window-util.h"
17
18 /*!
19  * @brief ターゲットを設定するコマンドのメインルーチン
20  * Target command
21  * @return なし
22  */
23 void do_cmd_target(player_type *creature_ptr)
24 {
25     if (creature_ptr->wild_mode)
26         return;
27
28     if (target_set(creature_ptr, TARGET_KILL))
29         msg_print(_("ターゲット決定。", "Target Selected."));
30     else
31         msg_print(_("ターゲット解除。", "Target Aborted."));
32 }
33
34 /*!
35  * @brief 周囲を見渡すコマンドのメインルーチン
36  * Look command
37  * @return なし
38  */
39 void do_cmd_look(player_type *creature_ptr)
40 {
41     creature_ptr->window |= PW_MONSTER_LIST;
42     handle_stuff(creature_ptr);
43     if (target_set(creature_ptr, TARGET_LOOK))
44         msg_print(_("ターゲット決定。", "Target Selected."));
45 }
46
47 /*!
48  * @brief 位置を確認するコマンドのメインルーチン
49  * Allow the player to examine other sectors on the map
50  * @return なし
51  */
52 void do_cmd_locate(player_type *creature_ptr)
53 {
54     DIRECTION dir;
55     POSITION y1, x1;
56     GAME_TEXT tmp_val[80];
57     GAME_TEXT out_val[MAX_MONSTER_NAME];
58     TERM_LEN wid, hgt;
59     get_screen_size(&wid, &hgt);
60     POSITION y2 = y1 = panel_row_min;
61     POSITION x2 = x1 = panel_col_min;
62     while (TRUE) {
63         if ((y2 == y1) && (x2 == x1))
64             strcpy(tmp_val, _("真上", "\0"));
65         else
66             sprintf(tmp_val, "%s%s", ((y2 < y1) ? _("北", " North") : (y2 > y1) ? _("南", " South") : ""),
67                 ((x2 < x1) ? _("西", " West") : (x2 > x1) ? _("東", " East") : ""));
68
69         sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s)  方向?", "Map sector [%d(%02d),%d(%02d)], which is%s your sector.  Direction?"),
70             y2 / (hgt / 2), y2 % (hgt / 2), x2 / (wid / 2), x2 % (wid / 2), tmp_val);
71
72         dir = 0;
73         while (!dir) {
74             char command;
75             if (!get_com(out_val, &command, TRUE))
76                 break;
77
78             dir = get_keymap_dir(command);
79             if (!dir)
80                 bell();
81         }
82
83         if (!dir)
84             break;
85
86         if (change_panel(creature_ptr, ddy[dir], ddx[dir])) {
87             y2 = panel_row_min;
88             x2 = panel_col_min;
89         }
90     }
91
92     verify_panel(creature_ptr);
93     creature_ptr->update |= PU_MONSTERS;
94     creature_ptr->redraw |= PR_MAP;
95     creature_ptr->window |= PW_OVERHEAD | PW_DUNGEON;
96     handle_stuff(creature_ptr);
97 }