Module Name: src Committed By: rillig Date: Sun May 29 16:30:44 UTC 2022
Modified Files: src/games/gomoku: bdinit.c bdisp.c gomoku.h Log Message: gomoku: when starting a new game, start in the middle of the board Previously, when starting a new game, the user coordinate was kept at the previously selected spot. Since playing in the center is common sense, reset the coordinate. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/games/gomoku/bdinit.c cvs rdiff -u -r1.53 -r1.54 src/games/gomoku/bdisp.c src/games/gomoku/gomoku.h 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/bdinit.c diff -u src/games/gomoku/bdinit.c:1.34 src/games/gomoku/bdinit.c:1.35 --- src/games/gomoku/bdinit.c:1.34 Sun May 29 14:37:44 2022 +++ src/games/gomoku/bdinit.c Sun May 29 16:30:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bdinit.c,v 1.34 2022/05/29 14:37:44 rillig Exp $ */ +/* $NetBSD: bdinit.c,v 1.35 2022/05/29 16:30:44 rillig Exp $ */ /* * Copyright (c) 1994 @@ -34,7 +34,7 @@ #include <sys/cdefs.h> /* from: @(#)bdinit.c 8.2 (Berkeley) 5/3/95 */ -__RCSID("$NetBSD: bdinit.c,v 1.34 2022/05/29 14:37:44 rillig Exp $"); +__RCSID("$NetBSD: bdinit.c,v 1.35 2022/05/29 16:30:44 rillig Exp $"); #include <string.h> #include "gomoku.h" @@ -130,6 +130,8 @@ init_board(void) game.nmoves = 0; game.win_spot = 0; + game.user_x = 1 + (BSZ - 1) / 2; + game.user_y = 1 + (BSZ - 1) / 2; struct spotstr *sp = board; for (int i = 0; i < 1 + BSZ + 1; i++, sp++) { Index: src/games/gomoku/bdisp.c diff -u src/games/gomoku/bdisp.c:1.53 src/games/gomoku/bdisp.c:1.54 --- src/games/gomoku/bdisp.c:1.53 Sun May 29 16:19:52 2022 +++ src/games/gomoku/bdisp.c Sun May 29 16:30:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bdisp.c,v 1.53 2022/05/29 16:19:52 rillig Exp $ */ +/* $NetBSD: bdisp.c,v 1.54 2022/05/29 16:30:44 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.53 2022/05/29 16:19:52 rillig Exp $"); +__RCSID("$NetBSD: bdisp.c,v 1.54 2022/05/29 16:30:44 rillig Exp $"); #include <curses.h> #include <string.h> @@ -355,8 +355,7 @@ get_coord_mouse(int *x, int *y) int get_coord(void) { - static int x = 1 + (BSZ - 1) / 2; - static int y = 1 + (BSZ - 1) / 2; + int x = game.user_x, y = game.user_y; move(scr_y(y), scr_x(x)); refresh(); @@ -457,6 +456,8 @@ get_coord(void) case '\r': selected: (void)mvhline(BSZ + 3, 6, ' ', 6); + game.user_x = x; + game.user_y = y; return PT(x, y); } Index: src/games/gomoku/gomoku.h diff -u src/games/gomoku/gomoku.h:1.53 src/games/gomoku/gomoku.h:1.54 --- src/games/gomoku/gomoku.h:1.53 Sun May 29 15:31:12 2022 +++ src/games/gomoku/gomoku.h Sun May 29 16:30:44 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: gomoku.h,v 1.53 2022/05/29 15:31:12 rillig Exp $ */ +/* $NetBSD: gomoku.h,v 1.54 2022/05/29 16:30:44 rillig Exp $ */ /* * Copyright (c) 1994 @@ -236,6 +236,8 @@ struct game { spot_index moves[BSZ * BSZ]; /* log of all played moves */ spot_index win_spot; /* the winning move, or 0 */ direction win_dir; + int user_x; + int user_y; }; extern const char letters[];