2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2012, 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
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 if (move_amt > unit_max - unit_amt)
330 move_amt = unit_max - unit_amt;
331 if (move_amt < -unit_amt)
332 move_amt = -unit_amt;
333 if (move_amt > sect_amt)
335 if (move_amt < sect_amt - ITEM_MAX)
336 move_amt = sect_amt - ITEM_MAX;
341 load_comm_ok(struct sctstr *sectp, natid unit_own,
342 i_type item, int move_amt)
346 if (move_amt < 0 && !player->god && unit_own != player->cnum)
348 if (move_amt > 0 && !player->god && sectp->sct_own != player->cnum)
350 if (sectp->sct_oldown != unit_own && item == I_CIVIL) {
351 pr("%s civilians refuse to %s at %s!\n",
352 (move_amt < 0 ? unit_own : sectp->sct_oldown) == player->cnum
353 ? "Your" : "Foreign",
354 move_amt < 0 ? "disembark" : "board",
355 xyas(sectp->sct_x, sectp->sct_y, player->cnum));
362 gift(natid givee, natid giver, void *ptr, char *mesg)
365 wu(0, givee, "%s %s %s\n", cname(giver), unit_nameof(ptr), mesg);
366 unit_give_away(ptr, givee, 0);
370 still_ok_ship(struct sctstr *sectp, struct shpstr *shipp)
372 if (!check_sect_ok(sectp))
374 if (!check_ship_ok(shipp))
380 still_ok_land(struct sctstr *sectp, struct lndstr *landp)
382 if (!check_sect_ok(sectp))
384 if (!check_land_ok(landp))
390 load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
391 int load_unload, int *nshipsp)
399 struct mchrstr *mcp = mchr + sp->shp_type;
401 if (mcp->m_nplanes + mcp->m_nchoppers + mcp->m_nxlight == 0) {
403 pr("%s cannot carry planes\n", prship(sp));
406 if (load_unload == LOAD &&
407 shp_nplane(sp, NULL, NULL, NULL)
408 >= mcp->m_nchoppers + mcp->m_nxlight + mcp->m_nplanes) {
410 pr("%s doesn't have room for any more planes\n", prship(sp));
413 sprintf(prompt, "Plane(s) to %s %s? ",
414 load_unload == LOAD ? "load onto" : "unload from", prship(sp));
415 p = getstarg(player->argp[3], prompt, buf);
418 if (!snxtitem(&ni, EF_PLANE, p, NULL))
421 if (!still_ok_ship(sectp, sp))
424 if (noisy && p && *p)
427 while (nxtitem(&ni, &pln)) {
430 if (!(plchr[(int)pln.pln_type].pl_flags & P_L)
431 && !(plchr[(int)pln.pln_type].pl_flags & P_E)
432 && !(plchr[(int)pln.pln_type].pl_flags & P_K)
433 && !(plchr[(int)pln.pln_type].pl_flags & P_M)
436 pr("You can only load light planes, helos, xtra-light, or missiles onto ships.\n");
439 if (load_unload == LOAD && pln.pln_ship > -1) {
441 pr("%s is already on ship #%d!\n",
442 prplane(&pln), pln.pln_ship);
445 if (load_unload == LOAD && pln.pln_land > -1) {
447 pr("%s is already on land unit #%d!\n",
448 prplane(&pln), pln.pln_land);
451 if (pln.pln_harden != 0) {
453 pr("%s has been hardened and can't be loaded\n",
458 if (load_unload == UNLOAD) {
459 if (pln.pln_ship != sp->shp_uid)
461 } else if (sp->shp_x != pln.pln_x || sp->shp_y != pln.pln_y)
464 if (!could_be_on_ship(&pln, sp, 0, 0, 0, 0)) {
466 if (plchr[(int)pln.pln_type].pl_flags & P_K)
468 else if (plchr[(int)pln.pln_type].pl_flags & P_E)
469 p = "extra light planes";
470 else if (plchr[(int)pln.pln_type].pl_flags & P_M)
474 pr("%s cannot carry %s.\n", prship(sp), p);
478 /* Fit plane on ship */
479 if (load_unload == LOAD) {
480 if (!put_plane_on_ship(&pln, sp)) {
482 pr("Can't put plane %d on this ship!\n", pln.pln_uid);
485 sprintf(buf, "loaded on your %s at %s",
486 prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
487 gift(sp->shp_own, player->cnum, &pln, buf);
488 putplane(pln.pln_uid, &pln);
491 sprintf(buf, "unloaded in your %s at %s",
492 dchr[sectp->sct_type].d_name,
493 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
494 gift(sectp->sct_own, player->cnum, &pln, buf);
495 putplane(pln.pln_uid, &pln);
497 pr("%s %s %s at %s.\n",
499 (load_unload == UNLOAD) ?
500 "unloaded from" : "loaded onto",
501 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
509 load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
510 int load_unload, int *nshipsp)
520 if (load_unload == LOAD) {
521 if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
522 (mchr[(int)sp->shp_type].m_nland == 0)) {
523 if (shp_nland(sp) >= 2) {
524 pr("Non-land unit carrying subs can only carry up to two spy units.\n");
527 /* Eh, let 'em load a spy only */
530 if (!load_spy && shp_nland(sp) >= mchr[sp->shp_type].m_nland) {
532 if (mchr[(int)sp->shp_type].m_nland)
533 pr("%s doesn't have room for any more land units!\n",
536 pr("%s cannot carry land units!\n", prship(sp));
541 sprintf(prompt, "Land unit(s) to %s %s? ",
542 load_unload == LOAD ? "load onto" : "unload from", prship(sp));
543 p = getstarg(player->argp[3], prompt, buf);
546 if (!snxtitem(&ni, EF_LAND, p, NULL))
549 if (!still_ok_ship(sectp, sp))
552 if (noisy && p && *p)
555 while (nxtitem(&ni, &land)) {
559 if (load_unload == LOAD) {
560 if (land.lnd_ship > -1) {
562 pr("%s is already on ship #%d!\n",
563 prland(&land), land.lnd_ship);
566 if (land.lnd_land > -1) {
568 pr("%s is already on land #%d!\n",
569 prland(&land), land.lnd_land);
572 if (lnd_first_on_land(&land) >= 0) {
574 pr("%s cannot be loaded since it is carrying units\n",
578 if (lchr[(int)land.lnd_type].l_flags & L_HEAVY) {
580 pr("%s is too heavy to load.\n", prland(&land));
583 if (load_spy && !(lchr[(int)land.lnd_type].l_flags & L_SPY)) {
585 pr("Subs can only carry spy units.\n");
590 /* Unit sanity done */
591 /* Find the right ship */
592 if (load_unload == UNLOAD) {
593 if (land.lnd_ship != sp->shp_uid)
595 if (land.lnd_land > -1)
597 } else if (sp->shp_x != land.lnd_x || sp->shp_y != land.lnd_y)
600 if ((!(lchr[(int)land.lnd_type].l_flags & L_LIGHT)) &&
601 (!((mchr[(int)sp->shp_type].m_flags & M_SUPPLY) &&
602 (!(mchr[(int)sp->shp_type].m_flags & M_SUB))))) {
604 pr("You can only load light units onto ships,\n");
605 pr("unless the ship is a non-sub supply ship\n");
606 pr("%s not loaded\n", prland(&land));
610 /* Fit unit on ship */
611 if (load_unload == LOAD) {
612 /* We have to check again, since it may have changed */
613 if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
614 (mchr[(int)sp->shp_type].m_nland == 0)) {
615 if (shp_nland(sp) >= 2) {
616 pr("Non-land unit carrying subs can only carry up to two spy units.\n");
619 /* Eh, let 'em load a spy only */
622 if (!load_spy && shp_nland(sp) >= mchr[sp->shp_type].m_nland) {
624 if (mchr[(int)sp->shp_type].m_nland)
625 pr("%s doesn't have room for any more land units!\n",
628 pr("%s cannot carry land units!\n", prship(sp));
632 sprintf(buf, "loaded on your %s at %s",
633 prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
634 gift(sp->shp_own, player->cnum, &land, buf);
635 land.lnd_ship = sp->shp_uid;
637 putland(land.lnd_uid, &land);
640 * FIXME if this supplies from the sector, the putsect in
641 * load() / lload() duplicates those supplies, causing a
644 if (!lnd_supply_all(&land))
645 pr("WARNING: %s is out of supply!\n", prland(&land));
647 if (!lnd_in_supply(&land))
648 pr("WARNING: %s is out of supply!\n", prland(&land));
651 sprintf(buf, "unloaded in your %s at %s",
652 dchr[sectp->sct_type].d_name,
653 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
655 /* Spies are unloaded quietly, others aren't */
656 if (!(lchr[(int)land.lnd_type].l_flags & L_SPY))
657 gift(sectp->sct_own, player->cnum, &land, buf);
659 putland(land.lnd_uid, &land);
661 pr("%s %s %s at %s.\n",
663 (load_unload == UNLOAD) ?
664 "unloaded from" : "loaded onto",
665 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
673 load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
674 struct ichrstr *ich, int load_unload, int *nshipsp)
676 i_type item = ich->i_uid;
677 struct mchrstr *mcp = &mchr[(int)sp->shp_type];
678 int ship_amt, sect_amt, move_amt;
683 sprintf(prompt, "Number of %s to %s %s at %s? ",
685 (load_unload == UNLOAD) ?
686 "unload from" : "load onto",
687 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
688 p = getstarg(player->argp[3], prompt, buf);
692 if (!still_ok_ship(sectp, sp))
695 ship_amt = sp->shp_item[item];
696 sect_amt = sectp->sct_item[item];
697 move_amt = move_amount(sect_amt, ship_amt, mcp->m_item[item],
698 load_unload, atoi(p));
699 if (!load_comm_ok(sectp, sp->shp_own, item, move_amt))
701 if (!want_to_abandon(sectp, item, move_amt, NULL))
703 if (!still_ok_ship(sectp, sp))
705 sectp->sct_item[item] = sect_amt - move_amt;
706 sp->shp_item[item] = ship_amt + move_amt;
709 pr("%d %s loaded onto %s at %s\n",
710 move_amt, ich->i_name,
711 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
712 if (sp->shp_own != player->cnum) {
713 wu(0, sp->shp_own, "%s loaded %d %s onto %s at %s\n",
714 cname(player->cnum), move_amt, ich->i_name,
715 prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
718 pr("%d %s unloaded from %s at %s\n",
719 -move_amt, ich->i_name,
720 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
721 if (sectp->sct_own != player->cnum) {
722 wu(0, sectp->sct_own, "%s unloaded %d %s from %s at %s\n",
723 cname(player->cnum), -move_amt, ich->i_name,
724 prship(sp), xyas(sp->shp_x, sp->shp_y, sectp->sct_own));
732 load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
733 int load_unload, int *nunitsp)
741 struct lchrstr *lcp = lchr + lp->lnd_type;
743 if (!lcp->l_nxlight) {
745 pr("%s cannot carry extra-light planes.\n", prland(lp));
748 if (load_unload == LOAD && lnd_nxlight(lp) >= lcp->l_nxlight) {
750 pr("%s doesn't have room for any more extra-light planes\n",
754 sprintf(prompt, "Plane(s) to %s %s? ",
755 load_unload == LOAD ? "load onto" : "unload from", prland(lp));
756 p = getstarg(player->argp[3], prompt, buf);
759 if (!snxtitem(&ni, EF_PLANE, p, NULL))
762 if (!still_ok_land(sectp, lp))
765 if (noisy && p && *p)
768 while (nxtitem(&ni, &pln)) {
772 if (!(plchr[(int)pln.pln_type].pl_flags & P_E)) {
774 pr("You can only load xlight planes onto units.\n");
778 if (load_unload == LOAD && pln.pln_ship > -1) {
780 pr("%s is already on ship #%d!\n",
781 prplane(&pln), pln.pln_ship);
784 if (load_unload == LOAD && pln.pln_land > -1) {
786 pr("%s is already on unit #%d!\n",
787 prplane(&pln), pln.pln_land);
790 if (pln.pln_harden != 0) {
792 pr("%s has been hardened and can't be loaded\n",
797 /* Plane sanity done */
798 /* Find the right unit */
799 if (load_unload == UNLOAD) {
800 if (pln.pln_land != lp->lnd_uid)
802 } else if (lp->lnd_x != pln.pln_x || lp->lnd_y != pln.pln_y)
805 /* Fit plane on unit */
806 if (load_unload == LOAD) {
807 if (!put_plane_on_land(&pln, lp)) {
809 pr("Can't put plane %d on this unit!\n", pln.pln_uid);
812 sprintf(buf, "loaded on %s at %s",
813 prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
814 gift(lp->lnd_own, player->cnum, &pln, buf);
815 putplane(pln.pln_uid, &pln);
818 sprintf(buf, "unloaded at your sector at %s",
819 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
820 gift(sectp->sct_own, player->cnum, &pln, buf);
821 putplane(pln.pln_uid, &pln);
823 pr("%s %s %s at %s.\n",
825 (load_unload == UNLOAD) ?
826 "unloaded from" : "loaded onto",
827 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
835 load_comm_land(struct sctstr *sectp, struct lndstr *lp,
836 struct ichrstr *ich, int load_unload, int *nunitsp)
838 i_type item = ich->i_uid;
839 struct lchrstr *lcp = &lchr[(int)lp->lnd_type];
840 int land_amt, sect_amt, move_amt;
845 sprintf(prompt, "Number of %s to %s %s at %s? ",
847 (load_unload == UNLOAD) ?
848 "unload from" : "load onto",
849 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
850 p = getstarg(player->argp[3], prompt, buf);
854 if (!still_ok_land(sectp, lp))
857 land_amt = lp->lnd_item[item];
858 sect_amt = sectp->sct_item[item];
859 move_amt = move_amount(sect_amt, land_amt, lcp->l_item[item],
860 load_unload, atoi(p));
861 if (!load_comm_ok(sectp, lp->lnd_own, item, move_amt))
863 sectp->sct_item[item] = sect_amt - move_amt;
864 lp->lnd_item[item] = land_amt + move_amt;
866 /* Did we put mils onto this unit? If so, reset the fortification */
867 if (item == I_MILIT && move_amt > 0)
871 pr("%d %s loaded onto %s at %s\n",
872 move_amt, ich->i_name,
873 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
874 if (lp->lnd_own != player->cnum) {
875 wu(0, lp->lnd_own, "%s loaded %d %s onto %s at %s\n",
876 cname(player->cnum), move_amt, ich->i_name,
877 prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
880 pr("%d %s unloaded from %s at %s\n",
881 -move_amt, ich->i_name,
882 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
883 if (sectp->sct_own != player->cnum) {
884 wu(0, sectp->sct_own, "%s unloaded %d %s from %s at %s\n",
885 cname(player->cnum), -move_amt, ich->i_name,
886 prland(lp), xyas(lp->lnd_x, lp->lnd_y, sectp->sct_own));
894 load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
895 int load_unload, int *nunitsp)
904 if (load_unload == LOAD
905 && lnd_nland(lp) >= lchr[lp->lnd_type].l_nland) {
907 if (lchr[lp->lnd_type].l_nland)
908 pr("%s doesn't have room for any more land units!\n",
911 pr("%s cannot carry land units!\n", prland(lp));
915 sprintf(prompt, "Land unit(s) to %s %s? ",
916 load_unload == LOAD ? "load onto" : "unload from", prland(lp));
917 p = getstarg(player->argp[3], prompt, buf);
920 if (!snxtitem(&ni, EF_LAND, p, NULL))
923 if (!still_ok_land(sectp, lp))
926 if (noisy && p && *p)
929 while (nxtitem(&ni, &land)) {
933 if (load_unload == LOAD) {
934 if (land.lnd_ship > -1) {
936 pr("%s is already on ship #%d!\n",
937 prland(&land), land.lnd_ship);
940 if (land.lnd_land > -1) {
942 pr("%s is already on land #%d!\n",
943 prland(&land), land.lnd_land);
946 if (lnd_first_on_land(&land) >= 0) {
948 pr("%s cannot be loaded since it is carrying units\n",
952 if (land.lnd_uid == lp->lnd_uid) {
954 pr("%s can't be loaded onto itself!\n", prland(&land));
957 if (lchr[(int)land.lnd_type].l_flags & (L_HEAVY | L_TRAIN)) {
959 pr("%s is too heavy to load.\n", prland(&land));
964 /* Unit sanity done */
965 /* Find the right ship */
966 if (load_unload == UNLOAD) {
967 if (land.lnd_land != lp->lnd_uid)
969 if (land.lnd_ship > -1)
971 } else if (lp->lnd_x != land.lnd_x || lp->lnd_y != land.lnd_y)
974 /* Fit unit on ship */
975 if (load_unload == LOAD) {
976 if (lnd_nland(lp) >= lchr[lp->lnd_type].l_nland) {
978 if (lchr[lp->lnd_type].l_nland)
979 pr("%s doesn't have room for any more land units!\n",
982 pr("%s cannot carry land units!\n", prland(lp));
986 sprintf(buf, "loaded on your %s at %s",
987 prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
988 gift(lp->lnd_own, player->cnum, &land, buf);
989 land.lnd_land = lp->lnd_uid;
991 putland(land.lnd_uid, &land);
993 /* FIXME same issue as in load_land_ship() */
994 if (!lnd_supply_all(&land))
995 pr("WARNING: %s is out of supply!\n", prland(&land));
997 if (!lnd_in_supply(&land))
998 pr("WARNING: %s is out of supply!\n", prland(&land));
1001 sprintf(buf, "unloaded in your %s at %s",
1002 dchr[sectp->sct_type].d_name,
1003 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
1004 gift(sectp->sct_own, player->cnum, &land, buf);
1006 putland(land.lnd_uid, &land);
1008 pr("%s %s %s at %s.\n",
1010 (load_unload == UNLOAD) ?
1011 "unloaded from" : "loaded onto",
1012 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));