summaryrefslogtreecommitdiffstats
path: root/games/backgammon
diff options
context:
space:
mode:
authorsteve <steve@FreeBSD.org>1999-04-19 03:59:02 +0000
committersteve <steve@FreeBSD.org>1999-04-19 03:59:02 +0000
commitd59a3ca336bac3dac6ad8918ff6cb28fcbbba718 (patch)
treec2b57d23128f242645f8e3e16274a587229383ec /games/backgammon
parent390eb1b3d201760a5e8b76e2431c1f667648718f (diff)
downloadFreeBSD-src-d59a3ca336bac3dac6ad8918ff6cb28fcbbba718.zip
FreeBSD-src-d59a3ca336bac3dac6ad8918ff6cb28fcbbba718.tar.gz
Merge a bunch of cleanups from NetBSD.
PR: 8083 Submitted by: Stephen J. Roznowski <sjr@home.net> Obtained from: a whole slew of NetBSD PRs
Diffstat (limited to 'games/backgammon')
-rw-r--r--games/backgammon/backgammon/backgammon.62
-rw-r--r--games/backgammon/backgammon/main.c78
-rw-r--r--games/backgammon/backgammon/text.c7
-rw-r--r--games/backgammon/backgammon/version.c2
-rw-r--r--games/backgammon/common_source/back.h102
-rw-r--r--games/backgammon/common_source/board.c4
-rw-r--r--games/backgammon/common_source/fancy.c8
-rw-r--r--games/backgammon/common_source/init.c42
-rw-r--r--games/backgammon/common_source/save.c36
-rw-r--r--games/backgammon/common_source/subs.c22
-rw-r--r--games/backgammon/common_source/table.c4
-rw-r--r--games/backgammon/teachgammon/data.c50
-rw-r--r--games/backgammon/teachgammon/teach.c7
-rw-r--r--games/backgammon/teachgammon/ttext1.c20
-rw-r--r--games/backgammon/teachgammon/ttext2.c17
-rw-r--r--games/backgammon/teachgammon/tutor.c12
-rw-r--r--games/backgammon/teachgammon/tutor.h20
17 files changed, 228 insertions, 205 deletions
diff --git a/games/backgammon/backgammon/backgammon.6 b/games/backgammon/backgammon/backgammon.6
index 1f85818..040a64b 100644
--- a/games/backgammon/backgammon/backgammon.6
+++ b/games/backgammon/backgammon/backgammon.6
@@ -97,8 +97,6 @@ uses /etc/termcap
.B -s\fIfile
recover previously saved game from
.IR file .
-(This can also be done by executing the saved file,
-i.e., typing its name in as a command)
.ad
.PP
.PP
diff --git a/games/backgammon/backgammon/main.c b/games/backgammon/backgammon/main.c
index 6bf3ec4..81cac2a 100644
--- a/games/backgammon/backgammon/main.c
+++ b/games/backgammon/backgammon/main.c
@@ -45,55 +45,48 @@ static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
+#include <signal.h>
#include "back.h"
#define MVPAUSE 5 /* time to sleep when stuck */
#define MAXUSERS 35 /* maximum number of users */
-extern char *instr[]; /* text of instructions */
-extern char *message[]; /* update message */
+extern const char *const instr[]; /* text of instructions */
+extern const char *const message[]; /* update message */
char ospeed; /* tty output speed */
-char *helpm[] = { /* help message */
+const char *helpm[] = { /* help message */
"Enter a space or newline to roll, or",
" R to reprint the board\tD to double",
" S to save the game\tQ to quit",
0
};
-char *contin[] = { /* pause message */
+const char *contin[] = { /* pause message */
"(Type a newline to continue.)",
"",
0
};
-static char user1a[] =
- "Sorry, you cannot play backgammon when there are more than ";
-static char user1b[] =
- " users\non the system.";
-static char user2a[] =
- "\nThere are now more than ";
-static char user2b[] =
- " users on the system, so you cannot play\nanother game. ";
-static char rules[] = "\nDo you want the rules of the game?";
-static char noteach[] = "Teachgammon not available!\n\007";
-static char need[] = "Do you need instructions for this program?";
-static char askcol[] =
+static const char rules[] = "\nDo you want the rules of the game?";
+static const char noteach[] = "Teachgammon not available!\n\007";
+static const char need[] = "Do you need instructions for this program?";
+static const char askcol[] =
"Enter 'r' to play red, 'w' to play white, 'b' to play both:";
-static char rollr[] = "Red rolls a ";
-static char rollw[] = ". White rolls a ";
-static char rstart[] = ". Red starts.\n";
-static char wstart[] = ". White starts.\n";
-static char toobad1[] = "Too bad, ";
-static char unable[] = " is unable to use that roll.\n";
-static char toobad2[] = ". Too bad, ";
-static char cantmv[] = " can't move.\n";
-static char bgammon[] = "Backgammon! ";
-static char gammon[] = "Gammon! ";
-static char again[] = ".\nWould you like to play again?";
-static char svpromt[] = "Would you like to save this game?";
-
-static char password[] = "losfurng";
+static const char rollr[] = "Red rolls a ";
+static const char rollw[] = ". White rolls a ";
+static const char rstart[] = ". Red starts.\n";
+static const char wstart[] = ". White starts.\n";
+static const char toobad1[] = "Too bad, ";
+static const char unable[] = " is unable to use that roll.\n";
+static const char toobad2[] = ". Too bad, ";
+static const char cantmv[] = " can't move.\n";
+static const char bgammon[] = "Backgammon! ";
+static const char gammon[] = "Gammon! ";
+static const char again[] = ".\nWould you like to play again?";
+static const char svpromt[] = "Would you like to save this game?";
+
+static const char password[] = "losfurng";
static char pbuf[10];
main (argc,argv)
@@ -111,7 +104,7 @@ char **argv;
/* initialization */
bflag = 2; /* default no board */
acnt = 1; /* Nuber of args */
- signal (2,getout); /* trap interrupts */
+ signal (SIGINT,getout); /* trap interrupts */
if (gtty (0,&tty) == -1) /* get old tty mode */
errexit ("backgammon(gtty)");
old = tty.sg_flags;
@@ -122,16 +115,6 @@ char **argv;
#endif
ospeed = tty.sg_ospeed; /* for termlib */
- /* check user count */
-# ifdef CORY
- if (ucount() > MAXUSERS) {
- writel (user1a);
- wrint (MAXUSERS);
- writel (user1b);
- getout();
- }
-# endif
-
/* get terminal
* capabilities, and
* decide if it can
@@ -222,7 +205,7 @@ char **argv;
else
writec ('\n');
writel ("Password:");
- signal (14,getout);
+ signal (SIGALRM,getout);
cflag = 1;
alarm (10);
for (i = 0; i < 10; i++) {
@@ -550,17 +533,6 @@ char **argv;
/* write score */
wrscore();
- /* check user count */
-# ifdef CORY
- if (ucount() > MAXUSERS) {
- writel (user2a);
- wrint (MAXUSERS);
- writel (user2b);
- rfl = 1;
- break;
- }
-# endif
-
/* see if he wants
* another game */
writel (again);
diff --git a/games/backgammon/backgammon/text.c b/games/backgammon/backgammon/text.c
index e6c3a21..0198f73 100644
--- a/games/backgammon/backgammon/text.c
+++ b/games/backgammon/backgammon/text.c
@@ -37,7 +37,7 @@ static char sccsid[] = "@(#)text.c 8.1 (Berkeley) 5/31/93";
#include "back.h"
-char *instr[] = {
+const char *const instr[] = {
" If you did not notice by now, this program reacts to things as",
"soon as you type them, without waiting for a newline. This means that",
"the special characters RUBOUT, ESC, and CONTROL-D, will not perform",
@@ -104,12 +104,13 @@ char *instr[] = {
0};
+int
text (t)
-char **t;
+const char *const *t;
{
register int i;
- register char *s, *a;
+ const char *s, *a;
fixtty (noech);
while (*t != 0) {
diff --git a/games/backgammon/backgammon/version.c b/games/backgammon/backgammon/version.c
index a3d829f..e6465a8 100644
--- a/games/backgammon/backgammon/version.c
+++ b/games/backgammon/backgammon/version.c
@@ -35,7 +35,7 @@
static char sccsid[] = "@(#)version.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
-char *message[] = {
+const char *const message[] = {
"Last updated on Saturday, January 11, 1986.",
0
};
diff --git a/games/backgammon/common_source/back.h b/games/backgammon/common_source/back.h
index 01003a6..88ca933 100644
--- a/games/backgammon/common_source/back.h
+++ b/games/backgammon/common_source/back.h
@@ -53,75 +53,75 @@
*
*/
-extern char EXEC[]; /* object for main program */
-extern char TEACH[]; /* object for tutorial program */
+extern const char EXEC[]; /* object for main program */
+extern const char TEACH[];/* object for tutorial program */
-int pnum; /* color of player:
+extern int pnum; /* color of player:
-1 = white
1 = red
0 = both
2 = not yet init'ed */
-char *args[16]; /* args passed to teachgammon and back */
-int acnt; /* number of args */
-int aflag; /* flag to ask for rules or instructions */
-int bflag; /* flag for automatic board printing */
-int cflag; /* case conversion flag */
-int hflag; /* flag for cleaning screen */
-int mflag; /* backgammon flag */
-int raflag; /* 'roll again' flag for recovered game */
-int rflag; /* recovered game flag */
-int tflag; /* cursor addressing flag */
-int rfl; /* saved value of rflag */
-int iroll; /* special flag for inputting rolls */
-int board[26]; /* board: negative values are white,
+extern char *args[16]; /* args passed to teachgammon and back */
+extern int acnt; /* number of args */
+extern int aflag; /* flag to ask for rules or instructions */
+extern int bflag; /* flag for automatic board printing */
+extern int cflag; /* case conversion flag */
+extern int hflag; /* flag for cleaning screen */
+extern int mflag; /* backgammon flag */
+extern int raflag; /* 'roll again' flag for recovered game */
+extern int rflag; /* recovered game flag */
+extern int tflag; /* cursor addressing flag */
+extern int rfl; /* saved value of rflag */
+extern int iroll; /* special flag for inputting rolls */
+extern int board[26]; /* board: negative values are white,
positive are red */
-int dice[2]; /* value of dice */
-int mvlim; /* 'move limit': max. number of moves */
-int mvl; /* working copy of mvlim */
-int p[5]; /* starting position of moves */
-int g[5]; /* ending position of moves (goals) */
-int h[4]; /* flag for each move if a man was hit */
-int cturn; /* whose turn it currently is:
+extern int dice[2]; /* value of dice */
+extern int mvlim; /* 'move limit': max. number of moves */
+extern int mvl; /* working copy of mvlim */
+extern int p[5]; /* starting position of moves */
+extern int g[5]; /* ending position of moves (goals) */
+extern int h[4]; /* flag for each move if a man was hit */
+extern int cturn; /* whose turn it currently is:
-1 = white
1 = red
0 = just quitted
-2 = white just lost
2 = red just lost */
-int d0; /* flag if dice have been reversed from
+extern int d0; /* flag if dice have been reversed from
original position */
-int table[6][6]; /* odds table for possible rolls */
-int rscore; /* red's score */
-int wscore; /* white's score */
-int gvalue; /* value of game (64 max.) */
-int dlast; /* who doubled last (0 = neither) */
-int bar; /* position of bar for current player */
-int home; /* position of home for current player */
-int off[2]; /* number of men off board */
-int *offptr; /* pointer to off for current player */
-int *offopp; /* pointer to off for opponent */
-int in[2]; /* number of men in inner table */
-int *inptr; /* pointer to in for current player */
-int *inopp; /* pointer to in for opponent */
+extern int table[6][6]; /* odds table for possible rolls */
+extern int rscore; /* red's score */
+extern int wscore; /* white's score */
+extern int gvalue; /* value of game (64 max.) */
+extern int dlast; /* who doubled last (0 = neither) */
+extern int bar; /* position of bar for current player */
+extern int home; /* position of home for current player */
+extern int off[2]; /* number of men off board */
+extern int *offptr; /* pointer to off for current player */
+extern int *offopp; /* pointer to off for opponent */
+extern int in[2]; /* number of men in inner table */
+extern int *inptr; /* pointer to in for current player */
+extern int *inopp; /* pointer to in for opponent */
-int ncin; /* number of characters in cin */
-char cin[100]; /* input line of current move
+extern int ncin; /* number of characters in cin */
+extern char cin[100]; /* input line of current move
(used for reconstructing input after
a backspace) */
-extern char *color[];
+extern const char *const color[];
/* colors as strings */
-char **colorptr; /* color of current player */
-char **Colorptr; /* color of current player, capitalized */
-int colen; /* length of color of current player */
+extern const char *const *colorptr; /* color of current player */
+extern const char *const *Colorptr; /* color of current player, capitalized */
+extern int colen; /* length of color of current player */
-struct sgttyb tty; /* tty information buffer */
-int old; /* original tty status */
-int noech; /* original tty status without echo */
-int raw; /* raw tty status, no echo */
+extern struct sgttyb tty; /* tty information buffer */
+extern int old; /* original tty status */
+extern int noech; /* original tty status without echo */
+extern int raw; /* raw tty status, no echo */
-int curr; /* row position of cursor */
-int curc; /* column position of cursor */
-int begscr; /* 'beginning' of screen
+extern int curr; /* row position of cursor */
+extern int curc; /* column position of cursor */
+extern int begscr; /* 'beginning' of screen
(not including board) */
-int getout(); /* function to exit backgammon cleanly */
+void getout(); /* function to exit backgammon cleanly */
diff --git a/games/backgammon/common_source/board.c b/games/backgammon/common_source/board.c
index cb12279..8176666 100644
--- a/games/backgammon/common_source/board.c
+++ b/games/backgammon/common_source/board.c
@@ -43,9 +43,9 @@ static char ln[60];
wrboard () {
register int l;
- static char bl[] =
+ static const char bl[] =
"| | | |\n";
- static char sv[] =
+ static const char sv[] =
"| | | | \n";
fixtty (noech);
diff --git a/games/backgammon/common_source/fancy.c b/games/backgammon/common_source/fancy.c
index 783a294..f19cbd1 100644
--- a/games/backgammon/common_source/fancy.c
+++ b/games/backgammon/common_source/fancy.c
@@ -591,9 +591,6 @@ clear () {
tputs (CL,CO,addbuf); /* put CL in buffer */
}
-tos () { /* home cursor */
- curmove (0,0);
-}
fancyc (c)
register char c; /* character to output */
@@ -703,8 +700,9 @@ newline () {
curmove (curr+1,0);
}
+int
getcaps (s)
-register char *s;
+const char *s;
{
register char *code; /* two letter code */
@@ -712,7 +710,7 @@ register char *s;
char *bufp; /* pointer to cap buffer */
char tentry[1024]; /* temporary uncoded caps buffer */
- tgetent (tentry,s); /* get uncoded termcap entry */
+ tgetent (tentry, (char *)s); /* get uncoded termcap entry */
LI = tgetnum ("li"); /* get number of lines */
if (LI == -1)
diff --git a/games/backgammon/common_source/init.c b/games/backgammon/common_source/init.c
index 82f8950..d0cf548 100644
--- a/games/backgammon/common_source/init.c
+++ b/games/backgammon/common_source/init.c
@@ -35,15 +35,16 @@
static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
-#include <sgtty.h>
+#include <sys/cdefs.h>
+#include <termios.h>
/*
* variable initialization.
*/
/* name of executable object programs */
-char EXEC[] = "/usr/games/backgammon";
-char TEACH[] = "/usr/games/teachgammon";
+const char EXEC[] = "/usr/games/backgammon";
+const char TEACH[] = "/usr/games/teachgammon";
int pnum = 2; /* color of player:
-1 = white
@@ -62,4 +63,37 @@ int tflag = 0; /* cursor addressing flag */
int iroll = 0; /* special flag for inputting rolls */
int rfl = 0;
-char *color[] = {"White","Red","white","red"};
+const char *const color[] = {"White","Red","white","red"};
+
+const char *const *Colorptr;
+const char *const *colorptr;
+int *inopp;
+int *inptr;
+int *offopp;
+int *offptr;
+char args[100];
+int bar;
+int begscr;
+int board[26];
+char cin[100];
+int colen;
+int cturn;
+int curc;
+int curr;
+int d0;
+int dice[2];
+int dlast;
+int g[5];
+int gvalue;
+int h[4];
+int home;
+int in[2];
+int mvl;
+int mvlim;
+int ncin;
+int off[2];
+int p[5];
+int rscore;
+int table[6][6];
+int wscore;
+struct termios tty, old, noech, raw;
diff --git a/games/backgammon/common_source/save.c b/games/backgammon/common_source/save.c
index b25e194..e62f192 100644
--- a/games/backgammon/common_source/save.c
+++ b/games/backgammon/common_source/save.c
@@ -35,20 +35,20 @@
static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */
+#include <fcntl.h>
+#include <errno.h>
#include "back.h"
-extern int errno;
-
-static char confirm[] = "Are you sure you want to leave now?";
-static char prompt[] = "Enter a file name: ";
-static char exist1[] = "The file '";
-static char exist2[] =
+static const char confirm[] = "Are you sure you want to leave now?";
+static const char prompt[] = "Enter a file name: ";
+static const char exist1[] = "The file '";
+static const char exist2[] =
"' already exists.\nAre you sure you want to use this file?";
-static char cantuse[] = "\nCan't use ";
-static char saved[] = "This game has been saved on the file '";
-static char type[] = "'.\nType \"backgammon ";
-static char rec[] = "\" to recover your game.\n\n";
-static char cantrec[] = "Can't recover file: ";
+static const char cantuse[] = "\nCan't use ";
+static const char saved[] = "This game has been saved on the file '";
+static const char type[] = "'.\nType \"backgammon ";
+static const char rec[] = "\" to recover your game.\n\n";
+static const char cantrec[] = "Can't recover file: ";
save (n)
register int n;
@@ -87,8 +87,8 @@ register int n;
writec (*fs++);
}
*fs = '\0';
- if ((fdesc = open(fname,2)) == -1 && errno == 2) {
- if ((fdesc = creat (fname,0700)) != -1)
+ if ((fdesc = open(fname,O_RDWR)) == -1 && errno == ENOENT) {
+ if ((fdesc = creat (fname,0600)) != -1)
break;
}
if (fdesc != -1) {
@@ -141,14 +141,15 @@ register int n;
getout ();
}
+int
recover (s)
-char *s;
+const char *s;
{
register int i;
int fdesc;
- if ((fdesc = open (s,0)) == -1)
+ if ((fdesc = open (s,O_RDONLY)) == -1)
norec (s);
read (fdesc,board,sizeof board);
read (fdesc,off,sizeof off);
@@ -165,11 +166,12 @@ char *s;
rflag = 1;
}
+int
norec (s)
-register char *s;
+const char *s;
{
- register char *c;
+ const char *c;
tflag = 0;
writel (cantrec);
diff --git a/games/backgammon/common_source/subs.c b/games/backgammon/common_source/subs.c
index a9e998b..69763d8 100644
--- a/games/backgammon/common_source/subs.c
+++ b/games/backgammon/common_source/subs.c
@@ -43,11 +43,11 @@ static char sccsid[] = "@(#)subs.c 8.1 (Berkeley) 5/31/93";
int buffnum;
char outbuff[BUFSIZ];
-static char plred[] = "Player is red, computer is white.";
-static char plwhite[] = "Player is white, computer is red.";
-static char nocomp[] = "(No computer play.)";
+static const char plred[] = "Player is red, computer is white.";
+static const char plwhite[] = "Player is white, computer is red.";
+static const char nocomp[] = "(No computer play.)";
-char *descr[] = {
+const char *const descr[] = {
"Usage: backgammon [-h n r w b pr pw pb tterm sfile]\n",
"\t-h\tgets this list\n\t-n\tdon't ask for rules or instructions",
"\t-r\tplayer is red (implies -n)\n\t-w\tplayer is white (implies -n)",
@@ -68,12 +68,6 @@ register char *s;
getout();
}
-strset (s1,s2)
-register char *s1, *s2;
-{
- while ( (*s1++ = *s2++) != '\0');
-}
-
int addbuf (c)
register int c;
@@ -131,11 +125,12 @@ char c;
addbuf (c);
}
+void
writel (l)
-register char *l;
+const char *l;
{
#ifdef DEBUG
- register char *s;
+ const char *s;
if (trace == NULL)
trace = fopen ("bgtrace","w");
@@ -325,7 +320,7 @@ register char **argv;
args[acnt++] = strdup ("-n");
break;
- /* player is both read and white */
+ /* player is both red and white */
case 'b':
if (rflag)
break;
@@ -424,6 +419,7 @@ int mode;
errexit("fixtty");
}
+void
getout () {
/* go to bottom of screen */
if (tflag) {
diff --git a/games/backgammon/common_source/table.c b/games/backgammon/common_source/table.c
index e119e8b..4ef1ca4 100644
--- a/games/backgammon/common_source/table.c
+++ b/games/backgammon/common_source/table.c
@@ -37,7 +37,7 @@ static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 5/31/93";
#include "back.h"
-char *help2[] = {
+const char *const help2[] = {
" Enter moves as <s>-<f> or <s>/<r> where <s> is the starting",
"position, <f> is the finishing position, and <r> is the roll.",
"Remember, each die roll must be moved separately.",
@@ -50,7 +50,7 @@ struct state {
int newst;
};
-struct state atmata[] = {
+static const struct state atmata[] = {
'R', 1, 0, '?', 7, 0, 'Q', 0, -3, 'B', 8, 25,
'9', 2, 25, '8', 2, 25, '7', 2, 25, '6', 2, 25,
diff --git a/games/backgammon/teachgammon/data.c b/games/backgammon/teachgammon/data.c
index b63da67..7013627 100644
--- a/games/backgammon/teachgammon/data.c
+++ b/games/backgammon/teachgammon/data.c
@@ -39,7 +39,7 @@ static char sccsid[] = "@(#)data.c 8.1 (Berkeley) 5/31/93";
int maxmoves = 23;
-char *text0[] = {
+const char *const text0[] = {
"To start the game, I roll a 3, and you roll a 1. This means",
"that I get to start first. I move 8-5,6-5 since this makes a",
"new point and helps to trap your back men on 1. You should be",
@@ -47,7 +47,7 @@ char *text0[] = {
0
};
-char *text1[] = {
+const char *const text1[] = {
"Now you shall see a move using doubles. I just rolled double",
"5's. I will move two men from position 13 to position 3. The",
"notation for this is 13-8,13-8,8-3,8-3. You will also roll dou-",
@@ -55,7 +55,7 @@ char *text1[] = {
0
};
-char *text2[] = {
+const char *const text2[] = {
"Excellent! As you can see, you are beginning to develop a wall",
"which is trapping my men on position 24. Also, moving your back",
"men forward not only improves your board position safely, but it",
@@ -68,7 +68,7 @@ char *text2[] = {
0
};
-char *text3[] = {
+const char *const text3[] = {
"As you can see, although you left a man open, it is a rela-",
"tively safe move to an advantageous position, which might help",
"you make a point later. Only two rolls (4 5 or 5 4) will allow",
@@ -77,13 +77,13 @@ char *text3[] = {
0
};
-char *text4[] = {
+const char *const text4[] = {
"You're pretty lucky yourself, you know. I follow by rolling 2 3",
"and moving 25-22,24-22, forming a new point.",
0
};
-char *text5[] = {
+const char *const text5[] = {
"Not a spectacular move, but a safe one. I follow by rolling 6 1.",
"I decide to use this roll to move 22-16,16-15. It leaves me with",
"one man still open, but the blot is farther back on the board, and",
@@ -91,7 +91,7 @@ char *text5[] = {
0
};
-char *text6[] = {
+const char *const text6[] = {
"By moving your two men from 17 to 20, you lessen my chance of",
"getting my man off the board. In fact, the odds are 5 to 4",
"against me getting off. I roll with the odds and helplessly",
@@ -99,7 +99,7 @@ char *text6[] = {
0
};
-char *text7[] = {
+const char *const text7[] = {
"Note that the blot on 7 cannot be hit unless I get off the bar",
"and have a 1 or a 6 left over, and doing so will leave two of",
"my men open. Also, the blot on 16 cannot be hit at all! With",
@@ -107,27 +107,27 @@ char *text7[] = {
0
};
-char *text8[] = {
+const char *const text8[] = {
"See, you did not get hit and, you got to 'cover up' your open men.",
"Quite an accomplishment. Finally, I get off the bar by rolling",
"6 2 and moving 25-23,23-17.",
0
};
-char *text9[] = {
+const char *const text9[] = {
"My venture off the bar did not last long. However, I got lucky",
"and rolled double 1's, allowing me to move 25-24,24-23,15-14,15-14.",
0
};
-char *text10[] = {
+const char *const text10[] = {
"You are improving your position greatly and safely, and are well",
"on the way to winning the game. I roll a 6 2 and squeak past",
"your back man. Now the game becomes a race to the finish.",
0
};
-char *text11[] = {
+const char *const text11[] = {
"Now that it is merely a race, you are trying to get as many men",
"as possible into the inner table, so you can start removing them.",
"I roll a 3 4 and move my two men farthest back to position 11",
@@ -135,20 +135,20 @@ char *text11[] = {
0
};
-char *text12[] = {
+const char *const text12[] = {
"The race is still on, and you have seem to be doing all right.",
"I roll 6 1 and move 14-8,13-12.",
0
};
-char *text13[] = {
+const char *const text13[] = {
"Notice that you get to remove men the instant you have all of",
"them at your inner table, even if it is the middle of a turn.",
"I roll 1 2 and move 13-11,12-11.",
0
};
-char *text14[] = {
+const char *const text14[] = {
"Although you could have removed a man, this move illustrates two",
"points: 1) You never have to remove men, and 2) You should try",
"to spread out your men on your inner table. Since you have one",
@@ -157,25 +157,25 @@ char *text14[] = {
0
};
-char *text15[] = {
+const char *const text15[] = {
"This time you were able to remove men. I roll 3 4 and move",
"11-7,11-8. The race continues.",
0
};
-char *text16[] = {
+const char *const text16[] = {
"More holes are opening up in your inner table, but you are",
"still very much ahead. If we were doubling, you would have",
"doubled long ago. I roll 2 6 and move 8-6,11-5.",
0
};
-char *text17[] = {
+const char *const text17[] = {
"It pays to spread out your men. I roll 3 5 and move 7-4,8-3.",
0
};
-char *text18[] = {
+const char *const text18[] = {
"You can only remove some men, but you spread out more and",
"more, in order to be able to remove men more efficiently.",
"I roll double 3's, which help, but not that much. I move",
@@ -183,30 +183,30 @@ char *text18[] = {
0
};
-char *text19[] = {
+const char *const text19[] = {
"I roll 1 4 and move 5-4,4-0.",
0
};
-char *text20[] = {
+const char *const text20[] = {
"You are now nicely spread out to win a game. I roll 5 6 and",
"move 5-0,6-0.",
0
};
-char *text21[] = {
+const char *const text21[] = {
"Any minute now. Just a few short steps from victory. I roll",
"2 4 and move 6-4,4-0.",
0
};
-char *text22[] = {
+const char *const text22[] = {
"It looks pretty hopeless for me, but I play on, rolling 1 3 and",
"moving 4-3,3-0.",
0
};
-char *text23[] = {
+const char *const text23[] = {
"Congratulations! You just won a game of backgammon against the",
"computer! You will now be able to play a game, but remember,",
"when you start playing, that doubling will be enabled, which",
@@ -215,7 +215,7 @@ char *text23[] = {
0
};
-struct situatn test[] = {
+const struct situatn test[] = {
{
{0,2,0,0,0,0,-5,0,-3,0,0,0,5,-5,0,0,0,3,0,5,0,0,0,0,-2,0},
3, 1, {8,6,0,0}, {5,5,0,0}, 4, 2, text0
diff --git a/games/backgammon/teachgammon/teach.c b/games/backgammon/teachgammon/teach.c
index 9921cbe..9bdee20 100644
--- a/games/backgammon/teachgammon/teach.c
+++ b/games/backgammon/teachgammon/teach.c
@@ -44,6 +44,7 @@ static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93";
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
+#include <signal.h>
#include "back.h"
extern char *hello[];
@@ -61,7 +62,7 @@ extern char *lastch[];
extern char ospeed; /* tty output speed for termlib */
-char *helpm[] = {
+const char *const helpm[] = {
"\nEnter a space or newline to roll, or",
" b to display the board",
" d to double",
@@ -69,7 +70,7 @@ char *helpm[] = {
0
};
-char *contin[] = {
+const char *const contin[] = {
"",
0
};
@@ -85,7 +86,7 @@ char **argv;
setgid(getgid());
acnt = 1;
- signal (2,getout);
+ signal (SIGINT,getout);
if (gtty (0,&tty) == -1) /* get old tty mode */
errexit ("teachgammon(gtty)");
old = tty.sg_flags;
diff --git a/games/backgammon/teachgammon/ttext1.c b/games/backgammon/teachgammon/ttext1.c
index 3835259..b4b160a 100644
--- a/games/backgammon/teachgammon/ttext1.c
+++ b/games/backgammon/teachgammon/ttext1.c
@@ -37,10 +37,10 @@ static char sccsid[] = "@(#)ttext1.c 8.1 (Berkeley) 5/31/93";
#include "back.h"
-char *opts = " QIMRHEDSPT";
-char *prompt = "-->";
+const char *opts = " QIMRHEDSPT";
+const char *prompt = "-->";
-char *list[] = {
+const char *const list[] = {
"\n\n\tI\tIntroduction to Backgammon",
"\tM\tMoves and Points",
"\tR\tRemoving Men from the Board",
@@ -56,7 +56,7 @@ char *list[] = {
0
};
-char *hello[] = {
+const char *const hello[] = {
"\n\032 These rules consist of text describing how to play Backgammon",
"followed by a tutorial session where you play a practice game",
"against the computer. When using this program, think carefuly",
@@ -74,7 +74,7 @@ char *hello[] = {
0
};
-char *intro1[] = {
+const char *const intro1[] = {
"\nIntroduction:",
"\n Backgammon is a game involving the skill of two players and",
"the luck of two dice. There are two players, red and white, and",
@@ -85,7 +85,7 @@ char *intro1[] = {
"",
0};
-char *intro2[] = {
+const char *const intro2[] = {
"",
"\n Although not indicated on the board, the players' homes are",
"located just to the right of the board. A player's men are placed",
@@ -99,7 +99,7 @@ char *intro2[] = {
"",
0};
-char *moves[] = {
+const char *const moves[] = {
"\nMoves and Points:",
"\n Moves are made along the positions on the board according to",
"their numbers. Red moves in the positive direction (clockwise",
@@ -130,7 +130,7 @@ char *moves[] = {
"",
0};
-char *remove[] = {
+const char *const remove[] = {
"\nRemoving Men from the Board:",
"\n The most important part of the game is removing men, since",
"that is how you win the game. Once a man is removed, he stays",
@@ -154,7 +154,7 @@ char *remove[] = {
"",
0};
-char *hits[] = {
+const char *const hits[] = {
"\nHitting Blots:",
"\n Although two men on a position form an impenetrable point, a",
"lone man is not so secure. Such a man is called a 'blot' and has",
@@ -171,7 +171,7 @@ char *hits[] = {
"",
0};
-char *endgame[] = {
+const char *const endgame[] = {
"\nEnding the Game and Scoring:",
"\n Winning a game usually wins one point, the normal value of a",
"game. However, if the losing player has not removed any men yet,",
diff --git a/games/backgammon/teachgammon/ttext2.c b/games/backgammon/teachgammon/ttext2.c
index 1ad90fb..aaaf84a 100644
--- a/games/backgammon/teachgammon/ttext2.c
+++ b/games/backgammon/teachgammon/ttext2.c
@@ -39,7 +39,7 @@ static char sccsid[] = "@(#)ttext2.c 8.1 (Berkeley) 5/31/93";
char *prompt, *list, *opts;
-char *doubl[] = {
+const char *const doubl[] = {
"\nDoubling:",
"\n If a player thinks he is in a good position, he may double the",
"value of the game. However, his opponent may not accept the pro-",
@@ -54,7 +54,7 @@ char *doubl[] = {
"",
0};
-char *stragy[] = {
+const char *const stragy[] = {
"\nStrategy:",
"\n Some general hints when playing: Try not to leave men open",
"unless absolutely necessary. Also, it is good to make as many",
@@ -70,7 +70,7 @@ char *stragy[] = {
"",
0};
-char *prog[] = {
+const char *const prog[] = {
"\nThe Program and How It Works:",
"\n A general rule of thumb is when you don't know what to do,",
"type a question mark, and you should get some help. When it is",
@@ -104,7 +104,7 @@ char *prog[] = {
"",
0};
-char *lastch[] = {
+const char *const lastch[] = {
"\nTutorial (Practice Game):",
"\n This tutorial, for simplicity's sake, will let you play one",
"predetermined game. All the rolls have been pre-arranged, and",
@@ -123,14 +123,15 @@ char *lastch[] = {
"",
0};
+int
text (txt)
-char **txt;
+const char *const *txt;
{
- char **begin;
- char *a;
+ const char *const *begin;
+ const char *a;
char b;
- char *c;
+ const char *c;
int i;
fixtty (noech);
diff --git a/games/backgammon/teachgammon/tutor.c b/games/backgammon/teachgammon/tutor.c
index 71cf531..e87e5b6 100644
--- a/games/backgammon/teachgammon/tutor.c
+++ b/games/backgammon/teachgammon/tutor.c
@@ -39,12 +39,13 @@ static char sccsid[] = "@(#)tutor.c 8.1 (Berkeley) 5/31/93";
#include "tutor.h"
extern int maxmoves;
-extern char *finis[];
+extern const char *const finis[];
-extern struct situatn test[];
+extern const struct situatn test[];
-static char better[] = "That is a legal move, but there is a better one.\n";
+static const char better[] = "That is a legal move, but there is a better one.\n";
+void
tutor () {
register int i, j;
@@ -141,11 +142,12 @@ clrest () {
curmove (r,c);
}
+int
brdeq (b1,b2)
-register int *b1, *b2;
+const int *b1, *b2;
{
- register int *e;
+ const int *e;
e = b1+26;
while (b1 < e)
diff --git a/games/backgammon/teachgammon/tutor.h b/games/backgammon/teachgammon/tutor.h
index 6fe35fb..8b20e33 100644
--- a/games/backgammon/teachgammon/tutor.h
+++ b/games/backgammon/teachgammon/tutor.h
@@ -41,5 +41,23 @@ struct situatn {
int mg[4];
int new1;
int new2;
- char *(*com[8]);
+ const char *const (*com[8]);
};
+
+extern const char *const doubl[];
+extern const char *const endgame[];
+extern const char *const finis[];
+extern const char *const hello[];
+extern const char *const hits[];
+extern const char *const intro1[];
+extern const char *const intro2[];
+extern const char *const lastch[];
+extern const char *const list[];
+extern int maxmoves;
+extern const char *const moves[];
+extern const char *const opts;
+extern const char *const prog[];
+extern const char *const prompt;
+extern const char *const removepiece[];
+extern const char *const stragy[];
+extern const struct situatn test[];
OpenPOWER on IntegriCloud