]> git.pond.sub.org Git - empserver/commitdiff
Make ship_bomb() friendlier
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 3 Aug 2008 01:22:11 +0000 (21:22 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 3 Aug 2008 01:25:31 +0000 (21:25 -0400)
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

index 05b88fff0de0ecbed6497c5e77b5ed79dff3d7e4..9140936a53f765a28f64abf6e4970869ce12b59d 100644 (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;