Module Name:    src
Committed By:   rillig
Date:           Sat May 21 09:25:51 UTC 2022

Modified Files:
        src/games/gomoku: bdisp.c gomoku.h main.c

Log Message:
gomoku: make drawing the player's names simpler

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/games/gomoku/bdisp.c
cvs rdiff -u -r1.31 -r1.32 src/games/gomoku/gomoku.h
cvs rdiff -u -r1.42 -r1.43 src/games/gomoku/main.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/gomoku/bdisp.c
diff -u src/games/gomoku/bdisp.c:1.36 src/games/gomoku/bdisp.c:1.37
--- src/games/gomoku/bdisp.c:1.36	Thu May 19 22:49:05 2022
+++ src/games/gomoku/bdisp.c	Sat May 21 09:25:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdisp.c,v 1.36 2022/05/19 22:49:05 rillig Exp $	*/
+/*	$NetBSD: bdisp.c,v 1.37 2022/05/21 09:25:51 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 /*	@(#)bdisp.c	8.2 (Berkeley) 5/3/95	*/
-__RCSID("$NetBSD: bdisp.c,v 1.36 2022/05/19 22:49:05 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.37 2022/05/21 09:25:51 rillig Exp $");
 
 #include <curses.h>
 #include <string.h>
@@ -109,7 +109,7 @@ bdisp_init(void)
 		mvprintw(scr_y(j), scr_x(BSZ) + 2, "%d ", j);
 	}
 
-	bdwho(false);
+	bdwho();
 	mvaddstr(0, TRANSCRIPT_COL + 1, "#  black  white");
 	lastline = 0;
 	bdisp();
@@ -119,21 +119,18 @@ bdisp_init(void)
  * Update who is playing whom.
  */
 void
-bdwho(bool update)
+bdwho(void)
 {
 	int bw = (int)strlen(plyr[BLACK]);
 	int ww = (int)strlen(plyr[WHITE]);
 	int available = 3 + (1 + scr_x(BSZ) - scr_x(1)) + 3;
 	int fixed = (int)sizeof("BLACK/ (*) vs. WHITE/ (O)") - 1;
 	int total = fixed + bw + ww;
+	int x;
 
-	mvhline(BSZ + 2, 0, ' ', available);
-
-	if (total <= available) {
-		mvprintw(BSZ + 2, (available - total) / 2,
-		    "BLACK/%s (*) vs. WHITE/%s (O)",
-		    plyr[BLACK], plyr[WHITE]);
-	} else {
+	if (total <= available)
+		x = (available - total) / 2;
+	else {
 		int remaining = available - fixed;
 		int half = remaining / 2;
 
@@ -143,12 +140,12 @@ bdwho(bool update)
 			bw = remaining - ww;
 		else
 			bw = half, ww = remaining - half;
-
-		mvprintw(BSZ + 2, 0, "BLACK/%.*s (*) vs. WHITE/%.*s (O)",
-		    bw, plyr[BLACK], ww, plyr[WHITE]);
+		x = 0;
 	}
-	if (update)
-		refresh();
+
+	mvhline(BSZ + 2, 0, ' ', available);
+	mvprintw(BSZ + 2, x, "BLACK/%.*s (*) vs. WHITE/%.*s (O)",
+	    bw, plyr[BLACK], ww, plyr[WHITE]);
 }
 
 /*

Index: src/games/gomoku/gomoku.h
diff -u src/games/gomoku/gomoku.h:1.31 src/games/gomoku/gomoku.h:1.32
--- src/games/gomoku/gomoku.h:1.31	Fri May 20 19:30:17 2022
+++ src/games/gomoku/gomoku.h	Sat May 21 09:25:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: gomoku.h,v 1.31 2022/05/20 19:30:17 rillig Exp $	*/
+/*	$NetBSD: gomoku.h,v 1.32 2022/05/21 09:25:51 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -237,7 +237,7 @@ void	bdisp(void);
 void	bdisp_init(void);
 void	cursfini(void);
 void	cursinit(void);
-void	bdwho(bool);
+void	bdwho(void);
 void	panic(const char *, ...) __printflike(1, 2) __dead;
 void	debuglog(const char *, ...) __printflike(1, 2);
 void	whatsup(int);

Index: src/games/gomoku/main.c
diff -u src/games/gomoku/main.c:1.42 src/games/gomoku/main.c:1.43
--- src/games/gomoku/main.c:1.42	Thu May 19 22:49:05 2022
+++ src/games/gomoku/main.c	Sat May 21 09:25:51 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.42 2022/05/19 22:49:05 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.43 2022/05/21 09:25:51 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -36,7 +36,7 @@
 __COPYRIGHT("@(#) Copyright (c) 1994\
  The Regents of the University of California.  All rights reserved.");
 /*	@(#)main.c	8.4 (Berkeley) 5/4/95	*/
-__RCSID("$NetBSD: main.c,v 1.42 2022/05/19 22:49:05 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.43 2022/05/21 09:25:51 rillig Exp $");
 
 #include <curses.h>
 #include <err.h>
@@ -215,7 +215,8 @@ again:
 	if (interactive) {
 		plyr[BLACK] = input[BLACK] == USER ? user : prog;
 		plyr[WHITE] = input[WHITE] == USER ? user : prog;
-		bdwho(true);
+		bdwho();
+		refresh();
 	}
 
 	for (color = BLACK; ; color = color != BLACK ? BLACK : WHITE) {
@@ -244,7 +245,8 @@ again:
 			}
 			plyr[BLACK] = input[BLACK] == USER ? user : prog;
 			plyr[WHITE] = input[WHITE] == USER ? user : prog;
-			bdwho(true);
+			bdwho();
+			refresh();
 			goto top;
 
 		case USER: /* input comes from standard input */

Reply via email to