1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: char copyright[] =
   9: "@(#) Copyright (c) 1980 Regents of the University of California.\n\
  10:  All rights reserved.\n";
  11: #endif not lint
  12: 
  13: #ifndef lint
  14: static char sccsid[] = "@(#)main.c	5.1 (Berkeley) 5/30/85";
  15: #endif not lint
  16: 
  17: # include   "robots.h"
  18: # include   <signal.h>
  19: # include   <ctype.h>
  20: 
  21: main(ac, av)
  22: int ac;
  23: char    **av;
  24: {
  25:     register char   *sp;
  26:     register bool   bad_arg;
  27:     register bool   show_only;
  28:     extern char *Scorefile;
  29:     extern int  Max_per_uid;
  30:     extern char *rindex();
  31: 
  32:     show_only = FALSE;
  33:     if (ac > 1) {
  34:         bad_arg = FALSE;
  35:         for (++av; ac > 1 && *av[0]; av++, ac--)
  36:             if (av[0][0] != '-')
  37:                 if (isdigit(av[0][0]))
  38:                     Max_per_uid = atoi(av[0]);
  39:                 else {
  40:                     setuid(getuid());
  41:                     setgid(getgid());
  42:                     Scorefile = av[0];
  43: # ifdef FANCY
  44:                     sp = rindex(Scorefile, '/');
  45:                     if (sp == NULL)
  46:                         sp = Scorefile;
  47:                     if (strcmp(sp, "pattern_roll") == 0)
  48:                         Pattern_roll = TRUE;
  49:                     else if (strcmp(sp, "stand_still") == 0)
  50:                         Stand_still = TRUE;
  51:                     if (Pattern_roll || Stand_still)
  52:                         Teleport = TRUE;
  53: # endif
  54:                 }
  55:             else
  56:                 for (sp = &av[0][1]; *sp; sp++)
  57:                     switch (*sp) {
  58:                       case 's':
  59:                         show_only = TRUE;
  60:                         break;
  61:                       case 'r':
  62:                         Real_time = TRUE;
  63:                         break;
  64:                       case 'a':
  65:                         Start_level = 4;
  66:                         break;
  67:                       case 'j':
  68:                         Jump = TRUE;
  69:                         break;
  70:                       case 't':
  71:                         Teleport = TRUE;
  72:                         break;
  73:                       default:
  74:                         fprintf(stderr, "robots: uknown option: %c\n", *sp);
  75:                         bad_arg = TRUE;
  76:                         break;
  77:                     }
  78:         if (bad_arg) {
  79:             exit(1);
  80:             /* NOTREACHED */
  81:         }
  82:     }
  83: 
  84:     if (show_only) {
  85:         show_score();
  86:         exit(0);
  87:         /* NOTREACHED */
  88:     }
  89: 
  90:     initscr();
  91:     signal(SIGINT, quit);
  92:     crmode();
  93:     noecho();
  94:     nonl();
  95:     if (LINES != Y_SIZE || COLS != X_SIZE) {
  96:         if (LINES < Y_SIZE || COLS < X_SIZE) {
  97:             endwin();
  98:             printf("Need at least a %dx%d screen\n", Y_SIZE, X_SIZE);
  99:             exit(1);
 100:         }
 101:         delwin(stdscr);
 102:         stdscr = newwin(Y_SIZE, X_SIZE, 0, 0);
 103:     }
 104: 
 105:     srand(getpid());
 106:     if (Real_time)
 107:         signal(SIGALRM, move_robots);
 108:     do {
 109:         init_field();
 110:         for (Level = Start_level; !Dead; Level++) {
 111:             make_level();
 112:             play_level();
 113:         }
 114:         move(My_pos.y, My_pos.x);
 115:         printw("AARRrrgghhhh....");
 116:         refresh();
 117:         score();
 118:     } while (another());
 119:     quit();
 120: }
 121: 
 122: /*
 123:  * quit:
 124:  *	Leave the program elegantly.
 125:  */
 126: quit()
 127: {
 128:     extern int  _putchar();
 129: 
 130:     mvcur(0, COLS - 1, LINES - 1, 0);
 131:     if (CE) {
 132:         tputs(CE, 1, _putchar);
 133:         endwin();
 134:     }
 135:     else {
 136:         endwin();
 137:         putchar('\n');
 138:     }
 139:     exit(0);
 140:     /* NOTREACHED */
 141: }
 142: 
 143: /*
 144:  * another:
 145:  *	See if another game is desired
 146:  */
 147: another()
 148: {
 149:     register int    y;
 150: 
 151: #ifdef  FANCY
 152:     if ((Stand_still || Pattern_roll) && !Newscore)
 153:         return TRUE;
 154: #endif
 155: 
 156:     if (query("Another game?")) {
 157:         if (Full_clear) {
 158:             for (y = 1; y <= Num_scores; y++) {
 159:                 move(y, 1);
 160:                 clrtoeol();
 161:             }
 162:             refresh();
 163:         }
 164:         return TRUE;
 165:     }
 166:     return FALSE;
 167: }

Defined functions

another defined in line 147; used 1 times
main defined in line 21; never used
quit defined in line 126; used 4 times

Defined variables

copyright defined in line 8; never used
sccsid defined in line 14; never used
Last modified: 1985-05-31
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1477
Valid CSS Valid XHTML 1.0 Strict