remove obj guard from stone_missile(obj) macro

Checking the callers:
toss_up() would have segfaulted prior to use of stone_missile() if obj were NULL.
thitu() now has a guard prior to use of stone_missile()
ohitmon() would have crashed from earlier dereference otmp->dknown if it were NULL,
   otmp arg is declared nonnull
thitm() now has a guard prior to use of stone_missile().
hmon_hitmon_do_hit() null obj takes a different code path than the code path
    using stone_missile(); comment asserting that added
This commit is contained in:
nhmall
2023-12-16 07:58:44 -05:00
parent 0099098d35
commit 70dcab833d
6 changed files with 11 additions and 9 deletions

View File

@@ -67,7 +67,7 @@ static void untrap_box(struct obj *, boolean, boolean);
#if 0
static void join_adjacent_pits(struct trap *);
#endif
static boolean thitm(int, struct monst *, struct obj *, int, boolean);
static boolean thitm(int, struct monst *, struct obj *, int, boolean) NONNULLARG2;
static void maybe_finish_sokoban(void);
static const char *const a_your[2] = { "a", "your" };
@@ -6345,7 +6345,7 @@ thitm(
pline("%s is almost hit by %s!", Monnam(mon), doname(obj));
} else {
int dam = 1;
boolean harmless = (stone_missile(obj) && passes_rocks(mon->data));
boolean harmless = (obj && stone_missile(obj) && passes_rocks(mon->data));
if (obj && cansee(mon->mx, mon->my))
pline("%s is hit by %s%s", Monnam(mon), doname(obj),