UnNetHack SVN版rev.773を適用した。
Patch: MSGTYPE option (by Pasi Kallinen)
パッチ: MSGTYPEオプション (Pasi Kallinenより)
@@ -1615,6 +1615,8 @@ | ||
1615 | 1615 | |
1616 | 1616 | /* ### pline.c ### */ |
1617 | 1617 | |
1618 | +E void FDECL(msgpline_add, (int, char *)); | |
1619 | +E void NDECL(msgpline_free); | |
1618 | 1620 | E void VDECL(pline, (const char *,...)) PRINTF_F(1,2); |
1619 | 1621 | E void VDECL(Norep, (const char *,...)) PRINTF_F(1,2); |
1620 | 1622 | E void NDECL(free_youbuf); |
@@ -484,6 +484,19 @@ | ||
484 | 484 | }; |
485 | 485 | #endif /* AUTOPICKUP_EXCEPTIONS */ |
486 | 486 | |
487 | +struct _plinemsg { | |
488 | + xchar msgtype; | |
489 | + char *pattern; | |
490 | + struct _plinemsg *next; | |
491 | +}; | |
492 | + | |
493 | +E struct _plinemsg *pline_msg; | |
494 | + | |
495 | +#define MSGTYP_NORMAL 0 | |
496 | +#define MSGTYP_NOREP 1 | |
497 | +#define MSGTYP_NOSHOW 2 | |
498 | +#define MSGTYP_STOP 3 | |
499 | + | |
487 | 500 | #ifdef RECORD_ACHIEVE |
488 | 501 | struct u_achieve { |
489 | 502 | Bitfield(get_bell,1); /* You have obtained the bell of |
@@ -365,6 +365,8 @@ | ||
365 | 365 | struct realtime_data realtime_data = { 0, 0, 0 }; |
366 | 366 | #endif |
367 | 367 | |
368 | +struct _plinemsg *pline_msg = NULL; | |
369 | + | |
368 | 370 | /* dummy routine used to force linkage */ |
369 | 371 | void |
370 | 372 | decl_init() |
@@ -2012,6 +2012,20 @@ | ||
2012 | 2012 | } else if (match_varname(buf, "NAME", 4)) { |
2013 | 2013 | (void) strncpy(plname, bufp, PL_NSIZ-1); |
2014 | 2014 | plnamesuffix(); |
2015 | + } else if (match_varname(buf, "MSGTYPE", 7)) { | |
2016 | + char pattern[256]; | |
2017 | + char msgtype[11]; | |
2018 | + if (sscanf(bufp, "%10s \"%255[^\"]\"", msgtype, pattern) == 2) { | |
2019 | + int typ = MSGTYP_NORMAL; | |
2020 | + if (!strcasecmp("norep", msgtype)) typ = MSGTYP_NOREP; | |
2021 | + else if (!strcasecmp("hide", msgtype)) typ = MSGTYP_NOSHOW; | |
2022 | + else if (!strcasecmp("noshow", msgtype)) typ = MSGTYP_NOSHOW; | |
2023 | + else if (!strcasecmp("more", msgtype)) typ = MSGTYP_STOP; | |
2024 | + else if (!strcasecmp("stop", msgtype)) typ = MSGTYP_STOP; | |
2025 | + if (typ != MSGTYP_NORMAL) { | |
2026 | + msgpline_add(typ, pattern); | |
2027 | + } | |
2028 | + } | |
2015 | 2029 | } else if (match_varname(buf, "ROLE", 4) || |
2016 | 2030 | match_varname(buf, "CHARACTER", 4)) { |
2017 | 2031 | if ((len = str2role(bufp)) >= 0) |
@@ -1152,6 +1152,7 @@ | ||
1152 | 1152 | unload_qtlist(); |
1153 | 1153 | free_invbuf(); /* let_to_name (invent.c) */ |
1154 | 1154 | free_youbuf(); /* You_buf,&c (pline.c) */ |
1155 | + msgpline_free(); | |
1155 | 1156 | #ifdef MENU_COLOR |
1156 | 1157 | free_menu_coloring(); |
1157 | 1158 | #endif |
@@ -30,6 +30,45 @@ | ||
30 | 30 | int lastmsg = -1; |
31 | 31 | #endif |
32 | 32 | |
33 | +void | |
34 | +msgpline_add(typ, pattern) | |
35 | + int typ; | |
36 | + char *pattern; | |
37 | +{ | |
38 | + struct _plinemsg *tmp = (struct _plinemsg *) alloc(sizeof(struct _plinemsg)); | |
39 | + if (!tmp) return; | |
40 | + tmp->msgtype = typ; | |
41 | + tmp->pattern = strdup(pattern); | |
42 | + tmp->next = pline_msg; | |
43 | + pline_msg = tmp; | |
44 | +} | |
45 | + | |
46 | +void | |
47 | +msgpline_free() | |
48 | +{ | |
49 | + struct _plinemsg *tmp = pline_msg; | |
50 | + struct _plinemsg *tmp2; | |
51 | + while (tmp) { | |
52 | + free(tmp->pattern); | |
53 | + tmp2 = tmp; | |
54 | + tmp = tmp->next; | |
55 | + free(tmp2); | |
56 | + } | |
57 | + pline_msg = NULL; | |
58 | +} | |
59 | + | |
60 | +int | |
61 | +msgpline_type(msg) | |
62 | + char *msg; | |
63 | +{ | |
64 | + struct _plinemsg *tmp = pline_msg; | |
65 | + while (tmp) { | |
66 | + if (pmatch(tmp->pattern, msg)) return tmp->msgtype; | |
67 | + tmp = tmp->next; | |
68 | + } | |
69 | + return MSGTYP_NORMAL; | |
70 | +} | |
71 | + | |
33 | 72 | /*VARARGS1*/ |
34 | 73 | /* Note that these declarations rely on knowledge of the internals |
35 | 74 | * of the variable argument handling stuff in "tradstdc.h" |
@@ -46,6 +85,8 @@ | ||
46 | 85 | VA_END(); |
47 | 86 | } |
48 | 87 | |
88 | +char prevmsg[BUFSZ]; | |
89 | + | |
49 | 90 | # ifdef USE_STDARG |
50 | 91 | static void |
51 | 92 | vpline(const char *line, va_list the_args) { |
@@ -63,6 +104,7 @@ | ||
63 | 104 | #endif /* USE_STDARG | USE_VARARG */ |
64 | 105 | |
65 | 106 | char pbuf[BUFSZ]; |
107 | + int typ; | |
66 | 108 | /* Do NOT use VA_START and VA_END in here... see above */ |
67 | 109 | |
68 | 110 | if (!line || !*line) return; |
@@ -82,6 +124,7 @@ | ||
82 | 124 | } |
83 | 125 | } |
84 | 126 | #endif |
127 | + typ = msgpline_type(line); | |
85 | 128 | if (!iflags.window_inited) { |
86 | 129 | raw_print(line); |
87 | 130 | return; |
@@ -92,7 +135,11 @@ | ||
92 | 135 | #endif /* MAC */ |
93 | 136 | if (vision_full_recalc) vision_recalc(0); |
94 | 137 | if (u.ux) flush_screen(1); /* %% */ |
138 | + if (typ == MSGTYP_NOSHOW) return; | |
139 | + if (typ == MSGTYP_NOREP && !strcmp(line, prevmsg)) return; | |
95 | 140 | putstr(WIN_MESSAGE, 0, line); |
141 | + strncpy(prevmsg, line, BUFSZ); | |
142 | + if (typ == MSGTYP_STOP) display_nhwindow(WIN_MESSAGE, TRUE); /* --more-- */ | |
96 | 143 | } |
97 | 144 | |
98 | 145 | /*VARARGS1*/ |
@@ -5,6 +5,7 @@ | ||
5 | 5 | * HTML dump: output IBMgraphics and DECgraphics characters |
6 | 6 | |
7 | 7 | * patches: |
8 | + - MSGTYPE option (by Pasi Kallinen) | |
8 | 9 | - Sortloot (by Jukka Lahtinen) |
9 | 10 | |
10 | 11 | * user interface improvements: |