annotate rogue3/wizard.c @ 93:8f7c082fde46

Don't set DESTDIR via configure. DESTDIR ought to be set via option passed to 'make install'.
author John "Elwin" Edwards
date Mon, 26 Aug 2013 19:58:44 -0700
parents 527e2150eaf0
children e7aab31362af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
1
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
2 /*
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
3 * Special wizard commands (some of which are also non-wizard commands
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
4 * under strange circumstances)
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
5 *
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
6 * @(#)wizard.c 3.8 (Berkeley) 6/3/81
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
7 *
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
8 * Rogue: Exploring the Dungeons of Doom
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
10 * All rights reserved.
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
11 *
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
12 * See the file LICENSE.TXT for full copyright and licensing information.
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
13 */
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
14
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
15 #include "curses.h"
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
16 #include <ctype.h>
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
17 #include <string.h>
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
18 #include <stdlib.h>
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
19 #include "machdep.h"
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
20 #include "rogue.h"
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
21
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
22 /*
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
23 * whatis:
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
24 * What a certin object is
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
25 */
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
26
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
27 void
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
28 whatis()
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
29 {
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
30 struct object *obj;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
31 struct linked_list *item;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
32
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
33 if ((item = get_item("identify", 0)) == NULL)
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
34 return;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
35 obj = (struct object *) ldata(item);
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
36 switch (obj->o_type)
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
37 {
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
38 case SCROLL:
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
39 s_know[obj->o_which] = TRUE;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
40 if (s_guess[obj->o_which])
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
41 {
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
42 free(s_guess[obj->o_which]);
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
43 s_guess[obj->o_which] = NULL;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
44 }
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
45 when POTION:
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
46 p_know[obj->o_which] = TRUE;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
47 if (p_guess[obj->o_which])
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
48 {
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
49 free(p_guess[obj->o_which]);
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
50 p_guess[obj->o_which] = NULL;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
51 }
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
52 when STICK:
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
53 ws_know[obj->o_which] = TRUE;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
54 obj->o_flags |= ISKNOW;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
55 if (ws_guess[obj->o_which])
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
56 {
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
57 free(ws_guess[obj->o_which]);
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
58 ws_guess[obj->o_which] = NULL;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
59 }
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
60 when WEAPON:
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
61 case ARMOR:
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
62 obj->o_flags |= ISKNOW;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
63 when RING:
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
64 r_know[obj->o_which] = TRUE;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
65 obj->o_flags |= ISKNOW;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
66 if (r_guess[obj->o_which])
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
67 {
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
68 free(r_guess[obj->o_which]);
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
69 r_guess[obj->o_which] = NULL;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
70 }
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
71 }
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
72 msg(inv_name(obj, FALSE));
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
73 }
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
74
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
75 /*
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
76 * create_obj:
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
77 * Wizard command for getting anything he wants
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
78 */
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
79
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
80 void
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
81 create_obj()
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
82 {
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
83 struct linked_list *item;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
84 struct object *obj;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
85 int bless;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
86 int ch;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
87
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
88 item = new_item(sizeof *obj);
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
89 obj = (struct object *) ldata(item);
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
90 msg("Type of item: ");
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
91 obj->o_type = readchar(cw);
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
92 mpos = 0;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
93 msg("Which %c do you want? (0-f)", obj->o_type);
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
94 obj->o_which = (isdigit((ch = readchar(cw))) ? ch - '0' : ch - 'a' + 10);
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
95 obj->o_group = 0;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
96 obj->o_count = 1;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
97 mpos = 0;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
98 if (obj->o_type == WEAPON || obj->o_type == ARMOR)
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
99 {
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
100 msg("Blessing? (+,-,n)");
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
101 bless = readchar(cw);
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
102 mpos = 0;
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
103 if (obj->o_type == WEAPON)
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
104 {
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
105 init_weapon(obj, obj->o_which);
527e2150eaf0 Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset