* Copyright (c) 1983 Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)pl_main.c 5.5 (Berkeley) 2/28/91";
printf("Can't sail on this terminal.\n");
Signal("Aye aye, Sir", (struct ship
*)0);
return 0; /* for lint, play() never returns */
register struct File
*fp
;
register struct ship
*sp
;
(void) puts("Choose a scenario:\n");
(void) puts("\n\tNUMBER\tSHIPS\tIN PLAY\tTITLE");
for (n
= 0; n
< NSCENE
; n
++) {
printf("\t%d):\t%d\t%s\t%s\n", n
, scene
[n
].vessels
,
sync_exists(n
) ? "YES" : "no",
printf("\nScenario number? ");
(void) scanf("%d", &game
);
while (getchar() != '\n')
if (game
< 0 || game
>= NSCENE
) {
(void) puts("Very funny.");
for (n
= 0; n
< NNATION
; n
++)
(sp
->file
= (struct File
*)calloc(1, sizeof (struct File
))) == NULL
) {
(void) puts("OUT OF MEMORY");
sp
->file
->index
= sp
- SHIP(0);
sp
->file
->stern
= nat
[sp
->nationality
]++;
sp
->file
->dir
= sp
->shipdir
;
sp
->file
->row
= sp
->shiprow
;
sp
->file
->col
= sp
->shipcol
;
windspeed
= cc
->windspeed
;
(void) signal(SIGHUP
, choke
);
(void) signal(SIGINT
, choke
);
hasdriver
= sync_exists(game
);
perror("sail: syncfile");
(void) puts("Synchronizing with the other players...");
if (sp
->file
->captain
[0] == 0 && !sp
->file
->struck
&& sp
->file
->captured
== 0)
(void) puts("All ships taken in that scenario.");
printf("%s\n\n", cc
->name
);
printf(" %2d: %-10s %-15s (%-2d pts) %s\n",
countryname
[sp
->nationality
],
printf("\nWhich ship (0-%d)? ", cc
->vessels
-1);
if (scanf("%d", &player
) != 1 || player
< 0
|| player
>= cc
->vessels
) {
while (getchar() != '\n')
(void) puts("Say what?");
while (getchar() != '\n')
if (fp
->captain
[0] || fp
->struck
|| fp
->captured
!= 0)
(void) puts("That ship is taken.");
Write(W_BEGIN
, ms
, 0, 0, 0, 0, 0);
(void) signal(SIGCHLD
, child
);
longjmp(restart
, MODE_DRIVER
);
printf("Your ship is the %s, a %d gun %s (%s crew).\n",
ms
->shipname
, mc
->guns
, classname
[mc
->class],
if ((nameptr
= (char *) getenv("SAILNAME")) && *nameptr
)
(void) strncpy(captain
, nameptr
, sizeof captain
);
(void) printf("Your name, Captain? ");
(void) strcpy(captain
, "no name");
captain
[sizeof captain
- 1] = '\0';
Write(W_CAPTAIN
, ms
, 1, (int)captain
, 0, 0, 0);
for (n
= 0; n
< 2; n
++) {
printf("\nInitial broadside %s (grape, chain, round, double): ",
mf
->readyR
= R_LOADED
|R_INITIAL
;
mf
->readyL
= R_LOADED
|R_INITIAL
;
(void) sprintf(message
, "Captain %s assuming command", captain
);
Write(W_SIGNAL
, ms
, 1, (int)message
, 0, 0, 0);