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"); } }
static int load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy, int load_unload, int *nunitsp) { struct nstr_item ni; struct lndstr land; int loaded = 0; char *p; char prompt[512]; char buf[1024]; if (load_unload == LOAD && lnd_nland(lp) >= lchr[lp->lnd_type].l_nland) { if (noisy) { if (lchr[lp->lnd_type].l_nland) pr("%s doesn't have room for any more land units!\n", prland(lp)); else pr("%s cannot carry land units!\n", prland(lp)); } return 0; } sprintf(prompt, "Land unit(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_LAND, p, NULL)) return RET_SYN; if (!still_ok_land(sectp, lp)) return RET_SYN; if (noisy && p && *p) noisy = isdigit(*p); while (nxtitem(&ni, &land)) { if (!player->owner) continue; if (load_unload == LOAD) { if (land.lnd_ship > -1) { if (noisy) pr("%s is already on ship #%d!\n", prland(&land), land.lnd_ship); continue; } if (land.lnd_land > -1) { if (noisy) pr("%s is already on land #%d!\n", prland(&land), land.lnd_land); continue; } if (lnd_first_on_land(&land) >= 0) { if (noisy) pr("%s cannot be loaded since it is carrying units\n", prland(&land)); continue; } if (land.lnd_uid == lp->lnd_uid) { if (noisy) pr("%s can't be loaded onto itself!\n", prland(&land)); continue; } if (lchr[(int)land.lnd_type].l_flags & (L_HEAVY | L_TRAIN)) { if (noisy) pr("%s is too heavy to load.\n", prland(&land)); continue; } } /* Unit sanity done */ /* Find the right ship */ if (load_unload == UNLOAD) { if (land.lnd_land != lp->lnd_uid) continue; if (land.lnd_ship > -1) continue; } else if (lp->lnd_x != land.lnd_x || lp->lnd_y != land.lnd_y) continue; /* Fit unit on ship */ if (load_unload == LOAD) { if (lnd_nland(lp) >= lchr[lp->lnd_type].l_nland) { if (noisy) { if (lchr[lp->lnd_type].l_nland) pr("%s doesn't have room for any more land units!\n", prland(lp)); else pr("%s cannot carry land units!\n", prland(lp)); } break; } sprintf(buf, "loaded on your %s at %s", prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own)); gift(lp->lnd_own, player->cnum, &land, buf); land.lnd_land = lp->lnd_uid; land.lnd_harden = 0; putland(land.lnd_uid, &land); #if 0 /* FIXME same issue as in load_land_ship() */ if (!lnd_supply_all(&land)) pr("WARNING: %s is out of supply!\n", prland(&land)); #else if (!lnd_in_supply(&land)) pr("WARNING: %s is out of supply!\n", prland(&land)); #endif } else { sprintf(buf, "unloaded in your %s at %s", dchr[sectp->sct_type].d_name, xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own)); gift(sectp->sct_own, player->cnum, &land, buf); land.lnd_land = -1; putland(land.lnd_uid, &land); } pr("%s %s %s at %s.\n", prland(&land), (load_unload == UNLOAD) ? "unloaded from" : "loaded onto", prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum)); loaded = 1; } *nunitsp += loaded; return 0; }