Mercurial > hg > early-roguelike
annotate urogue/main.c @ 269:a413bc97d3ea
UltraRogue: fix the arrow keys.
The startup sequence now calls keypad() to turn on curses recognition
of special keys.
author | John "Elwin" Edwards |
---|---|
date | Tue, 28 Feb 2017 21:14:53 -0500 |
parents | 4ab49e42dd6a |
children | 1db299e868b8 |
rev | line source |
---|---|
256
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
1 /* |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
2 main.c - setup code |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
3 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
4 UltraRogue: The Ultimate Adventure in the Dungeons of Doom |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
5 Copyright (C) 1985, 1986, 1992, 1993, 1995 Herb Chong |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
6 All rights reserved. |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
7 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
8 Based on "Advanced Rogue" |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
9 Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
10 All rights reserved. |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
11 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
12 Based on "Rogue: Exploring the Dungeons of Doom" |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
13 Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
14 All rights reserved. |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
15 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
16 See the file LICENSE.TXT for full copyright and licensing information. |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
17 */ |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
18 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
19 #define _ALL_SOURCE |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
20 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
21 #include <time.h> |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
22 #include <stdlib.h> |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
23 #include <string.h> |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
24 #include <signal.h> |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
25 #include <stdlib.h> |
259 | 26 #include <errno.h> |
256
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
27 #include "rogue.h" |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
28 |
259 | 29 #define SAVEDIR "." |
263
08057be02f47
UltraRogue: make scorefile location configurable.
John "Elwin" Edwards
parents:
259
diff
changeset
|
30 #define SCOREFILE "/var/local/games/roguelike/urogue.scr" |
268 | 31 #define LOGFILE "/var/local/games/roguelike/urogue.log" |
259 | 32 |
256
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
33 FILE *fd_score = NULL; |
268 | 34 FILE *file_log = NULL; |
256
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
35 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
36 /* Command line options */ |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
37 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
38 int prscore; /* Print scores */ |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
39 int prversion; /* Print version info */ |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
40 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
41 int |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
42 main(int argc, char *argv[]) |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
43 { |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
44 int x; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
45 char *env; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
46 time_t lowtime; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
47 time_t now; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
48 int rflag = 0; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
49 char *nm; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
50 float scale; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
51 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
52 for (x = 1; x < argc; x++) |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
53 { |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
54 if (argv[x][0] != '-') |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
55 break; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
56 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
57 switch (argv[x][1]) |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
58 { |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
59 case 's': |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
60 prscore = TRUE; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
61 break; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
62 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
63 case 'v': |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
64 prversion = TRUE; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
65 break; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
66 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
67 case 'r': |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
68 rflag = TRUE; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
69 break; |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
70 |
259 | 71 #ifdef SAVEDIR |
72 case 'n': | |
73 if (x + 1 < argc) { | |
74 use_savedir = TRUE; | |
75 x++; | |
76 // Set rogue's name to the next argument | |
77 strncpy(whoami, argv[x], 2*LINELEN); | |
78 whoami[2*LINELEN - 1] = '\0'; | |
79 // And set up the savefile name | |
80 snprintf(file_name, 2*LINELEN, "%s/%d-%.80s.ursav", SAVEDIR, | |
81 md_getuid(), whoami); | |
82 } | |
83 break; | |
84 #endif | |
85 | |
256
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
86 default: |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
87 fprintf(stderr,"%s: Unknown option '%c'.\n",argv[0],argv[x][1]); |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
88 exit(1); |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
89 } |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
90 } |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
91 |
c495a4f288c6
Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
|