typedef struct stat STAT
;
extern char etext
[], /* end of text space */
*yn_only
[] = { "yes", "no"};
static bool new_play
; /* set if move on to new player */
* This routine executes the given command by index number
new_play
= FALSE
; /* new_play is true if fixing */
printf("%s rolled doubles. Goes again\n", cur_p
->name
);
* This routine moves a piece around.
new_play
= was_jail
= FALSE
;
printf("roll is %d, %d\n", r1
=roll(1, 6), r2
=roll(1, 6));
if (cur_p
->loc
== JAIL
) {
if (!move_jail(r1
, r2
)) {
if (r1
== r2
&& ++num_doub
== 3) {
printf("That's 3 doubles. You go to jail\n");
if (r1
!= r2
|| was_jail
)
* This routine moves a normal move
cur_p
->loc
= (cur_p
->loc
+ rl
) % N_SQRS
;
if (cur_p
->loc
< old_loc
&& rl
> 0) {
printf("You pass %s and get $200\n", board
[0].name
);
* This routine shows the results of a move
sqp
= &board
[cur_p
->loc
];
printf("That puts you on %s\n", sqp
->name
);
printf("That is a safe place\n");
(*((int (*)())(sqp
->desc
)))();
printf("That would cost $%d\n", sqp
->cost
);
if (getyn("Do you want to buy? ") == 0) {
cur_p
->money
-= sqp
->cost
;
else if (sqp
->owner
== player
)
* This routine saves the current game for use at a later date
printf("Which file do you wish to save it in? ");
while ((*sp
++=getchar()) != '\n')
* check for existing files, and confirm overwrite if needed
&& getyn("File exists. Do you wish to overwrite? ", yn_only
) > 0)
if ((outf
=creat(buf
, 0644)) < 0) {
time(tp
); /* get current time */
for (sp
= buf
; *sp
!= '\n'; sp
++)
start
= (((int) etext
+ (SEGSIZE
-1)) / SEGSIZE
) * SEGSIZE
;
while (start
< end
) { /* write out entire data space */
num
= start
+ 16 * 1024 > end
? end
- start
: 16 * 1024;
* This routine restores an old game from a file
printf("Which file do you wish to restore from? ");
for (sp
= buf
; (*sp
=getchar()) != '\n'; sp
++)
* This does the actual restoring. It returns TRUE if the
* backup was successful, else false.
if ((inf
=open(file
, 0)) < 0) {
if (fstat(inf
, &sbuf
) < 0) { /* get file stats */
start
= (((int) etext
+ (SEGSIZE
-1)) / SEGSIZE
) * SEGSIZE
;
brk(end
= start
+ sbuf
.st_size
);
while (start
< end
) { /* write out entire data space */
num
= start
+ 16 * 1024 > end
? end
- start
: 16 * 1024;
strcpy(buf
, ctime(sbuf
.st_mtime
));
for (sp
= buf
; *sp
!= '\n'; sp
++)