Mercurial > hg > early-roguelike
annotate arogue7/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 |
---|---|
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 * options.c - This file has all the code for the option command |
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 /* |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
16 * This file has all the code for the option command. |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
17 * I would rather this command were not necessary, but |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
18 * it is the only way to keep the wolves off of my back. |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
19 * |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
20 */ |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
21 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
22 #include "curses.h" |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
23 #include <ctype.h> |
310
827441d05b3e
Advanced Rogue family: fix some potential buffer overflows.
John "Elwin" Edwards
parents:
304
diff
changeset
|
24 #include <limits.h> |
126 | 25 #include <string.h> |
125
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 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
28 #define NUM_OPTS (sizeof optlist / sizeof (OPTION)) |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
29 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
30 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
31 /* |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
32 * description of an option and what to do with it |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
33 */ |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
34 struct optstruct { |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
35 char *o_name; /* option name */ |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
36 char *o_prompt; /* prompt for interactive entry */ |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
37 void *o_opt; /* pointer to thing to set */ |
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
38 void (*o_putfunc)(); /* function to print value */ |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
39 int (*o_getfunc)(); /* function to get value interactively */ |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
40 }; |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
41 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
42 typedef struct optstruct OPTION; |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
43 |
219
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
150
diff
changeset
|
44 void put_bool(bool *b, WINDOW *win); |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
150
diff
changeset
|
45 int get_bool(bool *bp, WINDOW *win); |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
150
diff
changeset
|
46 void put_str(char *str, WINDOW *win); |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
150
diff
changeset
|
47 int get_str(char *opt, WINDOW *win); |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
150
diff
changeset
|
48 void put_abil(int *ability, WINDOW *win); |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
49 int get_abil(int *abil, WINDOW *win); |
219
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
150
diff
changeset
|
50 void put_quest(int *quest, WINDOW *win); |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
51 int get_quest(int *quest, WINDOW *win); |
219
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
150
diff
changeset
|
52 int get_ro(WINDOW *win, int oy, int ox); |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
53 |
129
9c4e50b5825c
arogue7: prevent changing protected options.
John "Elwin" Edwards
parents:
126
diff
changeset
|
54 int get_str_prot(char *opt, WINDOW *win); |
145
aac28331e71d
Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents:
129
diff
changeset
|
55 int get_score(char *opt, WINDOW *win); |
129
9c4e50b5825c
arogue7: prevent changing protected options.
John "Elwin" Edwards
parents:
126
diff
changeset
|
56 bool allowchange(OPTION *op); |
9c4e50b5825c
arogue7: prevent changing protected options.
John "Elwin" Edwards
parents:
126
diff
changeset
|
57 |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
58 OPTION optlist[] = { |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
59 {"terse", "Terse output: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
60 (void *) &terse, put_bool, get_bool }, |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
61 {"flush", "Flush typeahead during battle: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
62 (void *) &fight_flush, put_bool, get_bool }, |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
63 {"jump", "Show position only at end of run: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
64 (void *) &jump, put_bool, get_bool }, |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
65 {"step", "Do inventories one line at a time: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
66 (void *) &slow_invent, put_bool, get_bool }, |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
67 {"askme", "Ask me about unidentified things: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
68 (void *) &askme, put_bool, get_bool }, |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
69 {"pickup", "Pick things up automatically: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
70 (void *) &auto_pickup, put_bool, get_bool }, |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
71 {"overlay", "Overlay menu: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
72 (void *) &menu_overlay, put_bool, get_bool }, |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
73 {"name", "Name: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
74 (void *) whoami, put_str, get_str_prot }, |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
75 {"file", "Save file: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
76 (void *) file_name, put_str, get_str_prot }, |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
77 {"score", "Score file: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
78 (void *) score_file, put_str, get_score }, |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
79 {"class", "Character class: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
80 (void *)&char_type, put_abil, get_abil }, |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
81 {"quest", "Quest item: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
82 (void *) &quest_item, put_quest, get_quest } |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|