gomoku: convert input source constants to an enum
I also tried converting other macros, but s_occ would use more memory and the return values for makemove are special values, besides the usual coordinates in the form PT(x, y), so turning the special values into an enum would be confusing. No functional change.
This commit is contained in:
parent
7e168a678f
commit
1425a8ae20
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.9 2022/05/16 21:48:45 rillig Exp $
|
||||
# $NetBSD: Makefile,v 1.10 2022/05/21 14:55:26 rillig Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 7/24/94
|
||||
|
||||
PROG= gomoku
|
||||
|
@ -11,5 +11,6 @@ CPPFLAGS+= ${DEBUG:D-DDEBUG}
|
|||
|
||||
LINTFLAGS+= -w # treat warnings as errors
|
||||
LINTFLAGS+= -T # strict bool mode
|
||||
LINTFLAGS+= -e # strict enum checks
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: gomoku.h,v 1.33 2022/05/21 12:29:34 rillig Exp $ */
|
||||
/* $NetBSD: gomoku.h,v 1.34 2022/05/21 14:55:26 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994
|
||||
|
@ -59,14 +59,13 @@
|
|||
#define EMPTY 2
|
||||
#define BORDER 3
|
||||
|
||||
/* return values for makemove() */
|
||||
/* return values for makemove, readinput */
|
||||
#define MOVEOK 0
|
||||
#define RESIGN 1
|
||||
#define ILLEGAL 2
|
||||
#define WIN 3
|
||||
#define TIE 4
|
||||
#define SAVE 5
|
||||
|
||||
#define PT(x, y) ((x) + (BSZ + 1) * (y))
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: main.c,v 1.46 2022/05/21 14:23:10 rillig Exp $ */
|
||||
/* $NetBSD: main.c,v 1.47 2022/05/21 14:55: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.46 2022/05/21 14:23:10 rillig Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.47 2022/05/21 14:55:26 rillig Exp $");
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <curses.h>
|
||||
|
@ -51,9 +51,11 @@ __RCSID("$NetBSD: main.c,v 1.46 2022/05/21 14:23:10 rillig Exp $");
|
|||
|
||||
#include "gomoku.h"
|
||||
|
||||
#define USER 0 /* get input from standard input */
|
||||
#define PROGRAM 1 /* get input from program */
|
||||
#define INPUTF 2 /* get input from a file */
|
||||
enum input_source {
|
||||
USER, /* get input from standard input */
|
||||
PROGRAM, /* get input from program */
|
||||
INPUTF /* get input from a file */
|
||||
};
|
||||
|
||||
bool interactive = true; /* true if interactive */
|
||||
int debug; /* > 0 if debugging */
|
||||
|
@ -102,7 +104,7 @@ main(int argc, char **argv)
|
|||
char fname[PATH_MAX];
|
||||
char *user_name;
|
||||
int color, curmove, i, ch;
|
||||
int input[2];
|
||||
enum input_source input[2];
|
||||
|
||||
/* Revoke setgid privileges */
|
||||
setgid(getgid());
|
||||
|
@ -235,6 +237,7 @@ again:
|
|||
curmove = readinput(inputfp);
|
||||
if (curmove != ILLEGAL)
|
||||
break;
|
||||
/* Switch to another input source. */
|
||||
switch (test) {
|
||||
case 0: /* user versus program */
|
||||
input[color] = USER;
|
||||
|
|
Loading…
Reference in New Issue