Mercurial > hg > early-roguelike
annotate xrogue/options.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 |
rev | line source |
---|---|
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
1 /* |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
2 options.c - This file has all the code for the option command |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
3 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
4 XRogue: Expeditions into the Dungeons of Doom |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
5 Copyright (C) 1991 Robert Pietkivitch |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
6 All rights reserved. |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
7 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
8 Based on "Advanced Rogue" |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
9 Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
10 All rights reserved. |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
11 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
12 Based on "Rogue: Exploring the Dungeons of Doom" |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
13 Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
14 All rights reserved. |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
15 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
16 See the file LICENSE.TXT for full copyright and licensing information. |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
17 */ |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
18 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
19 /* |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
20 * I would rather this command were not necessary, but |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
21 * it is the only way to keep the wolves off of my back. |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
22 */ |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
23 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
24 #include <curses.h> |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
25 #include <ctype.h> |
135 | 26 #include <string.h> |
310
827441d05b3e
Advanced Rogue family: fix some potential buffer overflows.
John "Elwin" Edwards
parents:
304
diff
changeset
|
27 #include <limits.h> |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
28 #include "rogue.h" |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
29 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
30 #define NUM_OPTS (sizeof optlist / sizeof (OPTION)) |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
31 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
32 /* |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
33 * description of an option and what to do with it |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
34 */ |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
35 struct optstruct { |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
36 char *o_name; /* option name */ |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
37 char *o_prompt; /* prompt for interactive entry */ |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
38 void *o_opt; /* pointer to thing to set */ |
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
39 void (*o_putfunc)(); /* function to print value */ |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
40 int (*o_getfunc)(); /* function to get value interactively */ |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
41 }; |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
42 |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
43 typedef struct optstruct OPTION; |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
44 |
220
f54901b9c39b
XRogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
145
diff
changeset
|
45 int get_ro(WINDOW *win, int oy, int ox); |
f54901b9c39b
XRogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
145
diff
changeset
|
46 void put_bool(bool *b, WINDOW *win); |
f54901b9c39b
XRogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
145
diff
changeset
|
47 int get_bool(bool *bp, WINDOW *win); |
f54901b9c39b
XRogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
145
diff
changeset
|
48 void put_str(char *str, WINDOW *win); |
f54901b9c39b
XRogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
145
diff
changeset
|
49 int get_str(char *opt, WINDOW *win); |
f54901b9c39b
XRogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
145
diff
changeset
|
50 void put_abil(int *ability, WINDOW *win); |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
51 int get_abil(int *abil, WINDOW *win); |
220
f54901b9c39b
XRogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
145
diff
changeset
|
52 void put_quest(int *quest, WINDOW *win); |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
53 int get_quest(int *quest, WINDOW *win); |
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
54 int get_default(bool *bp, WINDOW *win); |
137
443c8bd3e290
xrogue: restrict changes to the save file location.
John "Elwin" Edwards
parents:
135
diff
changeset
|
55 int get_str_prot(char *opt, WINDOW *win); |
145
aac28331e71d
Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents:
137
diff
changeset
|
56 int get_score(char *opt, WINDOW *win); |
137
443c8bd3e290
xrogue: restrict changes to the save file location.
John "Elwin" Edwards
parents:
135
diff
changeset
|
57 bool allowchange(OPTION *op); |
443c8bd3e290
xrogue: restrict changes to the save file location.
John "Elwin" Edwards
parents:
135
diff
changeset
|
58 |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
59 OPTION optlist[] = { |
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
60 {"terse", "Terse output: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
61 (void *) &terse, put_bool, get_bool }, |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
62 {"flush", "Flush typeahead during battle: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
63 (void *) &fight_flush, put_bool, get_bool }, |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
64 {"jump", "Show position only at end of run: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
65 (void *) &jump, put_bool, get_bool }, |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
66 {"step", "Do inventories one line at a time: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
67 (void *) &slow_invent, put_bool, get_bool }, |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
68 {"askme", "Ask me about unidentified things: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
69 (void *) &askme, put_bool, get_bool }, |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
70 {"pickup", "Pick things up automatically: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
71 (void *) &auto_pickup, put_bool, get_bool }, |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
72 {"overlay", "Overlay menu: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
73 (void *) &menu_overlay, put_bool, get_bool }, |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
74 {"name", "Name: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
75 (void *) whoami, put_str, get_str_prot }, |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
76 {"file", "Save file: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
77 (void *) file_name, put_str, get_str_prot }, |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
78 {"score", "Score file: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
79 (void *) score_file, put_str, get_score }, |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
80 {"class", "Character type: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
81 (void *) &char_type, put_abil, get_abil }, |
133
e6179860cb76
Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
82 {"quest", "Quest item: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
220
diff
changeset
|
83 (void *) &quest_item, put_quest, get_quest }, |