From 5c18d33e2177c3e62ac2e30768d74f8b27413c94 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 2 Aug 2008 21:22:11 -0400 Subject: [PATCH] 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. --- src/lib/commands/bomb.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/commands/bomb.c b/src/lib/commands/bomb.c index 05b88fff..9140936a 100644 --- a/src/lib/commands/bomb.c +++ b/src/lib/commands/bomb.c @@ -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;