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 spot_index from int to unsigned...



details:   https://anonhg.NetBSD.org/src/rev/9f32625803f4
branches:  trunk
changeset: 366488:9f32625803f4
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun May 29 00:38:26 2022 +0000

description:
gomoku: migrate spot_index from int to unsigned short

This matches the type of 'intersect'.

No functional change.

diffstat:

 games/gomoku/bdinit.c   |   6 +++---
 games/gomoku/gomoku.h   |   9 +++++----
 games/gomoku/main.c     |   6 +++---
 games/gomoku/makemove.c |   6 +++---
 games/gomoku/pickmove.c |  39 +++++++++++++++++++--------------------
 5 files changed, 33 insertions(+), 33 deletions(-)

diffs (222 lines):

diff -r 3a9cae5fb563 -r 9f32625803f4 games/gomoku/bdinit.c
--- a/games/gomoku/bdinit.c     Sun May 29 00:12:11 2022 +0000
+++ b/games/gomoku/bdinit.c     Sun May 29 00:38:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bdinit.c,v 1.28 2022/05/29 00:12:11 rillig Exp $       */
+/*     $NetBSD: bdinit.c,v 1.29 2022/05/29 00:38:26 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.28 2022/05/29 00:12:11 rillig Exp $");
+__RCSID("$NetBSD: bdinit.c,v 1.29 2022/05/29 00:38:26 rillig Exp $");
 
 #include <string.h>
 #include "gomoku.h"
@@ -248,7 +248,7 @@
                                continue;
 
                        int fib = (int)(spb0->s_frame[rb] - frames);
-                       intersect[fia * FAREA + fib] = (short)s;
+                       intersect[fia * FAREA + fib] = s;
                        u_char *op = &overlap[fia * FAREA + fib];
                        *op = adjust_overlap(*op, ra, sia, rb, sib, mask);
                }
diff -r 3a9cae5fb563 -r 9f32625803f4 games/gomoku/gomoku.h
--- a/games/gomoku/gomoku.h     Sun May 29 00:12:11 2022 +0000
+++ b/games/gomoku/gomoku.h     Sun May 29 00:38:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gomoku.h,v 1.47 2022/05/29 00:12:11 rillig Exp $       */
+/*     $NetBSD: gomoku.h,v 1.48 2022/05/29 00:38:26 rillig Exp $       */
 
 /*
  * Copyright (c) 1994
@@ -59,8 +59,9 @@
 #define EMPTY  2
 #define BORDER 3
 
+/* A spot on the board, or in some cases one of the below special values. */
+typedef unsigned short spot_index;
 /* return values for makemove, readinput */
-typedef int spot_index;
 #define MOVEOK 0
 #define RESIGN 1
 #define ILLEGAL        2
@@ -232,7 +233,7 @@
 extern struct  combostr frames[FAREA];         /* storage for single frames */
 extern struct  combostr *sortframes[2];        /* sorted, non-empty frames */
 extern u_char  overlap[FAREA * FAREA];
-extern short   intersect[FAREA * FAREA];       /* frame [a][b] intersection */
+extern spot_index intersect[FAREA * FAREA];    /* frame [a][b] intersection */
 extern struct game     game;
 extern int     debug;
 
@@ -256,7 +257,7 @@
 void   whatsup(int);
 const char *stoc(spot_index);
 spot_index ctos(const char *);
-int    makemove(int, int);
+int    makemove(int, spot_index);
 void   clearcombo(struct combostr *, int);
 void   markcombo(struct combostr *);
 int    pickmove(int);
diff -r 3a9cae5fb563 -r 9f32625803f4 games/gomoku/main.c
--- a/games/gomoku/main.c       Sun May 29 00:12:11 2022 +0000
+++ b/games/gomoku/main.c       Sun May 29 00:38:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.67 2022/05/29 00:12:11 rillig Exp $ */
+/*     $NetBSD: main.c,v 1.68 2022/05/29 00:38:26 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.67 2022/05/29 00:12:11 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.68 2022/05/29 00:38:26 rillig Exp $");
 
 #include <sys/stat.h>
 #include <curses.h>
@@ -78,7 +78,7 @@
 struct combostr *sortframes[2];        /* sorted list of non-empty frames */
 u_char overlap[FAREA * FAREA];         /* non-zero if frame [a][b] overlap;
                                         * see init_overlap */
-short  intersect[FAREA * FAREA];       /* frame [a][b] intersection */
+spot_index intersect[FAREA * FAREA];   /* frame [a][b] intersection */
 struct game game;
 const char *plyr[2] = { "???", "???" };        /* who's who */
 
diff -r 3a9cae5fb563 -r 9f32625803f4 games/gomoku/makemove.c
--- a/games/gomoku/makemove.c   Sun May 29 00:12:11 2022 +0000
+++ b/games/gomoku/makemove.c   Sun May 29 00:38:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: makemove.c,v 1.33 2022/05/28 08:32:55 rillig Exp $     */
+/*     $NetBSD: makemove.c,v 1.34 2022/05/29 00:38:26 rillig Exp $     */
 
 /*
  * Copyright (c) 1994
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 /*     @(#)makemove.c  8.2 (Berkeley) 5/3/95   */
-__RCSID("$NetBSD: makemove.c,v 1.33 2022/05/28 08:32:55 rillig Exp $");
+__RCSID("$NetBSD: makemove.c,v 1.34 2022/05/29 00:38:26 rillig Exp $");
 
 #include "gomoku.h"
 
@@ -97,7 +97,7 @@
  *     TIE     The game is a tie.
  */
 int
-makemove(int us, int mv)
+makemove(int us, spot_index mv)
 {
 
        /* check for end of game */
diff -r 3a9cae5fb563 -r 9f32625803f4 games/gomoku/pickmove.c
--- a/games/gomoku/pickmove.c   Sun May 29 00:12:11 2022 +0000
+++ b/games/gomoku/pickmove.c   Sun May 29 00:38:26 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pickmove.c,v 1.49 2022/05/29 00:12:11 rillig Exp $     */
+/*     $NetBSD: pickmove.c,v 1.50 2022/05/29 00:38:26 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.49 2022/05/29 00:12:11 rillig Exp $");
+__RCSID("$NetBSD: pickmove.c,v 1.50 2022/05/29 00:38:26 rillig Exp $");
 
 #include <stdlib.h>
 #include <string.h>
@@ -1078,7 +1078,6 @@
        int i, n, mask, flags, verts, myindex, fcnt;
        union comboval cb;
        u_char *str;
-       short *ip;
 
        lcbp = NULL;
        flags = 0;
@@ -1089,7 +1088,7 @@
        myindex = cbp->c_nframes;
        n = (int)(fcbp - frames) * FAREA;
        str = &overlap[n];
-       ip = &intersect[n];
+       spot_index *ip = &intersect[n];
        /*
         * i == which overlap bit to test based on whether 'fcbp' is
         * an open or closed frame.
@@ -1119,8 +1118,8 @@
                         * 'fcbp' to, and it is a reasonable intersection
                         * spot, then there might be a loop.
                         */
-                       n = ip[tcbp - frames];
-                       if (osp != &board[n]) {
+                       spot_index s = ip[tcbp - frames];
+                       if (osp != &board[s]) {
                                /* check to see if this is a valid loop */
                                if (verts != 0)
                                        return -1;
@@ -1132,16 +1131,16 @@
                                 * open-ended frame.
                                 */
                                if ((flags & C_OPEN_1) != 0 &&
-                                   (n == tcbp->c_vertex ||
-                                    n == tcbp->c_vertex + 5 * dd[tcbp->c_dir]))
+                                   (s == tcbp->c_vertex ||
+                                    s == tcbp->c_vertex + 5 * dd[tcbp->c_dir]))
                                        return -1;      /* invalid overlap */
                                if (cb.cv_win != 0 &&
-                                   (n == fcbp->c_vertex ||
-                                    n == fcbp->c_vertex + 5 * dd[fcbp->c_dir]))
+                                   (s == fcbp->c_vertex ||
+                                    s == fcbp->c_vertex + 5 * dd[fcbp->c_dir]))
                                        return -1;      /* invalid overlap */
 
-                               vertices->o_intersect = n;
-                               vertices->o_off = (n - tcbp->c_vertex) /
+                               vertices->o_intersect = s;
+                               vertices->o_off = (s - tcbp->c_vertex) /
                                        dd[tcbp->c_dir];
                                vertices->o_frameindex = myindex;
                                verts++;
@@ -1167,8 +1166,8 @@
                 * 'fcbp' to, and it is a reasonable intersection
                 * spot, then there might be a loop.
                 */
-               n = ip[cbp - frames];
-               if (osp != &board[n]) {
+               spot_index s = ip[cbp - frames];
+               if (osp != &board[s]) {
                        /* check to see if this is a valid loop */
                        if (verts != 0)
                                return -1;
@@ -1180,16 +1179,16 @@
                         * frame.
                         */
                        if ((flags & C_OPEN_0) != 0 &&
-                           (n == cbp->c_vertex ||
-                            n == cbp->c_vertex + 5 * dd[cbp->c_dir]))
+                           (s == cbp->c_vertex ||
+                            s == cbp->c_vertex + 5 * dd[cbp->c_dir]))
                                return -1;      /* invalid overlap */
                        if (cb.cv_win != 0 &&
-                           (n == fcbp->c_vertex ||
-                            n == fcbp->c_vertex + 5 * dd[fcbp->c_dir]))
+                           (s == fcbp->c_vertex ||
+                            s == fcbp->c_vertex + 5 * dd[fcbp->c_dir]))
                                return -1;      /* invalid overlap */
 
-                       vertices->o_intersect = n;
-                       vertices->o_off = (n - cbp->c_vertex) /
+                       vertices->o_intersect = s;
+                       vertices->o_off = (s - cbp->c_vertex) /
                                dd[cbp->c_dir];
                        vertices->o_frameindex = 0;
                        verts++;



Home | Main Index | Thread Index | Old Index