Subject: Re: /oC in BoH: explosion not in ^P

From: [email-masked] (Jay Tilton)
Date: Wed, 24 Oct 2001 03:43:42 GMT

On 19 Oct 2001 18:08:33 +0300, Jukka Lahtinen <[email-masked]> wrote:

[Synopsis: patching vanilla so all messages go to ^P history,
even after cancelling --More-- by pressing <ESC>.]

>Even if some interfaces don't use win/tty/topl.c, at least a patch done
>there will not harm those interfaces any way. 
>It just wouldn't affect them any way.
>
>So, just go ahead.

Fair enough.  Here's a diff.  It changes a couple of tests for
cancelled message window that would preclude all processing of a
new message, i.e. concatenating short lines, adding the old line
to the history, putting breaks in the new line, and finally
displaying the message.  The desired behavior would be to do all
that, but suppress the actual display if messages have been
cancelled, which the code takes care of already.

diff -auwr nethack-3.3.1-orig\win\tty\topl.c nethack-3.3.1-test\win\tty\topl.c
--- nethack-3.3.1-orig\win\tty\topl.c	Sun Jan 30 14:24:48 2000
+++ nethack-3.3.1-test\win\tty\topl.c	Sun Oct 21 16:53:40 2001
@@ -147,7 +147,8 @@
 	/* If there is room on the line, print message on same line */
 	/* But messages like "You die..." deserve their own line */
 	n0 = strlen(bp);
-	if(ttyDisplay->toplin == 1 && cw->cury == 0 &&
+	if(	(ttyDisplay->toplin == 1 || cw->flags & WIN_STOP) &&
+		cw->cury == 0 &&
 	    n0 + (int)strlen(toplines) + 3 < CO-8 &&  /* room for --More-- */
 	    (notdied = strncmp(bp, "You die", 7))) {
 		Strcat(toplines, "  ");
@@ -156,7 +157,8 @@
 		if(!(cw->flags & WIN_STOP))
 		    addtopl(bp);
 		return;
-	} else if(!(cw->flags & WIN_STOP)) {
+	}
+	if(!(cw->flags & WIN_STOP)) {
 	    if(ttyDisplay->toplin == 1) more();
 	    else if(cw->cury) {	/* for when flags.toplin == 2 && cury > 1 */
 		docorner(1, cw->cury+1); /* reset cury = 0 if redraw screen */
diff -auwr nethack-3.3.1-orig\win\tty\wintty.c nethack-3.3.1-test\win\tty\wintty.c
--- nethack-3.3.1-orig\win\tty\wintty.c	Fri Jul 21 20:59:28 2000
+++ nethack-3.3.1-test\win\tty\wintty.c	Sun Oct 21 16:52:52 2001
@@ -1703,8 +1703,10 @@
 	return;
     }
 
-    if(str == (const char*)0 || (cw->flags & WIN_CANCELLED))
-	return;
+    if( str == (const char*)0 ||
+        /* Ignore cancel for message, but not others */
+        ( (cw->flags & WIN_CANCELLED) && (cw->type != NHW_MESSAGE) )
+    ) return;
     if(cw->type != NHW_MESSAGE)
 	str = compress_str(str);

>With Pasi Kallinen's alternative tty_doprev_message in
>the same source file 

The one in the thread "tips for a Qt/X11 -> tty convert?"
that spews the whole message history to screen?

Pasi may not wish to accept blame for that one.  :) 

Especially since it introduces a bug that can adversely affect
gameplay, as well as a couple irritating glitches.  See my new
followup under that thread for the new fix.