]> git.pond.sub.org Git - empserver/commitdiff
Change launch of anti-sat to take plane# argument
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 13 Sep 2009 17:19:19 +0000 (13:19 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 8 Dec 2009 07:15:50 +0000 (08:15 +0100)
Before, it took a sector argument, and targeted the lowest-numbered
satellite there.  Rather inconvenient when your own satellite masks
one of the enemy's.

Moreover, the command could be abused to find all sectors with
satellites.  Now it can "only" be abused to find satellite ids, and
whether they're in range.  Still not ideal, but tolerable.

info/launch.t
src/lib/commands/laun.c

index 974f4c226bccc6e5ccc0fc67c5397893f009b131..ac5fec2b1c5d7cd746809b0cdc71d8be543808da 100644 (file)
@@ -1,7 +1,7 @@
 .TH Command LAUNCH
 .NA launch "Launch missiles or satellites"
 .LV Expert
-.SY "launch <PLANES> <SECT|SHIP>"
+.SY "launch <PLANES> <SECT|SHIP|PLANE>"
 The launch command is used to launch missiles (or satellites)
 from sectors or submarines owned by you.
 .s1
index cfd05db0cc727cbb23557865d3883fff4b9d807c..98799ba9a3025feeeec56a9987d9de442e28452d 100644 (file)
@@ -136,39 +136,26 @@ laun(void)
 static int
 launch_as(struct plnstr *pp)
 {
-    coord sx, sy;
     char *cp, buf[1024];
     struct plnstr plane;
-    struct nstr_item ni;
-    int goodtarget;
     int dam, nukedam;
     natid oldown;
 
-    cp = getstarg(player->argp[2], "Target sector? ", buf);
+    cp = getstarg(player->argp[2], "Target satellite? ", buf);
     if (!check_plane_ok(pp))
        return RET_FAIL;
     if (!cp || !*cp)
        return RET_SYN;
-    if (!sarg_xy(cp, &sx, &sy)) {
-       pr("Bad sector designation!\n");
-       return RET_SYN;
-    }
-    if (mapdist(pp->pln_x, pp->pln_y, sx, sy) > pp->pln_range) {
-       pr("Range too great!\n");
+    if (!getplane(atoi(cp), &plane) || !plane.pln_own
+       || !pln_is_in_orbit(&plane)) {
+       pr("No such satellite exists!\n");
        return RET_FAIL;
+       /* Can be abused to find satellite ids.  Tolerable.  */
     }
-    goodtarget = 0;
-    snxtitem_xy(&ni, EF_PLANE, sx, sy);
-    while (!goodtarget && nxtitem(&ni, &plane)) {
-       if (!plane.pln_own)
-           continue;
-       if (!pln_is_in_orbit(&plane))
-           continue;
-       goodtarget = 1;
 
-    }
-    if (!goodtarget) {
-       pr("No satellites there!\n");
+    if (mapdist(pp->pln_x, pp->pln_y, plane.pln_x, plane.pln_y)
+       > pp->pln_range) {
+       pr("Range too great!\n");
        return RET_FAIL;
     }
     if (msl_equip(pp, 'p') < 0) {
@@ -176,10 +163,9 @@ launch_as(struct plnstr *pp)
        return RET_FAIL;
     }
     if (msl_hit(pp, pln_def(&plane), EF_PLANE, N_SAT_KILL, N_SAT_KILL,
-               prplane(&plane), sx, sy, plane.pln_own)) {
-       dam = pln_damage(pp, sx, sy, 'p', &nukedam, 1);
-       if (CANT_HAPPEN(nukedam))
-           return RET_OK;
+               prplane(&plane), plane.pln_x, plane.pln_y, plane.pln_own)) {
+       dam = pln_damage(pp, plane.pln_x, plane.pln_y, 'p', &nukedam, 1);
+       CANT_HAPPEN(nukedam);
        oldown = plane.pln_own;
        planedamage(&plane, dam);
        pr("Hit satellite for %d%% damage!\n", dam);