* canseemon() or canspotmon() which already check that.
*/
#define see_with_infrared(mon) \
- (!Blind && Infravision && infravisible(mon->data) \
+ (!Blind && Infravision && mon && infravisible(mon->data) \
&& couldsee(mon->mx, mon->my))
/*
You("don't have enough room in here.");
return FALSE;
}
- x = cc->x;
- y = cc->y;
+ x = cc ? cc->x : u.ux;
+ y = cc ? cc->y : u.uy;
if (!isok(x, y)) {
if (!quietly)
You("cannot put the figurine there.");
struct obj *obj;
{
register const struct artifact *oart = get_artifact(obj);
-
+ if (!obj) {
+ impossible("arti_invoke without obj");
+ return 0;
+ }
if (!oart || !oart->inv_prop) {
if (obj->otyp == CRYSTAL_BALL)
use_crystal_ball(&obj);
biggest = 0;
while (!ret) {
i = n = 0;
- accelerator = 0;
any = zeroany;
/* populate choices */
for (efp = extcmdlist; efp->ef_txt; efp++) {
/* otherwise... */
win = create_nhwindow(NHW_MENU);
start_menu(win);
- prevaccelerator = 0;
+ accelerator = prevaccelerator = 0;
acount = 0;
for (i = 0; choices[i]; ++i) {
accelerator = choices[i]->ef_txt[matchlevel];
/* when mounted, Wounded_legs applies to steed rather than to
hero; we only report steed's wounded legs in wizard mode */
if (u.usteed) { /* not `Riding' here */
- if (wizard) {
+ if (wizard && steedname) {
Strcpy(buf, steedname);
*buf = highc(*buf);
enl_msg(buf, " has", " had", " wounded legs", "");
static char wholebuf[80];
Strcpy(wholebuf, is_u(etmp) ? "You" : Monnam(etmp->emon));
- if (!*verb)
+ if (!verb || !*verb)
return wholebuf;
Strcat(wholebuf, " ");
if (is_u(etmp))
{
boolean was_blind = Blind, changed = FALSE;
+ if (!otmp) {
+ impossible("Blindf_off without otmp");
+ return;
+ }
context.takeoff.mask &= ~W_TOOL;
setworn((struct obj *) 0, otmp->owornmask);
off_msg(otmp);
recalc_wt()
{
struct obj *piece = context.victual.piece;
-
+ if (!piece) {
+ impossible("recalc_wt without piece");
+ return;
+ }
debugpline1("Old weight = %d", piece->owt);
debugpline2("Used time = %d, Req'd time = %d", context.victual.usedtime,
context.victual.reqtime);
{
char c = 0, defquery;
char qbuf[QBUFSZ];
- boolean ask;
+ boolean ask = FALSE;
if (invent && !done_stopprint) {
if (taken)
return actions[3]; /* same as lock_pick */
else if (xlock.door)
return actions[0]; /* "unlocking the door" */
- else
+ else if (xlock.box)
return xlock.box->otyp == CHEST ? actions[1] : actions[2];
+ else
+ return actions[3];
}
/* try to open/close a lock */
}
/* All special cases should precede the G_NOCORPSE check */
+ if (!obj) return NULL;
+
/* if polymorph or undead turning has killed this monster,
prevent the same attack beam from hitting its corpse */
if (context.bypasses)
case A_NEUTRAL:
if (class_gift != STRANGE_OBJECT) {
; /* already got bonus above */
- } else if (in_hand) {
+ } else if (obj && in_hand) {
Your("%s goes snicker-snack!", xname(obj));
obj->dknown = TRUE;
} else if (!already_exists) {
Sprintf(swordbuf, "%s sword", hcolor(NH_BLACK));
if (class_gift != STRANGE_OBJECT) {
; /* already got bonus above */
- } else if (in_hand) {
+ } else if (obj && in_hand) {
Your("%s hums ominously!", swordbuf);
obj->dknown = TRUE;
} else if (!already_exists) {
schar try_x, try_y;
register int trycnt = 0;
+ if (!x || !y)
+ panic("get_free_room_loc: x or y is null");
+
get_location_coord(&try_x, &try_y, DRY, croom, pos);
if (levl[try_x][try_y].typ != ROOM) {
do {
move_into_trap(ttmp)
struct trap *ttmp;
{
- int bc;
+ int bc = 0;
xchar x = ttmp->tx, y = ttmp->ty, bx, by, cx, cy;
boolean unused;
break;
}
- while (skills->skill != P_NONE) {
+ while (skills && skills->skill != P_NONE) {
if (skills->skill == this_skill)
return FALSE;
++skills;