static void unit_list(struct emp_qelem *unit_list) { struct emp_qelem *qp; struct emp_qelem *next; struct ulist *ulp; int type, npln, nch, nxl; struct empobj *unit; struct lndstr *lnd; struct shpstr *shp; if (CANT_HAPPEN(QEMPTY(unit_list))) return; qp = unit_list->q_back; ulp = (struct ulist *)qp; type = ulp->unit.gen.ef_type; if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP)) return; if (type == EF_LAND) pr("lnd# land type x,y a eff mil sh gun xl ln mu tech retr\n"); else pr("shp# ship type x,y fl eff mil sh gun pn he xl ln mob tech\n"); for (; qp != unit_list; qp = next) { next = qp->q_back; ulp = (struct ulist *)qp; lnd = &ulp->unit.land; shp = &ulp->unit.ship; unit = &ulp->unit.gen; if (CANT_HAPPEN(type != unit->ef_type)) continue; pr("%4d ", unit->uid); pr("%-16.16s ", empobj_chr_name(unit)); prxy("%4d,%-4d ", unit->x, unit->y); pr("%1.1s", &unit->group); pr("%4d%%", unit->effic); if (type == EF_LAND) { pr("%4d", lnd->lnd_item[I_MILIT]); pr("%4d", lnd->lnd_item[I_SHELL]); pr("%4d", lnd->lnd_item[I_GUN]); pr("%3d%3d", lnd_nxlight(lnd), lnd_nland(lnd)); } else { pr("%4d", shp->shp_item[I_MILIT]); pr("%4d", shp->shp_item[I_SHELL]); pr("%4d", shp->shp_item[I_GUN]); npln = shp_nplane(shp, &nch, &nxl, NULL); pr("%3d%3d%3d", npln - nch - nxl, nch, nxl); pr("%3d", shp_nland(shp)); } pr("%4d", unit->mobil); pr("%4d", unit->tech); if (type == EF_LAND) { pr("%4d%%", lnd->lnd_retreat); } pr("\n"); } }
int put_plane_on_land(struct plnstr *plane, struct lndstr *land) { if (plane->pln_land == land->lnd_uid) return 1; /* Already on unit */ if (!(plchr[plane->pln_type].pl_flags & P_E)) return 0; if (lnd_nxlight(land) >= lchr[land->lnd_type].l_nxlight) return 0; plane->pln_x = land->lnd_x; plane->pln_y = land->lnd_y; plane->pln_land = land->lnd_uid; putplane(plane->pln_uid, plane); return 1; }
static int load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy, int load_unload, int *nunitsp) { struct nstr_item ni; struct plnstr pln; int loaded = 0; char *p; char prompt[512]; char buf[1024]; struct lchrstr *lcp = lchr + lp->lnd_type; if (!lcp->l_nxlight) { if (noisy) pr("%s cannot carry extra-light planes.\n", prland(lp)); return 0; } if (load_unload == LOAD && lnd_nxlight(lp) >= lcp->l_nxlight) { if (noisy) pr("%s doesn't have room for any more extra-light planes\n", prland(lp)); return 0; } sprintf(prompt, "Plane(s) to %s %s? ", load_unload == LOAD ? "load onto" : "unload from", prland(lp)); p = getstarg(player->argp[3], prompt, buf); if (!p) return RET_SYN; if (!snxtitem(&ni, EF_PLANE, p, NULL)) return RET_SYN; if (!still_ok_land(sectp, lp)) return RET_SYN; if (noisy && p && *p) noisy = isdigit(*p); while (nxtitem(&ni, &pln)) { if (!player->owner) continue; if (!(plchr[(int)pln.pln_type].pl_flags & P_E)) { if (noisy) pr("You can only load xlight planes onto units.\n"); continue; } if (load_unload == LOAD && pln.pln_ship > -1) { if (noisy) pr("%s is already on ship #%d!\n", prplane(&pln), pln.pln_ship); continue; } if (load_unload == LOAD && pln.pln_land > -1) { if (noisy) pr("%s is already on unit #%d!\n", prplane(&pln), pln.pln_land); continue; } if (pln.pln_harden != 0) { if (noisy) pr("%s has been hardened and can't be loaded\n", prplane(&pln)); continue; } /* Plane sanity done */ /* Find the right unit */ if (load_unload == UNLOAD) { if (pln.pln_land != lp->lnd_uid) continue; } else if (lp->lnd_x != pln.pln_x || lp->lnd_y != pln.pln_y) continue; /* Fit plane on unit */ if (load_unload == LOAD) { if (!put_plane_on_land(&pln, lp)) { if (noisy) pr("Can't put plane %d on this unit!\n", pln.pln_uid); continue; } sprintf(buf, "loaded on %s at %s", prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own)); gift(lp->lnd_own, player->cnum, &pln, buf); putplane(pln.pln_uid, &pln); } else { pln.pln_land = -1; sprintf(buf, "unloaded at your sector at %s", xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own)); gift(sectp->sct_own, player->cnum, &pln, buf); putplane(pln.pln_uid, &pln); } pr("%s %s %s at %s.\n", prplane(&pln), (load_unload == UNLOAD) ? "unloaded from" : "loaded onto", prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum)); loaded = 1; } *nunitsp += loaded; return 0; }