Mercurial > hg > early-roguelike
annotate rogue3/main.c @ 214:e5a15b09ce1d
rogue3, rogue5: fix all GCC5 warnings.
GCC5 enables more warnings by default, including pre-ANSI implicit
function definitions. These two games now build cleanly, but the others
will require more effort.
author | John "Elwin" Edwards |
---|---|
date | Sat, 23 Jan 2016 09:35:14 -0500 |
parents | 12e070d1a780 |
children | 3d4252fa2ed3 |
rev | line source |
---|---|
0
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
1 /* |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
2 * @(#)main.c 3.27 (Berkeley) 6/15/81 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
3 * |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
4 * Rogue: Exploring the Dungeons of Doom |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
5 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
6 * All rights reserved. |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
7 * |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
8 * See the file LICENSE.TXT for full copyright and licensing information. |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
9 */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
10 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
11 #include "curses.h" |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
12 #include <time.h> |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
13 #include <signal.h> |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
14 #include <limits.h> |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
15 #include <stdlib.h> |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
16 #include <stdarg.h> |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
17 #include <string.h> |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
18 #include "machdep.h" |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
19 #include "rogue.h" |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
20 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
21 int num_checks = 0; /* times we've gone over in checkout() */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
22 WINDOW *cw; /* Window that the player sees */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
23 WINDOW *hw; /* Used for the help command */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
24 WINDOW *mw; /* Used to store mosnters */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
25 FILE *scoreboard = NULL; |
17 | 26 FILE *logfi = NULL; |
0
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
27 |
214
e5a15b09ce1d
rogue3, rogue5: fix all GCC5 warnings.
John "Elwin" Edwards
parents:
212
diff
changeset
|
28 int |
e5a15b09ce1d
rogue3, rogue5: fix all GCC5 warnings.
John "Elwin" Edwards
parents:
212
diff
changeset
|
29 main(int argc, char *argv[], char *envp[]) |
0
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
30 { |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
31 char *env; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
32 struct linked_list *item; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
33 struct object *obj; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
34 int lowtime; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
35 time_t now; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
36 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
37 md_init(MD_STRIP_CTRL_KEYPAD); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
38 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
39 open_score(); |
19 | 40 open_log(); |
0
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
41 |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
42 /* |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
43 * check for print-score option |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
44 */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
45 if (argc == 2 && strcmp(argv[1], "-s") == 0) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
46 { |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
47 waswizard = TRUE; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
48 score(0, -1, 0); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
49 exit(0); |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
50 } |
11 | 51 |
52 #ifdef WIZARD | |
0
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
53 /* |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
54 * Check to see if he is a wizard |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
55 */ |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
56 if (argc >= 2 && argv[1][0] == '\0') |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
57 if (strcmp(PASSWD, crypt(md_getpass("Wizard's password: "), "mT")) == 0) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
58 { |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
59 wizard = TRUE; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
60 argv++; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
61 argc--; |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
62 } |
11 | 63 #endif |
0
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
64 |
1 | 65 /* Are we using the system savefile directory? */ |
66 #ifdef SAVEDIR | |
67 if (argc >= 3 && !strcmp(argv[1], "-n")) | |
68 { | |
69 strncpy(whoami, argv[2], 79); | |
70 whoami[79] = '\0'; | |
71 use_savedir = TRUE; | |
30 | 72 /* look for savefile at SAVEDIR/UID-playername.r3sav */ |
112
ee250e3646fd
Don't truncate player name in savefile name or log message.
John "Elwin" Edwards
parents:
95
diff
changeset
|
73 if (snprintf(file_name, 256, "%s/%d-%s.r3sav", SAVEDIR, md_getuid(), whoami) >= 256) |
1 | 74 { |
75 /* this shouldn't happen */ | |
76 strcpy(file_name, "rogue3.save"); | |
77 use_savedir = FALSE; | |
78 } | |
79 } | |
80 #endif | |
81 | |
82 if (use_savedir == FALSE) | |
83 { | |
84 md_normaluser(); | |
85 /* because we don't need to create a file in the common savedir, | |
86 * and the scorefile is already open */ | |
87 strcpy(home, md_gethomedir()); | |
0
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
88 |
1 | 89 if (strlen(home) > PATH_MAX - strlen("rogue3.save") - 1) |
90 *home = 0; | |
0
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
91 |
1 | 92 strcpy(file_name, home); |
93 strcat(file_name, "rogue3.save"); | |
94 } | |
95 | |
0
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
96 if ((env = getenv("ROGUEOPTS")) != NULL) |
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
97 parse_opts(env); |
1 | 98 if (!use_savedir && (env == NULL || whoami[0] == '\0')) |
0
527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
99 strucpy(whoami, md_getusername(), strlen(md_getusername())); |