Mercurial > hg > early-roguelike
annotate arogue5/options.c @ 162:600873555ec0
Don't swap signal handlers in md_shellescape().
md_shellescape() sets SIGINT and SIGQUIT to be ignored, storing the
previous handlers, and restores them after the shell exits. But it
mixed up the two handlers.
Since the signals were usually handled by the same function, this fix
doesn't have much effect, but anything that makes signal code less
confusing is a good thing.
author | John "Elwin" Edwards |
---|---|
date | Mon, 08 Jun 2015 10:01:25 -0400 |
parents | aac28331e71d |
children | 56e748983fa8 |
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 * This file has all the code for the option command. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
3 * I would rather this command were not necessary, but |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
4 * it is the only way to keep the wolves off of my back. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
5 * |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
6 * Advanced Rogue |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
7 * 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
|
8 * All rights reserved. |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
9 * |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
10 * Based on "Rogue: Exploring the Dungeons of Doom" |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
11 * 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
|
12 * All rights reserved. |
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 * 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
|
15 */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
16 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
17 #include "curses.h" |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
18 #include <ctype.h> |
67 | 19 #include <string.h> |
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
20 #include "rogue.h" |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
21 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
22 #define NUM_OPTS (sizeof optlist / sizeof (OPTION)) |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
23 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
24 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
25 /* |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
26 * description of an option and what to do with it |
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 struct optstruct { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
29 char *o_name; /* option name */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
30 char *o_prompt; /* prompt for interactive entry */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
31 int *o_opt; /* pointer to thing to set */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
32 int (*o_putfunc)(); /* function to print value */ |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
33 int (*o_getfunc)(); /* function to get value interactively */ |
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 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
36 typedef struct optstruct OPTION; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
37 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
38 int put_bool(), |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
39 get_bool(), |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
40 put_str(), |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
41 get_str(), |
66 | 42 get_restr(), |
145
aac28331e71d
Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents:
97
diff
changeset
|
43 get_score(), |
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
44 put_abil(), |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
45 get_abil(), |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
46 get_quest(), |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
47 put_quest(); |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
48 |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
49 OPTION optlist[] = { |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
50 {"terse", "Terse output: ", |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
51 (int *) &terse, put_bool, get_bool }, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
52 {"flush", "Flush typeahead during battle: ", |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
53 (int *) &fight_flush, put_bool, get_bool }, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
54 {"jump", "Show position only at end of run: ", |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
55 (int *) &jump, put_bool, get_bool }, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
56 {"step", "Do inventories one line at a time: ", |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
57 (int *) &slow_invent, put_bool, get_bool }, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
58 {"askme", "Ask me about unidentified things: ", |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
59 (int *) &askme, put_bool, get_bool }, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
60 {"pickup", "Pick things up automatically: ", |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
61 (int *) &auto_pickup, put_bool, get_bool }, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
62 {"name", "Name: ", |
66 | 63 (int *) whoami, put_str, get_restr }, |
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
64 {"fruit", "Fruit: ", |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
65 (int *) fruit, put_str, get_str }, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
66 {"file", "Save file: ", |
66 | 67 (int *) file_name, put_str, get_restr }, |
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
68 {"score", "Score file: ", |
145
aac28331e71d
Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents:
97
diff
changeset
|
69 (int *) score_file, put_str, get_score }, |
63
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
70 {"class", "Character class: ", |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
71 (int *)&char_type, put_abil, get_abil }, |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
72 {"quest", "Quest item: ", |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
73 (int *) &quest_item, put_quest, get_quest } |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
74 }; |
0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff
changeset
|
75 |
66 | 76 /* For fields that would be restricted if use_savedir is set. */ |
77 int get_restr(char *optstr, WINDOW *win) | |
78 { | |
79 int oy, ox; | |
80 | |
81 if (use_savedir) | |
82 { | |
83 getyx(win, oy, ox); | |
84 put_str(optstr, win); | |
85 return get_ro(win, oy, ox); | |
86 } | |
87 else | |
88 return get_str(optstr, win); | |
89 } | |
90 | |
145
aac28331e71d
Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents:
97
diff
changeset
|
91 /* For the score file, which must be opened. */ |
aac28331e71d
Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents:
97
diff
changeset
|
92 int get_score(char *optstr, WINDOW *win) |
aac28331e71d
Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents:
97
diff
changeset
|
93 { |
aac28331e71d
Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents:
97
diff
changeset
|
94 char old_score_file[LINELEN]; |
aac28331e71d
Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents:
97
diff
changeset
|
95 int status; |
aac28331e71d
Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents:
97
diff
changeset
|
96 |
aac28331e71d
Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents:
97
diff
changeset
|
97 if (use_savedir) |
aac28331e71d
Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents:
97
diff
changeset
|
98 return get_restr(optstr, win); |