abort declaration is not just implicit but incompatibly implicit, so make it explicit.
[rogue-pphs.git] / wizard.c
1
2 /*
3 * Special wizard commands (some of which are also non-wizard commands
4 * under strange circumstances)
5 *
6 * @(#)wizard.c 3.8 (Berkeley) 6/3/81
7 *
8 * Rogue: Exploring the Dungeons of Doom
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
10 * All rights reserved.
11 *
12 * See the file LICENSE.TXT for full copyright and licensing information.
13 */
14
15 #include "curses.h"
16 #include <ctype.h>
17 #include <string.h>
18 #include "rogue.h"
19
20 /*
21 * whatis:
22 * What a certin object is
23 */
24
25 whatis()
26 {
27 register struct object *obj;
28 register struct linked_list *item;
29
30 if ((item = get_item("identify", 0)) == NULL)
31 return;
32 obj = (struct object *) ldata(item);
33 switch (obj->o_type)
34 {
35 case SCROLL:
36 s_know[obj->o_which] = TRUE;
37 if (s_guess[obj->o_which])
38 {
39 free(s_guess[obj->o_which]);
40 s_guess[obj->o_which] = NULL;
41 }
42 when POTION:
43 p_know[obj->o_which] = TRUE;
44 if (p_guess[obj->o_which])
45 {
46 free(p_guess[obj->o_which]);
47 p_guess[obj->o_which] = NULL;
48 }
49 when STICK:
50 ws_know[obj->o_which] = TRUE;
51 obj->o_flags |= ISKNOW;
52 if (ws_guess[obj->o_which])
53 {
54 free(ws_guess[obj->o_which]);
55 ws_guess[obj->o_which] = NULL;
56 }
57 when WEAPON:
58 case ARMOR:
59 obj->o_flags |= ISKNOW;
60 when RING:
61 r_know[obj->o_which] = TRUE;
62 obj->o_flags |= ISKNOW;
63 if (r_guess[obj->o_which])
64 {
65 free(r_guess[obj->o_which]);
66 r_guess[obj->o_which] = NULL;
67 }
68 }
69 msg(inv_name(obj, FALSE));
70 }
71
72 /*
73 * create_obj:
74 * Wizard command for getting anything he wants
75 */
76
77 create_obj()
78 {
79 register struct linked_list *item;
80 register struct object *obj;
81 register char ch, bless;
82
83 item = new_item(sizeof *obj);
84 obj = (struct object *) ldata(item);
85 msg("Type of item: ");
86 obj->o_type = readchar(cw);
87 mpos = 0;
88 msg("Which %c do you want? (0-f)", obj->o_type);
89 obj->o_which = (isdigit((ch = readchar(cw))) ? ch - '0' : ch - 'a' + 10);
90 obj->o_group = 0;
91 obj->o_count = 1;
92 mpos = 0;
93 if (obj->o_type == WEAPON || obj->o_type == ARMOR)
94 {
95 msg("Blessing? (+,-,n)");
96 bless = readchar(cw);
97 mpos = 0;
98 if (obj->o_type == WEAPON)
99 {
100 init_weapon(obj, obj->o_which);
101 if (bless == '-') {
102 obj->o_hplus -= rnd(3)+1;
103 obj->o_flags |= ISCURSED;
104 }
105 if (bless == '+')
106 obj->o_hplus += rnd(3)+1;
107 }
108 else
109 {
110 obj->o_ac = a_class[obj->o_which];
111 if (bless == '-') {
112 obj->o_ac += rnd(3)+1;
113 obj->o_flags |= ISCURSED;
114 }
115 if (bless == '+')
116 obj->o_ac -= rnd(3)+1;
117 }
118 }
119 else if (obj->o_type == RING)
120 switch (obj->o_which)
121 {
122 case R_PROTECT:
123 case R_ADDSTR:
124 case R_ADDHIT:
125 case R_ADDDAM:
126 msg("Blessing? (+,-,n)");
127 bless = readchar(cw);
128 mpos = 0;
129 if (bless == '-')
130 obj->o_flags |= ISCURSED;
131 obj->o_ac = (bless == '-' ? -1 : rnd(2) + 1);
132 }
133 else if (obj->o_type == STICK)
134 fix_stick(obj);
135 add_pack(item, FALSE);
136 }
137
138 /*
139 * telport:
140 * Bamf the hero someplace else
141 */
142
143 teleport()
144 {
145 register int rm;
146 coord c;
147
148 c = hero;
149 mvwaddch(cw, hero.y, hero.x, mvwinch(stdscr, hero.y, hero.x));
150 do
151 {
152 rm = rnd_room();
153 rnd_pos(&rooms[rm], &hero);
154 } until(winat(hero.y, hero.x) == FLOOR);
155 light(&c);
156 light(&hero);
157 mvwaddch(cw, hero.y, hero.x, PLAYER);
158 /*
159 * turn off ISHELD in case teleportation was done while fighting
160 * a Fungi
161 */
162 if (on(player, ISHELD)) {
163 player.t_flags &= ~ISHELD;
164 fung_hit = 0;
165 strcpy(monsters['F'-'A'].m_stats.s_dmg, "000d0");
166 }
167 count = 0;
168 running = FALSE;
169 flush_type(); /* flush typeahead */
170 return rm;
171 }
172
173 /*
174 * passwd:
175 * see if user knows password
176 */
177
178 passwd()
179 {
180 register char *sp, c;
181 char buf[80], *xcrypt();
182
183 msg("Wizard's Password:");
184 mpos = 0;
185 sp = buf;
186 while ((c = readchar(cw)) != '\n' && c != '\r' && c != '\033')
187 if (c == md_killchar())
188 sp = buf;
189 else if (c == md_erasechar() && sp > buf)
190 sp--;
191 else
192 *sp++ = c;
193 if (sp == buf)
194 return FALSE;
195 *sp = '\0';
196 return (strcmp(PASSWD, xcrypt(buf, "mT")) == 0);
197 }