]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/tend.c
Update known contributors comments
[empserver] / src / lib / commands / tend.c
index 8c6f026d65f26e6bc5dfda9dfd38f7eac4598922..403d704fbde1d85c51182e89f63dacd2ed73104b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
  *  ---
  *
  *  tend.c: Transfer goodies from one ship to another.
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare, 1986
  *     Thomas Ruschak, 1992
  *     Steve McClure, 2000
+ *     Markus Armbruster, 2004-2009
  */
 
 #include <config.h>
@@ -67,8 +68,9 @@ tend(void)
     char prompt[512];
     char buf[1024];
 
-    if (!(p = getstarg(player->argp[1],
-                      "Tend what commodity (or 'land')? ", buf)) || !*p)
+    p = getstarg(player->argp[1], "Tend what commodity (or 'land')? ",
+                buf);
+    if (!p || !*p)
        return RET_SYN;
 
     if (!strncmp(p, "land", 4))
@@ -80,8 +82,7 @@ tend(void)
        return RET_SYN;
     }
 
-    if (!snxtitem(&tenders, EF_SHIP,
-                 getstarg(player->argp[2], "Tender(s)? ", buf)))
+    if (!snxtitem(&tenders, EF_SHIP, player->argp[2], "Tender(s)? "))
        return RET_SYN;
 
     while (nxtitem(&tenders, &tender)) {
@@ -90,7 +91,10 @@ tend(void)
        if (type == EF_LAND) {
            sprintf(prompt, "Land unit(s) to tend from %s? ",
                    prship(&tender));
-           if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
+           p = getstarg(player->argp[3], prompt, buf);
+           if (!p)
+               return RET_FAIL;
+           if (!*p)
                continue;
            if (!check_ship_ok(&tender))
                return RET_SYN;
@@ -100,7 +104,10 @@ tend(void)
        }
        sprintf(prompt, "Number of %s to tend from %s? ",
                ip->i_name, prship(&tender));
-       if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
+       p = getstarg(player->argp[3], prompt, buf);
+       if (!p)
+           return RET_FAIL;
+       if (!*p)
            continue;
        if (!check_ship_ok(&tender))
            return RET_SYN;
@@ -121,9 +128,8 @@ tend(void)
            break;
        }
        if (!snxtitem(&targets, EF_SHIP,
-                     getstarg(player->argp[4], "Ships to be tended? ",
-                              buf)))
-           break;
+                     player->argp[4], "Ships to be tended? "))
+           return RET_FAIL;
        if (!check_ship_ok(&tender))
            return RET_SYN;
        total = 0;
@@ -203,11 +209,9 @@ tend_land(struct shpstr *tenderp, char *units)
     struct nstr_item targets;
     struct shpstr target;
     struct lndstr land;
-    struct plnstr plane;
-    struct nstr_item pni;
     char buf[1024];
 
-    if (!snxtitem(&lni, EF_LAND, units))
+    if (!snxtitem(&lni, EF_LAND, units, NULL))
        return RET_SYN;
 
     while (nxtitem(&lni, &land)) {
@@ -223,10 +227,9 @@ tend_land(struct shpstr *tenderp, char *units)
            continue;
        }
        if (!snxtitem(&targets, EF_SHIP,
-                     getstarg(player->argp[4], "Ship to be tended? ",
-                              buf)))
-           break;
-       if (!check_land_ok(&land))
+                     player->argp[4], "Ship to be tended? "))
+           return RET_FAIL;
+       if (!check_ship_ok(tenderp) || !check_land_ok(&land))
            return RET_SYN;
        while (nxtitem(&targets, &target)) {
            if (!player->owner &&
@@ -239,7 +242,6 @@ tend_land(struct shpstr *tenderp, char *units)
                continue;
 
            /* Fit unit on ship */
-           count_units(&target);
            getship(target.shp_uid, &target);
 
            if ((!(lchr[(int)land.lnd_type].l_flags & L_LIGHT)) &&
@@ -254,12 +256,12 @@ tend_land(struct shpstr *tenderp, char *units)
            if ((mchr[(int)target.shp_type].m_flags & M_SUB) &&
                (lchr[(int)land.lnd_type].l_flags & L_SPY) &&
                !mchr[(int)target.shp_type].m_nland) {
-               if (target.shp_nland > 1) {
+               if (shp_nland(&target) > 1) {
                    pr("%s doesn't have room for more than two spy units!\n",
                       prship(&target));
                    continue;
                }
-           } else if (target.shp_nland >= mchr[(int)target.shp_type].m_nland) {
+           } else if (shp_nland(&target) >= mchr[target.shp_type].m_nland) {
                if (mchr[(int)target.shp_type].m_nland)
                    pr("%s doesn't have room for any more land units!\n",
                       prship(&target));
@@ -275,24 +277,10 @@ tend_land(struct shpstr *tenderp, char *units)
            gift(target.shp_own, player->cnum, &land, buf);
            land.lnd_ship = target.shp_uid;
            land.lnd_harden = 0;
-           land.lnd_mission = 0;
-           target.shp_nland++;
            putland(land.lnd_uid, &land);
            expose_ship(tenderp, &target);
            putship(target.shp_uid, &target);
-           count_units(tenderp);
            putship(tenderp->shp_uid, tenderp);
-           snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
-           while (nxtitem(&pni, &plane)) {
-               if (plane.pln_flags & PLN_LAUNCHED)
-                   continue;
-               if (plane.pln_land != land.lnd_uid)
-                   continue;
-               sprintf(buf, "loaded on %s", prship(&target));
-               gift(target.shp_own, player->cnum, &plane, buf);
-               plane.pln_mission = 0;
-               putplane(plane.pln_uid, &plane);
-           }
        }
     }
     return 0;