Mercurial > hg > early-roguelike
annotate arogue7/main.c @ 238:e1cd27c5464f
arogue7, xrogue: improve the handling of the arguments to fuses.
fuse() now expects a pointer as the argument to a fuse function. If
this is one of the functions that takes int, fuse() follows the pointer
and stores that value in the f_list slot, in the integer field of the
argument union. When the fuse goes off, do_fuses() recognizes the
function and passes it the integer field instead of the pointer.
This has the disadvantage of hard-coding the functions that require int
in daemon.c, but since the int is copied into f_list, it no longer has
to be in static or global memory, which simplifies several files.
author | John "Elwin" Edwards |
---|---|
date | Fri, 11 Mar 2016 17:40:00 -0500 |
parents | f9ef86cf22b2 |
children | 3d4252fa2ed3 |
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 int lowtime; |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
51 time_t now; |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
52 #ifdef PC7300 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
53 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
|
54 #endif |
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 md_init(); |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
57 |
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 * get home and options from environment |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
60 */ |
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 strncpy(home, md_gethomedir(), LINELEN); |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
63 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
64 /* Get default save file */ |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
65 strcpy(file_name, home); |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
66 strcat(file_name, "arogue77.sav"); |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
67 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
68 /* Get default score file */ |
127
8ae3ffd6c6e7
arogue7: make the scorefile location configurable.
John "Elwin" Edwards
parents:
126
diff
changeset
|
69 #ifdef SCOREFILE |
8ae3ffd6c6e7
arogue7: make the scorefile location configurable.
John "Elwin" Edwards
parents:
126
diff
changeset
|
70 strncpy(score_file, SCOREFILE, LINELEN); |
8ae3ffd6c6e7
arogue7: make the scorefile location configurable.
John "Elwin" Edwards
parents:
126
diff
changeset
|
71 score_file[LINELEN-1] = '\0'; |
8ae3ffd6c6e7
arogue7: make the scorefile location configurable.
John "Elwin" Edwards
parents:
126
diff
changeset
|
72 #else |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
73 strcpy(score_file, md_getroguedir()); |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
74 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
75 if (*score_file) |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
76 strcat(score_file,"/"); |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
77 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
78 strcat(score_file,"arogue77.scr"); |
127
8ae3ffd6c6e7
arogue7: make the scorefile location configurable.
John "Elwin" Edwards
parents:
126
diff
changeset
|
79 #endif |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
80 |
128 | 81 #ifdef SAVEDIR |
82 /* Check for common save location */ | |
83 if (argc >= 3 && strcmp(argv[1], "-n") == 0) | |
84 { | |
85 strncpy(whoami, argv[2], 79); | |
86 whoami[79] = '\0'; | |
87 use_savedir = TRUE; | |
88 if (LINELEN <= snprintf(file_name, LINELEN, "%s/%d-%s.ar7sav", SAVEDIR, | |
c697782a9b37
arogue7: implement the -n option.
John "Elwin" Edwards |