]> git.pond.sub.org Git - empserver/blob - src/lib/commands/load.c
Import of Empire 4.2.12
[empserver] / src / lib / commands / load.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                           Ken Stevens, Steve McClure
5  *
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.
10  *
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.
15  *
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
19  *
20  *  ---
21  *
22  *  See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23  *  related information and legal notices. It is expected that any future
24  *  projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  load.c: load/unload goods from a sector onto a ship or land unit
29  * 
30  *  Known contributors to this file:
31  *     David Sharnoff, 1987
32  *     Ken Stevens, 1995 (rewritten)
33  *     Steve McClure, 1998-2000
34  */
35
36 #ifdef Rel4
37 #include <string.h>
38 #endif /* Rel4 */
39 #include "misc.h"
40 #include "player.h"
41 #include "xy.h"
42 #include "file.h"
43 #include "var.h"
44 #include "sect.h"
45 #include "ship.h"
46 #include "plane.h"      
47 #include "land.h"       
48 #include "item.h"
49 #include "nsc.h"
50 #include "nat.h"
51 #include "optlist.h"
52 #include "commands.h"
53
54 /*
55  * The values 1 and -1 are important below, don't change them.
56  */
57 #define LOAD    1
58 #define UNLOAD  -1
59
60 void gift(int givee, int giver, s_char *ptr, int type, s_char *mesg);
61 static int load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy, int load_unload, int *nshipsp);
62 static int load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy, int load_unload, int *nshipsp);
63 static int load_comm_ship(struct sctstr *sectp, struct shpstr *sp, struct ichrstr *ich, int load_unload, int *nshipsp);
64 static int load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy, int load_unload, int *nunitsp);
65 static int load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy, int load_unload, int *nunitsp);
66 static int load_comm_land(struct sctstr *sectp, struct lndstr *lp, struct ichrstr *ich, int load_unload, int *nunitsp);
67
68 int
69 load(void)
70 {
71         int     noisy;
72         int     load_unload;
73         int     type;
74         struct  nstr_item nbst;
75         struct  ichrstr *ich;
76         int     nships;
77         struct  sctstr sect;
78         struct  shpstr ship;
79         int     retval;
80         s_char  *p;
81         s_char  buf[1024];
82
83         if (!(p = getstarg(player->argp[1],
84                 "What commodity (or 'plane' or 'land')? ", buf)) || !*p)
85                 return RET_SYN;
86         
87         if (!strncmp(p, "plane", 5))
88                 type = EF_PLANE;
89         else if (!strncmp(p, "land", 4))
90                 type = EF_LAND;
91         else if (NULL != (ich = whatitem(p, (s_char *)0)))
92                 type = EF_SECTOR;
93         else {
94                 pr("Bad commodity.\n");
95                 return RET_SYN;
96         }
97
98         if (!(p = getstarg(player->argp[2], "Ship(s): ", buf)) || !*p)
99                 return RET_SYN;
100
101         noisy = isdigit(*p);
102
103         if (!snxtitem(&nbst, EF_SHIP, p))
104                 return RET_SYN;
105
106         nbst.flags &= ~(EFF_OWNER);
107
108         load_unload = **player->argp == 'l' ? LOAD : UNLOAD;
109
110         nships = 0;
111         while (nxtitem(&nbst, (s_char *)&ship)) {
112                 if (!ship.shp_own)
113                         continue;
114                 if (!player->owner && (load_unload == UNLOAD)) {
115                         continue;
116                 }
117                 if (opt_MARKET) {
118                     if (ontradingblock(EF_SHIP, (int *)&ship)) {
119                         pr("You cannot load/unload an item on the trading block!\n");
120                         continue;
121                     }
122                 }
123
124                 if (ship.shp_own != player->cnum) {
125                         if (!noisy)
126                                 continue;
127                         if (getrel(getnatp(player->cnum),ship.shp_own) < FRIENDLY)
128                                 continue;
129                 }
130                 if (!getsect(ship.shp_x, ship.shp_y, &sect)) /* XXX */
131                         continue;
132                 if ((sect.sct_own != player->cnum) &&
133                     (ship.shp_own != player->cnum))
134                         continue;
135                 if (!player->owner &&
136                     sect.sct_type != SCT_HARBR &&
137                     (!opt_BIG_CITY || sect.sct_type != SCT_CAPIT))
138                         continue;
139                 if (!sect.sct_own)
140                         continue;
141                 if ((sect.sct_own != player->cnum) && (load_unload == LOAD)) {
142                         if (noisy)
143                         pr("You don't own %s \n",
144                                 xyas(ship.shp_x, ship.shp_y, player->cnum));
145                         continue;
146                 }
147                 if (sect.sct_type != SCT_HARBR &&
148                     (!opt_BIG_CITY || sect.sct_type != SCT_CAPIT)) {
149                         if (noisy)
150                         pr("Sector %s is not a harbor%s.\n",
151                            xyas(ship.shp_x, ship.shp_y, player->cnum),
152                            opt_BIG_CITY?" or a city":"");
153                         continue;
154                 }
155                 if (sect.sct_own != player->cnum && load_unload == UNLOAD && getrel(getnatp(sect.sct_own), player->cnum) < FRIENDLY) {
156                         if (noisy)
157                         pr("You can't unload into an unfriendly %s\n",
158                            dchr[sect.sct_type].d_name);
159                         continue;
160                 }
161                 if (sect.sct_effic < 2) {
162                         if (noisy)
163                         pr("The %s at %s is not 2%% efficient yet.\n",
164                            dchr[sect.sct_type].d_name,
165                            xyas(ship.shp_x, ship.shp_y, player->cnum));
166                         continue;
167                 }
168                 switch (type) {
169                 case EF_PLANE:
170                         if (0 != (retval=load_plane_ship(&sect, &ship, noisy, load_unload, &nships)))
171                                 return retval;
172                         break;
173                 case EF_LAND:
174                         if (0 != (retval=load_land_ship(&sect, &ship, noisy, load_unload, &nships)))
175                                 return retval;
176                         break;
177                 case EF_SECTOR:
178                         if (0 != (retval=load_comm_ship(&sect, &ship, ich, load_unload, &nships)))
179                                 return retval;
180                 }
181                 /* load/unload plague */
182                 if (getvar(V_PSTAGE, (s_char *)&sect, EF_SECTOR) == PLG_INFECT &&
183                     getvar(V_PSTAGE, (s_char *)&ship, EF_SHIP) == PLG_HEALTHY)
184                         putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&ship, EF_SHIP);
185                 if (getvar(V_PSTAGE, (s_char *)&ship, EF_SHIP) == PLG_INFECT &&
186                     getvar(V_PSTAGE, (s_char *)&sect, EF_SECTOR) == PLG_HEALTHY)
187                         putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&sect, EF_SECTOR);
188                 putsect(&sect);
189                 putship(ship.shp_uid, &ship);
190         }
191         if (!nships)
192                 pr("No ships affected\n");
193         else
194                 pr("%d ship%s %sloaded\n", nships, splur(nships),
195                         load_unload == UNLOAD ? "un" : "");
196         return RET_OK;
197 }
198
199 int
200 lload(void)
201 {
202         int     noisy;
203         int     load_unload;
204         int     type;
205         struct  nstr_item nbst;
206         struct  ichrstr *ich;
207         int     nunits;
208         struct  sctstr sect;
209         struct  lndstr land;
210         int     retval;
211         s_char  *p;
212         s_char  buf[1024];
213
214         if (!(p = getstarg(player->argp[1],
215                    "What commodity (or 'plane' or 'land')? ", buf)) || !*p)
216                 return RET_SYN;
217         if (!strncmp(p, "plane", 5))
218                 type = EF_PLANE;
219         else if (!strncmp(p, "land", 4))
220                 type = EF_LAND;
221         else if (NULL != (ich = whatitem(p, (s_char *)0)))
222                 type = EF_SECTOR;
223         else {
224                 pr("Bad commodity.\n");
225                 return RET_SYN;
226         }
227
228         if (!(p = getstarg(player->argp[2], "Unit(s): ", buf)) || !*p)
229                 return RET_SYN;
230
231         noisy = isdigit(*p);
232
233         if (!snxtitem(&nbst, EF_LAND, p))
234                 return RET_SYN;
235
236         load_unload = *(*player->argp+1) == 'l' ? LOAD : UNLOAD;
237
238         nbst.flags &= ~(EFF_OWNER);
239
240         nunits = 0;
241         while (nxtitem(&nbst, (s_char *)&land)) {
242                 if (land.lnd_own == 0)
243                         continue;
244
245                 if (player->cnum != land.lnd_own &&
246                     getrel(getnatp(player->cnum), land.lnd_own) != ALLIED)
247                         continue;
248
249                 if (!getsect(land.lnd_x, land.lnd_y, &sect)) /* XXX */
250                         continue;
251
252                 if (sect.sct_own != player->cnum &&
253                     land.lnd_own != player->cnum)
254                         continue;
255                 if (opt_MARKET) {
256                     if (ontradingblock(EF_LAND, (int *)&land)) {
257                         pr("You cannot load/unload an item on the trading block!\n");
258                         continue;
259                     }
260                 }
261
262                 if (sect.sct_own != player->cnum &&
263                     getrel(getnatp(sect.sct_own), land.lnd_own) != ALLIED) {
264                         pr("Sector %s is not yours.\n",
265                                 xyas(land.lnd_x, land.lnd_y, player->cnum));
266                         continue;
267                 }
268                 switch (type) {
269                 case EF_LAND:
270                         if (0 != (retval=load_land_land(&sect, &land, noisy, load_unload, &nunits)))
271                                 return retval;
272                         break;
273                 case EF_PLANE:
274                         if (0 != (retval=load_plane_land(&sect, &land, noisy, load_unload, &nunits)))
275                                 return retval;
276                         break;
277                 case EF_SECTOR:
278                         if (0 != (retval=load_comm_land(&sect, &land, ich, load_unload, &nunits)))
279                                 return retval;
280                 }
281                 /* load/unload plague */
282                 if (getvar(V_PSTAGE, (s_char *)&sect, EF_SECTOR) == PLG_INFECT &&
283                     getvar(V_PSTAGE, (s_char *)&land, EF_LAND) == PLG_HEALTHY)
284                         putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&land, EF_LAND);
285                 if (getvar(V_PSTAGE, (s_char *)&land, EF_LAND) == PLG_INFECT &&
286                     getvar(V_PSTAGE, (s_char *)&sect, EF_SECTOR) == PLG_HEALTHY)
287                         putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&sect, EF_SECTOR);
288                 
289                 putsect(&sect);
290                 putland(land.lnd_uid, &land);
291         }
292         if (nunits == 0)
293                 pr("No units affected\n");
294         else
295                 pr("%d unit%s %sloaded\n", nunits, splur(nunits),
296                         load_unload == UNLOAD ? "un" : "");
297         return RET_OK;
298 }
299
300 void
301 gift(int givee, int giver, s_char *ptr, int type, s_char *mesg)
302 {
303         s_char  *p, line[256];
304
305         if (giver == givee)
306                 return;
307
308
309         switch(type) {
310                 case EF_SHIP:   p = prship((struct shpstr *)ptr);
311                                 break;
312                 case EF_PLANE:  p = prplane((struct plnstr *)ptr);
313                                 break;
314                 case EF_LAND:   p = prland((struct lndstr *)ptr);
315                                 break;
316         }
317
318         sprintf(line,"%s %s %s\n",cname(giver),p,mesg);
319         wu(0,givee,line);
320 }
321
322 static int
323 still_ok_ship(struct sctstr *sectp, struct shpstr *shipp)
324 {
325     if (!check_sect_ok(sectp))
326         return 0;
327     if (!check_ship_ok(shipp))
328         return 0;
329     return 1;
330 }
331
332 static int
333 still_ok_land(struct sctstr *sectp, struct lndstr *landp)
334 {
335     if (!check_sect_ok(sectp))
336         return 0;
337     if (!check_land_ok(landp))
338         return 0;
339     return 1;
340 }
341
342 static int
343 load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy, int load_unload, int *nshipsp)
344 {
345         struct  nstr_item ni;
346         struct  plnstr pln;
347         int     loaded = 0;
348         s_char  buf[1024];
349         s_char  *p;
350         s_char  prompt[512];
351         struct  mchrstr *mcp = mchr + sp->shp_type;
352
353         if (!(mcp->m_flags & (M_CHOPPER|M_XLIGHT|M_FLY|M_MSL))) {
354                 if (noisy)
355                         pr("%s cannot carry planes\n", prship(sp));
356                 return 0;
357         }
358         count_planes(sp);
359         if (load_unload==LOAD &&
360             sp->shp_nchoppers >= mcp->m_nchoppers &&
361             sp->shp_nxlight >= mcp->m_nxlight &&
362             sp->shp_nplane >= mcp->m_nplanes) {
363                 if (noisy)
364                         pr("%s doesn't have room for any more planes\n",
365                            prship(sp));
366                 return 0;
367         }
368         sprintf(prompt, "Plane(s) to %s %s? ",
369                 load_unload==LOAD?"load onto":"unload from",
370                 prship(sp));
371         if (!snxtitem(&ni, EF_PLANE, p=getstarg(player->argp[3], prompt, buf)))
372                 return RET_SYN;
373
374         if (!still_ok_ship(sectp, sp))
375             return RET_SYN;
376
377         if (p && *p)
378                 noisy &= isdigit(*p);
379
380         while(nxtitem(&ni, (s_char *)&pln)) {                   
381                 if (pln.pln_own != player->cnum)
382                         continue;
383                 if (!(plchr[(int)pln.pln_type].pl_flags & P_L)
384                     &&  !(plchr[(int)pln.pln_type].pl_flags & P_E)
385                     &&  !(plchr[(int)pln.pln_type].pl_flags & P_K)
386                     &&  !(plchr[(int)pln.pln_type].pl_flags & P_M)
387                     ) {
388                         if (noisy)
389                                 pr("You can only load light planes, helos, xtra-light, or missiles onto ships.\n");
390                         continue;
391                 }
392                 if (load_unload == LOAD && pln.pln_ship > -1) {
393                         if (noisy)
394                                 pr("%s is already on ship #%d!\n",
395                                    prplane(&pln), pln.pln_ship);
396                         continue;
397                 }
398                 if (load_unload == LOAD && pln.pln_land > -1) {
399                         if (noisy)
400                                 pr("%s is already on land unit #%d!\n",
401                                    prplane(&pln), pln.pln_land);
402                         continue;
403                 }
404
405                 /* Plane sanity done */
406                 /* Find the right ship */
407                 if (load_unload == UNLOAD) {
408                         if (pln.pln_ship != sp->shp_uid)
409                                 continue;
410                 } else if (sp->shp_x != pln.pln_x
411                            || sp->shp_y != pln.pln_y)
412                         continue;
413
414                 /* ship to (plane or missle) sanity */
415                 if (!can_be_on_ship(pln.pln_uid, sp->shp_uid)) {
416                         if (plchr[(int)pln.pln_type].pl_flags & P_L) {
417                                 strcpy(buf, "planes");
418                         } else if (plchr[(int)pln.pln_type].pl_flags & P_K) {
419                                 strcpy(buf, "choppers");
420                         } else if (plchr[(int)pln.pln_type].pl_flags & P_M) {
421                                 strcpy(buf, "missiles");
422                         } else if (plchr[(int)pln.pln_type].pl_flags & P_E) {
423                                 strcpy(buf, "extra light planes");
424                         } /* else impossible */
425                         if (noisy)
426                                 pr("%s cannot carry %s.\n",
427                                    prship(sp),
428                                    buf);
429                         continue;
430                 }
431                 /* Fit plane on ship */
432                 if (load_unload == LOAD){
433                         if (!put_plane_on_ship(&pln,sp)){
434                                 if (noisy)
435                                         pr("Can't put plane %d on this ship!\n",pln.pln_uid);
436                                 continue;
437                         }
438                         sprintf(buf, "loaded on your %s at %s",
439                                 prship(sp),xyas(sp->shp_x,
440                                                 sp->shp_y, sp->shp_own));
441                         gift(sp->shp_own, player->cnum, (s_char *)&pln,
442                              EF_PLANE, buf);
443                         makelost(EF_PLANE, pln.pln_own, pln.pln_uid, pln.pln_x, pln.pln_y);
444                         pln.pln_own = sp->shp_own;
445                         makenotlost(EF_PLANE, pln.pln_own, pln.pln_uid, pln.pln_x, pln.pln_y);
446                         pln.pln_mission = 0;
447                         putplane(pln.pln_uid,&pln);
448                 } else {
449                         if (!take_plane_off_ship(&pln,sp)) {
450                                 pr("Unable to take plane off ship!\n");
451                                 logerror("load: plane %d could not be taken off ship %d\n",pln.pln_uid,sp->shp_uid);
452                                 continue;
453                         }
454                         sprintf(buf, "unloaded in your %s at %s",
455                                 dchr[sectp->sct_type].d_name,
456                                 xyas(sectp->sct_x,sectp->sct_y,
457                                      sectp->sct_own));
458                         gift(sectp->sct_own, player->cnum, (s_char *)&pln,
459                              EF_PLANE, buf);
460                         makelost(EF_PLANE, pln.pln_own, pln.pln_uid, pln.pln_x, pln.pln_y);
461                         pln.pln_own = sectp->sct_own;
462                         makenotlost(EF_PLANE, pln.pln_own, pln.pln_uid, pln.pln_x, pln.pln_y);
463                         putplane(pln.pln_uid,&pln);
464                 }
465                 pr("%s %s %s at %s.\n",
466                    prplane(&pln),
467                    (load_unload==UNLOAD)?
468                    "unloaded from":"loaded onto",
469                    prship(sp),
470                    xyas(sp->shp_x, sp->shp_y, player->cnum));
471                 loaded = 1;
472         }
473         *nshipsp += loaded;
474         return 0;
475 }
476
477 static int
478 load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy, int load_unload, int *nshipsp)
479 {
480     struct      nstr_item pni, ni;
481     struct      lndstr land;
482     struct      plnstr plane;
483     int loaded = 0;
484     s_char      *p;
485     s_char      prompt[512];
486     s_char      buf[1024];
487     int     load_spy = 0;
488     
489     count_units(sp);
490     if (load_unload == LOAD) {
491         if (opt_LANDSPIES) {
492             if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
493                 (mchr[(int)sp->shp_type].m_nland == 0)) {
494                 if (sp->shp_nland >= 2) {
495                     pr("Non-land unit carrying subs can only carry up to two spy units.\n");
496                     return 0;
497                 }
498                 /* Eh, let 'em load a spy only */
499                 load_spy = 1;
500             }
501         }
502         if ((!load_spy) && 
503             (sp->shp_nland >= mchr[(int)sp->shp_type].m_nland)) {
504             if (noisy) {
505                 if (mchr[(int)sp->shp_type].m_nland)
506                     pr("%s doesn't have room for any more land units!\n",prship(sp));
507                 else
508                     pr("%s cannot carry land units!\n",prship(sp));
509             }
510             return 0;
511         }
512     }
513     sprintf(prompt, "Land unit(s) to %s %s? ",
514             load_unload==LOAD?"load onto":"unload from",
515             prship(sp));
516     if (!snxtitem(&ni, EF_LAND, p=getstarg(player->argp[3], prompt, buf)))
517         return RET_SYN;
518     
519     if (!still_ok_ship(sectp, sp))
520         return RET_SYN;
521     
522     if (p && *p)
523         noisy &= isdigit(*p);
524     
525     while(nxtitem(&ni, (s_char *)&land)) {
526         if (land.lnd_own != player->cnum)
527             continue;
528         
529         if (load_unload == LOAD) {
530             if (land.lnd_ship > -1) {
531                 if (noisy)
532                     pr("%s is already on ship #%d!\n",
533                        prland(&land), land.lnd_ship);
534                 continue;
535             }
536             if (land.lnd_land > -1) {
537                 if (noisy)
538                     pr("%s is already on land #%d!\n",
539                        prland(&land), land.lnd_land);
540                 continue;
541             }
542             lnd_count_units(&land);
543             if (land.lnd_nland > 0) {
544                 if (noisy)
545                     pr("%s cannot be loaded since it is carrying units\n",
546                        prland(&land));
547                 continue;
548             }
549             if (lchr[(int)land.lnd_type].l_flags & L_HEAVY) {
550                 if (noisy)
551                     pr("%s is too heavy to load.\n", prland(&land));
552                 continue;
553             }
554             if (load_spy && !(lchr[(int)land.lnd_type].l_flags & L_SPY)) {
555                 if (noisy)
556                     pr("Subs can only carry spy units.\n");
557                 continue;
558             }
559         }
560         
561         /* Unit sanity done */
562         /* Find the right ship */
563         if (load_unload == UNLOAD) {
564             if (land.lnd_ship != sp->shp_uid)
565                 continue;
566             if (land.lnd_land > -1)
567                 continue;
568         } else if (sp->shp_x != land.lnd_x
569                    || sp->shp_y != land.lnd_y)
570             continue;
571         
572         if ((!(lchr[(int)land.lnd_type].l_flags & L_LIGHT)) &&
573             (!((mchr[(int)sp->shp_type].m_flags & M_SUPPLY) &&
574                (!(mchr[(int)sp->shp_type].m_flags & M_SUB))))) {
575             if (noisy) {
576                 pr("You can only load light units onto ships,\n");
577                 pr("unless the ship is a non-sub supply ship\n");
578                 pr("%s not loaded\n", prland(&land));
579             }
580             continue;
581         }
582         /* Fit unit on ship */
583         if (load_unload == LOAD) {
584             count_units(sp);
585             /* We have to check again, since it may have changed */
586             if (opt_LANDSPIES) {
587                 if ((mchr[(int)sp->shp_type].m_flags & M_SUB) &&
588                     (mchr[(int)sp->shp_type].m_nland == 0)) {
589                     if (sp->shp_nland >= 2) {
590                         pr("Non-land unit carrying subs can only carry up to two spy units.\n");
591                         return 0;
592                     }
593                                 /* Eh, let 'em load a spy only */
594                     load_spy = 1;
595                 }
596             }
597             if ((!load_spy) && 
598                 (sp->shp_nland >= mchr[(int)sp->shp_type].m_nland)) {
599                 if (noisy) {
600                     if (mchr[(int)sp->shp_type].m_nland)
601                         pr("%s doesn't have room for any more land units!\n",prship(sp));
602                     else
603                         pr("%s cannot carry land units!\n",prship(sp));
604                 }
605                 return 0;
606             }
607 #if 0
608             if (sp->shp_nland >= mchr[(int)sp->shp_type].m_nland) {
609                 if (noisy)
610                     if (mchr[(int)sp->shp_type].m_nland)
611                         pr("%s doesn't have room for any more land units!\n",prship(sp));
612                     else
613                         pr("%s cannot carry land units!\n",prship(sp));
614                 break;
615             }
616 #endif
617             sprintf(buf, "loaded on your %s at %s",
618                     prship(sp),xyas(sp->shp_x,sp->shp_y,
619                                     sp->shp_own));
620             gift(sp->shp_own,player->cnum,(s_char *)&land,
621                  EF_LAND, buf);
622             makelost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
623                      land.lnd_y);
624             land.lnd_own = sp->shp_own;
625             makenotlost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
626                         land.lnd_y);
627             land.lnd_ship = sp->shp_uid;
628             land.lnd_harden = 0;
629             land.lnd_mission = 0;
630             resupply_all(&land);
631             sp->shp_nland++;
632             putland(land.lnd_uid,&land);
633             if (!has_supply(&land))
634                 pr("WARNING: %s is out of supply!\n",
635                    prland(&land));
636             putship(sp->shp_uid,sp);
637             snxtitem_xy(&pni,EF_PLANE,land.lnd_x,land.lnd_y);
638             while (nxtitem(&pni, (s_char *)&plane)){
639                 if (plane.pln_flags & PLN_LAUNCHED)
640                     continue;
641                 if (plane.pln_land != land.lnd_uid)
642                     continue;
643                 sprintf(buf, "loaded on %s",
644                         prship(sp));
645                 gift(sp->shp_own,player->cnum,(s_char *)&plane,
646                      EF_PLANE, buf);
647                 makelost(EF_PLANE, plane.pln_own, plane.pln_uid, plane.pln_x,
648                          plane.pln_y);
649                 plane.pln_own = sp->shp_own;
650                 makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid, 
651                             plane.pln_x, plane.pln_y);
652                 plane.pln_mission = 0;
653                 putplane(plane.pln_uid,&plane);
654             }
655         } else {
656             sprintf(buf, "unloaded in your %s at %s",
657                     dchr[sectp->sct_type].d_name,
658                     xyas(sectp->sct_x,sectp->sct_y,
659                          sectp->sct_own));
660             
661             /* Spies are unloaded quietly, others aren't */
662             if (!(lchr[(int)land.lnd_type].l_flags & L_SPY)) {
663                 gift(sectp->sct_own,player->cnum,(s_char *)&land,
664                      EF_LAND, buf);
665                 makelost(EF_LAND, land.lnd_own, land.lnd_uid,
666                          land.lnd_x, land.lnd_y);
667                 land.lnd_own = sectp->sct_own;
668                 makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
669                             land.lnd_x, land.lnd_y);
670             }
671             
672             land.lnd_ship = (-1);
673             sp->shp_nland--;
674             putland(land.lnd_uid,&land);
675             putship(sp->shp_uid,sp);
676             
677             /* Spies are unloaded quietly, others aren't, and
678                in the off chance they can carry a plane (missile?)
679                they are quietly unloaded too. */
680             if (!(lchr[(int)land.lnd_type].l_flags & L_SPY)) {
681                 snxtitem_xy(&pni,EF_PLANE,land.lnd_x,land.lnd_y);
682                 while (nxtitem(&pni, (s_char *)&plane)){
683                     if (plane.pln_flags & PLN_LAUNCHED)
684                         continue;
685                     if (plane.pln_land != land.lnd_uid)
686                         continue;
687                     sprintf(buf, "unloaded at %s",
688                             xyas(plane.pln_x,plane.pln_y,
689                                  sectp->sct_own));
690                     gift(sectp->sct_own,player->cnum,(s_char *)&plane,
691                          EF_PLANE, buf);
692                     makelost(EF_PLANE, plane.pln_own, plane.pln_uid,
693                              plane.pln_x, plane.pln_y);
694                     plane.pln_own = sectp->sct_own;
695                     makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid,
696                                 plane.pln_x, plane.pln_y);
697                     plane.pln_mission = 0;
698                     putplane(plane.pln_uid,&plane);
699                 }
700             }
701         }
702         pr("%s %s %s at %s.\n",
703            prland(&land),
704            (load_unload==UNLOAD)?
705            "unloaded from":"loaded onto",
706            prship(sp),
707            xyas(sp->shp_x, sp->shp_y, player->cnum));
708         loaded = 1;
709     }
710     *nshipsp += loaded;
711     return 0;
712 }
713
714 static int
715 load_comm_ship(struct sctstr *sectp, struct shpstr *sp, struct ichrstr *ich, int load_unload, int *nshipsp)
716 {
717         register int item = ich->i_vtype;
718         register int max_amt;
719         register int move_amt;
720         register int ship_amt;
721         register int sect_amt;
722         int     amount;
723         int     upto=0, abs_max;
724         s_char  prompt[512];
725         s_char  *p;
726         s_char  buf[1024];
727
728         sprintf(prompt, "Number of %s to %s %s at %s? ",
729                 ich->i_name,
730                 (load_unload==UNLOAD)?
731                 "unload from":"load onto",
732                 prship(sp),
733                 xyas(sp->shp_x, sp->shp_y, player->cnum));
734         if (!(p = getstarg(player->argp[3], prompt, buf)) ||
735             !*p)
736                 return RET_SYN;
737
738         if (!still_ok_ship(sectp, sp))
739             return RET_SYN;
740
741         amount = atoi(p);
742         if (amount < 0) {
743                 /* We want to load up to this amount */
744                 upto = -(amount);
745                 load_unload = LOAD;
746         } else if (!amount)
747                 return 0;
748         ship_amt = getvar(item, (s_char *)sp, EF_SHIP);
749         sect_amt = getvar(item, (s_char *)sectp, EF_SECTOR);
750         if (sectp->sct_oldown != player->cnum &&
751             item == V_CIVIL) {
752                 pr("%s civilians refuse to %s at %s!\n",
753                    load_unload == UNLOAD ? "Your" : "Foreign",
754                    load_unload == UNLOAD ?
755                    "disembark" : "board",
756                    xyas(sectp->sct_x, sectp->sct_y, player->cnum));
757                 return 0;
758         }
759         if (load_unload == UNLOAD) {
760                 abs_max = max_amt = min(9999 - sect_amt, ship_amt);
761         } else {
762                 struct mchrstr *vbase;
763                 vbase = &mchr[(int)sp->shp_type];
764                 abs_max = max_amt = vl_find(item, vbase->m_vtype,
765                                             vbase->m_vamt, (int) vbase->m_nv);
766                 max_amt = min(sect_amt, max_amt - ship_amt);
767         }
768         if (max_amt <= 0 && !upto)
769                 return 0;
770         if (upto) {
771                 move_amt = upto - ship_amt;
772                 if (move_amt > sect_amt)
773                         move_amt = sect_amt;
774                 if (ship_amt+move_amt > abs_max)
775                         move_amt = abs_max - ship_amt;
776         } else
777                 move_amt = load_unload * min(amount, max_amt);
778         if (!move_amt)
779                 return 0;
780
781         if (!want_to_abandon(sectp, item, move_amt, 0))
782             return RET_FAIL;
783         if (!still_ok_ship(sectp, sp))
784             return RET_SYN;
785         putvar(item, sect_amt - move_amt, (s_char *)sectp, EF_SECTOR);
786         putvar(item, ship_amt + move_amt, (s_char *)sp, EF_SHIP);
787         if (load_unload == LOAD) {
788                 pr("%d %s loaded onto %s at %s\n",
789                    move_amt,
790                    ich->i_name,
791                    prship(sp),
792                    xyas(sp->shp_x, sp->shp_y, player->cnum));
793                 if (sp->shp_own != player->cnum) {
794                         sprintf(buf,"%s loaded %d %s onto %s at %s\n",
795                                 cname(player->cnum),
796                                 move_amt,
797                                 ich->i_name,
798                                 prship(sp),
799                                 xyas(sp->shp_x, sp->shp_y,
800                                      sp->shp_own));
801                         wu(0, sp->shp_own, buf);
802                 }
803         } else {
804                 pr("%d %s unloaded from %s at %s\n",
805                    -move_amt,
806                    ich->i_name,
807                    prship(sp),
808                    xyas(sp->shp_x, sp->shp_y, player->cnum));
809                 if (sectp->sct_own != player->cnum) {
810                         sprintf(buf,"%s unloaded %d %s from %s at %s\n",
811                                 cname(player->cnum),
812                                 -move_amt,
813                                 ich->i_name,
814                                 prship(sp),
815                                 xyas(sp->shp_x, sp->shp_y,
816                                      sectp->sct_own));
817                         wu(0, sectp->sct_own, buf);
818                 }
819         }
820         ++(*nshipsp);
821         return 0;
822 }
823
824 static int
825 load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy, int load_unload, int *nunitsp)
826 {
827         struct  nstr_item ni;
828         struct  plnstr pln;
829         int     loaded = 0;
830         s_char  *p;
831         s_char  prompt[512];
832         s_char  buf[1024];
833
834         if (!(lchr[(int)lp->lnd_type].l_flags & L_XLIGHT)) {
835                 if (noisy)
836                         pr("%s cannot carry extra-light planes.\n",
837                            prland(lp));
838                 return 0;
839         }
840         count_land_planes(lp);
841         if (load_unload==LOAD &&
842             lp->lnd_nxlight >= lp->lnd_maxlight) {
843                 if (noisy)
844                         pr("%s doesn't have room for any more extra-light planes\n",
845                            prland(lp));
846                 return 0;
847         }
848         sprintf(prompt, "Plane(s) to %s %s? ",
849                 load_unload==LOAD?"load onto":"unload from",
850                 prland(lp));
851         if (!snxtitem(&ni, EF_PLANE, p=getstarg(player->argp[3], prompt, buf)))
852                 return RET_SYN;
853
854         if (!still_ok_land(sectp, lp))
855             return RET_SYN;
856
857         if (p && *p)
858                 noisy &= isdigit(*p);
859
860         if (sectp->sct_own != player->cnum && load_unload == LOAD) {
861                 pr("Sector %s is not yours.\n",
862                    xyas(lp->lnd_x, lp->lnd_y, player->cnum));
863                 return 0;
864         }
865
866         while(nxtitem(&ni, (s_char *)&pln)) {                   
867                 if (pln.pln_own != player->cnum)
868                         continue;
869                 
870                 if (!(plchr[(int)pln.pln_type].pl_flags & P_E)) {
871                         if (noisy)
872                                 pr("You can only load xlight planes onto units.\n");
873                         continue;
874                 }
875
876                 if (load_unload == LOAD && pln.pln_ship > -1) {
877                         if (noisy)
878                                 pr("%s is already on ship #%d!\n",
879                                    prplane(&pln), pln.pln_ship);
880                         continue;
881                 }
882                 if (load_unload == LOAD && pln.pln_land > -1) {
883                         if (noisy)
884                                 pr("%s is already on unit #%d!\n",
885                                    prplane(&pln), pln.pln_land);
886                         continue;
887                 }
888                 /* Plane sanity done */
889                 /* Find the right unit */
890                 if (load_unload == UNLOAD) {
891                         if (pln.pln_land != lp->lnd_uid)
892                                 continue;
893                 } else if (lp->lnd_x != pln.pln_x
894                            || lp->lnd_y != pln.pln_y)
895                         continue;
896
897                 /* Fit plane on unit */
898                 if (load_unload == LOAD){
899                         if (!put_plane_on_land(&pln,lp)){
900                                 if (noisy)
901                                         pr("Can't put plane %d on this unit!\n",pln.pln_uid);
902                                 continue;
903                         }
904                         sprintf(buf, "loaded on %s at %s",
905                                 prland(lp), xyas(lp->lnd_x,
906                                                    lp->lnd_y, lp->lnd_own));
907                         gift(lp->lnd_own,player->cnum,(s_char *)&pln,
908                              EF_PLANE, buf);
909                         makelost(EF_PLANE, pln.pln_own, pln.pln_uid, pln.pln_x, pln.pln_y);
910                         pln.pln_own = lp->lnd_own;
911                         makenotlost(EF_PLANE, pln.pln_own, pln.pln_uid, pln.pln_x, pln.pln_y);
912                         putplane(pln.pln_uid,&pln);
913                 }else{
914                         if (!take_plane_off_land(&pln,lp)){
915                                 pr("Unable to take plane off unit!\n");
916                                 logerror("load: plane %d could not be taken off unit %d\n",pln.pln_uid,lp->lnd_uid);
917                                 continue;
918                         }
919                         sprintf(buf, "unloaded at your sector at %s",
920                                 xyas(sectp->sct_x,sectp->sct_y,
921                                      sectp->sct_own));
922                         gift(sectp->sct_own,player->cnum,(s_char *)&pln,
923                              EF_PLANE, buf);
924                         makelost(EF_PLANE, pln.pln_own, pln.pln_uid, pln.pln_x, pln.pln_y);
925                         pln.pln_own = sectp->sct_own;
926                         makenotlost(EF_PLANE, pln.pln_own, pln.pln_uid, pln.pln_x, pln.pln_y);
927                         putplane(pln.pln_uid,&pln);
928                 }
929                 pr("%s %s %s at %s.\n",
930                    prplane(&pln),
931                    (load_unload==UNLOAD)?
932                    "unloaded from":"loaded onto",
933                    prland(lp),
934                    xyas(lp->lnd_x, lp->lnd_y, player->cnum));
935                 loaded = 1;
936         }
937         *nunitsp += loaded;
938         return 0;
939 }
940
941 static int
942 load_comm_land(struct sctstr *sectp, struct lndstr *lp, struct ichrstr *ich, int load_unload, int *nunitsp)
943 {
944         register int item = ich->i_vtype;
945         register int max_amt;
946         register int move_amt;
947         register int land_amt;
948         register int sect_amt;
949         int     amount;
950         int     upto=0, abs_max;
951         s_char  prompt[512];
952         s_char  *p;
953         s_char  buf[1024];
954
955         sprintf(prompt, "Number of %s to %s %s at %s? ",
956                 ich->i_name,
957                 (load_unload==UNLOAD)?
958                 "unload from":"load onto",
959                 prland(lp),
960                 xyas(lp->lnd_x, lp->lnd_y, player->cnum));
961         if (!(p = getstarg(player->argp[3], prompt, buf)) ||
962             !*p)
963                 return RET_SYN;
964
965         if (!still_ok_land(sectp, lp))
966             return RET_SYN;
967
968         amount = atoi(p);
969         if (amount < 0) {
970                 /* We want to load up to this amount */
971                 upto = -(amount);
972                 load_unload = LOAD;
973         } else if (!amount)
974                 return 0;
975
976         if (sectp->sct_own != player->cnum && load_unload == LOAD) {
977                 pr("Sector %s is not yours.\n",
978                    xyas(lp->lnd_x, lp->lnd_y, player->cnum));
979                 return 0;
980         }
981
982         land_amt = getvar(item, (s_char *)lp, EF_LAND);
983         sect_amt = getvar(item, (s_char *)sectp, EF_SECTOR);
984         if (sectp->sct_oldown != player->cnum && item == V_CIVIL) {
985                 pr("%s civilians refuse to %s at %s!\n",
986                    load_unload == UNLOAD ? "Your" : "Foreign",
987                    load_unload == UNLOAD ?
988                    "disembark" : "board",
989                    xyas(sectp->sct_x, sectp->sct_y, player->cnum));
990                 return 0;
991         }
992         if (load_unload == UNLOAD) {
993                 abs_max = max_amt = min(9999 - sect_amt, land_amt);
994         } else {
995                 struct lchrstr *vbase;
996                 vbase = &lchr[(int)lp->lnd_type];
997                 abs_max = max_amt = vl_find(item, vbase->l_vtype,
998                                             vbase->l_vamt, (int) vbase->l_nv);
999                 max_amt = min(sect_amt, max_amt - land_amt);
1000         }
1001         if ((max_amt <= 0) && (upto == 0))
1002                 return 0;
1003         if (upto){
1004                 move_amt = upto - land_amt;
1005                 if (land_amt+move_amt > abs_max)
1006                         move_amt = abs_max - land_amt;
1007                 if (move_amt > sect_amt)
1008                         move_amt = sect_amt;
1009         }else
1010                 move_amt = load_unload * min(amount, max_amt);
1011         if (move_amt == 0)
1012                 return 0;
1013         putvar(item, sect_amt - move_amt, (s_char *)sectp, EF_SECTOR);
1014         putvar(item, land_amt + move_amt, (s_char *)lp, EF_LAND);
1015
1016         /* Did we put mils onto this unit? If so, reset the fortification */
1017         if (item == V_MILIT && move_amt > 0)
1018             lp->lnd_harden = 0;
1019         if (load_unload == LOAD) {
1020                 pr("%d %s loaded onto %s at %s\n",
1021                    move_amt,
1022                    ich->i_name,
1023                    prland(lp),
1024                    xyas(lp->lnd_x, lp->lnd_y, player->cnum));
1025                 if (lp->lnd_own != player->cnum) {
1026                         sprintf(buf,"%s loaded %d %s onto %s at %s\n",
1027                                 cname(player->cnum),
1028                                 move_amt,
1029                                 ich->i_name,
1030                                 prland(lp),
1031                                 xyas(lp->lnd_x, lp->lnd_y,
1032                                      lp->lnd_own));
1033                         wu(0, lp->lnd_own, buf);
1034                 }
1035         } else {
1036                 pr("%d %s unloaded from %s at %s\n",
1037                    -move_amt,
1038                    ich->i_name,
1039                    prland(lp),
1040                    xyas(lp->lnd_x, lp->lnd_y, player->cnum));
1041                 if (sectp->sct_own != player->cnum) {
1042                         sprintf(buf,"%s unloaded %d %s from %s at %s\n",
1043                                 cname(player->cnum),
1044                                 -move_amt,
1045                                 ich->i_name,
1046                                 prland(lp),
1047                                 xyas(lp->lnd_x, lp->lnd_y,
1048                                      sectp->sct_own));
1049                         wu(0, sectp->sct_own, buf);
1050                 }
1051         }
1052
1053         ++(*nunitsp);
1054         return 0;
1055 }
1056
1057 static int
1058 load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy, int load_unload, int *nunitsp)
1059 {
1060         struct  nstr_item pni, ni;
1061         struct  lndstr land;
1062         struct  plnstr plane;
1063         int     loaded = 0;
1064         s_char  *p;
1065         s_char  prompt[512];
1066         s_char  buf[1024];
1067
1068         lnd_count_units(lp);
1069
1070         if (load_unload==LOAD &&
1071             lp->lnd_nland >= lp->lnd_maxland) {
1072                 if (noisy) {
1073                         if (lp->lnd_nland)
1074                                 pr("%s doesn't have room for any more land units!\n",prland(lp));
1075                         else
1076                                 pr("%s cannot carry land units!\n",prland(lp));
1077                 }
1078                 return 0;
1079         }
1080         sprintf(prompt, "Land unit(s) to %s %s? ",
1081                 load_unload==LOAD?"load onto":"unload from",
1082                 prland(lp));
1083         if (!snxtitem(&ni, EF_LAND, p=getstarg(player->argp[3], prompt, buf)))
1084                 return RET_SYN;
1085
1086         if (!still_ok_land(sectp, lp))
1087             return RET_SYN;
1088
1089         if (p && *p)
1090                 noisy &= isdigit(*p);
1091
1092         while(nxtitem(&ni, (s_char *)&land)) {
1093                         
1094                 if (land.lnd_own != player->cnum)
1095                         continue;
1096                 
1097                 if (load_unload == LOAD) {
1098                   if (land.lnd_ship > -1) {
1099                     if (noisy)
1100                       pr("%s is already on ship #%d!\n",
1101                          prland(&land), land.lnd_ship);
1102                     continue;
1103                   }
1104                   if (land.lnd_land > -1) {
1105                     if (noisy)
1106                       pr("%s is already on land #%d!\n",
1107                          prland(&land), land.lnd_land);
1108                     continue;
1109                   }
1110                   lnd_count_units(&land);
1111                   if (land.lnd_nland > 0) {
1112                     if (noisy)
1113                       pr("%s cannot be loaded since it is carrying units\n",
1114                          prland(&land));
1115                     continue;
1116                   }
1117                   if (land.lnd_uid == lp->lnd_uid) {
1118                     if (noisy)
1119                       pr("%s can't be loaded onto itself!\n", prland(&land));
1120                     continue;
1121                   }
1122                   if (lchr[(int)land.lnd_type].l_flags & L_HEAVY) {
1123                     if (noisy)
1124                       pr("%s is too heavy to load.\n", prland(&land));
1125                     continue;
1126                   }
1127                 }
1128
1129                 /* Unit sanity done */
1130                 /* Find the right ship */
1131                 if (load_unload == UNLOAD) {
1132                         if (land.lnd_land != lp->lnd_uid)
1133                                 continue;
1134                         if (land.lnd_ship > -1)
1135                                 continue;
1136                 } else if (lp->lnd_x != land.lnd_x
1137                            || lp->lnd_y != land.lnd_y)
1138                         continue;
1139
1140                 /* Fit unit on ship */
1141                 if (load_unload == LOAD) {
1142                         lnd_count_units(lp);
1143                         if (lp->lnd_nland >= lp->lnd_maxland) {
1144                                 if (noisy) {
1145                                         if (lp->lnd_nland)
1146                                                 pr("%s doesn't have room for any more land units!\n",prland(lp));
1147                                         else
1148                                                 pr("%s cannot carry land units!\n",prland(lp));
1149                                 }
1150                                 break;
1151                         }
1152                         sprintf(buf, "loaded on your %s at %s",
1153                                 prland(lp),xyas(lp->lnd_x,lp->lnd_y,
1154                                                    lp->lnd_own));
1155                         gift(lp->lnd_own,player->cnum,(s_char *)&land,
1156                              EF_LAND, buf);
1157                         makelost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x, land.lnd_y);
1158                         land.lnd_own = lp->lnd_own;
1159                         makenotlost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x, land.lnd_y);
1160                         land.lnd_land = lp->lnd_uid;
1161                         land.lnd_harden = 0;
1162                         land.lnd_mission = 0;
1163                         resupply_all(&land);
1164                         lp->lnd_nland++;
1165                         putland(land.lnd_uid,&land);
1166                         if (!has_supply(&land))
1167                                 pr("WARNING: %s is out of supply!\n",
1168                                    prland(&land));
1169                         putland(lp->lnd_uid,lp);
1170                         snxtitem_xy(&pni,EF_PLANE,land.lnd_x,land.lnd_y);
1171                         while (nxtitem(&pni, (s_char *)&plane)){
1172                                 if (plane.pln_flags & PLN_LAUNCHED)
1173                                         continue;
1174                                 if (plane.pln_land != land.lnd_uid)
1175                                         continue;
1176                                 sprintf(buf, "loaded on %s",
1177                                         prland(lp));
1178                                 gift(lp->lnd_own,player->cnum,(s_char *)&plane,
1179                                      EF_PLANE, buf);
1180                                 makelost(EF_PLANE, plane.pln_own, plane.pln_uid, plane.pln_x, plane.pln_y);
1181                                 plane.pln_own = lp->lnd_own;
1182                                 makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid, plane.pln_x, plane.pln_y);
1183                                 plane.pln_mission = 0;
1184                                 putplane(plane.pln_uid,&plane);
1185                         }
1186                 } else {
1187                         sprintf(buf, "unloaded in your %s at %s",
1188                                 dchr[sectp->sct_type].d_name,
1189                                 xyas(sectp->sct_x,sectp->sct_y,
1190                                      sectp->sct_own));
1191                         gift(sectp->sct_own,player->cnum,(s_char *)&land,
1192                              EF_LAND, buf);
1193                         makelost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x, land.lnd_y);
1194                         land.lnd_own = sectp->sct_own;
1195                         makenotlost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x, land.lnd_y);
1196                         land.lnd_land = (-1);
1197                         lp->lnd_nland--;
1198                         putland(land.lnd_uid,&land);
1199                         putland(lp->lnd_uid,lp);
1200                         snxtitem_xy(&pni,EF_PLANE,land.lnd_x,land.lnd_y);
1201                         while (nxtitem(&pni, (s_char *)&plane)){
1202                                 if (plane.pln_flags & PLN_LAUNCHED)
1203                                         continue;
1204                                 if (plane.pln_land != land.lnd_uid)
1205                                         continue;
1206                                 sprintf(buf, "unloaded at %s",
1207                                         xyas(plane.pln_x,plane.pln_y,
1208                                              sectp->sct_own));
1209                                 gift(sectp->sct_own,player->cnum,(s_char *)&plane,
1210                                      EF_PLANE, buf);
1211                                 makelost(EF_PLANE, plane.pln_own, plane.pln_uid, plane.pln_x, plane.pln_y);
1212                                 plane.pln_own = sectp->sct_own;
1213                                 makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid, plane.pln_x, plane.pln_y);
1214                                 plane.pln_mission = 0;
1215                                 putplane(plane.pln_uid,&plane);
1216                         }
1217                 }
1218                 pr("%s %s %s at %s.\n",
1219                    prland(&land),
1220                    (load_unload==UNLOAD)?
1221                    "unloaded from":"loaded onto",
1222                    prland(lp),
1223                    xyas(lp->lnd_x, lp->lnd_y, player->cnum));
1224                 loaded = 1;
1225         }
1226         *nunitsp += loaded;
1227         return 0;
1228 }
1229