Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/gomoku gomoku: migrate remaining functions to type pla...



details:   https://anonhg.NetBSD.org/src/rev/43cc788517b5
branches:  trunk
changeset: 366529:43cc788517b5
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun May 29 21:02:37 2022 +0000

description:
gomoku: migrate remaining functions to type player_color

No functional change.

diffstat:

 games/gomoku/main.c     |  10 +++++-----
 games/gomoku/pickmove.c |  24 ++++++++++++------------
 2 files changed, 17 insertions(+), 17 deletions(-)

diffs (138 lines):

diff -r 9dadb26e2146 -r 43cc788517b5 games/gomoku/main.c
--- a/games/gomoku/main.c       Sun May 29 20:21:28 2022 +0000
+++ b/games/gomoku/main.c       Sun May 29 21:02:37 2022 +0000
@@ -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 @@
 }
 
 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 @@
 }
 
 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 @@
 
 struct outcome {
        int result;
-       int winner;
+       player_color winner;
 };
 
 static struct outcome
diff -r 9dadb26e2146 -r 43cc788517b5 games/gomoku/pickmove.c
--- a/games/gomoku/pickmove.c   Sun May 29 20:21:28 2022 +0000
+++ b/games/gomoku/pickmove.c   Sun May 29 21:02:37 2022 +0000
@@ -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 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 @@
        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 @@
  * 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 @@
                    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 @@
        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 @@
  * 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 @@
  * 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;
 



Home | Main Index | Thread Index | Old Index