]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/load.c
Update copyright notice
[empserver] / src / lib / commands / load.c
index 90b6f483c262e2530c167569faeab11e498ab995..ae70cbff0ac7f0a3065a2bbef43252f83371e4b2 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
  *     David Sharnoff, 1987
  *     Ken Stevens, 1995 (rewritten)
  *     Steve McClure, 1998-2000
- *     Markus Armbruster, 2004-2008
+ *     Markus Armbruster, 2004-2011
  */
 
 #include <config.h>
 
 #include <ctype.h>
 #include "commands.h"
-#include "empobj.h"
 #include "item.h"
 #include "land.h"
 #include "optlist.h"
@@ -50,8 +48,8 @@
 /*
  * The values 1 and -1 are important below, don't change them.
  */
-#define        LOAD    1
-#define        UNLOAD  -1
+#define LOAD   1
+#define UNLOAD -1
 
 static int load_plane_ship(struct sctstr *sectp, struct shpstr *sp,
                           int noisy, int load_unload, int *nshipsp);
@@ -83,9 +81,9 @@ load(void)
     char *p;
     char buf[1024];
 
-    if (!(p = getstarg(player->argp[1],
-                      "What commodity (or 'plane' or 'land')? ", buf))
-       || !*p)
+    p = getstarg(player->argp[1],
+                "What commodity (or 'plane' or 'land')? ", buf);
+    if (!p || !*p)
        return RET_SYN;
 
     if (!strncmp(p, "plane", 5))
@@ -99,7 +97,8 @@ load(void)
        return RET_SYN;
     }
 
-    if (!(p = getstarg(player->argp[2], "Ship(s): ", buf)) || !*p)
+    p = getstarg(player->argp[2], "Ship(s): ", buf);
+    if (!p || !*p)
        return RET_SYN;
 
     noisy = isdigit(*p);
@@ -113,46 +112,38 @@ load(void)
     while (nxtitem(&nbst, &ship)) {
        if (!ship.shp_own)
            continue;
-       if (!player->owner && (load_unload == UNLOAD)) {
-           continue;
-       }
-       if (opt_MARKET) {
-           if (ontradingblock(EF_SHIP, &ship)) {
-               pr("You cannot load/unload an item on the trading block!\n");
-               continue;
-           }
-       }
-
-       if (ship.shp_own != player->cnum) {
-           if (!noisy)
+       if (!player->owner) {
+           if (load_unload == UNLOAD || !noisy)
                continue;
-           if (getrel(getnatp(ship.shp_own), player->cnum) < FRIENDLY)
+           if (relations_with(ship.shp_own, player->cnum) < FRIENDLY)
                continue;
        }
+
        if (!getsect(ship.shp_x, ship.shp_y, &sect))    /* XXX */
            continue;
-       if ((sect.sct_own != player->cnum) &&
-           (ship.shp_own != player->cnum))
-           continue;
-       if (!player->owner &&
-           !sect_has_dock(&sect))
-           continue;
        if (!sect.sct_own)
            continue;
-       if ((sect.sct_own != player->cnum) && (load_unload == LOAD)) {
-           if (noisy)
-               pr("You don't own %s \n",
-                  xyas(ship.shp_x, ship.shp_y, player->cnum));
-           continue;
+       if (!player->owner) {
+           if (ship.shp_own != player->cnum)
+               continue;
+           if (!sect_has_dock(&sect))
+               continue;
+           if (load_unload == LOAD) {
+               if (noisy)
+                   pr("You don't own %s \n",
+                      xyas(sect.sct_x, sect.sct_y, player->cnum));
+               continue;
+           }
        }
        if (!sect_has_dock(&sect)) {
            if (noisy)
                pr("Sector %s is not a harbor or canal.\n",
-                  xyas(ship.shp_x, ship.shp_y, player->cnum));
+                  xyas(sect.sct_x, sect.sct_y, player->cnum));
            continue;
        }
-       if (sect.sct_own != player->cnum && load_unload == UNLOAD
-           && getrel(getnatp(sect.sct_own), player->cnum) < FRIENDLY) {
+       if (load_unload == UNLOAD
+           && !player->owner
+           && relations_with(sect.sct_own, player->cnum) < FRIENDLY) {
            if (noisy)
                pr("You can't unload into an unfriendly %s\n",
                   dchr[sect.sct_type].d_name);
@@ -162,28 +153,34 @@ load(void)
            if (noisy)
                pr("The %s at %s is not 2%% efficient yet.\n",
                   dchr[sect.sct_type].d_name,
-                  xyas(ship.shp_x, ship.shp_y, player->cnum));
+                  xyas(sect.sct_x, sect.sct_y, player->cnum));
            continue;
        }
+
+       if (opt_MARKET) {
+           if (ontradingblock(EF_SHIP, &ship)) {
+               pr("You cannot load/unload an item on the trading block!\n");
+               continue;
+           }
+       }
+
        switch (type) {
        case EF_PLANE:
-           if (0 !=
-               (retval =
-                load_plane_ship(&sect, &ship, noisy, load_unload,
-                                &nships)))
+           retval = load_plane_ship(&sect, &ship, noisy, load_unload,
+                                    &nships);
+           if (retval != 0)
                return retval;
            break;
        case EF_LAND:
-           if (0 !=
-               (retval =
-                load_land_ship(&sect, &ship, noisy, load_unload,
-                               &nships)))
+           retval = load_land_ship(&sect, &ship, noisy, load_unload,
+                                   &nships);
+           if (retval != 0)
                return retval;
            break;
        case EF_SECTOR:
-           if (0 !=
-               (retval =
-                load_comm_ship(&sect, &ship, ich, load_unload, &nships)))
+           retval = load_comm_ship(&sect, &ship, ich, load_unload,
+                                   &nships);
+           if (retval != 0)
                return retval;
        }
        /* load/unload plague */
@@ -219,9 +216,9 @@ lload(void)
     char *p;
     char buf[1024];
 
-    if (!(p = getstarg(player->argp[1],
-                      "What commodity (or 'plane' or 'land')? ", buf))
-       || !*p)
+    p = getstarg(player->argp[1],
+                "What commodity (or 'plane' or 'land')? ", buf);
+    if (!p || !*p)
        return RET_SYN;
     if (!strncmp(p, "plane", 5))
        type = EF_PLANE;
@@ -234,7 +231,8 @@ lload(void)
        return RET_SYN;
     }
 
-    if (!(p = getstarg(player->argp[2], "Unit(s): ", buf)) || !*p)
+    p = getstarg(player->argp[2], "Unit(s): ", buf);
+    if (!p || !*p)
        return RET_SYN;
 
     noisy = isdigit(*p);
@@ -248,18 +246,31 @@ lload(void)
     while (nxtitem(&nbst, &land)) {
        if (land.lnd_own == 0)
            continue;
-       if (player->cnum != land.lnd_own) {
-           if (!noisy)
+       if (!player->owner) {
+           if (load_unload == UNLOAD || !noisy)
                continue;
-           if (getrel(getnatp(land.lnd_own), player->cnum) != ALLIED)
+           if (relations_with(land.lnd_own, player->cnum) != ALLIED)
                continue;
        }
 
        if (!getsect(land.lnd_x, land.lnd_y, &sect))    /* XXX */
            continue;
+       if (!player->owner) {
+           if (land.lnd_own != player->cnum)
+               continue;
+           if (load_unload == LOAD) {
+               if (noisy)
+                   pr("Sector %s is not yours.\n",
+                      xyas(sect.sct_x, sect.sct_y, player->cnum));
+               continue;
+           }
+           if (relations_with(sect.sct_own, player->cnum) != ALLIED) {
+               pr("Sector %s is not yours.\n",
+                  xyas(sect.sct_x, sect.sct_y, player->cnum));
+               continue;
+           }
+       }
 
-       if (sect.sct_own != player->cnum && land.lnd_own != player->cnum)
-           continue;
        if (opt_MARKET) {
            if (ontradingblock(EF_LAND, &land)) {
                pr("You cannot load/unload an item on the trading block!\n");
@@ -267,31 +278,23 @@ lload(void)
            }
        }
 
-       if (sect.sct_own != player->cnum &&
-           getrel(getnatp(sect.sct_own), player->cnum) != ALLIED) {
-           pr("Sector %s is not yours.\n",
-              xyas(land.lnd_x, land.lnd_y, player->cnum));
-           continue;
-       }
        switch (type) {
        case EF_LAND:
-           if (0 !=
-               (retval =
-                load_land_land(&sect, &land, noisy, load_unload,
-                               &nunits)))
+           retval = load_land_land(&sect, &land, noisy, load_unload,
+                                   &nunits);
+           if (retval != 0)
                return retval;
            break;
        case EF_PLANE:
-           if (0 !=
-               (retval =
-                load_plane_land(&sect, &land, noisy, load_unload,
-                                &nunits)))
+           retval = load_plane_land(&sect, &land, noisy, load_unload,
+                                    &nunits);
+           if (retval != 0)
                return retval;
            break;
        case EF_SECTOR:
-           if (0 !=
-               (retval =
-                load_comm_land(&sect, &land, ich, load_unload, &nunits)))
+           retval = load_comm_land(&sect, &land, ich, load_unload,
+                                   &nunits);
+           if (retval != 0)
                return retval;
        }
        /* load/unload plague */
@@ -313,11 +316,53 @@ lload(void)
     return RET_OK;
 }
 
+static int
+move_amount(int sect_amt, int unit_amt, int unit_max,
+          int load_unload, int amount)
+{
+    int move_amt;
+
+    if (amount < 0)
+       move_amt = -amount - unit_amt;
+    else
+       move_amt = load_unload == LOAD ? amount : -amount;
+    if (move_amt > unit_max - unit_amt)
+       move_amt = unit_max - unit_amt;
+    if (move_amt < -unit_amt)
+       move_amt = -unit_amt;
+    if (move_amt > sect_amt)
+       move_amt = sect_amt;
+    if (move_amt < sect_amt - ITEM_MAX)
+       move_amt = sect_amt - ITEM_MAX;
+    return move_amt;
+}
+
+static int
+load_comm_ok(struct sctstr *sectp, natid unit_own,
+            i_type item, int move_amt)
+{
+    if (!move_amt)
+       return 0;
+    if (move_amt < 0 && !player->god && unit_own != player->cnum)
+       return 0;
+    if (move_amt > 0 && !player->god && sectp->sct_own != player->cnum)
+       return 0;
+    if (sectp->sct_oldown != unit_own && item == I_CIVIL) {
+       pr("%s civilians refuse to %s at %s!\n",
+          (move_amt < 0 ? unit_own : sectp->sct_oldown) == player->cnum
+          ? "Your" : "Foreign",
+          move_amt < 0 ? "disembark" : "board",
+          xyas(sectp->sct_x, sectp->sct_y, player->cnum));
+       return 0;
+    }
+    return 1;
+}
+
 void
 gift(natid givee, natid giver, void *ptr, char *mesg)
 {
     if (giver != givee)
-       wu(0, givee, "%s %s %s\n", cname(giver), obj_nameof(ptr), mesg);
+       wu(0, givee, "%s %s %s\n", cname(giver), unit_nameof(ptr), mesg);
     unit_give_away(ptr, givee, 0);
 }
 
@@ -380,7 +425,7 @@ load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
        noisy = isdigit(*p);
 
     while (nxtitem(&ni, &pln)) {
-       if (pln.pln_own != player->cnum)
+       if (!player->owner)
            continue;
        if (!(plchr[(int)pln.pln_type].pl_flags & P_L)
            && !(plchr[(int)pln.pln_type].pl_flags & P_E)
@@ -410,27 +455,24 @@ load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
            continue;
        }
 
-       /* Plane sanity done */
-       /* Find the right ship */
        if (load_unload == UNLOAD) {
            if (pln.pln_ship != sp->shp_uid)
                continue;
        } else if (sp->shp_x != pln.pln_x || sp->shp_y != pln.pln_y)
            continue;
 
-       /* ship to (plane or missle) sanity */
        if (!could_be_on_ship(&pln, sp, 0, 0, 0, 0)) {
-           if (plchr[(int)pln.pln_type].pl_flags & P_L) {
-               strcpy(buf, "planes");
-           } else if (plchr[(int)pln.pln_type].pl_flags & P_K) {
-               strcpy(buf, "choppers");
-           } else if (plchr[(int)pln.pln_type].pl_flags & P_M) {
-               strcpy(buf, "missiles");
-           } else if (plchr[(int)pln.pln_type].pl_flags & P_E) {
-               strcpy(buf, "extra light planes");
-           }                   /* else impossible */
-           if (noisy)
-               pr("%s cannot carry %s.\n", prship(sp), buf);
+           if (noisy) {
+               if (plchr[(int)pln.pln_type].pl_flags & P_K)
+                   p = "choppers";
+               else if (plchr[(int)pln.pln_type].pl_flags & P_E)
+                   p = "extra light planes";
+               else if (plchr[(int)pln.pln_type].pl_flags & P_M)
+                   p = "missiles";
+               else
+                   p = "planes";
+               pr("%s cannot carry %s.\n", prship(sp), p);
+           }
            continue;
        }
        /* Fit plane on ship */
@@ -476,16 +518,14 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
     int load_spy = 0;
 
     if (load_unload == LOAD) {
-       if (opt_LANDSPIES) {
-           if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
-               (mchr[(int)sp->shp_type].m_nland == 0)) {
-               if (shp_nland(sp) >= 2) {
-                   pr("Non-land unit carrying subs can only carry up to two spy units.\n");
-                   return 0;
-               }
-               /* Eh, let 'em load a spy only */
-               load_spy = 1;
+       if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
+           (mchr[(int)sp->shp_type].m_nland == 0)) {
+           if (shp_nland(sp) >= 2) {
+               pr("Non-land unit carrying subs can only carry up to two spy units.\n");
+               return 0;
            }
+           /* Eh, let 'em load a spy only */
+           load_spy = 1;
        }
        if (!load_spy && shp_nland(sp) >= mchr[sp->shp_type].m_nland) {
            if (noisy) {
@@ -513,7 +553,7 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
        noisy = isdigit(*p);
 
     while (nxtitem(&ni, &land)) {
-       if (land.lnd_own != player->cnum)
+       if (!player->owner)
            continue;
 
        if (load_unload == LOAD) {
@@ -570,16 +610,14 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
        /* Fit unit on ship */
        if (load_unload == LOAD) {
            /* We have to check again, since it may have changed */
-           if (opt_LANDSPIES) {
-               if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
-                   (mchr[(int)sp->shp_type].m_nland == 0)) {
-                   if (shp_nland(sp) >= 2) {
-                       pr("Non-land unit carrying subs can only carry up to two spy units.\n");
-                       return 0;
-                   }
-                   /* Eh, let 'em load a spy only */
-                   load_spy = 1;
+           if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
+               (mchr[(int)sp->shp_type].m_nland == 0)) {
+               if (shp_nland(sp) >= 2) {
+                   pr("Non-land unit carrying subs can only carry up to two spy units.\n");
+                   return 0;
                }
+               /* Eh, let 'em load a spy only */
+               load_spy = 1;
            }
            if (!load_spy && shp_nland(sp) >= mchr[sp->shp_type].m_nland) {
                if (noisy) {
@@ -596,17 +634,19 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
            gift(sp->shp_own, player->cnum, &land, buf);
            land.lnd_ship = sp->shp_uid;
            land.lnd_harden = 0;
-#if 0
-           /*
-            * FIXME if this supplies from the sector, the putsect in
-            * load() / lload() duplicates those supplies, causing a
-            * seqno mismatch
-            */
-           resupply_all(&land);
-#endif
            putland(land.lnd_uid, &land);
-           if (!has_supply(&land))
+#if 0
+          /*
+           * FIXME if this supplies from the sector, the putsect in
+           * load() / lload() duplicates those supplies, causing a
+           * seqno mismatch
+           */
+           if (!lnd_supply_all(&land))
+               pr("WARNING: %s is out of supply!\n", prland(&land));
+#else
+           if (!lnd_in_supply(&land))
                pr("WARNING: %s is out of supply!\n", prland(&land));
+#endif
        } else {
            sprintf(buf, "unloaded in your %s at %s",
                    dchr[sectp->sct_type].d_name,
@@ -635,8 +675,7 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
 {
     i_type item = ich->i_uid;
     struct mchrstr *mcp = &mchr[(int)sp->shp_type];
-    int ship_amt, ship_max, sect_amt, move_amt;
-    int amount;
+    int ship_amt, sect_amt, move_amt;
     char prompt[512];
     char *p;
     char buf[1024];
@@ -646,44 +685,26 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
            (load_unload == UNLOAD) ?
            "unload from" : "load onto",
            prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
-    if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
+    p = getstarg(player->argp[3], prompt, buf);
+    if (!p || !*p)
        return RET_SYN;
 
     if (!still_ok_ship(sectp, sp))
        return RET_SYN;
 
     ship_amt = sp->shp_item[item];
-    ship_max = mcp->m_item[item];
     sect_amt = sectp->sct_item[item];
-    amount = atoi(p);
-    if (amount < 0)
-       move_amt = -amount - ship_amt;
-    else
-       move_amt = load_unload == LOAD ? amount : -amount;
-    if (move_amt > ship_max - ship_amt)
-       move_amt = ship_max - ship_amt;
-    if (move_amt < -ship_amt)
-       move_amt = -ship_amt;
-    if (move_amt > sect_amt)
-       move_amt = sect_amt;
-    if (move_amt < sect_amt - ITEM_MAX)
-       move_amt = sect_amt - ITEM_MAX;
-    if (!move_amt)
+    move_amt = move_amount(sect_amt, ship_amt, mcp->m_item[item],
+                          load_unload, atoi(p));
+    if (!load_comm_ok(sectp, sp->shp_own, item, move_amt))
        return RET_OK;
-    if (sectp->sct_oldown != player->cnum && item == I_CIVIL) {
-       pr("%s civilians refuse to %s at %s!\n",
-          move_amt < 0 ? "Your" : "Foreign",
-          move_amt < 0 ? "disembark" : "board",
-          xyas(sectp->sct_x, sectp->sct_y, player->cnum));
-       return RET_FAIL;
-    }
-
-    if (!want_to_abandon(sectp, item, move_amt, 0))
+    if (!want_to_abandon(sectp, item, move_amt, NULL))
        return RET_FAIL;
     if (!still_ok_ship(sectp, sp))
        return RET_SYN;
     sectp->sct_item[item] = sect_amt - move_amt;
     sp->shp_item[item] = ship_amt + move_amt;
+
     if (move_amt >= 0) {
        pr("%d %s loaded onto %s at %s\n",
           move_amt, ich->i_name,
@@ -744,14 +765,8 @@ load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
     if (noisy && p && *p)
        noisy = isdigit(*p);
 
-    if (sectp->sct_own != player->cnum && load_unload == LOAD) {
-       pr("Sector %s is not yours.\n",
-          xyas(lp->lnd_x, lp->lnd_y, player->cnum));
-       return 0;
-    }
-
     while (nxtitem(&ni, &pln)) {
-       if (pln.pln_own != player->cnum)
+       if (!player->owner)
            continue;
 
        if (!(plchr[(int)pln.pln_type].pl_flags & P_E)) {
@@ -822,8 +837,7 @@ load_comm_land(struct sctstr *sectp, struct lndstr *lp,
 {
     i_type item = ich->i_uid;
     struct lchrstr *lcp = &lchr[(int)lp->lnd_type];
-    int land_amt, land_max, sect_amt, move_amt;
-    int amount;
+    int land_amt, sect_amt, move_amt;
     char prompt[512];
     char *p;
     char buf[1024];
@@ -833,48 +847,26 @@ load_comm_land(struct sctstr *sectp, struct lndstr *lp,
            (load_unload == UNLOAD) ?
            "unload from" : "load onto",
            prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
-    if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
+    p = getstarg(player->argp[3], prompt, buf);
+    if (!p || !*p)
        return RET_SYN;
 
     if (!still_ok_land(sectp, lp))
        return RET_SYN;
 
     land_amt = lp->lnd_item[item];
-    land_max = lcp->l_item[item];
     sect_amt = sectp->sct_item[item];
-    amount = atoi(p);
-    if (amount < 0)
-       move_amt = -amount - land_amt;
-    else
-       move_amt = load_unload == LOAD ? amount : -amount;
-    if (move_amt > land_max - land_amt)
-       move_amt = land_max - land_amt;
-    if (move_amt < -land_amt)
-       move_amt = -land_amt;
-    if (move_amt > sect_amt)
-       move_amt = sect_amt;
-    if (move_amt < sect_amt - ITEM_MAX)
-       move_amt = sect_amt - ITEM_MAX;
-    if (!move_amt)
+    move_amt = move_amount(sect_amt, land_amt, lcp->l_item[item],
+                          load_unload, atoi(p));
+    if (!load_comm_ok(sectp, lp->lnd_own, item, move_amt))
        return RET_OK;
-    if (sectp->sct_own != player->cnum && move_amt > 0) {
-       pr("Sector %s is not yours.\n",
-          xyas(lp->lnd_x, lp->lnd_y, player->cnum));
-       return RET_FAIL;
-    }
-    if (sectp->sct_oldown != player->cnum && item == I_CIVIL) {
-       pr("%s civilians refuse to %s at %s!\n",
-          move_amt < 0 ? "Your" : "Foreign",
-          move_amt < 0 ? "disembark" : "board",
-          xyas(sectp->sct_x, sectp->sct_y, player->cnum));
-       return RET_FAIL;
-    }
     sectp->sct_item[item] = sect_amt - move_amt;
     lp->lnd_item[item] = land_amt + move_amt;
 
     /* Did we put mils onto this unit? If so, reset the fortification */
     if (item == I_MILIT && move_amt > 0)
        lp->lnd_harden = 0;
+
     if (move_amt >= 0) {
        pr("%d %s loaded onto %s at %s\n",
           move_amt, ich->i_name,
@@ -935,8 +927,7 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
        noisy = isdigit(*p);
 
     while (nxtitem(&ni, &land)) {
-
-       if (land.lnd_own != player->cnum)
+       if (!player->owner)
            continue;
 
        if (load_unload == LOAD) {
@@ -997,13 +988,15 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
            gift(lp->lnd_own, player->cnum, &land, buf);
            land.lnd_land = lp->lnd_uid;
            land.lnd_harden = 0;
-#if 0
-           /* FIXME same issue as in load_land_ship() */
-           resupply_all(&land);
-#endif
            putland(land.lnd_uid, &land);
-           if (!has_supply(&land))
+#if 0
+          /* FIXME same issue as in load_land_ship() */
+           if (!lnd_supply_all(&land))
                pr("WARNING: %s is out of supply!\n", prland(&land));
+#else
+           if (!lnd_in_supply(&land))
+               pr("WARNING: %s is out of supply!\n", prland(&land));
+#endif
        } else {
            sprintf(buf, "unloaded in your %s at %s",
                    dchr[sectp->sct_type].d_name,