Mercurial > hg > early-roguelike
annotate xrogue/main.c @ 281:4a3f4729257c
Merge the urogue and bugfix branches.
author | John "Elwin" Edwards |
---|---|
date | Fri, 15 Sep 2017 21:16:28 -0400 |
parents | 3d4252fa2ed3 |
children | e52a8a7ad4c5 |
rev | line source |
---|---|
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
1 /* |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
2 main.c - setup code |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
3 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
4 XRogue: Expeditions into the Dungeons of Doom |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
5 Copyright (C) 1991 Robert Pietkivitch |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
6 All rights reserved. |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
7 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
8 Based on "Advanced Rogue" |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
9 Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
10 All rights reserved. |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
11 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
12 Based on "Rogue: Exploring the Dungeons of Doom" |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
13 Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
14 All rights reserved. |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
15 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
16 See the file LICENSE.TXT for full copyright and licensing information. |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
17 */ |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
18 |
135 | 19 #include <stdlib.h> |
20 #include <string.h> | |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
21 #include <curses.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
22 #include <signal.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
23 #include <time.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
24 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
25 #include "mach_dep.h" |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
26 #include "network.h" |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
27 #include "rogue.h" |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
28 |
143
7faf4568c295
Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents:
139
diff
changeset
|
29 void open_records(void); |
220
f54901b9c39b
XRogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
30 bool too_much(void); |
f54901b9c39b
XRogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
31 bool author(void); |
f54901b9c39b
XRogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
32 bool playtime(void); |
f54901b9c39b
XRogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
33 bool betaover(void); |
136
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
34 |
220
f54901b9c39b
XRogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
35 int |
f54901b9c39b
XRogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
151
diff
changeset
|
36 main(int argc, char *argv[], char *envp[]) |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
37 { |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
38 register char *env; |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
39 time_t now; |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
40 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
41 md_init(); |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
42 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
43 /* |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
44 * get home and options from environment |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
45 */ |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
46 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
47 strncpy(home, md_gethomedir(), LINELEN); |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
48 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
49 /* Get default save file */ |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
50 strcpy(file_name, home); |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
51 strcat(file_name, "xrogue.sav"); |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
52 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
53 /* Get default score file */ |
136
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
54 #ifdef SCOREFILE |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
55 strncpy(score_file, SCOREFILE, LINELEN); |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
56 score_file[LINELEN-1] = '\0'; |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
57 #else |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
58 strcpy(score_file, md_getroguedir()); |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
59 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
60 if (*score_file) |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
61 strcat(score_file,"/"); |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
62 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
63 strcat(score_file, "xrogue.scr"); |
136
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
64 #endif |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
65 |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
66 #ifdef SAVEDIR |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
67 /* Check for common save location */ |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
68 if (argc >= 3 && strcmp(argv[1], "-n") == 0) |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
69 { |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
70 strncpy(whoami, argv[2], 79); |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
71 whoami[79] = '\0'; |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
72 use_savedir = TRUE; |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
73 if (LINELEN <= snprintf(file_name, LINELEN, "%s/%d-%s.xrsav", SAVEDIR, |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
74 md_getuid(), whoami)) |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
75 { |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
76 strcpy(file_name, "xrogue.sav"); |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
77 use_savedir = FALSE; |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
78 } |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
79 } |
1fbdefa82533
xrogue: initial support for the -n option.
John "Elwin" Edwards
parents:
135
diff
changeset
|
80 #endif |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
81 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
82 if ((env = getenv("ROGUEOPTS")) != NULL) |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
83 parse_opts(env); |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
84 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
85 if (whoami[0] == '\0') |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
86 strucpy(whoami, md_getusername(), strlen(md_getusername())); |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
87 |
143
7faf4568c295
Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents:
139
diff
changeset
|
88 open_records(); |
7faf4568c295
Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents:
139
diff
changeset
|
89 if (!use_savedir) |
7faf4568c295
Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents:
139
diff
changeset
|
90 md_normaluser(); |