summaryrefslogtreecommitdiffstats
path: root/backgammon/teachgammon
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2012-10-13 19:19:38 +0000
committerdholland <dholland@NetBSD.org>2012-10-13 19:19:38 +0000
commit83f2ef7227030c4b88ec1006e49d9304aa6f7be0 (patch)
tree0f69865c3aa850090b15e95a6ae7a6d599c95e11 /backgammon/teachgammon
parentf70c1c7e831fd972c1f452e87709f5fe158e6f4d (diff)
downloadbsdgames-darwin-83f2ef7227030c4b88ec1006e49d9304aa6f7be0.tar.gz
bsdgames-darwin-83f2ef7227030c4b88ec1006e49d9304aa6f7be0.tar.zst
bsdgames-darwin-83f2ef7227030c4b88ec1006e49d9304aa6f7be0.zip
Pass the move info around instead of using it as a global.
Diffstat (limited to 'backgammon/teachgammon')
-rw-r--r--backgammon/teachgammon/teach.c13
-rw-r--r--backgammon/teachgammon/tutor.c21
-rw-r--r--backgammon/teachgammon/tutor.h6
3 files changed, 23 insertions, 17 deletions
diff --git a/backgammon/teachgammon/teach.c b/backgammon/teachgammon/teach.c
index 9d10908d..7559f5ad 100644
--- a/backgammon/teachgammon/teach.c
+++ b/backgammon/teachgammon/teach.c
@@ -1,4 +1,4 @@
-/* $NetBSD: teach.c,v 1.21 2010/03/22 05:10:19 mrg Exp $ */
+/* $NetBSD: teach.c,v 1.22 2012/10/13 19:19:39 dholland Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\
#if 0
static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: teach.c,v 1.21 2010/03/22 05:10:19 mrg Exp $");
+__RCSID("$NetBSD: teach.c,v 1.22 2012/10/13 19:19:39 dholland Exp $");
#endif
#endif /* not lint */
@@ -63,6 +63,7 @@ int
main(int argc __unused, char *argv[])
{
int i;
+ struct move mmstore, *mm;
/* revoke setgid privileges */
setgid(getgid());
@@ -76,12 +77,16 @@ main(int argc __unused, char *argv[])
raw.c_lflag &= ~ICANON; /* set up modes */
ospeed = cfgetospeed(&old); /* for termlib */
tflag = getcaps(getenv("TERM"));
+
+ /* need this now beceause getarg() may try to load a game */
+ mm = &mmstore;
+ move_init(mm);
#ifdef V7
while (*++argv != 0)
#else
while (*++argv != -1)
#endif
- getarg(&argv);
+ getarg(mm, &argv);
if (tflag) {
noech.c_oflag &= ~(ONLCR | OXTABS);
raw.c_oflag &= ~(ONLCR | OXTABS);
@@ -137,7 +142,7 @@ main(int argc __unused, char *argv[])
if ((i = wrtext(lastch)) != 0)
break;
}
- tutor();
+ tutor(mm);
/* NOTREACHED */
return (0);
}
diff --git a/backgammon/teachgammon/tutor.c b/backgammon/teachgammon/tutor.c
index 394caf86..efbd7f08 100644
--- a/backgammon/teachgammon/tutor.c
+++ b/backgammon/teachgammon/tutor.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tutor.c,v 1.10 2012/10/13 18:44:15 dholland Exp $ */
+/* $NetBSD: tutor.c,v 1.11 2012/10/13 19:19:39 dholland Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)tutor.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: tutor.c,v 1.10 2012/10/13 18:44:15 dholland Exp $");
+__RCSID("$NetBSD: tutor.c,v 1.11 2012/10/13 19:19:39 dholland Exp $");
#endif
#endif /* not lint */
@@ -48,10 +48,9 @@ static int brdeq(const int *, const int *);
static void clrest(void);
void
-tutor(void)
+tutor(struct move *mm)
{
int i, j;
- struct move *mm = &gm;
i = 0;
begscr = 18;
@@ -73,17 +72,17 @@ tutor(void)
curmove(18, 0);
writel(better);
nexturn();
- movback(mm->mvlim);
+ movback(mm, mm->mvlim);
if (tflag) {
refresh();
clrest();
}
if ((!tflag) || curr == 19) {
- proll();
+ proll(mm);
writec('\t');
} else
curmove(curr > 19 ? curr - 2 : curr + 4, 25);
- getmove();
+ getmove(mm);
if (cturn == 0)
leave();
continue;
@@ -108,7 +107,7 @@ tutor(void)
}
if (mm->mvlim)
for (j = 0; j < mm->mvlim; j++)
- if (makmove(j))
+ if (makmove(mm, j))
writel("AARGH!!!\n");
if (tflag)
refresh();
@@ -117,13 +116,13 @@ tutor(void)
mm->D1 = test[i].new2;
mm->d0 = 0;
i++;
- mm->mvlim = movallow();
+ mm->mvlim = movallow(mm);
if (mm->mvlim) {
if (tflag)
clrest();
- proll();
+ proll(mm);
writec('\t');
- getmove();
+ getmove(mm);
if (tflag)
refresh();
if (cturn == 0)
diff --git a/backgammon/teachgammon/tutor.h b/backgammon/teachgammon/tutor.h
index 26e55e1f..203f0fca 100644
--- a/backgammon/teachgammon/tutor.h
+++ b/backgammon/teachgammon/tutor.h
@@ -1,4 +1,4 @@
-/* $NetBSD: tutor.h,v 1.10 2011/08/26 06:18:16 dholland Exp $ */
+/* $NetBSD: tutor.h,v 1.11 2012/10/13 19:19:39 dholland Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -31,6 +31,8 @@
* @(#)tutor.h 8.1 (Berkeley) 5/31/93
*/
+struct move; /* in back.h */
+
struct situatn {
int brd[26];
int roll1;
@@ -63,4 +65,4 @@ extern const struct situatn test[];
void leave(void) __dead;
-void tutor(void) __dead;
+void tutor(struct move *) __dead;