Mercurial > hg > early-roguelike
annotate arogue7/main.c @ 278:c222f9d56776
Remove an extra bracket from some Autoconf macros.
author | John "Elwin" Edwards |
---|---|
date | Sun, 10 Sep 2017 17:30:13 -0400 |
parents | 3d4252fa2ed3 |
children | d3968e9cb98d |
rev | line source |
---|---|
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
1 /* |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
2 * main.c - setup code |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
3 * |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
4 * Advanced Rogue |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
5 * Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
6 * All rights reserved. |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
7 * |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
8 * Based on "Rogue: Exploring the Dungeons of Doom" |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
10 * All rights reserved. |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
11 * |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
12 * See the file LICENSE.TXT for full copyright and licensing information. |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
13 */ |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
14 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
15 #include "curses.h" |
126 | 16 #include <stdlib.h> |
17 #include <string.h> | |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
18 #include <signal.h> |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
19 #ifdef BSD |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
20 #include <sys/time.h> |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
21 #else |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
22 #include <time.h> |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
23 #endif |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
24 #include "mach_dep.h" |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
25 #include "network.h" |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
26 #include "rogue.h" |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
27 #ifdef PC7300 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
28 #include "sys/window.h" |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
29 #include <ctype.h> |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
30 extern struct uwdata wdata, oldwin; |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
31 extern char oldtext[WTXTNUM][WTXTLEN]; |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
32 #endif |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
33 |
143
7faf4568c295
Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents:
131
diff
changeset
|
34 void open_records(void); |
219
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
35 bool too_much(void); |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
36 bool author(void); |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
37 void chmsg(char *fmt, int arg); |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
38 #ifdef MAXPROCESSES |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
39 int loadav(void); |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
40 #endif |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
41 #ifdef MAXUSERS |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
42 int ucount(void); |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
43 #endif |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
44 bool holiday(void); |
128 | 45 |
219
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
46 int |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
47 main(int argc, char *argv[], char *envp[]) |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
48 { |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
49 register char *env; |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
50 #ifdef PC7300 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
51 int hardwindow; /* Do we have a hardware window? */ |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
52 #endif |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
53 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
54 md_init(); |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
55 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
56 /* |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
57 * get home and options from environment |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
58 */ |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
59 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
60 strncpy(home, md_gethomedir(), LINELEN); |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
61 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
62 /* Get default save file */ |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
63 strcpy(file_name, home); |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
64 strcat(file_name, "arogue77.sav"); |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
65 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
66 /* Get default score file */ |
127
8ae3ffd6c6e7
arogue7: make the scorefile location configurable.
John "Elwin" Edwards
parents:
126
diff
changeset
|
67 #ifdef SCOREFILE |
8ae3ffd6c6e7
arogue7: make the scorefile location configurable.
John "Elwin" Edwards
parents:
126
diff
changeset
|
68 strncpy(score_file, SCOREFILE, LINELEN); |
8ae3ffd6c6e7
arogue7: make the scorefile location configurable.
John "Elwin" Edwards
parents:
126
diff
changeset
|
69 score_file[LINELEN-1] = '\0'; |
8ae3ffd6c6e7
arogue7: make the scorefile location configurable.
John "Elwin" Edwards
parents:
126
diff
changeset
|
70 #else |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
71 strcpy(score_file, md_getroguedir()); |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
72 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
73 if (*score_file) |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
74 strcat(score_file,"/"); |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
75 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
76 strcat(score_file,"arogue77.scr"); |
127
8ae3ffd6c6e7
arogue7: make the scorefile location configurable.
John "Elwin" Edwards
parents:
126
diff
changeset
|
77 #endif |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
78 |
128 | 79 #ifdef SAVEDIR |
80 /* Check for common save location */ | |
81 if (argc >= 3 && strcmp(argv[1], "-n") == 0) | |
82 { | |
83 strncpy(whoami, argv[2], 79); | |
84 whoami[79] = '\0'; | |
85 use_savedir = TRUE; | |
86 if (LINELEN <= snprintf(file_name, LINELEN, "%s/%d-%s.ar7sav", SAVEDIR, | |
87 md_getuid(), whoami)) | |
88 { | |
89 strcpy(file_name, "xrogue.sav"); | |