OSDN Git Service

Revert "Revert "Merge branch 'master' of git.osdn.net:/gitroot/hengband/hengband""
[hengband/hengband.git] / src / wizard / wizard-messages.c
1 #include "wizard/wizard-messages.h"
2 #include "game-option/cheat-options.h"
3 #include "game-option/cheat-types.h"
4 #include "io/write-diary.h"
5 #include "view/display-messages.h"
6
7 void msg_print_wizard(player_type *player_ptr, int cheat_type, concptr msg)
8 {
9     if (!cheat_room && cheat_type == CHEAT_DUNGEON)
10         return;
11     if (!cheat_peek && cheat_type == CHEAT_OBJECT)
12         return;
13     if (!cheat_hear && cheat_type == CHEAT_MONSTER)
14         return;
15     if (!cheat_xtra && cheat_type == CHEAT_MISC)
16         return;
17
18     concptr cheat_mes[] = { "ITEM", "MONS", "DUNG", "MISC" };
19     char buf[1024];
20     sprintf(buf, "WIZ-%s:%s", cheat_mes[cheat_type], msg);
21     msg_print(buf);
22
23     if (cheat_diary_output) {
24         exe_write_diary(player_ptr, DIARY_WIZARD_LOG, 0, buf);
25     }
26 }
27
28 /*
29  * Display a formatted message, using "vstrnfmt()" and "msg_print()".
30  */
31 void msg_format_wizard(player_type *player_ptr, int cheat_type, concptr fmt, ...)
32 {
33     if (!cheat_room && cheat_type == CHEAT_DUNGEON)
34         return;
35     if (!cheat_peek && cheat_type == CHEAT_OBJECT)
36         return;
37     if (!cheat_hear && cheat_type == CHEAT_MONSTER)
38         return;
39     if (!cheat_xtra && cheat_type == CHEAT_MISC)
40         return;
41
42     va_list vp;
43     char buf[1024];
44     va_start(vp, fmt);
45     (void)vstrnfmt(buf, 1024, fmt, vp);
46     va_end(vp);
47     msg_print_wizard(player_ptr, cheat_type, buf);
48 }