2 * Copyright (c) 1983-2003, Regents of the University of California.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * + Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * + Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * + Neither the name of the University of California, San Francisco nor
15 * the names of its contributors may be used to endorse or promote
16 * products derived from this software without specific prior written
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * $OpenBSD: expl.c,v 1.9 2007/09/04 22:39:31 hshoexer Exp $
32 * $NetBSD: expl.c,v 1.2 1997/10/10 16:33:18 lukem Exp $
33 * $DragonFly: src/games/hunt/huntd/expl.c,v 1.1 2008/09/02 21:50:21 dillon Exp $
43 static void remove_wall(int, int);
44 static void init_removed(void);
49 * Show the explosions as they currently are
59 if (y < 0 || y >= HEIGHT)
61 if (x < 0 || x >= WIDTH)
63 ep = (EXPL *) malloc(sizeof (EXPL)); /* NOSTRICT */
65 logit(LOG_ERR, "malloc");
72 if (Last_expl == NULL)
75 Last_expl->e_next = ep;
77 for (pp = Player; pp < End_player; pp++) {
78 if (pp->p_maze[y][x] == type)
80 pp->p_maze[y][x] = type;
84 for (pp = Monitor; pp < End_monitor; pp++) {
85 if (pp->p_maze[y][x] == type)
87 pp->p_maze[y][x] = type;
98 if (y >= UBOUND && y < DBOUND && x >= LBOUND && x < RBOUND)
106 * Roll the explosions over, so the next one in the list is at the
118 for (ep = Expl[EXPLEN - 1]; ep != NULL; ep = nextep) {
122 if (y < UBOUND || y >= DBOUND || x < LBOUND || x >= RBOUND)
126 for (pp = Player; pp < End_player; pp++)
127 if (pp->p_maze[y][x] == ep->e_char) {
128 pp->p_maze[y][x] = c;
132 for (pp = Monitor; pp < End_monitor; pp++)
136 memmove(&Expl[1], &Expl[0], (EXPLEN - 1) * sizeof Expl[0]);
137 /* for (x = EXPLEN - 1; x > 0; x--)
138 Expl[x] = Expl[x - 1]; */
139 Last_expl = Expl[0] = NULL;
147 for (i = EXPLEN - 1; i >= 0; i--)
153 static REGEN *removed = NULL;
154 static REGEN *rem_index = NULL;
159 rem_index = removed = calloc(conf_maxremove, sizeof(REGEN));
160 if (rem_index == NULL) {
161 logit(LOG_ERR, "malloc");
167 * remove_wall - add a location where the wall was blown away.
168 * if there is no space left over, put the a wall at
169 * the location currently pointed at.
183 while (r->r_y != 0) {
184 switch (Maze[r->r_y][r->r_x]) {
191 save_char = Maze[r->r_y][r->r_x];
194 if (++r >= removed + conf_maxremove)
200 /* Slot being used, put back this wall */
201 if (save_char == SPACE)
202 Maze[r->r_y][r->r_x] = Orig_maze[r->r_y][r->r_x];
204 /* We throw the player off the wall: */
205 pp = play_at(r->r_y, r->r_x);
206 if (pp->p_flying >= 0)
207 pp->p_flying += rand_num(conf_flytime / 2);
209 pp->p_flying = rand_num(conf_flytime);
210 pp->p_flyx = 2 * rand_num(conf_flystep + 1) -
212 pp->p_flyy = 2 * rand_num(conf_flystep + 1) -
215 pp->p_over = Orig_maze[r->r_y][r->r_x];
217 Maze[r->r_y][r->r_x] = FLYER;
218 showexpl(r->r_y, r->r_x, FLYER);
220 Maze[r->r_y][r->r_x] = Orig_maze[r->r_y][r->r_x];
221 if (conf_random && rand_num(100) < conf_prandom)
222 Maze[r->r_y][r->r_x] = DOOR;
223 if (conf_reflect && rand_num(100) == conf_preflect)
224 Maze[r->r_y][r->r_x] = WALL4;
225 for (pp = Monitor; pp < End_monitor; pp++)
226 check(pp, r->r_y, r->r_x);
231 if (++r >= removed + conf_maxremove)
237 for (pp = Monitor; pp < End_monitor; pp++)
243 * Clear out the walls array
252 for (rp = removed; rp < removed + conf_maxremove; rp++)