Annotation of 43BSDTahoe/games/sail/dr_main.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1983 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted
                      6:  * provided that the above copyright notice and this paragraph are
                      7:  * duplicated in all such forms and that any documentation,
                      8:  * advertising materials, and other materials related to such
                      9:  * distribution and use acknowledge that the software was developed
                     10:  * by the University of California, Berkeley.  The name of the
                     11:  * University may not be used to endorse or promote products derived
                     12:  * from this software without specific prior written permission.
                     13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     15:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     16:  */
                     17: 
                     18: #ifndef lint
                     19: static char sccsid[] = "@(#)dr_main.c  5.4 (Berkeley) 6/18/88";
                     20: #endif /* not lint */
                     21: 
                     22: #include "driver.h"
                     23: 
                     24: dr_main()
                     25: {
                     26:        register int n;
                     27:        register struct ship *sp;
                     28:        int nat[NNATION];
                     29:        int value = 0;
                     30: 
                     31:        (void) signal(SIGINT, SIG_IGN);
                     32:        (void) signal(SIGQUIT, SIG_IGN);
                     33:        (void) signal(SIGTSTP, SIG_IGN);
                     34:        if (issetuid)
                     35:                (void) setruid(geteuid());
                     36:        if (game < 0 || game >= NSCENE) {
                     37:                fprintf(stderr, "DRIVER: Bad game number %d\n", game);
                     38:                exit(1);
                     39:        }
                     40:        cc = &scene[game];
                     41:        ls = SHIP(cc->vessels);
                     42:        if (sync_open() < 0) {
                     43:                perror("driver: syncfile");
                     44:                exit(1);
                     45:        }
                     46:        for (n = 0; n < NNATION; n++)
                     47:                nat[n] = 0;
                     48:        foreachship(sp) {
                     49:                if (sp->file == NULL &&
                     50:                    (sp->file = (struct File *)calloc(1, sizeof (struct File))) == NULL) {
                     51:                        (void) fprintf(stderr, "DRIVER: Out of memory.\n");
                     52:                        exit(1);
                     53:                }
                     54:                sp->file->index = sp - SHIP(0);
                     55:                sp->file->loadL = L_ROUND;
                     56:                sp->file->loadR = L_ROUND;
                     57:                sp->file->readyR = R_LOADED|R_INITIAL;
                     58:                sp->file->readyL = R_LOADED|R_INITIAL;
                     59:                sp->file->stern = nat[sp->nationality]++;
                     60:                sp->file->dir = sp->shipdir;
                     61:                sp->file->row = sp->shiprow;
                     62:                sp->file->col = sp->shipcol;
                     63:        }
                     64:        windspeed = cc->windspeed;
                     65:        winddir = cc->winddir;
                     66:        people = 0;
                     67:        for (;;) {
                     68:                sleep(7);
                     69:                if (Sync() < 0) {
                     70:                        value = 1;
                     71:                        break;
                     72:                }
                     73:                if (next() < 0)
                     74:                        break;
                     75:                unfoul();
                     76:                checkup();
                     77:                prizecheck();
                     78:                moveall();
                     79:                thinkofgrapples();
                     80:                boardcomp();
                     81:                compcombat();
                     82:                resolve();
                     83:                reload();
                     84:                checksails();
                     85:                if (Sync() < 0) {
                     86:                        value = 1;
                     87:                        break;
                     88:                }
                     89:        }
                     90:        sync_close(1);
                     91:        return value;
                     92: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.