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