]> granicus.if.org Git - nethack/commitdiff
putmsghistory() (trunk only)
authornethack.rankin <nethack.rankin>
Mon, 6 Apr 2009 01:43:01 +0000 (01:43 +0000)
committernethack.rankin <nethack.rankin>
Mon, 6 Apr 2009 01:43:01 +0000 (01:43 +0000)
[Third of three message history patches.]

     Add another argument to putmsghistory() so that it can tell whether
it's processing multiple messages for restore (which should be treated as
being older than any current messages) or a single message to stuff into
history (which should be treated as the most recent message even though
it hasn't been displayed in the message window).

include/extern.h
include/winprocs.h
include/wintty.h
src/restore.c
src/windows.c
win/tty/topl.c
win/win32/mswproc.c
win/win32/winMS.h

index ce93bc144d8a68655fa94a536004b3af3f1d56d7..089d1efaef00c3d25ec36ab92e55aeb9b92c9274 100644 (file)
@@ -2572,7 +2572,7 @@ E void FDECL(choose_windows, (const char *));
 E char FDECL(genl_message_menu, (CHAR_P,int,const char *));
 E void FDECL(genl_preference_update, (const char *));
 E char *FDECL(genl_getmsghistory, (BOOLEAN_P));
-E void FDECL(genl_putmsghistory, (const char *));
+E void FDECL(genl_putmsghistory, (const char *,BOOLEAN_P));
 #ifdef HANGUPHANDLING
 E void NDECL(nhwindows_hangup);
 #endif
index 2623abaa7a0752d566836df1507726c7fe73d628..612daa588884df5cacc37691a50edd88297b8ac8 100644 (file)
@@ -69,7 +69,7 @@ struct window_procs {
     void FDECL((*win_outrip), (winid,int));
     void FDECL((*win_preference_update), (const char *));
     char * FDECL((*win_getmsghistory), (BOOLEAN_P));
-    void FDECL((*win_putmsghistory), (const char *));
+    void FDECL((*win_putmsghistory), (const char *,BOOLEAN_P));
 #ifdef STATUS_VIA_WINDOWPORT
     void NDECL((*win_status_init));
     void NDECL((*win_status_finish));
index 34cd1050c85c9f018c8f17d2e41c3ff4b5103117..cd83e3aa725b93eb820738ba06d8909cf12ebfe8 100644 (file)
@@ -229,7 +229,7 @@ E void NDECL(tty_end_screen);
 E void FDECL(genl_outrip, (winid,int));
 
 E char *FDECL(tty_getmsghistory, (BOOLEAN_P));
-E void FDECL(tty_putmsghistory, (const char *));
+E void FDECL(tty_putmsghistory, (const char *,BOOLEAN_P));
 
 
 #ifdef NO_TERMS
index b4153924ee36b0526311116fc0b4277ac85df1e6..8b823ccbc8fd27c9dd5bd23c923432b654cce332 100644 (file)
@@ -1152,10 +1152,10 @@ register int fd;
                        panic("restore_msghistory: msg too big (%d)", msgsize);
                mread(fd, (genericptr_t)msg, msgsize);
                msg[msgsize] = '\0';
-               putmsghistory(msg);
+               putmsghistory(msg, TRUE);
                ++msgcount;
        }
-       if (msgcount) putmsghistory((char *)0);
+       if (msgcount) putmsghistory((char *)0, TRUE);
 #ifdef DEBUG_MSGCOUNT
        pline("Read %d messages from savefile.", msgcount);
 #endif
index 4b490d22de8fcbb242489179f4c0b04174607261..1bc872fe96aa5458f8838161d8d85079896f4f88 100644 (file)
@@ -177,8 +177,9 @@ boolean init;
 
 /*ARGSUSED*/
 void
-genl_putmsghistory(msg)
+genl_putmsghistory(msg, restoring)
 const char *msg;
+boolean restoring;
 {
        /* window ports can provide
           their own putmsghistory() routine to
@@ -197,6 +198,9 @@ const char *msg;
           so it should keep all pointers/indexes
           intact at the end of each call.
         */
+#if 0          /* maybe... */
+       if (!restoring) pline("%s", msg);
+#endif
        return;
 }
 
@@ -387,7 +391,7 @@ char *outbuf;
     Strcpy(outbuf, "\033");
 }
 
-/*ARGUSED*/
+/*ARGSUSED*/
 static void
 hup_init_nhwindows(argc_p, argv)
 int *argc_p;
@@ -396,7 +400,7 @@ char **argv;
     iflags.window_inited = 1;
 }
 
-/*ARGSUSED*/
+/*ARGUSED*/
 static winid
 hup_create_nhwindow(type)
 int type;
index 35d9f79baa5cff639ceee7b4853a0572fe66e45b..ff53200dfb8bc14f4c4faffd39ccd77db4ad8896 100644 (file)
@@ -704,13 +704,14 @@ boolean init;
  * Called with a null pointer to finish up.
  */
 void
-tty_putmsghistory(msg)
+tty_putmsghistory(msg, restoring)
 const char *msg;
+boolean restoring;
 {
     static boolean initd = FALSE;
     int idx;
 
-    if (!initd) {
+    if (restoring && !initd) {
        /* we're restoring history from the previous session, but new
           messages have already been issued this session ("Restoring...",
           for instance); collect current history (ie, those new messages),
index dc2c5c35bbfe6ee2a4740388878133294027dea9..328dc0be6ce9724cbc870049a882ebe20da05877 100644 (file)
@@ -1980,9 +1980,12 @@ char *mswin_getmsghistory(BOOLEAN_P init)
        }
 }
 
-void mswin_putmsghistory(const char * msg)
+void mswin_putmsghistory(const char * msg, BOOLEAN_P restoring)
 {
-       BOOL save_sound_opt = GetNHApp()->bNoSounds;
+       BOOL save_sound_opt;
+
+       if (!msg) return;       /* end of message history restore */
+       save_sound_opt = GetNHApp()->bNoSounds;
        GetNHApp()->bNoSounds = TRUE;   /* disable sounds while restoring message history */
        mswin_putstr_ex(WIN_MESSAGE, ATR_NONE, msg, 0);
        clear_nhwindow(WIN_MESSAGE); /* it is in fact end-of-turn indication so each message will print on the new line */
index 04b42beb549762142dfca49b1f8676e6e3661e66..6fa9af430a0813643e34821376b289f6b3655abb 100644 (file)
@@ -160,7 +160,7 @@ void mswin_end_screen(void);
 void mswin_outrip(winid wid, int how);
 void mswin_preference_update(const char *pref);
 char *mswin_getmsghistory(BOOLEAN_P init);
-void mswin_putmsghistory(const char * msg);
+void mswin_putmsghistory(const char * msg,BOOLEAN_P);
 
 /* helper function */
 HWND mswin_hwnd_from_winid(winid wid);