annotate arogue5/main.c @ 317:aab761616489 default tip

Rearrange some Autoconf files. Autoconf was failing to detect install-sh at the top level and needed some explicit directions. It also wants config.guess and config.sub to be provided too. A few other macros have also been updated.
author John "Elwin" Edwards
date Tue, 05 Sep 2023 20:05:24 -0400
parents 827441d05b3e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
1 /*
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
2 * Rogue
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
3 *
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
4 * Advanced Rogue
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
5 * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
6 * All rights reserved.
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
7 *
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
8 * Based on "Rogue: Exploring the Dungeons of Doom"
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
10 * All rights reserved.
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
11 *
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
12 * See the file LICENSE.TXT for full copyright and licensing information.
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
13 */
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
14
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
15 #include "curses.h"
67
c49f7927b0fa arogue5: add missing header files.
elwin
parents: 66
diff changeset
16 #include <stdlib.h>
c49f7927b0fa arogue5: add missing header files.
elwin
parents: 66
diff changeset
17 #include <string.h>
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
18 #include <fcntl.h>
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
19 #include <sys/stat.h>
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
20 #include <limits.h>
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
21 #include <signal.h>
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
22 #include <time.h>
279
d3968e9cb98d Use C stdio functions for score files and save files.
John "Elwin" Edwards
parents: 252
diff changeset
23 #include <errno.h>
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
24 #include "mach_dep.h"
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
25 #include "network.h"
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
26 #include "rogue.h"
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
27
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
28 #ifdef CHECKTIME
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
29 static int num_checks; /* times we've gone over in checkout() */
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
30 #endif
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
31
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
32 /*
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
33 * fruits that you get at startup
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
34 */
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
35 static char *funfruit[] = {
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
36 "candleberry", "caprifig", "dewberry", "elderberry",
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
37 "gooseberry", "guanabana", "hagberry", "ilama",
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
38 "imbu", "jaboticaba", "jujube", "litchi",
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
39 "mombin", "pitanga", "prickly pear", "rambutan",
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
40 "sapodilla", "soursop", "sweetsop", "whortleberry",
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
41 "jellybean", "apple", "strawberry", "blueberry",
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
42 "peach", "banana"
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
43 };
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
44 #define NFRUIT (sizeof(funfruit) / sizeof (char *))
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
45
143
7faf4568c295 Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents: 112
diff changeset
46 void open_records(void);
218
56e748983fa8 Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents: 145
diff changeset
47 bool holiday(void);
143
7faf4568c295 Advanced Rogue family: overhaul privilege handling.
John "Elwin" Edwards
parents: 112
diff changeset
48
218
56e748983fa8 Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents: 145
diff changeset
49 int
56e748983fa8 Advanced Rogue 5: convert to ANSI function declarations.
John "Elwin" Edwards
parents: 145
diff changeset
50 main(int argc, char *argv[], char *envp[])
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
51 {
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
52 register char *env;
304
e52a8a7ad4c5 Fix many compiler warnings.
John "Elwin" Edwards
parents: 285
diff changeset
53 #ifndef SCOREFILE
72
46f39359c4a7 arogue5: avoid segfaulting if getpwuid() fails.
elwin
parents: 68
diff changeset
54 char *roguedir;
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
55
72
46f39359c4a7 arogue5: avoid segfaulting if getpwuid() fails.
elwin
parents: 68
diff changeset
56 roguedir = md_getroguedir();
304
e52a8a7ad4c5 Fix many compiler warnings.
John "Elwin" Edwards
parents: 285
diff changeset
57 #endif
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
58 md_init();
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
59
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
60 /*
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
61 * get home and options from environment
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
62 */
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
63 strncpy(home,md_gethomedir(),LINELEN);
310
827441d05b3e Advanced Rogue family: fix some potential buffer overflows.
John "Elwin" Edwards
parents: 304
diff changeset
64 home[LINELEN-1] = '\0';
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
65
64
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
66 #ifdef SAVEDIR
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
67 if (argc >= 3 && !strcmp(argv[1], "-n")) {
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
68 use_savedir = TRUE;
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
69 strncpy(whoami, argv[2], LINELEN);
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
70 whoami[LINELEN - 1] = '\0';
112
ee250e3646fd Don't truncate player name in savefile name or log message.
John "Elwin" Edwards
parents: 107
diff changeset
71 if (snprintf(file_name, 256, "%s/%d-%s.ar5sav", SAVEDIR,
ee250e3646fd Don't truncate player name in savefile name or log message.
John "Elwin" Edwards
parents: 107
diff changeset
72 md_getuid(), whoami) >= 256)
64
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
73 {
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
74 /* The name is too long */
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
75 use_savedir = FALSE;
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
76 }
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
77 }
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
78 #endif
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
79 /* Get default save file */
64
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
80 if (!use_savedir) {
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
81 strcpy(file_name, home);
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
82 strcat(file_name, "arogue58.sav");
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
83 }
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
84
64
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
85 #ifdef SCOREFILE
310
827441d05b3e Advanced Rogue family: fix some potential buffer overflows.
John "Elwin" Edwards
parents: 304
diff changeset
86 strncpy(score_file, SCOREFILE, PATH_MAX);
827441d05b3e Advanced Rogue family: fix some potential buffer overflows.
John "Elwin" Edwards
parents: 304
diff changeset
87 score_file[PATH_MAX - 1] = '\0';
64
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
88 #else
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
89 /* Get default score file */
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
90 strcpy(score_file, roguedir);
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
91
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
92 if (*score_file)
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
93 strcat(score_file,"/");
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
94
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
95 strcat(score_file, "arogue58.scr");
64
a98834ce7e04 arogue5: add the savedir feature.
elwin
parents: 63
diff changeset
96 #endif
63
0ed67132cf10 Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
97