From 41ea0dbfd0fa937c96c965324e8f01aa9864130e Mon Sep 17 00:00:00 2001 From: dholland Date: Sun, 12 Jul 2020 02:34:54 +0000 Subject: Avoid messing up the display when too many letters are guessed at once. The field to put them in was made 26 characters wide... but includes the string "Guessed: ". So if you get to 17 it wraps to the next line and clreol()'s it. Instead, when reaching this point step on the "Guessed:" string instead. Reported by phil@. --- hangman/prdata.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hangman/prdata.c b/hangman/prdata.c index 5ade009f..279e41ad 100644 --- a/hangman/prdata.c +++ b/hangman/prdata.c @@ -1,4 +1,4 @@ -/* $NetBSD: prdata.c,v 1.7 2012/10/13 21:03:09 dholland Exp $ */ +/* $NetBSD: prdata.c,v 1.8 2020/07/12 02:34:54 dholland Exp $ */ /*- * Copyright (c) 1983, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)prdata.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: prdata.c,v 1.7 2012/10/13 21:03:09 dholland Exp $"); +__RCSID("$NetBSD: prdata.c,v 1.8 2020/07/12 02:34:54 dholland Exp $"); #endif #endif /* not lint */ @@ -47,9 +47,17 @@ __RCSID("$NetBSD: prdata.c,v 1.7 2012/10/13 21:03:09 dholland Exp $"); void prdata(void) { - int i; + int i, n, l; - move(GUESSY, GUESSX + sizeof "Guessed: "); + for (i = n = 0; i < 26; i++) + if (Guessed[i]) + n++; + + move(GUESSY, GUESSX); + l = sizeof "Guessed: "; + if (GUESSX + l + n < COLS) { + addstr("Guessed: "); + } for (i = 0; i < 26; i++) if (Guessed[i]) addch(i + 'a'); -- cgit v1.2.3-56-ge451