1: /* 2: * Copyright (c) 1983 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: static char sccsid[] = "@(#)dr_main.c 5.2 (Berkeley) 1/21/86"; 9: #endif not lint 10: 11: #include "driver.h" 12: 13: dr_main() 14: { 15: register int n; 16: register struct ship *sp; 17: int nat[NNATION]; 18: int value = 0; 19: 20: (void) signal(SIGINT, SIG_IGN); 21: (void) signal(SIGQUIT, SIG_IGN); 22: (void) signal(SIGTSTP, SIG_IGN); 23: if (issetuid) 24: (void) setruid(geteuid()); 25: if (game < 0 || game >= NSCENE) { 26: fprintf(stderr, "DRIVER: Bad game number %d\n", game); 27: exit(1); 28: } 29: cc = &scene[game]; 30: ls = SHIP(cc->vessels); 31: if (sync_open() < 0) { 32: perror("driver: syncfile"); 33: exit(1); 34: } 35: for (n = 0; n < NNATION; n++) 36: nat[n] = 0; 37: foreachship(sp) { 38: if (sp->file == NULL && 39: (sp->file = (struct File *)calloc(1, sizeof (struct File))) == NULL) { 40: (void) fprintf(stderr, "DRIVER: Out of memory.\n"); 41: exit(1); 42: } 43: sp->file->index = sp - SHIP(0); 44: sp->file->loadL = L_ROUND; 45: sp->file->loadR = L_ROUND; 46: sp->file->readyR = R_LOADED|R_INITIAL; 47: sp->file->readyL = R_LOADED|R_INITIAL; 48: sp->file->stern = nat[sp->nationality]++; 49: sp->file->dir = sp->shipdir; 50: sp->file->row = sp->shiprow; 51: sp->file->col = sp->shipcol; 52: } 53: windspeed = cc->windspeed; 54: winddir = cc->winddir; 55: people = 0; 56: for (;;) { 57: sleep(7); 58: if (Sync() < 0) { 59: value = 1; 60: break; 61: } 62: if (next() < 0) 63: break; 64: unfoul(); 65: checkup(); 66: prizecheck(); 67: moveall(); 68: thinkofgrapples(); 69: boardcomp(); 70: compcombat(); 71: resolve(); 72: reload(); 73: checksails(); 74: if (Sync() < 0) { 75: value = 1; 76: break; 77: } 78: } 79: sync_close(1); 80: return value; 81: }