-/* $NetBSD: execute.c,v 1.4 1997/10/12 17:45:09 christos Exp $ */
+/* $NetBSD: execute.c,v 1.7 1999/09/08 21:17:51 jsm Exp $ */
/*
* Copyright (c) 1980, 1993
#if 0
static char sccsid[] = "@(#)execute.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: execute.c,v 1.4 1997/10/12 17:45:09 christos Exp $");
+__RCSID("$NetBSD: execute.c,v 1.7 1999/09/08 21:17:51 jsm Exp $");
#endif
#endif /* not lint */
#include <sys/stat.h>
#include <sys/time.h>
-# define SEGSIZE 8192
+#define SEGSIZE 8192
typedef struct stat STAT;
typedef struct tm TIME;
*/
void
execute(com_num)
-int com_num;
+ int com_num;
{
-
new_play = FALSE; /* new_play is true if fixing */
(*func[com_num])();
notify();
else if (num_doub)
printf("%s rolled doubles. Goes again\n", cur_p->name);
}
+
/*
* This routine moves a piece around.
*/
void
do_move()
{
-
- int r1, r2;
- bool was_jail;
+ int r1, r2;
+ bool was_jail;
new_play = was_jail = FALSE;
printf("roll is %d, %d\n", r1=roll(1, 6), r2=roll(1, 6));
ret:
return;
}
+
/*
* This routine moves a normal move
*/
void
move(rl)
-int rl;
+ int rl;
{
-
- int old_loc;
+ int old_loc;
old_loc = cur_p->loc;
cur_p->loc = (cur_p->loc + rl) % N_SQRS;
}
show_move();
}
+
/*
* This routine shows the results of a move
*/
static void
show_move()
{
-
- SQUARE *sqp;
+ SQUARE *sqp;
sqp = &board[cur_p->loc];
printf("That puts you on %s\n", sqp->name);
rent(sqp);
}
}
+
/*
* This routine saves the current game for use at a later date
*/
void
save()
{
-
- char *sp;
- int outf, num;
- time_t t;
- struct stat sb;
- char *start, *end;
+ char *sp;
+ int outf, num;
+ time_t t;
+ struct stat sb;
+ char *start, *end;
printf("Which file do you wish to save it in? ");
sp = buf;
close(outf);
printf("[%s]\n", buf);
}
+
/*
* This routine restores an old game from a file
*/
void
restore()
{
-
- char *sp;
+ char *sp;
printf("Which file do you wish to restore from? ");
for (sp = buf; (*sp=getchar()) != '\n'; sp++)
*sp = '\0';
rest_f(buf);
}
+
/*
* This does the actual restoring. It returns TRUE if the
* backup was successful, else false.
*/
int
rest_f(file)
-char *file;
+ const char *file;
{
+ char *sp;
+ int inf, num;
+ char buf[80];
+ char *start, *end;
+ STAT sbuf;
- char *sp;
- int inf, num;
- char buf[80];
- char *start, *end;
- STAT sbuf;
-
- if ((inf=open(file, 0)) < 0) {
+ if ((inf=open(file, O_RDONLY)) < 0) {
perror(file);
return FALSE;
}