2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * load.c: load/unload goods from a sector onto a ship or land unit
29 * Known contributors to this file:
30 * David Sharnoff, 1987
31 * Ken Stevens, 1995 (rewritten)
32 * Steve McClure, 1998-2000
33 * Markus Armbruster, 2004-2011
50 * The values 1 and -1 are important below, don't change them.
55 static int load_plane_ship(struct sctstr *sectp, struct shpstr *sp,
56 int noisy, int load_unload, int *nshipsp);
57 static int load_land_ship(struct sctstr *sectp, struct shpstr *sp,
58 int noisy, int load_unload, int *nshipsp);
59 static int load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
60 struct ichrstr *ich, int load_unload,
62 static int load_plane_land(struct sctstr *sectp, struct lndstr *lp,
63 int noisy, int load_unload, int *nunitsp);
64 static int load_land_land(struct sctstr *sectp, struct lndstr *lp,
65 int noisy, int load_unload, int *nunitsp);
66 static int load_comm_land(struct sctstr *sectp, struct lndstr *lp,
67 struct ichrstr *ich, int load_unload,
76 struct nstr_item nbst;
85 p = getstarg(player->argp[1],
86 "What commodity (or 'plane' or 'land')? ", buf);
90 if (!strncmp(p, "plane", 5))
92 else if (!strncmp(p, "land", 4))
94 else if (NULL != (ich = item_by_name(p)))
97 pr("Can't load '%s'\n", p);
101 p = getstarg(player->argp[2], "Ship(s): ", buf);
107 if (!snxtitem(&nbst, EF_SHIP, p, NULL))
110 load_unload = **player->argp == 'l' ? LOAD : UNLOAD;
113 while (nxtitem(&nbst, &ship)) {
116 if (!player->owner) {
117 if (load_unload == UNLOAD || !noisy)
119 if (relations_with(ship.shp_own, player->cnum) < FRIENDLY)
123 if (!getsect(ship.shp_x, ship.shp_y, §)) /* XXX */
127 if (!player->owner) {
128 if (ship.shp_own != player->cnum)
130 if (!sect_has_dock(§))
132 if (load_unload == LOAD) {
134 pr("You don't own %s \n",
135 xyas(sect.sct_x, sect.sct_y, player->cnum));
139 if (!sect_has_dock(§)) {
141 pr("Sector %s is not a harbor or canal.\n",
142 xyas(sect.sct_x, sect.sct_y, player->cnum));
145 if (load_unload == UNLOAD
147 && relations_with(sect.sct_own, player->cnum) < FRIENDLY) {
149 pr("You can't unload into an unfriendly %s\n",
150 dchr[sect.sct_type].d_name);
153 if (sect.sct_effic < 2) {
155 pr("The %s at %s is not 2%% efficient yet.\n",
156 dchr[sect.sct_type].d_name,
157 xyas(sect.sct_x, sect.sct_y, player->cnum));
162 if (ontradingblock(EF_SHIP, &ship)) {
163 pr("You cannot load/unload an item on the trading block!\n");
170 retval = load_plane_ship(§, &ship, noisy, load_unload,
176 retval = load_land_ship(§, &ship, noisy, load_unload,
182 retval = load_comm_ship(§, &ship, ich, load_unload,
187 /* load/unload plague */
188 if (sect.sct_pstage == PLG_INFECT
189 && ship.shp_pstage == PLG_HEALTHY)
190 ship.shp_pstage = PLG_EXPOSED;
191 if (ship.shp_pstage == PLG_INFECT
192 && sect.sct_pstage == PLG_HEALTHY)
193 sect.sct_pstage = PLG_EXPOSED;
195 putship(ship.shp_uid, &ship);
198 pr("No ships affected\n");
200 pr("%d ship%s %sloaded\n", nships, splur(nships),
201 load_unload == UNLOAD ? "un" : "");
211 struct nstr_item nbst;
220 p = getstarg(player->argp[1],
221 "What commodity (or 'plane' or 'land')? ", buf);
224 if (!strncmp(p, "plane", 5))
226 else if (!strncmp(p, "land", 4))
228 else if (NULL != (ich = item_by_name(p)))
231 pr("Can't load '%s'\n", p);
235 p = getstarg(player->argp[2], "Unit(s): ", buf);
241 if (!snxtitem(&nbst, EF_LAND, p, NULL))
244 load_unload = player->argp[0][1] == 'l' ? LOAD : UNLOAD;
247 while (nxtitem(&nbst, &land)) {
248 if (land.lnd_own == 0)
250 if (!player->owner) {
251 if (load_unload == UNLOAD || !noisy)
253 if (relations_with(land.lnd_own, player->cnum) != ALLIED)
257 if (!getsect(land.lnd_x, land.lnd_y, §)) /* XXX */
259 if (!player->owner) {
260 if (land.lnd_own != player->cnum)
262 if (load_unload == LOAD) {
264 pr("Sector %s is not yours.\n",
265 xyas(sect.sct_x, sect.sct_y, player->cnum));
268 if (relations_with(sect.sct_own, player->cnum) != ALLIED) {
269 pr("Sector %s is not yours.\n",
270 xyas(sect.sct_x, sect.sct_y, player->cnum));
276 if (ontradingblock(EF_LAND, &land)) {
277 pr("You cannot load/unload an item on the trading block!\n");
284 retval = load_land_land(§, &land, noisy, load_unload,
290 retval = load_plane_land(§, &land, noisy, load_unload,
296 retval = load_comm_land(§, &land, ich, load_unload,
301 /* load/unload plague */
302 if (sect.sct_pstage == PLG_INFECT
303 && land.lnd_pstage == PLG_HEALTHY)
304 land.lnd_pstage = PLG_EXPOSED;
305 if (land.lnd_pstage == PLG_INFECT
306 && sect.sct_pstage == PLG_HEALTHY)
307 sect.sct_pstage = PLG_EXPOSED;
310 putland(land.lnd_uid, &land);
313 pr("No units affected\n");
315 pr("%d unit%s %sloaded\n", nunits, splur(nunits),
316 load_unload == UNLOAD ? "un" : "");
321 move_amount(int sect_amt, int unit_amt, int unit_max,
322 int load_unload, int amount)
327 move_amt = -amount - unit_amt;
329 move_amt = load_unload == LOAD ? amount : -amount;
330 if (move_amt > unit_max - unit_amt)
331 move_amt = unit_max - unit_amt;
332 if (move_amt < -unit_amt)
333 move_amt = -unit_amt;
334 if (move_amt > sect_amt)
336 if (move_amt < sect_amt - ITEM_MAX)
337 move_amt = sect_amt - ITEM_MAX;
342 load_comm_ok(struct sctstr *sectp, natid unit_own,
343 i_type item, int move_amt)
347 if (move_amt < 0 && !player->god && unit_own != player->cnum)
349 if (move_amt > 0 && !player->god && sectp->sct_own != player->cnum)
351 if (sectp->sct_oldown != unit_own && item == I_CIVIL) {
352 pr("%s civilians refuse to %s at %s!\n",
353 (move_amt < 0 ? unit_own : sectp->sct_oldown) == player->cnum
354 ? "Your" : "Foreign",
355 move_amt < 0 ? "disembark" : "board",
356 xyas(sectp->sct_x, sectp->sct_y, player->cnum));
363 gift(natid givee, natid giver, void *ptr, char *mesg)
366 wu(0, givee, "%s %s %s\n", cname(giver), obj_nameof(ptr), mesg);
367 unit_give_away(ptr, givee, 0);
371 still_ok_ship(struct sctstr *sectp, struct shpstr *shipp)
373 if (!check_sect_ok(sectp))
375 if (!check_ship_ok(shipp))
381 still_ok_land(struct sctstr *sectp, struct lndstr *landp)
383 if (!check_sect_ok(sectp))
385 if (!check_land_ok(landp))
391 load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
392 int load_unload, int *nshipsp)
400 struct mchrstr *mcp = mchr + sp->shp_type;
402 if (mcp->m_nplanes + mcp->m_nchoppers + mcp->m_nxlight == 0) {
404 pr("%s cannot carry planes\n", prship(sp));
407 if (load_unload == LOAD &&
408 shp_nplane(sp, NULL, NULL, NULL)
409 >= mcp->m_nchoppers + mcp->m_nxlight + mcp->m_nplanes) {
411 pr("%s doesn't have room for any more planes\n", prship(sp));
414 sprintf(prompt, "Plane(s) to %s %s? ",
415 load_unload == LOAD ? "load onto" : "unload from", prship(sp));
416 p = getstarg(player->argp[3], prompt, buf);
419 if (!snxtitem(&ni, EF_PLANE, p, NULL))
422 if (!still_ok_ship(sectp, sp))
425 if (noisy && p && *p)
428 while (nxtitem(&ni, &pln)) {
431 if (!(plchr[(int)pln.pln_type].pl_flags & P_L)
432 && !(plchr[(int)pln.pln_type].pl_flags & P_E)
433 && !(plchr[(int)pln.pln_type].pl_flags & P_K)
434 && !(plchr[(int)pln.pln_type].pl_flags & P_M)
437 pr("You can only load light planes, helos, xtra-light, or missiles onto ships.\n");
440 if (load_unload == LOAD && pln.pln_ship > -1) {
442 pr("%s is already on ship #%d!\n",
443 prplane(&pln), pln.pln_ship);
446 if (load_unload == LOAD && pln.pln_land > -1) {
448 pr("%s is already on land unit #%d!\n",
449 prplane(&pln), pln.pln_land);
452 if (pln.pln_harden != 0) {
454 pr("%s has been hardened and can't be loaded\n",
459 if (load_unload == UNLOAD) {
460 if (pln.pln_ship != sp->shp_uid)
462 } else if (sp->shp_x != pln.pln_x || sp->shp_y != pln.pln_y)
465 if (!could_be_on_ship(&pln, sp, 0, 0, 0, 0)) {
467 if (plchr[(int)pln.pln_type].pl_flags & P_K)
469 else if (plchr[(int)pln.pln_type].pl_flags & P_E)
470 p = "extra light planes";
471 else if (plchr[(int)pln.pln_type].pl_flags & P_M)
475 pr("%s cannot carry %s.\n", prship(sp), p);
479 /* Fit plane on ship */
480 if (load_unload == LOAD) {
481 if (!put_plane_on_ship(&pln, sp)) {
483 pr("Can't put plane %d on this ship!\n", pln.pln_uid);
486 sprintf(buf, "loaded on your %s at %s",
487 prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
488 gift(sp->shp_own, player->cnum, &pln, buf);
489 putplane(pln.pln_uid, &pln);
492 sprintf(buf, "unloaded in your %s at %s",
493 dchr[sectp->sct_type].d_name,
494 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
495 gift(sectp->sct_own, player->cnum, &pln, buf);
496 putplane(pln.pln_uid, &pln);
498 pr("%s %s %s at %s.\n",
500 (load_unload == UNLOAD) ?
501 "unloaded from" : "loaded onto",
502 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
510 load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
511 int load_unload, int *nshipsp)
521 if (load_unload == LOAD) {
523 if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
524 (mchr[(int)sp->shp_type].m_nland == 0)) {
525 if (shp_nland(sp) >= 2) {
526 pr("Non-land unit carrying subs can only carry up to two spy units.\n");
529 /* Eh, let 'em load a spy only */
533 if (!load_spy && shp_nland(sp) >= mchr[sp->shp_type].m_nland) {
535 if (mchr[(int)sp->shp_type].m_nland)
536 pr("%s doesn't have room for any more land units!\n",
539 pr("%s cannot carry land units!\n", prship(sp));
544 sprintf(prompt, "Land unit(s) to %s %s? ",
545 load_unload == LOAD ? "load onto" : "unload from", prship(sp));
546 p = getstarg(player->argp[3], prompt, buf);
549 if (!snxtitem(&ni, EF_LAND, p, NULL))
552 if (!still_ok_ship(sectp, sp))
555 if (noisy && p && *p)
558 while (nxtitem(&ni, &land)) {
562 if (load_unload == LOAD) {
563 if (land.lnd_ship > -1) {
565 pr("%s is already on ship #%d!\n",
566 prland(&land), land.lnd_ship);
569 if (land.lnd_land > -1) {
571 pr("%s is already on land #%d!\n",
572 prland(&land), land.lnd_land);
575 if (lnd_first_on_land(&land) >= 0) {
577 pr("%s cannot be loaded since it is carrying units\n",
581 if (lchr[(int)land.lnd_type].l_flags & L_HEAVY) {
583 pr("%s is too heavy to load.\n", prland(&land));
586 if (load_spy && !(lchr[(int)land.lnd_type].l_flags & L_SPY)) {
588 pr("Subs can only carry spy units.\n");
593 /* Unit sanity done */
594 /* Find the right ship */
595 if (load_unload == UNLOAD) {
596 if (land.lnd_ship != sp->shp_uid)
598 if (land.lnd_land > -1)
600 } else if (sp->shp_x != land.lnd_x || sp->shp_y != land.lnd_y)
603 if ((!(lchr[(int)land.lnd_type].l_flags & L_LIGHT)) &&
604 (!((mchr[(int)sp->shp_type].m_flags & M_SUPPLY) &&
605 (!(mchr[(int)sp->shp_type].m_flags & M_SUB))))) {
607 pr("You can only load light units onto ships,\n");
608 pr("unless the ship is a non-sub supply ship\n");
609 pr("%s not loaded\n", prland(&land));
613 /* Fit unit on ship */
614 if (load_unload == LOAD) {
615 /* We have to check again, since it may have changed */
617 if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
618 (mchr[(int)sp->shp_type].m_nland == 0)) {
619 if (shp_nland(sp) >= 2) {
620 pr("Non-land unit carrying subs can only carry up to two spy units.\n");
623 /* Eh, let 'em load a spy only */
627 if (!load_spy && shp_nland(sp) >= mchr[sp->shp_type].m_nland) {
629 if (mchr[(int)sp->shp_type].m_nland)
630 pr("%s doesn't have room for any more land units!\n",
633 pr("%s cannot carry land units!\n", prship(sp));
637 sprintf(buf, "loaded on your %s at %s",
638 prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
639 gift(sp->shp_own, player->cnum, &land, buf);
640 land.lnd_ship = sp->shp_uid;
642 putland(land.lnd_uid, &land);
645 * FIXME if this supplies from the sector, the putsect in
646 * load() / lload() duplicates those supplies, causing a
649 if (!lnd_supply_all(&land))
650 pr("WARNING: %s is out of supply!\n", prland(&land));
652 if (!lnd_in_supply(&land))
653 pr("WARNING: %s is out of supply!\n", prland(&land));
656 sprintf(buf, "unloaded in your %s at %s",
657 dchr[sectp->sct_type].d_name,
658 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
660 /* Spies are unloaded quietly, others aren't */
661 if (!(lchr[(int)land.lnd_type].l_flags & L_SPY))
662 gift(sectp->sct_own, player->cnum, &land, buf);
664 putland(land.lnd_uid, &land);
666 pr("%s %s %s at %s.\n",
668 (load_unload == UNLOAD) ?
669 "unloaded from" : "loaded onto",
670 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
678 load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
679 struct ichrstr *ich, int load_unload, int *nshipsp)
681 i_type item = ich->i_uid;
682 struct mchrstr *mcp = &mchr[(int)sp->shp_type];
683 int ship_amt, sect_amt, move_amt;
688 sprintf(prompt, "Number of %s to %s %s at %s? ",
690 (load_unload == UNLOAD) ?
691 "unload from" : "load onto",
692 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
693 p = getstarg(player->argp[3], prompt, buf);
697 if (!still_ok_ship(sectp, sp))
700 ship_amt = sp->shp_item[item];
701 sect_amt = sectp->sct_item[item];
702 move_amt = move_amount(sect_amt, ship_amt, mcp->m_item[item],
703 load_unload, atoi(p));
704 if (!load_comm_ok(sectp, sp->shp_own, item, move_amt))
706 if (!want_to_abandon(sectp, item, move_amt, NULL))
708 if (!still_ok_ship(sectp, sp))
710 sectp->sct_item[item] = sect_amt - move_amt;
711 sp->shp_item[item] = ship_amt + move_amt;
714 pr("%d %s loaded onto %s at %s\n",
715 move_amt, ich->i_name,
716 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
717 if (sp->shp_own != player->cnum) {
718 wu(0, sp->shp_own, "%s loaded %d %s onto %s at %s\n",
719 cname(player->cnum), move_amt, ich->i_name,
720 prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
723 pr("%d %s unloaded from %s at %s\n",
724 -move_amt, ich->i_name,
725 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
726 if (sectp->sct_own != player->cnum) {
727 wu(0, sectp->sct_own, "%s unloaded %d %s from %s at %s\n",
728 cname(player->cnum), -move_amt, ich->i_name,
729 prship(sp), xyas(sp->shp_x, sp->shp_y, sectp->sct_own));
737 load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
738 int load_unload, int *nunitsp)
746 struct lchrstr *lcp = lchr + lp->lnd_type;
748 if (!lcp->l_nxlight) {
750 pr("%s cannot carry extra-light planes.\n", prland(lp));
753 if (load_unload == LOAD && lnd_nxlight(lp) >= lcp->l_nxlight) {
755 pr("%s doesn't have room for any more extra-light planes\n",
759 sprintf(prompt, "Plane(s) to %s %s? ",
760 load_unload == LOAD ? "load onto" : "unload from", prland(lp));
761 p = getstarg(player->argp[3], prompt, buf);
764 if (!snxtitem(&ni, EF_PLANE, p, NULL))
767 if (!still_ok_land(sectp, lp))
770 if (noisy && p && *p)
773 while (nxtitem(&ni, &pln)) {
777 if (!(plchr[(int)pln.pln_type].pl_flags & P_E)) {
779 pr("You can only load xlight planes onto units.\n");
783 if (load_unload == LOAD && pln.pln_ship > -1) {
785 pr("%s is already on ship #%d!\n",
786 prplane(&pln), pln.pln_ship);
789 if (load_unload == LOAD && pln.pln_land > -1) {
791 pr("%s is already on unit #%d!\n",
792 prplane(&pln), pln.pln_land);
795 if (pln.pln_harden != 0) {
797 pr("%s has been hardened and can't be loaded\n",
802 /* Plane sanity done */
803 /* Find the right unit */
804 if (load_unload == UNLOAD) {
805 if (pln.pln_land != lp->lnd_uid)
807 } else if (lp->lnd_x != pln.pln_x || lp->lnd_y != pln.pln_y)
810 /* Fit plane on unit */
811 if (load_unload == LOAD) {
812 if (!put_plane_on_land(&pln, lp)) {
814 pr("Can't put plane %d on this unit!\n", pln.pln_uid);
817 sprintf(buf, "loaded on %s at %s",
818 prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
819 gift(lp->lnd_own, player->cnum, &pln, buf);
820 putplane(pln.pln_uid, &pln);
823 sprintf(buf, "unloaded at your sector at %s",
824 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
825 gift(sectp->sct_own, player->cnum, &pln, buf);
826 putplane(pln.pln_uid, &pln);
828 pr("%s %s %s at %s.\n",
830 (load_unload == UNLOAD) ?
831 "unloaded from" : "loaded onto",
832 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
840 load_comm_land(struct sctstr *sectp, struct lndstr *lp,
841 struct ichrstr *ich, int load_unload, int *nunitsp)
843 i_type item = ich->i_uid;
844 struct lchrstr *lcp = &lchr[(int)lp->lnd_type];
845 int land_amt, sect_amt, move_amt;
850 sprintf(prompt, "Number of %s to %s %s at %s? ",
852 (load_unload == UNLOAD) ?
853 "unload from" : "load onto",
854 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
855 p = getstarg(player->argp[3], prompt, buf);
859 if (!still_ok_land(sectp, lp))
862 land_amt = lp->lnd_item[item];
863 sect_amt = sectp->sct_item[item];
864 move_amt = move_amount(sect_amt, land_amt, lcp->l_item[item],
865 load_unload, atoi(p));
866 if (!load_comm_ok(sectp, lp->lnd_own, item, move_amt))
868 sectp->sct_item[item] = sect_amt - move_amt;
869 lp->lnd_item[item] = land_amt + move_amt;
871 /* Did we put mils onto this unit? If so, reset the fortification */
872 if (item == I_MILIT && move_amt > 0)
876 pr("%d %s loaded onto %s at %s\n",
877 move_amt, ich->i_name,
878 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
879 if (lp->lnd_own != player->cnum) {
880 wu(0, lp->lnd_own, "%s loaded %d %s onto %s at %s\n",
881 cname(player->cnum), move_amt, ich->i_name,
882 prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
885 pr("%d %s unloaded from %s at %s\n",
886 -move_amt, ich->i_name,
887 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
888 if (sectp->sct_own != player->cnum) {
889 wu(0, sectp->sct_own, "%s unloaded %d %s from %s at %s\n",
890 cname(player->cnum), -move_amt, ich->i_name,
891 prland(lp), xyas(lp->lnd_x, lp->lnd_y, sectp->sct_own));
899 load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
900 int load_unload, int *nunitsp)
909 if (load_unload == LOAD
910 && lnd_nland(lp) >= lchr[lp->lnd_type].l_nland) {
912 if (lchr[lp->lnd_type].l_nland)
913 pr("%s doesn't have room for any more land units!\n",
916 pr("%s cannot carry land units!\n", prland(lp));
920 sprintf(prompt, "Land unit(s) to %s %s? ",
921 load_unload == LOAD ? "load onto" : "unload from", prland(lp));
922 p = getstarg(player->argp[3], prompt, buf);
925 if (!snxtitem(&ni, EF_LAND, p, NULL))
928 if (!still_ok_land(sectp, lp))
931 if (noisy && p && *p)
934 while (nxtitem(&ni, &land)) {
938 if (load_unload == LOAD) {
939 if (land.lnd_ship > -1) {
941 pr("%s is already on ship #%d!\n",
942 prland(&land), land.lnd_ship);
945 if (land.lnd_land > -1) {
947 pr("%s is already on land #%d!\n",
948 prland(&land), land.lnd_land);
951 if (lnd_first_on_land(&land) >= 0) {
953 pr("%s cannot be loaded since it is carrying units\n",
957 if (land.lnd_uid == lp->lnd_uid) {
959 pr("%s can't be loaded onto itself!\n", prland(&land));
962 if (lchr[(int)land.lnd_type].l_flags & (L_HEAVY | L_TRAIN)) {
964 pr("%s is too heavy to load.\n", prland(&land));
969 /* Unit sanity done */
970 /* Find the right ship */
971 if (load_unload == UNLOAD) {
972 if (land.lnd_land != lp->lnd_uid)
974 if (land.lnd_ship > -1)
976 } else if (lp->lnd_x != land.lnd_x || lp->lnd_y != land.lnd_y)
979 /* Fit unit on ship */
980 if (load_unload == LOAD) {
981 if (lnd_nland(lp) >= lchr[lp->lnd_type].l_nland) {
983 if (lchr[lp->lnd_type].l_nland)
984 pr("%s doesn't have room for any more land units!\n",
987 pr("%s cannot carry land units!\n", prland(lp));
991 sprintf(buf, "loaded on your %s at %s",
992 prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
993 gift(lp->lnd_own, player->cnum, &land, buf);
994 land.lnd_land = lp->lnd_uid;
996 putland(land.lnd_uid, &land);
998 /* FIXME same issue as in load_land_ship() */
999 if (!lnd_supply_all(&land))
1000 pr("WARNING: %s is out of supply!\n", prland(&land));
1002 if (!lnd_in_supply(&land))
1003 pr("WARNING: %s is out of supply!\n", prland(&land));
1006 sprintf(buf, "unloaded in your %s at %s",
1007 dchr[sectp->sct_type].d_name,
1008 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
1009 gift(sectp->sct_own, player->cnum, &land, buf);
1011 putland(land.lnd_uid, &land);
1013 pr("%s %s %s at %s.\n",
1015 (load_unload == UNLOAD) ?
1016 "unloaded from" : "loaded onto",
1017 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));