- foreachship(sp) {
- sp->file->dir = sp->shipdir;
- sp->file->row = sp->shiprow;
- sp->file->col = sp->shipcol;
- }
- windspeed = cc->windspeed;
- winddir = cc->winddir;
-
- initscreen();
-
- board();
- (void) sprintf(message, "Captain %s assuming command", captain);
- Write(W_SIGNAL, ms, 1, (int)message, 0, 0, 0);
-
- newturn();
-}
-
-leave(conditions)
-int conditions;
-{
- FILE *fp;
- int people;
- float net;
- char message[60];
- register int n;
- struct logs log[10], temp;
-
- (void) signal(SIGHUP, SIG_IGN);
- (void) signal(SIGINT, SIG_IGN);
- (void) signal(SIGQUIT, SIG_IGN);
- (void) signal(SIGALRM, SIG_IGN);
- (void) signal(SIGCHLD, SIG_IGN);
-
- if (conditions != -1) {
- (void) sprintf(message,"Captain %s relinquishing.",
- mf->captain);
- Write(W_SIGNAL, ms, 1, (int)message, 0, 0, 0);
- Write(W_END, ms, 0, 0, 0, 0, 0);
-
- if (fp = fopen(LOGFILE, "r+")) {
- net = (float)mf->points / mc->pts;
- people = getw(fp);
- n = fread((char *)log, sizeof(struct logs), 10, fp);
- for (; n < 10; n++)
- log[n].l_name[0]
- = log[n].l_uid
- = log[n].l_shipnum
- = log[n].l_gamenum
- = log[n].l_netpoints = 0;
- rewind(fp);
- if (people < 0)
- (void) putw(1, fp);
- else
- (void) putw(people + 1, fp);
- for (n = 0; n < 10; n++)
- if (net > (float) log[n].l_netpoints / scene[log[n].l_gamenum].ship[log[n].l_shipnum].specs->pts) {
- (void) fwrite((char *)log,
- sizeof (struct logs), n, fp);
- (void) strcpy(temp.l_name, mf->captain);
- temp.l_uid = getuid();
- temp.l_shipnum = player;
- temp.l_gamenum = game;
- temp.l_netpoints = mf->points;
- (void) fwrite((char *)&temp,
- sizeof temp, 1, fp);
- (void) fwrite((char *)&log[n],
- sizeof (struct logs), 9-n, fp);
- break;
- }
- (void) fclose(fp);
- }
- if (done_curses) {
- screen();
- Signal("It looks like you've had it!",
- (struct ship *)0);
- switch (conditions) {
- case LEAVE_QUIT:
- break;
- case LEAVE_CAPTURED:
- Signal("Your ship was captured.",
- (struct ship *)0);
- break;
- case LEAVE_HURRICAN:
- Signal("Hurricane! All ships destroyed.",
- (struct ship *)0);
- break;
- case LEAVE_DRIVER:
- Signal("The driver died.", (struct ship *)0);
- break;
- default:
- Signal("A funny thing happened (%d).",
- (struct ship *)0, conditions);
- }
- } else {
- if (conditions == LEAVE_DRIVER)
- printf("The driver died.\n");
- else
- printf("leave: unknown code %d\n", conditions);