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

unix.superglobalmegacorp.com

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