Annotation of 43BSDReno/games/mille/mille.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1982 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: char copyright[] =
        !            22: "@(#) Copyright (c) 1982 Regents of the University of California.\n\
        !            23:  All rights reserved.\n";
        !            24: #endif /* not lint */
        !            25: 
        !            26: #ifndef lint
        !            27: static char sccsid[] = "@(#)mille.c    5.4 (Berkeley) 6/1/90";
        !            28: #endif /* not lint */
        !            29: 
        !            30: # include      "mille.h"
        !            31: # include      <signal.h>
        !            32: # ifdef attron
        !            33: #      include <term.h>
        !            34: # endif        attron
        !            35: 
        !            36: /*
        !            37:  * @(#)mille.c 1.3 (Berkeley) 5/10/83
        !            38:  */
        !            39: 
        !            40: int    rub();
        !            41: 
        !            42: main(ac, av)
        !            43: reg int                ac;
        !            44: reg char       *av[]; {
        !            45: 
        !            46:        reg bool        restore;
        !            47: 
        !            48:        /* run as the user */
        !            49:        setuid(getuid());
        !            50: 
        !            51:        if (strcmp(av[0], "a.out") == 0) {
        !            52:                outf = fopen("q", "w");
        !            53:                setbuf(outf, (char *)NULL);
        !            54:                Debug = TRUE;
        !            55:        }
        !            56:        restore = FALSE;
        !            57:        switch (ac) {
        !            58:          case 2:
        !            59:                rest_f(av[1]);
        !            60:                restore = TRUE;
        !            61:          case 1:
        !            62:                break;
        !            63:          default:
        !            64:                printf("usage: milles [ restore_file ]\n");
        !            65:                exit(-1);
        !            66:                /* NOTREACHED */
        !            67:        }
        !            68:        Play = PLAYER;
        !            69:        initscr();
        !            70: # ifdef attron
        !            71: #      define  CA      cursor_address
        !            72: # endif
        !            73:        if (!CA) {
        !            74:                printf("Sorry.  Need cursor addressing to play mille\n");
        !            75:                exit(-1);
        !            76:        }
        !            77:        delwin(stdscr);
        !            78:        stdscr = Board = newwin(BOARD_Y, BOARD_X, 0, 0);
        !            79:        Score = newwin(SCORE_Y, SCORE_X, 0, 40);
        !            80:        Miles = newwin(MILES_Y, MILES_X, 17, 0);
        !            81: #ifdef attron
        !            82:        idlok(Board, TRUE);
        !            83:        idlok(Score, TRUE);
        !            84:        idlok(Miles, TRUE);
        !            85: #endif
        !            86:        leaveok(Score, TRUE);
        !            87:        leaveok(Miles, TRUE);
        !            88:        clearok(curscr, TRUE);
        !            89: # ifndef PROF
        !            90:        srandom(getpid());
        !            91: # else
        !            92:        srandom(0);
        !            93: # endif
        !            94:        crmode();
        !            95:        noecho();
        !            96:        signal(SIGINT, rub);
        !            97:        for (;;) {
        !            98:                if (!restore || (Player[PLAYER].total >= 5000
        !            99:                    || Player[COMP].total >= 5000)) {
        !           100:                        if (Player[COMP].total < Player[PLAYER].total)
        !           101:                                Player[PLAYER].games++;
        !           102:                        else if (Player[COMP].total > Player[PLAYER].total)
        !           103:                                Player[COMP].games++;
        !           104:                        Player[COMP].total = 0;
        !           105:                        Player[PLAYER].total = 0;
        !           106:                }
        !           107:                do {
        !           108:                        if (!restore)
        !           109:                                Handstart = Play = other(Handstart);
        !           110:                        if (!restore || On_exit) {
        !           111:                                shuffle();
        !           112:                                init();
        !           113:                        }
        !           114:                        newboard();
        !           115:                        if (restore)
        !           116:                                mvwaddstr(Score, ERR_Y, ERR_X, Initstr);
        !           117:                        prboard();
        !           118:                        do {
        !           119:                                domove();
        !           120:                                if (Finished)
        !           121:                                        newscore();
        !           122:                                prboard();
        !           123:                        } while (!Finished);
        !           124:                        check_more();
        !           125:                        restore = On_exit = FALSE;
        !           126:                } while (Player[COMP].total < 5000
        !           127:                    && Player[PLAYER].total < 5000);
        !           128:        }
        !           129: }
        !           130: 
        !           131: /*
        !           132:  *     Routine to trap rubouts, and make sure they really want to
        !           133:  * quit.
        !           134:  */
        !           135: rub() {
        !           136: 
        !           137:        (void)signal(SIGINT, SIG_IGN);
        !           138:        if (getyn(REALLYPROMPT))
        !           139:                die();
        !           140:        (void)signal(SIGINT, rub);
        !           141: }
        !           142: 
        !           143: /*
        !           144:  *     Time to go beddy-by
        !           145:  */
        !           146: die() {
        !           147: 
        !           148:        (void)signal(SIGINT, SIG_IGN);
        !           149:        if (outf)
        !           150:                fflush(outf);
        !           151:        mvcur(0, COLS - 1, LINES - 1, 0);
        !           152:        endwin();
        !           153:        exit(1);
        !           154: }
        !           155: 

unix.superglobalmegacorp.com

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