OSDN Git Service

Merge pull request #2942 from backwardsEric/sprintf-refactor-floor-save
[hengbandforosx/hengbandosx.git] / src / wizard / wizard-messages.cpp
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(PlayerType *player_ptr, int cheat_type, concptr msg)
8 {
9     if (!cheat_room && cheat_type == CHEAT_DUNGEON) {
10         return;
11     }
12     if (!cheat_peek && cheat_type == CHEAT_OBJECT) {
13         return;
14     }
15     if (!cheat_hear && cheat_type == CHEAT_MONSTER) {
16         return;
17     }
18     if (!cheat_xtra && cheat_type == CHEAT_MISC) {
19         return;
20     }
21
22     concptr cheat_mes[] = { "ITEM", "MONS", "DUNG", "MISC" };
23     char buf[1024 + 32];
24     sprintf(buf, "WIZ-%s:%s", cheat_mes[cheat_type], msg);
25     msg_print(buf);
26
27     if (cheat_diary_output) {
28         exe_write_diary(player_ptr, DIARY_WIZARD_LOG, 0, buf);
29     }
30 }
31
32 /*
33  * Display a formatted message, using "vstrnfmt()" and "msg_print()".
34  */
35 void msg_format_wizard(PlayerType *player_ptr, int cheat_type, concptr fmt, ...)
36 {
37     if (!cheat_room && cheat_type == CHEAT_DUNGEON) {
38         return;
39     }
40     if (!cheat_peek && cheat_type == CHEAT_OBJECT) {
41         return;
42     }
43     if (!cheat_hear && cheat_type == CHEAT_MONSTER) {
44         return;
45     }
46     if (!cheat_xtra && cheat_type == CHEAT_MISC) {
47         return;
48     }
49
50     va_list vp;
51     char buf[1024];
52     va_start(vp, fmt);
53     (void)vstrnfmt(buf, 1024, fmt, vp);
54     va_end(vp);
55     msg_print_wizard(player_ptr, cheat_type, buf);
56 }