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

@@ -120,7 +120,8 @@ thitu(
if (is_acid && Acid_resistance) {
pline("It doesn't seem to hurt you.");
monstseesu(M_SEEN_ACID);
} else if (stone_missile(obj) && passes_rocks(gy.youmonst.data)) {
} else if (obj && stone_missile(obj) && passes_rocks(gy.youmonst.data)) {
/* use 'named' as an approximation for "hitting from above";
we avoid "passes through you" for horizontal flight path
because missile stops and that wording would suggest that
@@ -323,6 +324,7 @@ ohitmon(
boolean vis, ismimic, objgone;
struct obj *mon_launcher = gm.marcher ? MON_WEP(gm.marcher) : NULL;
/* assert(otmp != NULL); */
gn.notonhead = (gb.bhitpos.x != mtmp->mx || gb.bhitpos.y != mtmp->my);
ismimic = M_AP_TYPE(mtmp) && M_AP_TYPE(mtmp) != M_AP_MONSTER;
vis = cansee(gb.bhitpos.x, gb.bhitpos.y);