From tiltonj@erols.com Wed Oct 24 13:51:42 2001
Path: ulcc.ac.uk!server3.netnews.ja.net!newspeer.clara.net!news.clara.net!feed2.onemain.com!feed1.onemain.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed2.news.rcn.net!feed1.news.rcn.net!rcn!not-for-mail
From: tiltonj@erols.com (Jay Tilton)
Newsgroups: rec.games.roguelike.nethack
Subject: Re: tips for a Qt/X11 -> tty convert? also a few tty YANIs
Date: Wed, 24 Oct 2001 03:40:25 GMT
Organization: none yet
Lines: 126
Message-ID: <3bd63825.336363608@news.erols.com>
References: <87g08jpsw8.fsf@dgp.toronto.edu> <9qhl3g$7b6$1@cc.joensuu.fi> <3bccb9fe.297539352@news.erols.com>
X-Trace: UmFuZG9tSVakE3BOa/1epprNODvmql9ZcdUwR4KB0w4wLRw8OTsZ8sM2pJ7xR0as
X-Complaints-To: abuse@rcn.com
NNTP-Posting-Date: 24 Oct 2001 03:40:51 GMT
X-Newsreader:  Forte Free Agent 1.21/32.243
Xref: ulcc.ac.uk rec.games.roguelike.nethack:149975

On Tue, 16 Oct 2001 23:10:45 GMT, tiltonj@erols.com (Jay Tilton) wrote:

[Synopsis: replacing tty_doprev_message() in win/tty/topl.c so 
entire message history is displayed, instead of backpedalling 
through it one line at a time.]

That mod needs a few more things.

1. Make tty_doprev_message() explicitly return 0.  Evidently, a 
   non-zero return indicates the player performed some time-
   consuming action, so there was a chance baddies would get a 
   turn to do things when the player reviews the message history.  
   That is definitely not kosher.

2. Doctor up a couple of code segments where the player is 
   allowed to review the message history while the game is 
   waiting for a question to be answered.  Left unchanged, the
   history gets displayed twice.

Here's a diff including all the changes.

diff -auwr nethack-3.3.1-orig\win\tty\getline.c nethack-3.3.1-test\win\tty\getline.c
--- nethack-3.3.1-orig\win\tty\getline.c	Fri Aug 04 20:29:16 2000
+++ nethack-3.3.1-test\win\tty\getline.c	Sun Oct 21 15:42:48 2001
@@ -46,7 +46,6 @@
 	register char *obufp = bufp;
 	register int c;
 	struct WinDesc *cw = wins[WIN_MESSAGE];
-	boolean doprev = 0;
 
 	if(ttyDisplay->toplin == 1 && !(cw->flags & WIN_STOP)) more();
 	cw->flags &= ~WIN_STOP;
@@ -72,15 +71,9 @@
 		    *bufp = 0;
 		}
 		if(c == '\020') { /* ctrl-P */
-		    if(!doprev)
-			(void) tty_doprev_message(); /* need two initially */
 		    (void) tty_doprev_message();
-		    doprev = 1;
-		    continue;
-		} else if(doprev) {
 		    tty_clear_nhwindow(WIN_MESSAGE);
 		    cw->maxcol = cw->maxrow;
-		    doprev = 0;
 		    addtopl(query);
 		    addtopl(" ");
 		    *bufp = 0;
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 15:42:48 2001
@@ -24,21 +24,21 @@
 int
 tty_doprev_message()
 {
+	winid prevmsg_win;
     register struct WinDesc *cw = wins[WIN_MESSAGE];
-
-    ttyDisplay->dismiss_more = C('p');	/* <ctrl/P> allowed at --More-- */
+	int i;
+	prevmsg_win = create_nhwindow(NHW_MENU);
+	putstr(prevmsg_win, 0, "Message History");
+	putstr(prevmsg_win, 0, "");
+	i = cw->maxcol;
     do {
-	morc = 0;
-	if (cw->maxcol == cw->maxrow)
-	    redotoplin(toplines);
-	else if (cw->data[cw->maxcol])
-	    redotoplin(cw->data[cw->maxcol]);
-	cw->maxcol--;
-	if (cw->maxcol < 0) cw->maxcol = cw->rows-1;
-	if (!cw->data[cw->maxcol])
-	    cw->maxcol = cw->maxrow;
-    } while (morc == C('p'));
-    ttyDisplay->dismiss_more = 0;
+		if(cw->data[i] && strcmp(cw->data[i], "") )
+			putstr(prevmsg_win, 0, cw->data[i]);
+		i = (i + 1) % cw->rows;
+	} while (i != cw->maxcol);
+	putstr(prevmsg_win, 0, toplines);
+	display_nhwindow(prevmsg_win, TRUE);
+	destroy_nhwindow(prevmsg_win);
     return 0;
 }
 
@@ -253,7 +253,6 @@
 	char rtmp[40];
 	boolean digit_ok, allow_num;
 	struct WinDesc *cw = wins[WIN_MESSAGE];
-	boolean doprev = 0;
 	char prompt[QBUFSZ];
 
 	if(ttyDisplay->toplin == 1 && !(cw->flags & WIN_STOP)) more();
@@ -279,18 +278,9 @@
 	do {	/* loop until we get valid input */
 	    q = lowc(readchar());
 	    if (q == '\020') { /* ctrl-P */
-		if(!doprev) (void) tty_doprev_message(); /* need two initially */
 		(void) tty_doprev_message();
-		doprev = 1;
-		q = '\0';	/* force another loop iteration */
-		continue;
-	    } else if (doprev) {
-		/* BUG[?]: this probably ought to check whether the
-		   character which has just been read is an acceptable
-		   response; if so, skip the reprompt and use it. */
 		tty_clear_nhwindow(WIN_MESSAGE);
 		cw->maxcol = cw->maxrow;
-		doprev = 0;
 		addtopl(prompt);
 		q = '\0';	/* force another loop iteration */
 		continue;
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:08:36 2001
@@ -2182,8 +2182,6 @@
 	} else if(ttyDisplay->inread) {
 	    /* this can only happen if we were reading and got interrupted */
 	    ttyDisplay->toplin = 3;
-	    /* do this twice; 1st time gets the Quit? message again */
-	    (void) tty_doprev_message();
 	    (void) tty_doprev_message();
 	    ttyDisplay->intr++;
 	    (void) fflush(stdout);


