2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program 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 2 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, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * load.c: load/unload goods from a sector onto a ship or land unit
30 * Known contributors to this file:
31 * David Sharnoff, 1987
32 * Ken Stevens, 1995 (rewritten)
33 * Steve McClure, 1998-2000
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 if (!(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 if (!(p = getstarg(player->argp[2], "Ship(s): ", buf)) || !*p)
105 if (!snxtitem(&nbst, EF_SHIP, p))
108 load_unload = **player->argp == 'l' ? LOAD : UNLOAD;
111 while (nxtitem(&nbst, &ship)) {
114 if (!player->owner && (load_unload == UNLOAD)) {
118 if (ontradingblock(EF_SHIP, &ship)) {
119 pr("You cannot load/unload an item on the trading block!\n");
124 if (ship.shp_own != player->cnum) {
127 if (getrel(getnatp(player->cnum), ship.shp_own) < FRIENDLY)
130 if (!getsect(ship.shp_x, ship.shp_y, §)) /* XXX */
132 if ((sect.sct_own != player->cnum) &&
133 (ship.shp_own != player->cnum))
135 if (!player->owner &&
136 !sect_has_dock(§))
140 if ((sect.sct_own != player->cnum) && (load_unload == LOAD)) {
142 pr("You don't own %s \n",
143 xyas(ship.shp_x, ship.shp_y, player->cnum));
146 if (!sect_has_dock(§)) {
148 pr("Sector %s is not a harbor or canal.\n",
149 xyas(ship.shp_x, ship.shp_y, player->cnum));
152 if (sect.sct_own != player->cnum && load_unload == UNLOAD
153 && getrel(getnatp(sect.sct_own), player->cnum) < FRIENDLY) {
155 pr("You can't unload into an unfriendly %s\n",
156 dchr[sect.sct_type].d_name);
159 if (sect.sct_effic < 2) {
161 pr("The %s at %s is not 2%% efficient yet.\n",
162 dchr[sect.sct_type].d_name,
163 xyas(ship.shp_x, ship.shp_y, player->cnum));
170 load_plane_ship(§, &ship, noisy, load_unload,
177 load_land_ship(§, &ship, noisy, load_unload,
184 load_comm_ship(§, &ship, ich, load_unload, &nships)))
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 if (!(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 if (!(p = getstarg(player->argp[2], "Unit(s): ", buf)) || !*p)
240 if (!snxtitem(&nbst, EF_LAND, p))
243 load_unload = player->argp[0][1] == 'l' ? LOAD : UNLOAD;
246 while (nxtitem(&nbst, &land)) {
247 if (land.lnd_own == 0)
250 if (player->cnum != land.lnd_own &&
251 getrel(getnatp(player->cnum), land.lnd_own) != ALLIED)
254 if (!getsect(land.lnd_x, land.lnd_y, §)) /* XXX */
257 if (sect.sct_own != player->cnum && land.lnd_own != player->cnum)
260 if (ontradingblock(EF_LAND, &land)) {
261 pr("You cannot load/unload an item on the trading block!\n");
266 if (sect.sct_own != player->cnum &&
267 getrel(getnatp(sect.sct_own), land.lnd_own) != ALLIED) {
268 pr("Sector %s is not yours.\n",
269 xyas(land.lnd_x, land.lnd_y, player->cnum));
276 load_land_land(§, &land, noisy, load_unload,
283 load_plane_land(§, &land, noisy, load_unload,
290 load_comm_land(§, &land, ich, load_unload, &nunits)))
293 /* load/unload plague */
294 if (sect.sct_pstage == PLG_INFECT
295 && land.lnd_pstage == PLG_HEALTHY)
296 land.lnd_pstage = PLG_EXPOSED;
297 if (land.lnd_pstage == PLG_INFECT
298 && sect.sct_pstage == PLG_HEALTHY)
299 sect.sct_pstage = PLG_EXPOSED;
302 putland(land.lnd_uid, &land);
305 pr("No units affected\n");
307 pr("%d unit%s %sloaded\n", nunits, splur(nunits),
308 load_unload == UNLOAD ? "un" : "");
313 gift(natid givee, natid giver, void *ptr, char *mesg)
315 struct empobj *gen = ptr;
318 wu(0, givee, "%s %s %s\n", cname(giver), obj_nameof(gen), mesg);
320 makelost(gen->ef_type, gen->own, gen->uid, gen->x, gen->y);
322 makenotlost(gen->ef_type, gen->own, gen->uid, gen->x, gen->y);
326 still_ok_ship(struct sctstr *sectp, struct shpstr *shipp)
328 if (!check_sect_ok(sectp))
330 if (!check_ship_ok(shipp))
336 still_ok_land(struct sctstr *sectp, struct lndstr *landp)
338 if (!check_sect_ok(sectp))
340 if (!check_land_ok(landp))
346 load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
347 int load_unload, int *nshipsp)
355 struct mchrstr *mcp = mchr + sp->shp_type;
357 if (mcp->m_nplanes + mcp->m_nchoppers + mcp->m_nxlight == 0) {
359 pr("%s cannot carry planes\n", prship(sp));
363 if (load_unload == LOAD &&
364 sp->shp_nchoppers >= mcp->m_nchoppers &&
365 sp->shp_nxlight >= mcp->m_nxlight &&
366 sp->shp_nplane >= mcp->m_nplanes) {
368 pr("%s doesn't have room for any more planes\n", prship(sp));
371 sprintf(prompt, "Plane(s) to %s %s? ",
372 load_unload == LOAD ? "load onto" : "unload from", prship(sp));
373 if (!snxtitem(&ni, EF_PLANE,
374 p = getstarg(player->argp[3], prompt, buf)))
377 if (!still_ok_ship(sectp, sp))
380 if (noisy && p && *p)
383 while (nxtitem(&ni, &pln)) {
384 if (pln.pln_own != player->cnum)
386 if (!(plchr[(int)pln.pln_type].pl_flags & P_L)
387 && !(plchr[(int)pln.pln_type].pl_flags & P_E)
388 && !(plchr[(int)pln.pln_type].pl_flags & P_K)
389 && !(plchr[(int)pln.pln_type].pl_flags & P_M)
392 pr("You can only load light planes, helos, xtra-light, or missiles onto ships.\n");
395 if (load_unload == LOAD && pln.pln_ship > -1) {
397 pr("%s is already on ship #%d!\n",
398 prplane(&pln), pln.pln_ship);
401 if (load_unload == LOAD && pln.pln_land > -1) {
403 pr("%s is already on land unit #%d!\n",
404 prplane(&pln), pln.pln_land);
408 /* Plane sanity done */
409 /* Find the right ship */
410 if (load_unload == UNLOAD) {
411 if (pln.pln_ship != sp->shp_uid)
413 } else if (sp->shp_x != pln.pln_x || sp->shp_y != pln.pln_y)
416 /* ship to (plane or missle) sanity */
417 if (!could_be_on_ship(&pln, sp)) {
418 if (plchr[(int)pln.pln_type].pl_flags & P_L) {
419 strcpy(buf, "planes");
420 } else if (plchr[(int)pln.pln_type].pl_flags & P_K) {
421 strcpy(buf, "choppers");
422 } else if (plchr[(int)pln.pln_type].pl_flags & P_M) {
423 strcpy(buf, "missiles");
424 } else if (plchr[(int)pln.pln_type].pl_flags & P_E) {
425 strcpy(buf, "extra light planes");
426 } /* else impossible */
428 pr("%s cannot carry %s.\n", prship(sp), buf);
431 /* Fit plane on ship */
432 if (load_unload == LOAD) {
433 if (!put_plane_on_ship(&pln, sp)) {
435 pr("Can't put plane %d on this ship!\n", pln.pln_uid);
438 sprintf(buf, "loaded on your %s at %s",
439 prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
440 gift(sp->shp_own, player->cnum, &pln, buf);
442 putplane(pln.pln_uid, &pln);
444 take_plane_off_ship(&pln, sp);
445 sprintf(buf, "unloaded in your %s at %s",
446 dchr[sectp->sct_type].d_name,
447 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
448 gift(sectp->sct_own, player->cnum, &pln, buf);
449 putplane(pln.pln_uid, &pln);
451 pr("%s %s %s at %s.\n",
453 (load_unload == UNLOAD) ?
454 "unloaded from" : "loaded onto",
455 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
463 load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
464 int load_unload, int *nshipsp)
466 struct nstr_item pni, ni;
476 if (load_unload == LOAD) {
478 if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
479 (mchr[(int)sp->shp_type].m_nland == 0)) {
480 if (sp->shp_nland >= 2) {
481 pr("Non-land unit carrying subs can only carry up to two spy units.\n");
484 /* Eh, let 'em load a spy only */
489 (sp->shp_nland >= mchr[(int)sp->shp_type].m_nland)) {
491 if (mchr[(int)sp->shp_type].m_nland)
492 pr("%s doesn't have room for any more land units!\n",
495 pr("%s cannot carry land units!\n", prship(sp));
500 sprintf(prompt, "Land unit(s) to %s %s? ",
501 load_unload == LOAD ? "load onto" : "unload from", prship(sp));
502 if (!snxtitem(&ni, EF_LAND,
503 p = getstarg(player->argp[3], prompt, buf)))
506 if (!still_ok_ship(sectp, sp))
509 if (noisy && p && *p)
512 while (nxtitem(&ni, &land)) {
513 if (land.lnd_own != player->cnum)
516 if (load_unload == LOAD) {
517 if (land.lnd_ship > -1) {
519 pr("%s is already on ship #%d!\n",
520 prland(&land), land.lnd_ship);
523 if (land.lnd_land > -1) {
525 pr("%s is already on land #%d!\n",
526 prland(&land), land.lnd_land);
529 lnd_count_units(&land);
530 if (land.lnd_nland > 0) {
532 pr("%s cannot be loaded since it is carrying units\n",
536 if (lchr[(int)land.lnd_type].l_flags & L_HEAVY) {
538 pr("%s is too heavy to load.\n", prland(&land));
541 if (load_spy && !(lchr[(int)land.lnd_type].l_flags & L_SPY)) {
543 pr("Subs can only carry spy units.\n");
548 /* Unit sanity done */
549 /* Find the right ship */
550 if (load_unload == UNLOAD) {
551 if (land.lnd_ship != sp->shp_uid)
553 if (land.lnd_land > -1)
555 } else if (sp->shp_x != land.lnd_x || sp->shp_y != land.lnd_y)
558 if ((!(lchr[(int)land.lnd_type].l_flags & L_LIGHT)) &&
559 (!((mchr[(int)sp->shp_type].m_flags & M_SUPPLY) &&
560 (!(mchr[(int)sp->shp_type].m_flags & M_SUB))))) {
562 pr("You can only load light units onto ships,\n");
563 pr("unless the ship is a non-sub supply ship\n");
564 pr("%s not loaded\n", prland(&land));
568 /* Fit unit on ship */
569 if (load_unload == LOAD) {
571 /* We have to check again, since it may have changed */
573 if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
574 (mchr[(int)sp->shp_type].m_nland == 0)) {
575 if (sp->shp_nland >= 2) {
576 pr("Non-land unit carrying subs can only carry up to two spy units.\n");
579 /* Eh, let 'em load a spy only */
584 (sp->shp_nland >= mchr[(int)sp->shp_type].m_nland)) {
586 if (mchr[(int)sp->shp_type].m_nland)
587 pr("%s doesn't have room for any more land units!\n",
590 pr("%s cannot carry land units!\n", prship(sp));
594 sprintf(buf, "loaded on your %s at %s",
595 prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
596 gift(sp->shp_own, player->cnum, &land, buf);
597 land.lnd_ship = sp->shp_uid;
599 land.lnd_mission = 0;
602 putland(land.lnd_uid, &land);
603 if (!has_supply(&land))
604 pr("WARNING: %s is out of supply!\n", prland(&land));
605 putship(sp->shp_uid, sp);
606 snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
607 while (nxtitem(&pni, &plane)) {
608 if (plane.pln_flags & PLN_LAUNCHED)
610 if (plane.pln_land != land.lnd_uid)
612 sprintf(buf, "loaded on %s", prship(sp));
613 gift(sp->shp_own, player->cnum, &plane, buf);
614 plane.pln_mission = 0;
615 putplane(plane.pln_uid, &plane);
618 sprintf(buf, "unloaded in your %s at %s",
619 dchr[sectp->sct_type].d_name,
620 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
622 /* Spies are unloaded quietly, others aren't */
623 if (!(lchr[(int)land.lnd_type].l_flags & L_SPY))
624 gift(sectp->sct_own, player->cnum, &land, buf);
627 putland(land.lnd_uid, &land);
628 putship(sp->shp_uid, sp);
630 /* Spies are unloaded quietly, others aren't, and
631 in the off chance they can carry a plane (missile?)
632 they are quietly unloaded too. */
633 if (!(lchr[(int)land.lnd_type].l_flags & L_SPY)) {
634 snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
635 while (nxtitem(&pni, &plane)) {
636 if (plane.pln_flags & PLN_LAUNCHED)
638 if (plane.pln_land != land.lnd_uid)
640 sprintf(buf, "unloaded at %s",
641 xyas(plane.pln_x, plane.pln_y,
643 gift(sectp->sct_own, player->cnum, &plane, buf);
644 plane.pln_mission = 0;
645 putplane(plane.pln_uid, &plane);
649 pr("%s %s %s at %s.\n",
651 (load_unload == UNLOAD) ?
652 "unloaded from" : "loaded onto",
653 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
661 load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
662 struct ichrstr *ich, int load_unload, int *nshipsp)
664 i_type item = ich->i_uid;
665 struct mchrstr *mcp = &mchr[(int)sp->shp_type];
666 int ship_amt, ship_max, sect_amt, move_amt;
672 sprintf(prompt, "Number of %s to %s %s at %s? ",
674 (load_unload == UNLOAD) ?
675 "unload from" : "load onto",
676 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
677 if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
680 if (!still_ok_ship(sectp, sp))
683 ship_amt = sp->shp_item[item];
684 ship_max = mcp->m_item[item];
685 sect_amt = sectp->sct_item[item];
688 move_amt = -amount - ship_amt;
690 move_amt = load_unload == LOAD ? amount : -amount;
691 if (move_amt > ship_max - ship_amt)
692 move_amt = ship_max - ship_amt;
693 if (move_amt < -ship_amt)
694 move_amt = -ship_amt;
695 if (move_amt > sect_amt)
697 if (move_amt < sect_amt - ITEM_MAX)
698 move_amt = sect_amt - ITEM_MAX;
701 if (sectp->sct_oldown != player->cnum && item == I_CIVIL) {
702 pr("%s civilians refuse to %s at %s!\n",
703 move_amt < 0 ? "Your" : "Foreign",
704 move_amt < 0 ? "disembark" : "board",
705 xyas(sectp->sct_x, sectp->sct_y, player->cnum));
709 if (!want_to_abandon(sectp, item, move_amt, 0))
711 if (!still_ok_ship(sectp, sp))
713 sectp->sct_item[item] = sect_amt - move_amt;
714 sp->shp_item[item] = ship_amt + move_amt;
716 pr("%d %s loaded onto %s at %s\n",
717 move_amt, ich->i_name,
718 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
719 if (sp->shp_own != player->cnum) {
720 wu(0, sp->shp_own, "%s loaded %d %s onto %s at %s\n",
721 cname(player->cnum), move_amt, ich->i_name,
722 prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
725 pr("%d %s unloaded from %s at %s\n",
726 -move_amt, ich->i_name,
727 prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
728 if (sectp->sct_own != player->cnum) {
729 wu(0, sectp->sct_own, "%s unloaded %d %s from %s at %s\n",
730 cname(player->cnum), -move_amt, ich->i_name,
731 prship(sp), xyas(sp->shp_x, sp->shp_y, sectp->sct_own));
739 load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
740 int load_unload, int *nunitsp)
749 if (!lp->lnd_maxlight) {
751 pr("%s cannot carry extra-light planes.\n", prland(lp));
754 count_land_planes(lp);
755 if (load_unload == LOAD && lp->lnd_nxlight >= lp->lnd_maxlight) {
757 pr("%s doesn't have room for any more extra-light planes\n",
761 sprintf(prompt, "Plane(s) to %s %s? ",
762 load_unload == LOAD ? "load onto" : "unload from", prland(lp));
763 if (!snxtitem(&ni, EF_PLANE,
764 p = getstarg(player->argp[3], prompt, buf)))
767 if (!still_ok_land(sectp, lp))
770 if (noisy && p && *p)
773 if (sectp->sct_own != player->cnum && load_unload == LOAD) {
774 pr("Sector %s is not yours.\n",
775 xyas(lp->lnd_x, lp->lnd_y, player->cnum));
779 while (nxtitem(&ni, &pln)) {
780 if (pln.pln_own != player->cnum)
783 if (!(plchr[(int)pln.pln_type].pl_flags & P_E)) {
785 pr("You can only load xlight planes onto units.\n");
789 if (load_unload == LOAD && pln.pln_ship > -1) {
791 pr("%s is already on ship #%d!\n",
792 prplane(&pln), pln.pln_ship);
795 if (load_unload == LOAD && pln.pln_land > -1) {
797 pr("%s is already on unit #%d!\n",
798 prplane(&pln), pln.pln_land);
801 /* Plane sanity done */
802 /* Find the right unit */
803 if (load_unload == UNLOAD) {
804 if (pln.pln_land != lp->lnd_uid)
806 } else if (lp->lnd_x != pln.pln_x || lp->lnd_y != pln.pln_y)
809 /* Fit plane on unit */
810 if (load_unload == LOAD) {
811 if (!put_plane_on_land(&pln, lp)) {
813 pr("Can't put plane %d on this unit!\n", pln.pln_uid);
816 sprintf(buf, "loaded on %s at %s",
817 prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
818 gift(lp->lnd_own, player->cnum, &pln, buf);
819 putplane(pln.pln_uid, &pln);
821 take_plane_off_land(&pln, lp);
822 sprintf(buf, "unloaded at your sector at %s",
823 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
824 gift(sectp->sct_own, player->cnum, &pln, buf);
825 putplane(pln.pln_uid, &pln);
827 pr("%s %s %s at %s.\n",
829 (load_unload == UNLOAD) ?
830 "unloaded from" : "loaded onto",
831 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
839 load_comm_land(struct sctstr *sectp, struct lndstr *lp,
840 struct ichrstr *ich, int load_unload, int *nunitsp)
842 i_type item = ich->i_uid;
843 struct lchrstr *lcp = &lchr[(int)lp->lnd_type];
844 int land_amt, land_max, 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 if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
858 if (!still_ok_land(sectp, lp))
861 land_amt = lp->lnd_item[item];
862 land_max = lcp->l_item[item];
863 sect_amt = sectp->sct_item[item];
866 move_amt = -amount - land_amt;
868 move_amt = load_unload == LOAD ? amount : -amount;
869 if (move_amt > land_max - land_amt)
870 move_amt = land_max - land_amt;
871 if (move_amt < -land_amt)
872 move_amt = -land_amt;
873 if (move_amt > sect_amt)
875 if (move_amt < sect_amt - ITEM_MAX)
876 move_amt = sect_amt - ITEM_MAX;
879 if (sectp->sct_own != player->cnum && move_amt > 0) {
880 pr("Sector %s is not yours.\n",
881 xyas(lp->lnd_x, lp->lnd_y, player->cnum));
884 if (sectp->sct_oldown != player->cnum && item == I_CIVIL) {
885 pr("%s civilians refuse to %s at %s!\n",
886 move_amt < 0 ? "Your" : "Foreign",
887 move_amt < 0 ? "disembark" : "board",
888 xyas(sectp->sct_x, sectp->sct_y, player->cnum));
891 sectp->sct_item[item] = sect_amt - move_amt;
892 lp->lnd_item[item] = land_amt + move_amt;
894 /* Did we put mils onto this unit? If so, reset the fortification */
895 if (item == I_MILIT && move_amt > 0)
898 pr("%d %s loaded onto %s at %s\n",
899 move_amt, ich->i_name,
900 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
901 if (lp->lnd_own != player->cnum) {
902 wu(0, lp->lnd_own, "%s loaded %d %s onto %s at %s\n",
903 cname(player->cnum), move_amt, ich->i_name,
904 prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
907 pr("%d %s unloaded from %s at %s\n",
908 -move_amt, ich->i_name,
909 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
910 if (sectp->sct_own != player->cnum) {
911 wu(0, sectp->sct_own, "%s unloaded %d %s from %s at %s\n",
912 cname(player->cnum), -move_amt, ich->i_name,
913 prland(lp), xyas(lp->lnd_x, lp->lnd_y, sectp->sct_own));
921 load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
922 int load_unload, int *nunitsp)
924 struct nstr_item pni, ni;
934 if (load_unload == LOAD && lp->lnd_nland >= lp->lnd_maxland) {
937 pr("%s doesn't have room for any more land units!\n",
940 pr("%s cannot carry land units!\n", prland(lp));
944 sprintf(prompt, "Land unit(s) to %s %s? ",
945 load_unload == LOAD ? "load onto" : "unload from", prland(lp));
946 if (!snxtitem(&ni, EF_LAND,
947 p = getstarg(player->argp[3], prompt, buf)))
950 if (!still_ok_land(sectp, lp))
953 if (noisy && p && *p)
956 while (nxtitem(&ni, &land)) {
958 if (land.lnd_own != player->cnum)
961 if (load_unload == LOAD) {
962 if (land.lnd_ship > -1) {
964 pr("%s is already on ship #%d!\n",
965 prland(&land), land.lnd_ship);
968 if (land.lnd_land > -1) {
970 pr("%s is already on land #%d!\n",
971 prland(&land), land.lnd_land);
974 lnd_count_units(&land);
975 if (land.lnd_nland > 0) {
977 pr("%s cannot be loaded since it is carrying units\n",
981 if (land.lnd_uid == lp->lnd_uid) {
983 pr("%s can't be loaded onto itself!\n", prland(&land));
986 if (lchr[(int)land.lnd_type].l_flags & L_HEAVY) {
988 pr("%s is too heavy to load.\n", prland(&land));
993 /* Unit sanity done */
994 /* Find the right ship */
995 if (load_unload == UNLOAD) {
996 if (land.lnd_land != lp->lnd_uid)
998 if (land.lnd_ship > -1)
1000 } else if (lp->lnd_x != land.lnd_x || lp->lnd_y != land.lnd_y)
1003 /* Fit unit on ship */
1004 if (load_unload == LOAD) {
1005 lnd_count_units(lp);
1006 if (lp->lnd_nland >= lp->lnd_maxland) {
1009 pr("%s doesn't have room for any more land units!\n",
1012 pr("%s cannot carry land units!\n", prland(lp));
1016 sprintf(buf, "loaded on your %s at %s",
1017 prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
1018 gift(lp->lnd_own, player->cnum, &land, buf);
1019 land.lnd_land = lp->lnd_uid;
1020 land.lnd_harden = 0;
1021 land.lnd_mission = 0;
1022 resupply_all(&land);
1024 putland(land.lnd_uid, &land);
1025 if (!has_supply(&land))
1026 pr("WARNING: %s is out of supply!\n", prland(&land));
1027 putland(lp->lnd_uid, lp);
1028 snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
1029 while (nxtitem(&pni, &plane)) {
1030 if (plane.pln_flags & PLN_LAUNCHED)
1032 if (plane.pln_land != land.lnd_uid)
1034 sprintf(buf, "loaded on %s", prland(lp));
1035 gift(lp->lnd_own, player->cnum, &plane, buf);
1036 plane.pln_mission = 0;
1037 putplane(plane.pln_uid, &plane);
1040 sprintf(buf, "unloaded in your %s at %s",
1041 dchr[sectp->sct_type].d_name,
1042 xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
1043 gift(sectp->sct_own, player->cnum, &land, buf);
1046 putland(land.lnd_uid, &land);
1047 putland(lp->lnd_uid, lp);
1048 snxtitem_xy(&pni, EF_PLANE, land.lnd_x, land.lnd_y);
1049 while (nxtitem(&pni, &plane)) {
1050 if (plane.pln_flags & PLN_LAUNCHED)
1052 if (plane.pln_land != land.lnd_uid)
1054 sprintf(buf, "unloaded at %s",
1055 xyas(plane.pln_x, plane.pln_y, sectp->sct_own));
1056 gift(sectp->sct_own, player->cnum, &plane, buf);
1057 plane.pln_mission = 0;
1058 putplane(plane.pln_uid, &plane);
1061 pr("%s %s %s at %s.\n",
1063 (load_unload == UNLOAD) ?
1064 "unloaded from" : "loaded onto",
1065 prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));