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

Defined functions

die defined in line 126; used 3 times
main defined in line 15; never used
rub defined in line 115; used 4 times

Defined variables

_sobuf defined in line 13; used 1 times
  • in line 47

Defined macros

CA defined in line 51; used 1 times
  • in line 53
Last modified: 1995-01-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3367
Valid CSS Valid XHTML 1.0 Strict