Annotation of researchv10no/games/mille/mille.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char sccsid[] = "@(#)mille.c    4.1 12/24/82";
        !             3: #endif
        !             4: 
        !             5: # include      "mille.h"
        !             6: # include      <signal.h>
        !             7: 
        !             8: int    rub(), tstp();
        !             9: 
        !            10: char   _sobuf[BUFSIZ];
        !            11: 
        !            12: main(ac, av)
        !            13: reg int                ac;
        !            14: reg char       *av[]; {
        !            15: 
        !            16:        reg bool        restore;
        !            17: 
        !            18: # if 0
        !            19:        if (getuid() == GURP) {
        !            20:                printf("%s: Permission denied\n", av[0]);
        !            21:                exit(1);
        !            22:        }
        !            23: # endif
        !            24:        if (strcmp(av[0], "a.out") == 0) {
        !            25:                outf = fopen("q", "w");
        !            26:                setbuf(outf, 0);
        !            27:                Debug = TRUE;
        !            28:        }
        !            29:        restore = FALSE;
        !            30: # ifdef pdp11
        !            31:        if (geteuid() != ARNOLD)
        !            32:                maxusers(MAXUSERS, NULL);
        !            33: # endif
        !            34:        switch (ac) {
        !            35:          case 2:
        !            36:                rest_f(av[1]);
        !            37:                restore = TRUE;
        !            38:          case 1:
        !            39:                break;
        !            40:          default:
        !            41:                printf("usage: milles [ restore_file ]\n");
        !            42:                exit(-1);
        !            43:                /* NOTREACHED */
        !            44:        }
        !            45:        setbuf(stdout, _sobuf);
        !            46:        Play = PLAYER;
        !            47:        initscr();
        !            48:        if (!CA) {
        !            49:                printf("Sorry.  Need cursor addressing to play mille\n");
        !            50:                exit(-1);
        !            51:        }
        !            52:        delwin(stdscr);
        !            53:        stdscr = Board = newwin(BOARD_Y, BOARD_X, 0, 0);
        !            54:        Score = newwin(SCORE_Y, SCORE_X, 0, 40);
        !            55:        Miles = newwin(MILES_Y, MILES_X, 17, 0);
        !            56:        leaveok(Score, TRUE);
        !            57:        leaveok(Miles, TRUE);
        !            58:        clearok(curscr, TRUE);
        !            59: # ifndef PROF
        !            60:        srand(getpid());
        !            61: # else
        !            62:        srand(0);
        !            63: # endif
        !            64:        crmode();
        !            65:        noecho();
        !            66:        signal(SIGINT, rub);
        !            67:        signal(SIGTSTP, tstp);
        !            68:        for (;;) {
        !            69:                if (!restore || (Player[PLAYER].total >= 5000
        !            70:                    || Player[COMP].total >= 5000)) {
        !            71:                        if (Player[COMP].total < Player[PLAYER].total)
        !            72:                                Player[PLAYER].games++;
        !            73:                        else if (Player[COMP].total > Player[PLAYER].total)
        !            74:                                Player[COMP].games++;
        !            75:                        Player[COMP].total = 0;
        !            76:                        Player[PLAYER].total = 0;
        !            77:                }
        !            78:                do {
        !            79:                        if (!restore)
        !            80:                                Handstart = Play = other(Handstart);
        !            81:                        if (!restore || On_exit) {
        !            82:                                shuffle();
        !            83:                                init();
        !            84:                        }
        !            85:                        newboard();
        !            86:                        if (restore)
        !            87:                                mvwaddstr(Score, ERR_Y, ERR_X, Initstr);
        !            88:                        prboard();
        !            89:                        do {
        !            90:                                domove();
        !            91:                                if (Finished)
        !            92:                                        newscore();
        !            93:                                prboard();
        !            94:                        } while (!Finished);
        !            95:                        check_more();
        !            96:                        restore = On_exit = FALSE;
        !            97:                } while (Player[COMP].total < 5000
        !            98:                    && Player[PLAYER].total < 5000);
        !            99:        }
        !           100: }
        !           101: 
        !           102: /*
        !           103:  *     Routine to trap rubouts, and make sure they really want to
        !           104:  * quit.
        !           105:  */
        !           106: rub() {
        !           107: 
        !           108:        signal(SIGINT, 1);
        !           109:        if (getyn("Really? "))
        !           110:                die();
        !           111:        signal(SIGINT, rub);
        !           112: }
        !           113: 
        !           114: /*
        !           115:  *     Time to go beddy-by
        !           116:  */
        !           117: die() {
        !           118: 
        !           119:        signal(SIGINT, 1);
        !           120:        if (outf)
        !           121:                fflush(outf);
        !           122:        mvcur(0, COLS - 1, LINES - 1, 0);
        !           123:        endwin();
        !           124:        exit(1);
        !           125: }
        !           126: 
        !           127: tstp() {
        !           128: 
        !           129:        if (outf)
        !           130:                fflush(outf);
        !           131:        resetty();
        !           132:        kill(0, SIGTSTP);
        !           133:        signal(SIGTSTP, tstp);
        !           134:        noecho();
        !           135:        crmode();
        !           136: }

unix.superglobalmegacorp.com

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