comparison srogue/misc.c @ 36:2128c7dc8a40

Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
author elwin
date Thu, 25 Nov 2010 12:21:41 +0000
parents
children 94a0d9dd5ce1
comparison
equal deleted inserted replaced
35:05018c63a721 36:2128c7dc8a40
1 /*
2 * all sorts of miscellaneous routines
3 *
4 * @(#)misc.c 9.0 (rdk) 7/17/84
5 *
6 * Super-Rogue
7 * Copyright (C) 1984 Robert D. Kindelberger
8 * All rights reserved.
9 *
10 * Based on "Rogue: Exploring the Dungeons of Doom"
11 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
12 * All rights reserved.
13 *
14 * See the file LICENSE.TXT for full copyright and licensing information.
15 */
16
17 #include "rogue.h"
18 #include <ctype.h>
19 #include "rogue.ext"
20
21 /*
22 * waste_time:
23 * Do nothing but let other things happen
24 */
25 waste_time()
26 {
27 if (inwhgt) /* if from wghtchk, then done */
28 return;
29 do_daemons(BEFORE);
30 do_daemons(AFTER);
31 do_fuses();
32 }
33
34 /*
35 * getindex:
36 * Convert a type into an index for the things structures
37 */
38 getindex(what)
39 char what;
40 {
41 int index = -1;
42
43 switch (what) {
44 case POTION: index = TYP_POTION;
45 when SCROLL: index = TYP_SCROLL;
46 when FOOD: index = TYP_FOOD;
47 when RING: index = TYP_RING;
48 when AMULET: index = TYP_AMULET;
49 when ARMOR: index = TYP_ARMOR;
50 when WEAPON: index = TYP_WEAPON;
51 when STICK: index = TYP_STICK;
52 }
53 return index;
54 }
55
56 /*
57 * tr_name:
58 * print the name of a trap
59 */
60 char *
61 tr_name(ch)
62 char ch;
63 {
64 reg char *s;
65
66 switch (ch) {
67 case TRAPDOOR:
68 s = "A trapdoor.";
69 when BEARTRAP:
70 s = "A beartrap.";
71 when SLEEPTRAP:
72 s = "A sleeping gas trap.";
73 when ARROWTRAP:
74 s = "An arrow trap.";
75 when TELTRAP:
76 s = "A teleport trap.";
77 when DARTTRAP:
78 s = "A dart trap.";
79 when POOL:
80 s = "A magic pool.";
81 when POST:
82 s = "A trading post.";
83 when MAZETRAP:
84 s = "A maze trap.";
85 otherwise:
86 s = "A bottomless pit."; /* shouldn't get here */
87 }
88 return s;
89 }
90
91 /*
92 * Look:
93 * A quick glance all around the player
94 */
95 look(wakeup)
96 bool wakeup;
97 {
98 reg char ch;
99 reg int oldx, oldy, y, x;
100 reg struct room *rp;
101 int ey, ex, oex, oey;
102 int passcount = 0;
103 bool inpass, blind;
104
105 getyx(cw, oldy, oldx);
106 oex = player.t_oldpos.x;
107 oey = player.t_oldpos.y;
108 blind = pl_on(ISBLIND);
109 if ((oldrp != NULL && rf_on(oldrp,ISDARK)) || blind) {
110 for (x = oex - 1; x <= oex + 1; x += 1)
111 for (y = oey - 1; y <= oey + 1; y += 1)
112 if ((y != hero.y || x != hero.x) && show(y, x) == FLOOR)
113 mvwaddch(cw, y, x, ' ');
114 }
115 rp = player.t_room;
116 inpass = (rp == NULL); /* TRUE when not in a room */
117 ey = hero.y + 1;
118 ex = hero.x + 1;
119 for (x = hero.x - 1; x <= ex; x += 1) {
120 if (x >= 0 && x <= COLS - 1) {
121 for (y = hero.y - 1; y <= ey; y += 1) {
122 if (y <= 0 || y >= LINES - 2)
123 continue;
124 if (isalpha(mvwinch(mw, y, x))) {
125 reg struct linked_list *it;
126 reg struct thing *tp;
127
128 if (wakeup || (!inpass && rf_on(rp, ISTREAS)))
129 it = wake_monster(y, x);
130 else
131 it = find_mons(y, x);
132 if (it == NULL) /* lost monster */
133 mvaddch(y, x, FLOOR);
134 else {
135 tp = THINGPTR(it);
136 if (isatrap(tp->t_oldch = mvinch(y, x))) {
137 struct trap *trp;
138
139 if ((trp = trap_at(y,x)) == NULL)
140 break;
141 if (trp->tr_flags & ISFOUND)
142 tp->t_oldch = trp->tr_type;
143 else
144 tp->t_oldch = FLOOR;
145 }
146 if (tp->t_oldch == FLOOR && rf_on(rp,ISDARK))
147 if (!blind)
148 tp->t_oldch = ' ';
149 }
150 }
151 /*
152 * Secret doors show as walls
153 */
154 if ((ch = show(y, x)) == SECRETDOOR) {
155 if (inpass || y == rp->r_pos.y || y == rp->r_pos.y + rp->r_max.y - 1)
156 ch = '-';
157 else
158 ch = '|';
159 }
160 /*
161 * Don't show room walls if he is in a passage
162 */
163 if (!blind) {
164 if ((y == hero.y && x == hero.x) || (inpass && (ch == '-' || ch == '|')))
165 continue;
166 }
167 else
168 ch = ' ';
169 wmove(cw, y, x);
170 waddch(cw, ch);
171 if (door_stop && !firstmove && running) {
172 switch (runch) {
173 case 'h':
174 if (x == ex)
175 continue;
176 when 'j':
177 if (y == hero.y - 1)
178 continue;
179 when 'k':