Make ship_bomb() friendlier

Behave like plane_bomb() and land_bomb(): deal with leading whitespace
and signs in the input, print a message when asked to bomb a ship that
is not there.
This commit is contained in:
Markus Armbruster 2008-08-02 21:22:11 -04:00
parent 278c3fe2d8
commit 5c18d33e21

View file

@ -497,16 +497,15 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
shipsatxy(target->sct_x, target->sct_y, 0, M_SUB, 0);
continue;
}
if (!isdigit(*q))
continue;
n = atoi(q);
if (n < 0)
continue;
if ((plp->pcp->pl_flags & P_A) && !on_shiplist(n, head))
continue;
if (getship(n, &ship) && ship.shp_own &&
if ((!(plp->pcp->pl_flags & P_A) || on_shiplist(n, head)) &&
getship(n, &ship) && ship.shp_own &&
ship.shp_x == target->sct_x && ship.shp_y == target->sct_y)
shipno = n;
else
pr("Ship #%d not spotted\n", n);
}
if (shipno < 0)
continue;