Module Name: src Committed By: rillig Date: Sun May 29 21:02:37 UTC 2022
Modified Files: src/games/gomoku: main.c pickmove.c Log Message: gomoku: migrate remaining functions to type player_color No functional change. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/games/gomoku/main.c cvs rdiff -u -r1.64 -r1.65 src/games/gomoku/pickmove.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/main.c diff -u src/games/gomoku/main.c:1.72 src/games/gomoku/main.c:1.73 --- src/games/gomoku/main.c:1.72 Sun May 29 20:21:28 2022 +++ src/games/gomoku/main.c Sun May 29 21:02:37 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.72 2022/05/29 20:21:28 rillig Exp $ */ +/* $NetBSD: main.c,v 1.73 2022/05/29 21:02:37 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.72 2022/05/29 20:21:28 rillig Exp $"); +__RCSID("$NetBSD: main.c,v 1.73 2022/05/29 21:02:37 rillig Exp $"); #include <sys/stat.h> #include <curses.h> @@ -162,7 +162,7 @@ parse_args(int argc, char **argv) } static void -set_input_sources(enum input_source *input, int color) +set_input_sources(enum input_source *input, player_color color) { switch (test) { case NORMAL_PLAY: @@ -249,7 +249,7 @@ again: } static void -declare_winner(int outcome, const enum input_source *input, int color) +declare_winner(int outcome, const enum input_source *input, player_color color) { move(BSZ + 3, 0); @@ -275,7 +275,7 @@ declare_winner(int outcome, const enum i struct outcome { int result; - int winner; + player_color winner; }; static struct outcome Index: src/games/gomoku/pickmove.c diff -u src/games/gomoku/pickmove.c:1.64 src/games/gomoku/pickmove.c:1.65 --- src/games/gomoku/pickmove.c:1.64 Sun May 29 18:25:39 2022 +++ src/games/gomoku/pickmove.c Sun May 29 21:02:37 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: pickmove.c,v 1.64 2022/05/29 18:25:39 rillig Exp $ */ +/* $NetBSD: pickmove.c,v 1.65 2022/05/29 21:02:37 rillig Exp $ */ /* * Copyright (c) 1994 @@ -34,7 +34,7 @@ #include <sys/cdefs.h> /* @(#)pickmove.c 8.2 (Berkeley) 5/3/95 */ -__RCSID("$NetBSD: pickmove.c,v 1.64 2022/05/29 18:25:39 rillig Exp $"); +__RCSID("$NetBSD: pickmove.c,v 1.65 2022/05/29 21:02:37 rillig Exp $"); #include <stdlib.h> #include <string.h> @@ -69,12 +69,12 @@ static unsigned int tmpmap[MAPSZ]; /* ma static int nforce; /* count of opponent <1,x> combos */ static bool better(spot_index, spot_index, player_color); -static void scanframes(int); +static void scanframes(player_color); static void makecombo2(struct combostr *, struct spotstr *, u_char, u_short); static void addframes(unsigned int); static void makecombo(struct combostr *, struct spotstr *, u_char, u_short); -static void appendcombo(struct combostr *, int); -static void updatecombo(struct combostr *, int); +static void appendcombo(struct combostr *); +static void updatecombo(struct combostr *, player_color); static void makeempty(struct combostr *); static int checkframes(struct combostr *, struct combostr *, struct spotstr *, u_short, struct overlap_info *); @@ -223,11 +223,11 @@ better(spot_index s, spot_index s1, play return (random() & 1) != 0; } -static int curcolor; /* implicit parameter to makecombo() */ +static player_color curcolor; /* implicit parameter to makecombo() */ static unsigned int curlevel; /* implicit parameter to makecombo() */ static bool -four_in_a_row(int color, spot_index s, direction r) +four_in_a_row(player_color color, spot_index s, direction r) { struct spotstr *sp = &board[s]; @@ -250,7 +250,7 @@ four_in_a_row(int color, spot_index s, d * Also, try to combine frames to find more complex (chained) moves. */ static void -scanframes(int color) +scanframes(player_color color) { struct combostr *ecbp; struct spotstr *sp; @@ -530,7 +530,7 @@ makecombo2(struct combostr *ocbp, struct makeempty(ncbp); /* add the new combo to the end of the list */ - appendcombo(ncbp, curcolor); + appendcombo(ncbp); } else { updatecombo(ncbp, curcolor); free(ncbp); @@ -565,7 +565,7 @@ addframes(unsigned int level) curlevel = level; /* scan for combos at empty spots */ - int c = curcolor; + player_color c = curcolor; for (spot_index s = PT(BSZ, BSZ) + 1; s-- > PT(1, 1); ) { struct spotstr *sp = &board[s]; for (struct elist *ep = sp->s_empty; ep != NULL; ep = nep) { @@ -953,7 +953,7 @@ makeempty(struct combostr *ocbp) * would be trying to "complete" the combo or trying to block it. */ static void -updatecombo(struct combostr *cbp, int color) +updatecombo(struct combostr *cbp, player_color color) { struct combostr *tcbp; union comboval cb; @@ -1041,7 +1041,7 @@ updatecombo(struct combostr *cbp, int co * Add combo to the end of the list. */ static void -appendcombo(struct combostr *cbp, int color __unused) +appendcombo(struct combostr *cbp) { struct combostr *pcbp, *ncbp;