Mercurial > hg > early-roguelike
annotate arogue7/options.c @ 237:2236ef808bcb
XRogue: fix some uses of entire structs instead of their members.
Some calls to runto() were given a pointer to the player struct instead
of to the player's coordinates. A call to death() was passed a pointer
to a monster instead of the monster's type number.
author | John "Elwin" Edwards |
---|---|
date | Tue, 08 Mar 2016 20:47:57 -0500 |
parents | 50b89f165a34 |
children | e940e6c00751 |
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> |
126 | 24 #include <string.h> |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
25 #include "rogue.h" |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
26 |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
27 #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
|
28 |
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 * 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
|
32 */ |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
33 struct optstruct { |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
34 char *o_name; /* option name */ |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
35 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
|
36 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
|
37 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
|
38 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
|
39 }; |
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 typedef struct optstruct OPTION; |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
42 |
219
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
150
diff
changeset
|
43 void put_bool(bool *b, WINDOW *win); |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
150
diff
changeset
|
44 int get_bool(bool *bp, WINDOW *win); |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
150
diff
changeset
|
45 void put_str(char *str, WINDOW *win); |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
150
diff
changeset
|
46 int get_str(char *opt, WINDOW *win); |
f9ef86cf22b2
Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents:
150
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 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
|
51 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
|
52 |
129
9c4e50b5825c
arogue7: prevent changing protected options.
John "Elwin" Edwards
parents:
126
diff
changeset
|
53 int get_str_prot(char *opt, WINDOW *win); |
145
aac28331e71d
Advanced Rogue family: fix the "score" option.
John "Elwin" Edwards
parents:
129
diff
changeset
|
54 int get_score(char *opt, WINDOW *win); |
129
9c4e50b5825c
arogue7: prevent changing protected options.
John "Elwin" Edwards
parents:
126
diff
changeset
|
55 bool allowchange(OPTION *op); |
9c4e50b5825c
arogue7: prevent changing protected options.
John "Elwin" Edwards
parents:
126
diff
changeset
|
56 |
125
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
57 OPTION optlist[] = { |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|
58 {"terse", "Terse output: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
59 (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
|
60 {"flush", "Flush typeahead during battle: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
61 (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
|
62 {"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
|
63 (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
|
64 {"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
|
65 (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
|
66 {"askme", "Ask me about unidentified things: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
67 (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
|
68 {"pickup", "Pick things up automatically: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
69 (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
|
70 {"overlay", "Overlay menu: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
71 (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
|
72 {"name", "Name: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
73 (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
|
74 {"file", "Save file: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
75 (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
|
76 {"score", "Score file: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
77 (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
|
78 {"class", "Character class: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
79 (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
|
80 {"quest", "Quest item: ", |
229
50b89f165a34
Use uniform return types for functions related to options.
John "Elwin" Edwards
parents:
219
diff
changeset
|
81 (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
|
82 }; |
adfa37e67084
Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff
changeset
|