-/* $NetBSD: shots.c,v 1.10 2009/07/04 04:29:55 dholland Exp $ */
+/* $NetBSD: shots.c,v 1.15 2019/10/13 07:42:57 mrg Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: shots.c,v 1.10 2009/07/04 04:29:55 dholland Exp $");
+__RCSID("$NetBSD: shots.c,v 1.15 2019/10/13 07:42:57 mrg Exp $");
#endif /* not lint */
#include <err.h>
static void chkslime(BULLET *, BULLET *);
static void explshot(BULLET *, int, int);
static void find_under(BULLET *, BULLET *);
-static int iswall(int, int);
+static bool iswall(int, int);
static void mark_boot(BULLET *);
static void mark_player(BULLET *);
#ifdef DRONE
"%3d", pp->p_ammo);
cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
outstr(pp, Buf, 3);
- return FALSE;
+ return false;
}
pp->p_ident->i_faced += bp->b_charge;
}
/*
* The shot hit that sucker! Blow it up.
*/
- /* FALLTHROUGH */
#ifndef RANDOM
+ /* FALLTHROUGH */
case DOOR:
#endif
+ /* FALLTHROUGH */
case WALL1:
case WALL2:
case WALL3:
- bp->b_expl = TRUE;
+ bp->b_expl = true;
break;
}
bp->b_x = x;
bp->b_y = y;
}
- return TRUE;
+ return true;
}
#ifdef DRONE
* All blocked up, just you wait
*/
if (count == 0)
- return TRUE;
+ return true;
/*
* Only one way to go.
(void) snprintf(Buf, sizeof(buf), "%3d", pp->p_ammo);
cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
outstr(pp, Buf, 3);
- return FALSE;
+ return false;
}
- bp->b_expl = TRUE;
+ bp->b_expl = true;
break;
}
- return TRUE;
+ return true;
}
#endif
case BOOT:
case BOOT_PAIR:
mark_boot(bp);
+ break;
#endif
-
+
default:
Maze[bp->b_y][bp->b_x] = bp->b_type;
break;
if (pp->p_undershot) {
fixshots(pp->p_y, pp->p_x, pp->p_over);
- pp->p_undershot = FALSE;
+ pp->p_undershot = false;
}
Maze[pp->p_y][pp->p_x] = pp->p_over;
x = pp->p_x + pp->p_flyx;
#ifdef BOOTS
if (pp->p_face != BOOT && pp->p_face != BOOT_PAIR) {
#endif
- checkdam(pp, (PLAYER *) NULL, (IDENT *) NULL,
+ checkdam(pp, NULL, NULL,
rand_num(pp->p_damage / 5), FALL);
pp->p_face = rand_dir();
showstat(pp);
y, x, LEFTS,
(Maze[y][x] == GMINE) ?
GRENREQ : BULREQ,
- (PLAYER *) NULL, TRUE, SPACE);
+ NULL, true, SPACE);
Maze[y][x] = SPACE;
break;
}
* move the given slime shot speed times and add it back if
* it hasn't fizzled yet
*/
-void
+static void
move_slime(BULLET *bp, int speed, BULLET *next)
{
int i, j, dirmask, count;
if (dirmask & WEST) {
count--;
nbp = create_shot(bp->b_type, bp->b_y, bp->b_x - 1, LEFTS,
- i, bp->b_size, bp->b_owner, bp->b_score, TRUE, SPACE);
+ i, bp->b_size, bp->b_owner, bp->b_score, true, SPACE);
move_slime(nbp, speed - 1, next);
}
if (dirmask & EAST) {
count--;
nbp = create_shot(bp->b_type, bp->b_y, bp->b_x + 1, RIGHT,
(count < j) ? i + 1 : i, bp->b_size, bp->b_owner,
- bp->b_score, TRUE, SPACE);
+ bp->b_score, true, SPACE);
move_slime(nbp, speed - 1, next);
}
if (dirmask & NORTH) {
count--;
nbp = create_shot(bp->b_type, bp->b_y - 1, bp->b_x, ABOVE,
(count < j) ? i + 1 : i, bp->b_size, bp->b_owner,
- bp->b_score, TRUE, SPACE);
+ bp->b_score, true, SPACE);
move_slime(nbp, speed - 1, next);
}
if (dirmask & SOUTH) {
count--;
nbp = create_shot(bp->b_type, bp->b_y + 1, bp->b_x, BELOW,
(count < j) ? i + 1 : i, bp->b_size, bp->b_owner,
- bp->b_score, TRUE, SPACE);
+ bp->b_score, true, SPACE);
move_slime(nbp, speed - 1, next);
}
* iswall:
* returns whether the given location is a wall
*/
-static int
+static bool
iswall(int y, int x)
{
if (y < 0 || x < 0 || y >= HEIGHT || x >= WIDTH)
- return TRUE;
+ return true;
switch (Maze[y][x]) {
case WALL1:
case WALL2:
case LAVA:
#endif
#endif
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
#endif
zapshot(BULLET *blist, BULLET *obp)
{
BULLET *bp;
- FLAG explode;
+ bool explode;
- explode = FALSE;
+ explode = false;
for (bp = blist; bp != NULL; bp = bp->b_next) {
if (bp->b_x != obp->b_x || bp->b_y != obp->b_y)
continue;
if (bp->b_face == obp->b_face)
continue;
- explode = TRUE;
+ explode = true;
break;
}
if (!explode)
* explshot -
* Make all shots at this location blow up
*/
-void
+static void
explshot(BULLET *blist, int y, int x)
{
BULLET *bp;
for (bp = blist; bp != NULL; bp = bp->b_next)
if (bp->b_x == x && bp->b_y == y) {
- bp->b_expl = TRUE;
+ bp->b_expl = true;
if (bp->b_owner != NULL)
message(bp->b_owner, "Shot intercepted");
}
/*
* opposite:
- * Return TRUE if the bullet direction faces the opposite direction
+ * Return true if the bullet direction faces the opposite direction
* of the player in the maze
*/
-int
+bool
opposite(int face, char dir)
{
switch (face) {
case BELOW:
return (dir == ABOVE);
default:
- return FALSE;
+ return false;
}
}
for (pp = Player; pp < End_player; pp++)
if (pp->p_y == bp->b_y && pp->p_x == bp->b_x) {
- pp->p_undershot = TRUE;
+ pp->p_undershot = true;
break;
}
}
for (pp = Boot; pp < &Boot[NBOOTS]; pp++)
if (pp->p_y == bp->b_y && pp->p_x == bp->b_x) {
- pp->p_undershot = TRUE;
+ pp->p_undershot = true;
break;
}
}