2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2018, 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-2014
49 * The values 1 and -1 are important below, don't change them.
54 static int load_plane_ship(struct sctstr *sectp, struct shpstr *sp,
55 int noisy, int load_unload, int *nshipsp);
56 static int load_land_ship(struct sctstr *sectp, struct shpstr *sp,
57 int noisy, int load_unload, int *nshipsp);
58 static int load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
59 struct ichrstr *ich, int load_unload,
61 static int load_plane_land(struct sctstr *sectp, struct lndstr *lp,
62 int noisy, int load_unload, int *nunitsp);
63 static int load_land_land(struct sctstr *sectp, struct lndstr *lp,
64 int noisy, int load_unload, int *nunitsp);
65 static int load_comm_land(struct sctstr *sectp, struct lndstr *lp,
66 struct ichrstr *ich, int load_unload,
75 struct nstr_item nbst;
84 p = getstarg(player->argp[1],
85 "What commodity (or 'plane' or 'land')? ", buf);
89 if (!strncmp(p, "plane", 5))
91 else if (!strncmp(p, "land", 4))
93 else if (NULL != (ich = item_by_name(p)))
96 pr("Can't load '%s'\n", p);
100 p = getstarg(player->argp[2], "Ship(s): ", buf);
106 if (!snxtitem(&nbst, EF_SHIP, p, NULL))
109 load_unload = **player->argp == 'l' ? LOAD : UNLOAD;
112 while (nxtitem(&nbst, &ship)) {
115 if (!player->owner) {
116 if (load_unload == UNLOAD || !noisy)
118 if (relations_with(ship.shp_own, player->cnum) < FRIENDLY)
122 if (!getsect(ship.shp_x, ship.shp_y, §)) /* XXX */
126 if (!player->owner) {
127 if (ship.shp_own != player->cnum)
129 if (!sect_has_dock(§))
131 if (load_unload == LOAD) {
133 pr("You don't own %s\n",
134 xyas(sect.sct_x, sect.sct_y, player->cnum));
138 if (!sect_has_dock(§)) {
140 pr("Sector %s is not a harbor or canal.\n",
141 xyas(sect.sct_x, sect.sct_y, player->cnum));
144 if (load_unload == UNLOAD
146 && relations_with(sect.sct_own, player->cnum) < FRIENDLY) {
148 pr("You can't unload into an unfriendly %s\n",
149 dchr[sect.sct_type].d_name);
152 if (sect.sct_effic < 2) {
154 pr("The %s at %s is not 2%% efficient yet.\n",
155 dchr[sect.sct_type].d_name,
156 xyas(sect.sct_x, sect.sct_y, player->cnum));
161 if (ontradingblock(EF_SHIP, &ship)) {
162 pr("You cannot load/unload an item on the trading block!\n");
169 retval = load_plane_ship(§, &ship, noisy, load_unload,
175 retval = load_land_ship(§, &ship, noisy, load_unload,
181 retval = load_comm_ship(§, &ship, ich, load_unload,
186 /* load/unload plague */
187 if (sect.sct_pstage == PLG_INFECT
188 && ship.shp_pstage == PLG_HEALTHY)
189 ship.shp_pstage = PLG_EXPOSED;
190 if (ship.shp_pstage == PLG_INFECT
191 && sect.sct_pstage == PLG_HEALTHY)
192 sect.sct_pstage = PLG_EXPOSED;
194 putship(ship.shp_uid, &ship);
197 pr("No ships affected\n");
199 pr("%d ship%s %sloaded\n", nships, splur(nships),
200 load_unload == UNLOAD ? "un" : "");
210 struct nstr_item nbst;
219 p = getstarg(player->argp[1],
220 "What commodity (or 'plane' or 'land')? ", buf);
223 if (!strncmp(p, "plane", 5))
225 else if (!strncmp(p, "land", 4))
227 else if (NULL != (ich = item_by_name(p)))
230 pr("Can't load '%s'\n", p);
234 p = getstarg(player->argp[2], "Unit(s): ", buf);
240 if (!snxtitem(&nbst, EF_LAND, p, NULL))
243 load_unload = player->argp[0][1] == 'l' ? LOAD : UNLOAD;
246 while (nxtitem(&nbst, &land)) {
247 if (land.lnd_own == 0)
249 if (!player->owner) {
250 if (load_unload == UNLOAD || !noisy)
252 if (relations_with(land.lnd_own, player->cnum) != ALLIED)
256 if (!getsect(land.lnd_x, land.lnd_y, §)) /* XXX */
258 if (!player->owner) {
259 if (land.lnd_own != player->cnum)
261 if (load_unload == LOAD) {
263 pr("Sector %s is not yours.\n",
264 xyas(sect.sct_x, sect.sct_y, player->cnum));
267 if (relations_with(sect.sct_own, player->cnum) != ALLIED) {
268 pr("Sector %s is not yours.\n",
269 xyas(sect.sct_x, sect.sct_y, player->cnum));
275 if (ontradingblock(EF_LAND, &land)) {
276 pr("You cannot load/unload an item on the trading block!\n");
283 retval = load_land_land(§, &land, noisy, load_unload,
289 retval = load_plane_land(§, &land, noisy, load_unload,
295 retval = load_comm_land(§, &land, ich, load_unload,
300 /* load/unload plague */
301 if (sect.sct_pstage == PLG_INFECT
302 && land.lnd_pstage == PLG_HEALTHY)
303 land.lnd_pstage = PLG_EXPOSED;
304 if (land.lnd_pstage == PLG_INFECT
305 && sect.sct_pstage == PLG_HEALTHY)
306 sect.sct_pstage = PLG_EXPOSED;
309 putland(land.lnd_uid, &land);
312 pr("No units affected\n");
314 pr("%d unit%s %sloaded\n", nunits, splur(nunits),
315 load_unload == UNLOAD ? "un" : "");
320 move_amount(int sect_amt, int unit_amt, int unit_max,
321 int load_unload, int amount)
326 move_amt = -amount - unit_amt;
328 move_amt = load_unload == LOAD ? amount : -amount;
329 move_amt = LIMIT_TO(move_amt, -unit_amt, unit_max - unit_amt);
330 move_amt = LIMIT_TO(move_amt, sect_amt - ITEM_MAX, sect_amt);
335 load_comm_ok(struct sctstr *sectp, natid unit_own,
336 i_type item, int move_amt)
340 if (move_amt < 0 && !player->god && unit_own != player->cnum)
342 if (move_amt > 0 && !player->god && sectp->sct_own != player->cnum)
344 if (sectp->sct_oldown != unit_own && item == I_CIVIL) {
345 pr("%s civilians refuse to %s at %s!\n",
346 (move_amt < 0 ? unit_own : sectp->sct_oldown) == player->cnum
347 ? "Your" : "Foreign",
348 move_amt < 0 ? "disembark" : "board",
349 xyas(sectp->sct_x, sectp->sct_y, player->cnum));
356 gift(natid givee, natid giver, void *ptr, char *mesg)
359 wu(0, givee, "%s %s %s\n", cname(giver), unit_nameof(ptr), mesg);
360 unit_give_away(ptr, givee, 0);
364 still_ok_ship(struct sctstr *sectp, struct shpstr *shipp)
366 if (!check_sect_ok(sectp))
368 if (!check_ship_ok(shipp))
374 still_ok_land(struct sctstr *sectp, struct lndstr *landp)
376 if (!check_sect_ok(sectp))
378 if (!check_land_ok(landp))
384 load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
385 int load_unload, int *nshipsp)
393 struct mchrstr *mcp = mchr + sp->shp_type;
395 if (mcp->m_nplanes + mcp->m_nchoppers + mcp->m_nxlight == 0) {
397 pr("%s cannot carry planes\n", prship(sp));
400 if (load_unload == LOAD &&
401 shp_nplane(sp, NULL, NULL, NULL)
402 >= mcp->m_nchoppers + mcp->m_nxlight + mcp->m_nplanes) {
404 pr("%s doesn't have room for any more planes\n", prship(sp));
407 sprintf(prompt, "Plane(s) to %s %s? ",
408 load_unload == LOAD ? "load onto" : "unload from", prship(sp));
409 p = getstarg(player->argp[3], prompt, buf);
412 if (!snxtitem(&ni, EF_PLANE, p, NULL))
415 if (!still_ok_ship(sectp, sp))
418 if (noisy && p && *p)
421 while (nxtitem(&ni, &pln)) {
424 if (!(plchr[(int)pln.pln_type].pl_flags & P_L)
425 && !(plchr[(int)pln.pln_type].pl_flags & P_E)
426 && !(plchr[(int)pln.pln_type].pl_flags & P_K)
427 && !(plchr[(int)pln.pln_type].pl_flags & P_M)
430 pr("You can only load light planes, helos, xtra-light, or missiles onto ships.\n");
433 if (load_unload == LOAD && pln.pln_ship > -1) {
435 pr("%s is already on ship #%d!\n",
436 prplane(&pln), pln.pln_ship);
439 if (load_unload == LOAD && pln.pln_land > -1) {
441 pr("%s is already on land unit #%d!\n",
442 prplane(&pln), pln.pln_land);
445 if (pln.pln_harden != 0) {
447 pr("%s has been hardened and can't be loaded\n",
452 if (load_unload == UNLOAD) {
453 if (pln.pln_ship != sp->shp_uid)
455 } else if (sp->shp_x != pln.pln_x || sp->shp_y != pln.pln_y)
458 if (!could_be_on_ship(&pln, sp)) {
460 if (plchr[(int)pln.pln_type].pl_flags & P_K)
462 else if (plchr[(int)pln.pln_type].pl_flags & P_E)
463 p = "extra light planes";
464 else if (plchr[(int)pln.pln_type].pl_flags & P_M)
468 pr("%s cannot carry %s.\n", prship(sp), p);
472 /* Fit plane on ship */
473 if (load_unload == LOAD) {
474 if (!put_plane_on_ship(&pln, sp)) {
476 pr("Can't put plane %d on this ship!\n", pln.pln_uid);
479 sprintf(buf, "loaded on your %s at %s",
480 prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
481 gift(sp->shp_own, player->cnum, &pln, buf);
482 putplane(pln.pln_uid, &pln);
485 sprintf(buf, "unloaded in your %s at %s",
486 dchr[sectp->sct_type].d_name,
487 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
488 gift(sectp->sct_own, player->cnum, &pln, buf);
489 putplane(pln.pln_uid, &pln);
491 pr("%s %s %s at %s.\n",
493 (load_unload == UNLOAD) ?
494 "unloaded from" : "loaded onto",
495 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
503 load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
504 int load_unload, int *nshipsp)
514 if (load_unload == LOAD) {
515 if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
516 (mchr[(int)sp->shp_type].m_nland == 0)) {
517 if (shp_nland(sp) >= 2) {
518 pr("Non-land unit carrying subs can only carry up to two spy units.\n");
521 /* Eh, let 'em load a spy only */
524 if (!load_spy && shp_nland(sp) >= mchr[sp->shp_type].m_nland) {
526 if (mchr[(int)sp->shp_type].m_nland)
527 pr("%s doesn't have room for any more land units!\n",
530 pr("%s cannot carry land units!\n", prship(sp));
535 sprintf(prompt, "Land unit(s) to %s %s? ",
536 load_unload == LOAD ? "load onto" : "unload from", prship(sp));
537 p = getstarg(player->argp[3], prompt, buf);
540 if (!snxtitem(&ni, EF_LAND, p, NULL))
543 if (!still_ok_ship(sectp, sp))
546 if (noisy && p && *p)
549 while (nxtitem(&ni, &land)) {
553 if (load_unload == LOAD) {
554 if (land.lnd_ship > -1) {
556 pr("%s is already on ship #%d!\n",
557 prland(&land), land.lnd_ship);
560 if (land.lnd_land > -1) {
562 pr("%s is already on land #%d!\n",
563 prland(&land), land.lnd_land);
566 if (lnd_first_on_land(&land) >= 0) {
568 pr("%s cannot be loaded since it is carrying units\n",
572 if (lchr[(int)land.lnd_type].l_flags & L_HEAVY) {
574 pr("%s is too heavy to load.\n", prland(&land));
577 if (load_spy && !(lchr[(int)land.lnd_type].l_flags & L_SPY)) {
579 pr("Subs can only carry spy units.\n");
584 /* Unit sanity done */
585 /* Find the right ship */
586 if (load_unload == UNLOAD) {
587 if (land.lnd_ship != sp->shp_uid)
589 if (land.lnd_land > -1)
591 } else if (sp->shp_x != land.lnd_x || sp->shp_y != land.lnd_y)
594 if ((!(lchr[(int)land.lnd_type].l_flags & L_LIGHT)) &&
595 (!((mchr[(int)sp->shp_type].m_flags & M_SUPPLY) &&
596 (!(mchr[(int)sp->shp_type].m_flags & M_SUB))))) {
598 pr("You can only load light units onto ships,\n");
599 pr("unless the ship is a non-sub supply ship\n");
600 pr("%s not loaded\n", prland(&land));
604 /* Fit unit on ship */
605 if (load_unload == LOAD) {
606 /* We have to check again, since it may have changed */
607 if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
608 (mchr[(int)sp->shp_type].m_nland == 0)) {
609 if (shp_nland(sp) >= 2) {
610 pr("Non-land unit carrying subs can only carry up to two spy units.\n");
613 /* Eh, let 'em load a spy only */
616 if (!load_spy && shp_nland(sp) >= mchr[sp->shp_type].m_nland) {
618 if (mchr[(int)sp->shp_type].m_nland)
619 pr("%s doesn't have room for any more land units!\n",
622 pr("%s cannot carry land units!\n", prship(sp));
626 sprintf(buf, "loaded on your %s at %s",
627 prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
628 gift(sp->shp_own, player->cnum, &land, buf);
629 land.lnd_ship = sp->shp_uid;
631 putland(land.lnd_uid, &land);
634 * FIXME if this supplies from the sector, the putsect in
635 * load() / lload() duplicates those supplies, causing a
638 if (!lnd_supply_all(&land))
639 pr("WARNING: %s is out of supply!\n", prland(&land));
641 if (!lnd_in_supply(&land))
642 pr("WARNING: %s is out of supply!\n", prland(&land));
645 sprintf(buf, "unloaded in your %s at %s",
646 dchr[sectp->sct_type].d_name,
647 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
649 /* Spies are unloaded quietly, others aren't */
650 if (!(lchr[(int)land.lnd_type].l_flags & L_SPY))
651 gift(sectp->sct_own, player->cnum, &land, buf);
653 putland(land.lnd_uid, &land);
655 pr("%s %s %s at %s.\n",
657 (load_unload == UNLOAD) ?
658 "unloaded from" : "loaded onto",
659 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
667 load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
668 struct ichrstr *ich, int load_unload, int *nshipsp)
670 i_type item = ich->i_uid;
671 struct mchrstr *mcp = &mchr[(int)sp->shp_type];
672 int ship_amt, sect_amt, move_amt;
677 sprintf(prompt, "Number of %s to %s %s at %s? ",
679 (load_unload == UNLOAD) ?
680 "unload from" : "load onto",
681 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
682 p = getstarg(player->argp[3], prompt, buf);
686 if (!still_ok_ship(sectp, sp))
689 ship_amt = sp->shp_item[item];
690 sect_amt = sectp->sct_item[item];
691 move_amt = move_amount(sect_amt, ship_amt, mcp->m_item[item],
692 load_unload, atoi(p));
693 if (!load_comm_ok(sectp, sp->shp_own, item, move_amt))
695 if (!abandon_askyn(sectp, item, move_amt, NULL))
697 if (!still_ok_ship(sectp, sp))
699 sectp->sct_item[item] = sect_amt - move_amt;
700 sp->shp_item[item] = ship_amt + move_amt;
703 pr("%d %s loaded onto %s at %s\n",
704 move_amt, ich->i_name,
705 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
706 if (sp->shp_own != player->cnum) {
707 wu(0, sp->shp_own, "%s loaded %d %s onto %s at %s\n",
708 cname(player->cnum), move_amt, ich->i_name,
709 prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
712 pr("%d %s unloaded from %s at %s\n",
713 -move_amt, ich->i_name,
714 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
715 if (sectp->sct_own != player->cnum) {
716 wu(0, sectp->sct_own, "%s unloaded %d %s from %s at %s\n",
717 cname(player->cnum), -move_amt, ich->i_name,
718 prship(sp), xyas(sp->shp_x, sp->shp_y, sectp->sct_own));
726 load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
727 int load_unload, int *nunitsp)
735 struct lchrstr *lcp = lchr + lp->lnd_type;
737 if (!lcp->l_nxlight) {
739 pr("%s cannot carry extra-light planes.\n", prland(lp));
742 if (load_unload == LOAD && lnd_nxlight(lp) >= lcp->l_nxlight) {
744 pr("%s doesn't have room for any more extra-light planes\n",
748 sprintf(prompt, "Plane(s) to %s %s? ",
749 load_unload == LOAD ? "load onto" : "unload from", prland(lp));
750 p = getstarg(player->argp[3], prompt, buf);
753 if (!snxtitem(&ni, EF_PLANE, p, NULL))
756 if (!still_ok_land(sectp, lp))
759 if (noisy && p && *p)
762 while (nxtitem(&ni, &pln)) {
766 if (!(plchr[(int)pln.pln_type].pl_flags & P_E)) {
768 pr("You can only load xlight planes onto units.\n");
772 if (load_unload == LOAD && pln.pln_ship > -1) {
774 pr("%s is already on ship #%d!\n",
775 prplane(&pln), pln.pln_ship);
778 if (load_unload == LOAD && pln.pln_land > -1) {
780 pr("%s is already on unit #%d!\n",
781 prplane(&pln), pln.pln_land);
784 if (pln.pln_harden != 0) {
786 pr("%s has been hardened and can't be loaded\n",
791 /* Plane sanity done */
792 /* Find the right unit */
793 if (load_unload == UNLOAD) {
794 if (pln.pln_land != lp->lnd_uid)
796 } else if (lp->lnd_x != pln.pln_x || lp->lnd_y != pln.pln_y)
799 /* Fit plane on unit */
800 if (load_unload == LOAD) {
801 if (!put_plane_on_land(&pln, lp)) {
803 pr("Can't put plane %d on this unit!\n", pln.pln_uid);
806 sprintf(buf, "loaded on %s at %s",
807 prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
808 gift(lp->lnd_own, player->cnum, &pln, buf);
809 putplane(pln.pln_uid, &pln);
812 sprintf(buf, "unloaded at your sector at %s",
813 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
814 gift(sectp->sct_own, player->cnum, &pln, buf);
815 putplane(pln.pln_uid, &pln);
817 pr("%s %s %s at %s.\n",
819 (load_unload == UNLOAD) ?
820 "unloaded from" : "loaded onto",
821 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
829 load_comm_land(struct sctstr *sectp, struct lndstr *lp,
830 struct ichrstr *ich, int load_unload, int *nunitsp)
832 i_type item = ich->i_uid;
833 struct lchrstr *lcp = &lchr[(int)lp->lnd_type];
834 int land_amt, sect_amt, move_amt;
839 sprintf(prompt, "Number of %s to %s %s at %s? ",
841 (load_unload == UNLOAD) ?
842 "unload from" : "load onto",
843 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
844 p = getstarg(player->argp[3], prompt, buf);
848 if (!still_ok_land(sectp, lp))
851 land_amt = lp->lnd_item[item];
852 sect_amt = sectp->sct_item[item];
853 move_amt = move_amount(sect_amt, land_amt, lcp->l_item[item],
854 load_unload, atoi(p));
855 if (!load_comm_ok(sectp, lp->lnd_own, item, move_amt))
857 sectp->sct_item[item] = sect_amt - move_amt;
858 lp->lnd_item[item] = land_amt + move_amt;
860 /* Did we put mils onto this unit? If so, reset the fortification */
861 if (item == I_MILIT && move_amt > 0)
865 pr("%d %s loaded onto %s at %s\n",
866 move_amt, ich->i_name,
867 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
868 if (lp->lnd_own != player->cnum) {
869 wu(0, lp->lnd_own, "%s loaded %d %s onto %s at %s\n",
870 cname(player->cnum), move_amt, ich->i_name,
871 prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
874 pr("%d %s unloaded from %s at %s\n",
875 -move_amt, ich->i_name,
876 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
877 if (sectp->sct_own != player->cnum) {
878 wu(0, sectp->sct_own, "%s unloaded %d %s from %s at %s\n",
879 cname(player->cnum), -move_amt, ich->i_name,
880 prland(lp), xyas(lp->lnd_x, lp->lnd_y, sectp->sct_own));
888 load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
889 int load_unload, int *nunitsp)
898 if (load_unload == LOAD
899 && lnd_nland(lp) >= lchr[lp->lnd_type].l_nland) {
901 if (lchr[lp->lnd_type].l_nland)
902 pr("%s doesn't have room for any more land units!\n",
905 pr("%s cannot carry land units!\n", prland(lp));
909 sprintf(prompt, "Land unit(s) to %s %s? ",
910 load_unload == LOAD ? "load onto" : "unload from", prland(lp));
911 p = getstarg(player->argp[3], prompt, buf);
914 if (!snxtitem(&ni, EF_LAND, p, NULL))
917 if (!still_ok_land(sectp, lp))
920 if (noisy && p && *p)
923 while (nxtitem(&ni, &land)) {
927 if (load_unload == LOAD) {
928 if (land.lnd_ship > -1) {
930 pr("%s is already on ship #%d!\n",
931 prland(&land), land.lnd_ship);
934 if (land.lnd_land > -1) {
936 pr("%s is already on land #%d!\n",
937 prland(&land), land.lnd_land);
940 if (lnd_first_on_land(&land) >= 0) {
942 pr("%s cannot be loaded since it is carrying units\n",
946 if (land.lnd_uid == lp->lnd_uid) {
948 pr("%s can't be loaded onto itself!\n", prland(&land));
951 if (lchr[(int)land.lnd_type].l_flags & (L_HEAVY | L_TRAIN)) {
953 pr("%s is too heavy to load.\n", prland(&land));
958 /* Unit sanity done */
959 /* Find the right ship */
960 if (load_unload == UNLOAD) {
961 if (land.lnd_land != lp->lnd_uid)
963 if (land.lnd_ship > -1)
965 } else if (lp->lnd_x != land.lnd_x || lp->lnd_y != land.lnd_y)
968 /* Fit unit on ship */
969 if (load_unload == LOAD) {
970 if (lnd_nland(lp) >= lchr[lp->lnd_type].l_nland) {
972 if (lchr[lp->lnd_type].l_nland)
973 pr("%s doesn't have room for any more land units!\n",
976 pr("%s cannot carry land units!\n", prland(lp));
980 sprintf(buf, "loaded on your %s at %s",
981 prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
982 gift(lp->lnd_own, player->cnum, &land, buf);
983 land.lnd_land = lp->lnd_uid;
985 putland(land.lnd_uid, &land);
987 /* FIXME same issue as in load_land_ship() */
988 if (!lnd_supply_all(&land))
989 pr("WARNING: %s is out of supply!\n", prland(&land));
991 if (!lnd_in_supply(&land))
992 pr("WARNING: %s is out of supply!\n", prland(&land));
995 sprintf(buf, "unloaded in your %s at %s",
996 dchr[sectp->sct_type].d_name,
997 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
998 gift(sectp->sct_own, player->cnum, &land, buf);
1000 putland(land.lnd_uid, &land);
1002 pr("%s %s %s at %s.\n",
1004 (load_unload == UNLOAD) ?
1005 "unloaded from" : "loaded onto",
1006 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));