• R/O
  • SSH
  • HTTPS

junnethack: Commit


Commit MetaInfo

Revisión410 (tree)
Tiempo2011-03-26 18:03:16
Autorso-miya

Log Message

UnNetHack SVN版rev.773を適用した。
Patch: MSGTYPE option (by Pasi Kallinen)
パッチ: MSGTYPEオプション (Pasi Kallinenより)

Cambiar Resumen

Diferencia

--- junnethack/trunk/include/extern.h (revision 409)
+++ junnethack/trunk/include/extern.h (revision 410)
@@ -1615,6 +1615,8 @@
16151615
16161616 /* ### pline.c ### */
16171617
1618+E void FDECL(msgpline_add, (int, char *));
1619+E void NDECL(msgpline_free);
16181620 E void VDECL(pline, (const char *,...)) PRINTF_F(1,2);
16191621 E void VDECL(Norep, (const char *,...)) PRINTF_F(1,2);
16201622 E void NDECL(free_youbuf);
--- junnethack/trunk/include/decl.h (revision 409)
+++ junnethack/trunk/include/decl.h (revision 410)
@@ -484,6 +484,19 @@
484484 };
485485 #endif /* AUTOPICKUP_EXCEPTIONS */
486486
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+
487500 #ifdef RECORD_ACHIEVE
488501 struct u_achieve {
489502 Bitfield(get_bell,1); /* You have obtained the bell of
--- junnethack/trunk/src/decl.c (revision 409)
+++ junnethack/trunk/src/decl.c (revision 410)
@@ -365,6 +365,8 @@
365365 struct realtime_data realtime_data = { 0, 0, 0 };
366366 #endif
367367
368+struct _plinemsg *pline_msg = NULL;
369+
368370 /* dummy routine used to force linkage */
369371 void
370372 decl_init()
--- junnethack/trunk/src/files.c (revision 409)
+++ junnethack/trunk/src/files.c (revision 410)
@@ -2012,6 +2012,20 @@
20122012 } else if (match_varname(buf, "NAME", 4)) {
20132013 (void) strncpy(plname, bufp, PL_NSIZ-1);
20142014 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+ }
20152029 } else if (match_varname(buf, "ROLE", 4) ||
20162030 match_varname(buf, "CHARACTER", 4)) {
20172031 if ((len = str2role(bufp)) >= 0)
--- junnethack/trunk/src/save.c (revision 409)
+++ junnethack/trunk/src/save.c (revision 410)
@@ -1152,6 +1152,7 @@
11521152 unload_qtlist();
11531153 free_invbuf(); /* let_to_name (invent.c) */
11541154 free_youbuf(); /* You_buf,&c (pline.c) */
1155+ msgpline_free();
11551156 #ifdef MENU_COLOR
11561157 free_menu_coloring();
11571158 #endif
--- junnethack/trunk/src/pline.c (revision 409)
+++ junnethack/trunk/src/pline.c (revision 410)
@@ -30,6 +30,45 @@
3030 int lastmsg = -1;
3131 #endif
3232
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+
3372 /*VARARGS1*/
3473 /* Note that these declarations rely on knowledge of the internals
3574 * of the variable argument handling stuff in "tradstdc.h"
@@ -46,6 +85,8 @@
4685 VA_END();
4786 }
4887
88+char prevmsg[BUFSZ];
89+
4990 # ifdef USE_STDARG
5091 static void
5192 vpline(const char *line, va_list the_args) {
@@ -63,6 +104,7 @@
63104 #endif /* USE_STDARG | USE_VARARG */
64105
65106 char pbuf[BUFSZ];
107+ int typ;
66108 /* Do NOT use VA_START and VA_END in here... see above */
67109
68110 if (!line || !*line) return;
@@ -82,6 +124,7 @@
82124 }
83125 }
84126 #endif
127+ typ = msgpline_type(line);
85128 if (!iflags.window_inited) {
86129 raw_print(line);
87130 return;
@@ -92,7 +135,11 @@
92135 #endif /* MAC */
93136 if (vision_full_recalc) vision_recalc(0);
94137 if (u.ux) flush_screen(1); /* %% */
138+ if (typ == MSGTYP_NOSHOW) return;
139+ if (typ == MSGTYP_NOREP && !strcmp(line, prevmsg)) return;
95140 putstr(WIN_MESSAGE, 0, line);
141+ strncpy(prevmsg, line, BUFSZ);
142+ if (typ == MSGTYP_STOP) display_nhwindow(WIN_MESSAGE, TRUE); /* --more-- */
96143 }
97144
98145 /*VARARGS1*/
--- junnethack/trunk/ChangeLog (revision 409)
+++ junnethack/trunk/ChangeLog (revision 410)
@@ -5,6 +5,7 @@
55 * HTML dump: output IBMgraphics and DECgraphics characters
66
77 * patches:
8+ - MSGTYPE option (by Pasi Kallinen)
89 - Sortloot (by Jukka Lahtinen)
910
1011 * user interface improvements:
Show on old repository browser