Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/gomoku gomoku: make drawing the player's names simpler
details: https://anonhg.NetBSD.org/src/rev/dd0d1bf3d2de
branches: trunk
changeset: 366263:dd0d1bf3d2de
user: rillig <rillig%NetBSD.org@localhost>
date: Sat May 21 09:25:51 2022 +0000
description:
gomoku: make drawing the player's names simpler
No functional change.
diffstat:
games/gomoku/bdisp.c | 29 +++++++++++++----------------
games/gomoku/gomoku.h | 4 ++--
games/gomoku/main.c | 10 ++++++----
3 files changed, 21 insertions(+), 22 deletions(-)
diffs (128 lines):
diff -r 937888a665fa -r dd0d1bf3d2de games/gomoku/bdisp.c
--- a/games/gomoku/bdisp.c Sat May 21 06:22:49 2022 +0000
+++ b/games/gomoku/bdisp.c Sat May 21 09:25:51 2022 +0000
@@ -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 @@
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 @@
* 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;
-
- mvhline(BSZ + 2, 0, ' ', available);
+ int x;
- 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 @@
bw = remaining - ww;
else
bw = half, ww = remaining - half;
+ x = 0;
+ }
- mvprintw(BSZ + 2, 0, "BLACK/%.*s (*) vs. WHITE/%.*s (O)",
- bw, plyr[BLACK], ww, plyr[WHITE]);
- }
- if (update)
- refresh();
+ mvhline(BSZ + 2, 0, ' ', available);
+ mvprintw(BSZ + 2, x, "BLACK/%.*s (*) vs. WHITE/%.*s (O)",
+ bw, plyr[BLACK], ww, plyr[WHITE]);
}
/*
diff -r 937888a665fa -r dd0d1bf3d2de games/gomoku/gomoku.h
--- a/games/gomoku/gomoku.h Sat May 21 06:22:49 2022 +0000
+++ b/games/gomoku/gomoku.h Sat May 21 09:25:51 2022 +0000
@@ -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_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);
diff -r 937888a665fa -r dd0d1bf3d2de games/gomoku/main.c
--- a/games/gomoku/main.c Sat May 21 06:22:49 2022 +0000
+++ b/games/gomoku/main.c Sat May 21 09:25:51 2022 +0000
@@ -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 @@
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 @@
}
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 */
Home |
Main Index |
Thread Index |
Old Index