/* * Dump items of type @type selected by @arg to @xd. * Return RET_OK on success, RET_SYN on error. */ static int xditem(struct xdstr *xd, int type, char *arg) { struct castr *ca; struct nstr_item ni; int n; unsigned char buf[EF_WITH_CADEF_MAX_ENTRY_SIZE]; ca = ef_cadef(type); if (!ca) return RET_SYN; if (!snxtitem(&ni, type, arg, NULL)) return RET_SYN; xdhdr(xd, ef_nameof(type), 0); n = 0; while (nxtitem(&ni, buf)) { if (!xdvisible(type, buf)) continue; ++n; xdflds(xd, ca, buf); xd->pr("\n"); } xdftr(xd, n); return RET_OK; }
/* * Drop cargo of @unit. * Give it to @newown, unless it's zero. */ void unit_drop_cargo(struct empobj *unit, natid newown) { int type; struct nstr_item ni; union empobj_storage cargo; for (type = EF_PLANE; type <= EF_NUKE; type++) { snxtitem_cargo(&ni, type, unit->ef_type, unit->uid); while (nxtitem(&ni, &cargo)) { switch (type) { case EF_PLANE: cargo.plane.pln_ship = cargo.plane.pln_land = -1; break; case EF_LAND: cargo.land.lnd_ship = cargo.land.lnd_land = -1; break; case EF_NUKE: cargo.nuke.nuk_plane = -1; break; } mpr(cargo.gen.own, "%s transferred off %s %d to %s\n", unit_nameof(&cargo.gen), ef_nameof(unit->ef_type), unit->uid, xyas(cargo.gen.x, cargo.gen.y, cargo.gen.own)); if (newown) unit_give_away(&cargo.gen, newown, cargo.gen.own); put_empobj(type, cargo.gen.uid, &cargo.gen); } } }
int reje(void) { static char *what[] = { "teles", "annos", "loans" }; char *p; enum rej_comm rej; int do_undo; struct natstr nat; struct nstr_item ni; char buf[1024]; if (!(p = getstarg(player->argp[1], "reject or accept? ", buf))) return RET_SYN; switch (*p) { case 'r': do_undo = 1; break; case 'a': do_undo = 0; break; default: pr("That's not one of the choices!\n"); return RET_SYN; } p = getstarg(player->argp[2], "mail, loans, or announcements? ", buf); if (!p) return RET_SYN; switch (*p) { case 'a': rej = REJ_ANNO; break; case 'l': rej = REJ_LOAN; break; case 'm': rej = REJ_TELE; break; default: pr("That's not one of the choices!\n"); return RET_SYN; } if (!snxtitem(&ni, EF_NATION, player->argp[3], NULL)) return RET_SYN; while (nxtitem(&ni, &nat)) { if (nat.nat_stat == STAT_GOD) { pr("You may not reject/accept stuff from %s\n" "because they are a deity.\n", nat.nat_cnam); continue; } if (nat.nat_stat == STAT_UNUSED) continue; pr("%s %s from %s\n", (do_undo == 1 ? "Rejecting" : "Accepting"), what[rej], nat.nat_cnam); setrej(player->cnum, (natid)ni.cur, do_undo, rej); } return RET_OK; }
/* * Give @unit and its cargo to @recipient. * No action if @recipient already owns @unit. * If @giver is non-zero, inform @recipient and @giver of the transaction. * Clears mission and group on the units given away. */ void unit_give_away(struct empobj *unit, natid recipient, natid giver) { int type; struct nstr_item ni; union empobj_storage cargo; if (unit->own == recipient) return; if (giver) { mpr(unit->own, "%s given to %s\n", unit_nameof(unit), cname(recipient)); mpr(recipient, "%s given to you by %s\n", unit_nameof(unit), cname(giver)); } unit->own = recipient; unit_wipe_orders(unit); put_empobj(unit->ef_type, unit->uid, unit); for (type = EF_PLANE; type <= EF_NUKE; type++) { snxtitem_cargo(&ni, type, unit->ef_type, unit->uid); while (nxtitem(&ni, &cargo)) unit_give_away(&cargo.gen, recipient, giver); } }
int wing(void) { struct plnstr plane; int count; char *cp; char c; struct nstr_item nstr; char buf[1024]; if (!(cp = getstarg(player->argp[1], "wing? ", buf))) return RET_SYN; c = *cp; if (!isalpha(c) && c != '~') { pr("Specify wing, (1 alpha char or '~')\n"); return RET_SYN; } if (c == '~') c = 0; if (!snxtitem(&nstr, EF_PLANE, player->argp[2], NULL)) return RET_SYN; count = 0; while (nxtitem(&nstr, &plane)) { if (plane.pln_own != player->cnum) continue; if (plane.pln_wing == c) continue; plane.pln_wing = c; putplane(plane.pln_uid, &plane); count++; } pr("%d plane%s added to wing `%1.1s'\n", count, splur(count), &c); return RET_OK; }
static int sanc_cmd(void) { struct nstr_item ni; struct natstr nat; int first = 1; if (!opt_BLITZ) { pr_id(player, C_BADCMD, "Command %s not found\n", player->argp[0]); return RET_FAIL; } snxtitem_all(&ni, EF_NATION); while (nxtitem(&ni, &nat)) { if (nat.nat_stat != STAT_SANCT) continue; if (first) { pr_id(player, C_DATA, "The following countries are still in sanctuary:\n"); first = 0; } pr_id(player, C_DATA, "%s\n", nat.nat_cnam); } if (first) pr_id(player, C_CMDOK, "There are no countries in sanctuary\n"); else pr_id(player, C_CMDOK, "\n"); return RET_OK; }
int supp(void) { int nunits; struct nstr_item ni; struct lndstr land; if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL)) return RET_SYN; nunits = 0; while (nxtitem(&ni, &land)) { if (!player->owner || land.lnd_own == 0) continue; nunits++; if (lnd_supply_all(&land)) pr("%s has supplies\n", prland(&land)); else pr("%s is out of supply\n", prland(&land)); } if (nunits == 0) { if (player->argp[1]) pr("%s: No unit(s)\n", player->argp[1]); else pr("%s: No unit(s)\n", ""); return RET_FAIL; } else pr("%d unit%s\n", nunits, splur(nunits)); return RET_OK; }
int range(void) { struct nstr_item np; struct plnstr plane; int i, rmax; char *p; char buf[1024]; if (!snxtitem(&np, EF_PLANE, player->argp[1], NULL)) return RET_SYN; while (nxtitem(&np, &plane)) { if (!player->owner || plane.pln_own == 0) continue; p = getstarg(player->argp[2], "New range? ", buf); if (!p) return RET_FAIL; if (!check_plane_ok(&plane)) return RET_SYN; if ((i = atoi(p)) < 0) continue; rmax = pln_range_max(&plane); plane.pln_range = MIN(rmax, i); pr("Plane %d range changed to %d\n", plane.pln_uid, plane.pln_range); putplane(plane.pln_uid, &plane); } return RET_OK; }
/* * Get assembly point argument. * If INPUT is not empty, use it, else prompt for more input using PROMPT. * If this yields a valid assembly point, read it into *AP_SECT and * return AP_SECT. * Else complain and return NULL. * *AP_SECT and BUF[1024] may be modified in either case. */ struct sctstr * get_assembly_point(char *input, struct sctstr *ap_sect, char *buf) { char *p; coord x, y; struct nstr_item ni; struct shpstr ship; p = getstarg(input, "assembly point? ", buf); if (!p || *p == 0) return NULL; if (!sarg_xy(p, &x, &y) || !getsect(x, y, ap_sect)) return NULL; /* over own or allied sector is fine */ if (relations_with(ap_sect->sct_own, player->cnum) == ALLIED) return ap_sect; /* over own or allied ship is fine */ snxtitem_xy(&ni, EF_SHIP, x, y); while (nxtitem(&ni, &ship)) { if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) continue; if (relations_with(ship.shp_own, player->cnum) == ALLIED) return ap_sect; } pr("Assembly point not owned by you or an ally!\n"); return NULL; }
int trade_has_unsalable_cargo(struct empobj *tgp, int noisy) { int ret, i, type; short *item; struct nstr_item ni; union empobj_storage cargo; ret = 0; if (tgp->ef_type == EF_SHIP || tgp->ef_type == EF_LAND) { item = tgp->ef_type == EF_SHIP ? ((struct shpstr *)tgp)->shp_item : ((struct lndstr *)tgp)->lnd_item; for (i = I_NONE + 1; i <= I_MAX; i++) { if (item[i] && !ichr[i].i_sell) { if (noisy) pr("%s carries %s, which you can't sell.\n", unit_nameof(tgp), ichr[i].i_name); ret = 1; } } } for (type = EF_PLANE; type <= EF_NUKE; type++) { snxtitem_cargo(&ni, type, tgp->ef_type, tgp->uid); while (nxtitem(&ni, &cargo)) ret |= trade_has_unsalable_cargo(&cargo.gen, noisy); } return ret; }
int do_look(int type) { int i; struct nstr_item ni; union empobj_storage unit; struct sctstr sect; int x, y; unsigned char *bitmap; int changed = 0; if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP)) type = EF_SHIP; if (!snxtitem(&ni, type, player->argp[1], NULL)) return RET_SYN; bitmap = calloc((WORLD_SZ() + 7) / 8, 1); if (!bitmap) { logerror("malloc failed in do_look\n"); pr("Memory error. Tell the deity.\n"); return RET_FAIL; } while (nxtitem(&ni, &unit)) { if (!player->owner) continue; if (type == EF_LAND) { if (unit.land.lnd_ship >= 0) continue; if (unit.land.lnd_land >= 0) continue; /* Spies don't need military to do a "llook". Other units do */ if ((unit.land.lnd_item[I_MILIT] <= 0) && !(lchr[(int)unit.land.lnd_type].l_flags & L_SPY)) continue; look_land(&unit.land); } else look_ship(&unit.ship); for (i = 0; i <= 6; i++) { x = diroff[i][0] + unit.gen.x; y = diroff[i][1] + unit.gen.y; if (emp_getbit(x, y, bitmap)) continue; emp_setbit(x, y, bitmap); getsect(x, y, §); if (sect.sct_type == SCT_WATER) continue; look_at_sect(§, 10); changed += map_set(player->cnum, x, y, dchr[sect.sct_type].d_mnem, 0); if (opt_HIDDEN) { setcont(player->cnum, sect.sct_own, FOUND_LOOK); } } } if (changed) writemap(player->cnum); free(bitmap); return RET_OK; }
int qorde(void) { int nships = 0; int i; struct nstr_item nb; struct shpstr ship; if (!snxtitem(&nb, EF_SHIP, player->argp[1], NULL)) return RET_SYN; while (nxtitem(&nb, (&ship))) { if (!player->owner || ship.shp_own == 0) continue; if (!(ship.shp_autonav & AN_AUTONAV) && (!opt_SAIL || !ship.shp_path[0])) continue; if (!nships) { /* 1st ship, print banner */ if (player->god) pr("own "); pr("shp# ship type "); pr("[Starting] (Ending) \n"); } nships++; if (player->god) pr("%3d ", ship.shp_own); pr("%4d", nb.cur); pr(" %-16.16s", mchr[(int)ship.shp_type].m_name); if (ship.shp_autonav & AN_AUTONAV) { pr(" ["); for (i = 0; i < TMAX; i++) prhold(i, ship.shp_tend[i], ship.shp_lend[i]); pr("] , ("); for (i = 0; i < TMAX; i++) prhold(i, ship.shp_tstart[i], ship.shp_lstart[i]); pr(")"); if (ship.shp_autonav & AN_SCUTTLE) pr(" scuttling"); pr("\n"); } else pr(" has a sail path\n"); if (ship.shp_name[0] != 0) { if (player->god) pr(" "); pr(" %s\n", ship.shp_name); } } if (!nships) { if (player->argp[1]) pr("%s: No ship(s)\n", player->argp[1]); else pr("%s: No ship(s)\n", ""); return RET_FAIL; } else pr("%d ship%s\n", nships, splur(nships)); return RET_OK; }
/* * Accept a loan. If the offering country has too little money, * leave him $100 left and offer the rest. Return RET_OK on * success, anything else on error. */ static int loan_accept(struct ltcomstr *ltcp) { struct lonstr *lp; struct natstr *lender; struct nstr_item nstr; struct lonstr loan; lp = <cp->u.l; if (ltcp->proposee != player->cnum) { pr("%s %d is still pending.\n", ltcp->Name, ltcp->num); return RET_OK; } if (!getloan(ltcp->num, lp)) { logerror("loan_accept: can't read loan"); pr("can't read loan; get help!\n"); return RET_FAIL; } if (lp->l_status == LS_FREE) { /* other guy retratcted already */ late(ltcp); return RET_OK; } if (lp->l_status == LS_SIGNED) { /* already signed somehow */ prev_signed(ltcp); return RET_OK; } /* check to see if a loan already exists */ snxtitem_all(&nstr, EF_LOAN); while (nxtitem(&nstr, &loan)) { if (loan.l_status == LS_SIGNED && loan.l_lonee == lp->l_loner && (loan.l_loner == lp->l_lonee)) { pr("He already owes you money - make him repay his loan!\n"); return RET_OK; } } lender = getnatp(ltcp->proposer); if (lender->nat_money < lp->l_amtdue) { /* other guy is poor */ lp->l_amtdue = lender->nat_money - 100; pr("%s no longer has the funds.\n", cname(ltcp->proposer)); if (lp->l_amtdue <= 0) return RET_FAIL; pr("You may borrow $%d at the same terms.\n", lp->l_amtdue); } lender->nat_money -= lp->l_amtdue; putnat(lender); player->dolcost -= lp->l_amtdue; lp->l_amtpaid = 0; (void)time(&lp->l_lastpay); lp->l_duedate = lp->l_ldur * SECS_PER_DAY + lp->l_lastpay; lp->l_status = LS_SIGNED; if (!putloan(ltcp->num, lp)) { pr("Problem writing lp->to disk; get help!\n"); return RET_FAIL; } accpt(ltcp); pr("You are now $%d richer (sort of).\n", lp->l_amtdue); return RET_OK; }
static void takeover_unit(struct empobj *unit, natid newown) { struct shpstr *sp; struct plnstr *pp; struct lndstr *lp; struct nukstr *np; int type; struct nstr_item ni; union empobj_storage cargo; unit->own = newown; if (opt_MARKET) trdswitchown(unit->ef_type, unit, newown); unit_wipe_orders(unit); switch (unit->ef_type) { case EF_SHIP: sp = (struct shpstr *)unit; sp->shp_off = 1; break; case EF_PLANE: pp = (struct plnstr *)unit; if (pp->pln_mobil > 0) pp->pln_mobil = 0; pp->pln_off = 1; break; case EF_LAND: lp = (struct lndstr *)unit; if (lp->lnd_mobil > 0) lp->lnd_mobil = 0; lp->lnd_off = 1; lp->lnd_harden = 0; break; case EF_NUKE: np = (struct nukstr *)unit; np->nuk_off = 1; break; default: CANT_REACH(); } put_empobj(unit->ef_type, unit->uid, unit); for (type = EF_PLANE; type <= EF_NUKE; type++) { snxtitem_cargo(&ni, type, unit->ef_type, unit->uid); while (nxtitem(&ni, &cargo)) { if (cargo.gen.own == newown) continue; if (type == EF_PLANE) cargo.plane.pln_effic = PLANE_MINEFF; takeover_unit(&cargo.gen, newown); } } }
int nuke(void) { int nnukes, noff; struct nstr_item nstr; struct nukstr nuk; struct plnstr plane; if (!snxtitem(&nstr, EF_NUKE, player->argp[1], NULL)) return RET_SYN; nnukes = noff = 0; while (nxtitem(&nstr, &nuk)) { if (!player->owner || nuk.nuk_own == 0) continue; if (nnukes++ == 0) { if (player->god) pr("own "); pr(" # nuke type x,y s eff tech carry burst\n"); } if (nuk.nuk_off) noff++; if (player->god) pr("%-3d ", nuk.nuk_own); pr("%4d %-19.19s ", nstr.cur, nchr[(int)nuk.nuk_type].n_name); prxy("%4d,%-4d", nuk.nuk_x, nuk.nuk_y); pr(" %1.1s %c%3d%% %4d", &nuk.nuk_stockpile, nuk.nuk_off ? '!' : ' ', nuk.nuk_effic, nuk.nuk_tech); if (nuk.nuk_plane >= 0) { getplane(nuk.nuk_plane, &plane); pr("%5dP %s", nuk.nuk_plane, plane.pln_flags & PLN_AIRBURST ? " air" : "ground"); } pr("\n"); } if (nnukes == 0) { if (player->argp[1]) pr("%s: No nuke(s)\n", player->argp[1]); else pr("%s: No nuke(s)\n", ""); return RET_FAIL; } else { pr("%d nuke%s", nnukes, splur(nnukes)); if (noff) pr(", %d stopped (eff marked with !)", noff); pr("\n"); } return RET_OK; }
void msl_sel(struct emp_qelem *list, coord x, coord y, natid victim, int wantflags, int nowantflags, int mission) { struct plchrstr *pcp; struct plnstr plane; struct plist *irv; struct nstr_item ni; emp_initque(list); snxtitem_all(&ni, EF_PLANE); while (nxtitem(&ni, &plane)) { if (!plane.pln_own) continue; pcp = &plchr[(int)plane.pln_type]; if (!(pcp->pl_flags & P_M)) continue; if (wantflags && (pcp->pl_flags & wantflags) != wantflags) continue; if (nowantflags && pcp->pl_flags & nowantflags) continue; if (mission && plane.pln_mission != mission) continue; if (mission && plane.pln_radius < mapdist(x, y, plane.pln_opx, plane.pln_opy)) continue; if (relations_with(plane.pln_own, victim) >= NEUTRAL) continue; /* missiles go one way, so we can use all the range */ if (plane.pln_range < mapdist(x, y, plane.pln_x, plane.pln_y)) continue; if (plane.pln_mobil <= 0) continue; if (plane.pln_effic < 100) continue; if (opt_MARKET) { if (ontradingblock(EF_PLANE, &plane)) continue; } if (!pln_airbase_ok(&plane, 1, 0)) continue; /* got a valid interceptor */ irv = malloc(sizeof(*irv)); irv->load = 0; irv->pstage = PLG_HEALTHY; irv->pcp = &plchr[(int)plane.pln_type]; irv->plane = plane; emp_insque(&irv->queue, list); } }
int coun(void) { struct nstr_item ni; struct natstr nat; if (!snxtitem(&ni, EF_NATION, player->argp[1], NULL)) return RET_SYN; prdate(); pr(" # last access %sstatus country name\n", player->god ? "BTU " : ""); while (nxtitem(&ni, &nat)) { if (nat.nat_stat == STAT_UNUSED) continue; coun_list(&nat); } return RET_OK; }
int ndump(void) { struct nstr_item nstr; struct nukstr nuk; time_t now; int nnukes; if (!snxtitem(&nstr, EF_NUKE, player->argp[1], NULL)) return RET_SYN; prdate(); if (player->god) pr(" "); time(&now); pr("DUMP NUKES %ld\n", (long)now); if (player->god) pr("own "); pr("id x y num type\n"); nnukes = 0; while (nxtitem(&nstr, &nuk)) { if (!player->god && !player->owner) continue; if (nuk.nuk_own == 0) continue; nnukes++; if (player->god) pr("%d ", nuk.nuk_own); pr("%d ", nuk.nuk_uid); prxy("%d %d", nuk.nuk_x, nuk.nuk_y); pr(" %d", 1); pr(" %.5s", nchr[(int)nuk.nuk_type].n_name); pr("\n"); } if (nnukes == 0) { if (player->argp[1]) pr("%s: No nuke(s)\n", player->argp[1]); else pr("%s: No nuke(s)\n", ""); return RET_FAIL; } else pr("%d nuke%s\n", nnukes, splur(nnukes)); return RET_OK; }
int lsta(void) { int nunits; struct nstr_item ni; struct lndstr land; struct lchrstr *lcp; if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL)) return RET_SYN; nunits = 0; while (nxtitem(&ni, &land)) { if (!player->owner || land.lnd_own == 0) continue; lcp = lchr + land.lnd_type; if (nunits++ == 0) { pr(" %16.16s s v s r r a f a a\n", ""); pr(" %16.16s p i p a n c i m a\n", ""); pr("lnd# %16.16s x,y eff tech att def vul d s y d g c r m f\n", "unit-type"); } pr("%4d %-16.16s ", land.lnd_uid, lcp->l_name); prxy("%4d,%-4d", land.lnd_x, land.lnd_y); pr(" %3d%% %3d %1.1f %1.1f %3d ", land.lnd_effic, land.lnd_tech, lnd_att(&land), lnd_def(&land), lnd_vul(&land)); pr("%2d %2d %2d %2d ", lnd_spd(&land), lnd_vis(&land), lcp->l_spy, lcp->l_rad); pr("%2d %2d %2d %2d %2d ", lnd_frg(&land), lnd_acc(&land), lnd_dam(&land), lcp->l_ammo, lnd_aaf(&land)); pr("\n"); } if (nunits == 0) { if (player->argp[1]) pr("%s: No unit(s)\n", player->argp[1]); else pr("%s: No unit(s)\n", ""); return RET_FAIL; } else pr("%d unit%s\n", nunits, splur(nunits)); return RET_OK; }
/* * Update cargo of @carrier for movement or destruction. * If the carrier is destroyed, destroy its cargo (planes, land units, * nukes). * Else update their location to the carrier's. Any op sectors equal * to location get updated, too. * Return number of units updated. */ int unit_update_cargo(struct empobj *carrier) { int cargo_type; struct nstr_item ni; union empobj_storage obj; int n = 0; for (cargo_type = EF_PLANE; cargo_type <= EF_NUKE; cargo_type++) { snxtitem_cargo(&ni, cargo_type, carrier->ef_type, carrier->uid); while (nxtitem(&ni, &obj)) { if (carrier->own) unit_teleport(&obj.gen, carrier->x, carrier->y); else { mpr(obj.gen.own, "%s lost!\n", unit_nameof(&obj.gen)); obj.gen.effic = 0; } put_empobj(cargo_type, obj.gen.uid, &obj); n++; } } return n; }
/* * format: fina */ int fina(void) { struct lonstr loan; struct nstr_item ni; time_t now; if (!opt_LOANS) { pr("Loans are not enabled.\n"); return RET_FAIL; } if (!snxtitem(&ni, EF_LOAN, "*", NULL)) return RET_SYN; (void)time(&now); pr("\n"); pr(" -= Empire Financial Status Report =-\n"); pr(" "); prdate(); pr("Loan From To Rate Dur Paid Total\n"); while (nxtitem(&ni, &loan)) { if (loan.l_status != LS_SIGNED) continue; pr(" %-2d (%3d) %-8.8s (%3d) %-8.8s ", ni.cur, loan.l_loner, cname(loan.l_loner), loan.l_lonee, cname(loan.l_lonee)); pr("%3d%% %3d %5d %7.0f", loan.l_irate, loan.l_ldur, loan.l_amtpaid, ceil(loan_owed(&loan, now))); if (now > loan.l_duedate) pr(" (in arrears)\n"); else pr("\n"); } pr("\n"); return RET_OK; }
static void starv_units(char *range) { struct nstr_item ni; struct lndstr land; int nunit = 0; int s; if (!snxtitem(&ni, EF_LAND, range, NULL)) return; while (nxtitem(&ni, &land)) { if (!player->owner || !land.lnd_own) continue; s = famine_victims(land.lnd_item, etu_per_update); if (s == 0) continue; if (nunit++ == 0) unit_hdr(); if (player->god) pr("%3d ", land.lnd_own); pr("%5d ", land.lnd_uid); pr("%-16.16s ", lchr[(int)land.lnd_type].l_name); starv_people(land.lnd_item, s); } if (nunit == 0) { if (range) pr("%s: No unit(s)\n", range); else pr("%s: No unit(s)\n", ""); return; } else pr("%d unit%s\n", nunit, splur(nunit)); return; }
static void starv_ships(char *range) { struct nstr_item ni; struct shpstr ship; int nship = 0; int s; if (!snxtitem(&ni, EF_SHIP, range, NULL)) return; while (nxtitem(&ni, &ship)) { if (!player->owner || !ship.shp_own) continue; s = famine_victims(ship.shp_item, etu_per_update); if (s == 0) continue; if (nship++ == 0) ship_hdr(); if (player->god) pr("%3d ", ship.shp_own); pr("%5d ", ship.shp_uid); pr("%-16.16s ", mchr[(int)ship.shp_type].m_name); starv_people(ship.shp_item, s); } if (nship == 0) { if (range) pr("%s: No ship(s)\n", range); else pr("%s: No ship(s)\n", ""); return; } else pr("%d ship%s\n", nship, splur(nship)); return; }
int pdump(void) { int nplanes; struct nstr_item np; struct plnstr plane; struct nukstr nuke; int field[128]; struct natstr *natp; int n, i; time_t now; if (!snxtitem(&np, EF_PLANE, player->argp[1], NULL)) return RET_SYN; prdate(); if (!player->argp[2]) { for (n = 1; n <= 32; n++) field[n - 1] = n; field[n - 1] = 0; } else { n = 2; i = 0; while (player->argp[n]) { if (!strcmp("type", player->argp[n])) { field[i++] = 1; } else if (!strcmp("x", player->argp[n])) { field[i++] = 2; } else if (!strcmp("y", player->argp[n])) { field[i++] = 3; } else if (!strcmp("wing", player->argp[n])) { field[i++] = 4; } else if (!strcmp("eff", player->argp[n])) { field[i++] = 5; } else if (!strcmp("mob", player->argp[n])) { field[i++] = 6; } else if (!strcmp("tech", player->argp[n])) { field[i++] = 7; } else if (!strcmp("att", player->argp[n])) { field[i++] = 8; } else if (!strcmp("def", player->argp[n])) { field[i++] = 9; } else if (!strcmp("acc", player->argp[n])) { field[i++] = 10; } else if (!strcmp("react", player->argp[n])) { field[i++] = 11; } else if (!strcmp("range", player->argp[n])) { field[i++] = 12; } else if (!strcmp("load", player->argp[n])) { field[i++] = 13; } else if (!strcmp("fuel", player->argp[n])) { field[i++] = 14; } else if (!strcmp("hard", player->argp[n])) { field[i++] = 15; } else if (!strcmp("ship", player->argp[n])) { field[i++] = 16; } else if (!strcmp("land", player->argp[n])) { field[i++] = 17; } else if (!strcmp("laun", player->argp[n])) { field[i++] = 18; } else if (!strcmp("orb", player->argp[n])) { field[i++] = 19; } else if (!strcmp("nuke", player->argp[n])) { field[i++] = 20; } else if (!strcmp("grd", player->argp[n])) { field[i++] = 21; } else { pr("Unrecognized field %s\n", player->argp[n]); } if (n++ > 100) { pr("Too many fields\n"); return RET_FAIL; } } field[i] = 0; } if (player->god) pr(" "); time(&now); pr("DUMP PLANES %ld\n", (long)now); if (player->god) pr("own "); pr("id"); n = 0; while (field[n]) { switch (field[n]) { case 1: pr(" type"); break; case 2: pr(" x"); break; case 3: pr(" y"); break; case 4: pr(" wing"); break; case 5: pr(" eff"); break; case 6: pr(" mob"); break; case 7: pr(" tech"); break; case 8: pr(" att"); break; case 9: pr(" def"); break; case 10: pr(" acc"); break; case 11: pr(" react"); break; case 12: pr(" range"); break; case 13: pr(" load"); break; case 14: pr(" fuel"); break; case 15: pr(" hard"); break; case 16: pr(" ship"); break; case 17: pr(" land"); break; case 18: pr(" laun"); break; case 19: pr(" orb"); break; case 20: pr(" nuke"); break; case 21: pr(" grd"); break; } n++; } pr("\n"); nplanes = 0; natp = getnatp(player->cnum); while (nxtitem(&np, &plane)) { if (!player->owner || plane.pln_own == 0) continue; nplanes++; if (player->god) pr("%d ", plane.pln_own); pr("%d", np.cur); n = 0; while (field[n]) { switch (field[n++]) { case 1: pr(" %.4s", plchr[(int)plane.pln_type].pl_name); break; case 2: pr(" %d", xrel(natp, plane.pln_x)); break; case 3: pr(" %d", yrel(natp, plane.pln_y)); break; case 4: pr(" %c", plane.pln_wing ? plane.pln_wing : '~'); break; case 5: pr(" %d", plane.pln_effic); break; case 6: pr(" %d", plane.pln_mobil); break; case 7: pr(" %d", plane.pln_tech); break; case 8: pr(" %d", pln_att(&plane)); break; case 9: pr(" %d", pln_def(&plane)); break; case 10: pr(" %d", pln_acc(&plane)); break; case 11: pr(" %d", plane.pln_range); break; case 12: pr(" %d", pln_range_max(&plane)); break; case 13: pr(" %d", pln_load(&plane)); break; case 14: pr(" %d", plchr[(int)plane.pln_type].pl_fuel); break; case 15: pr(" %d", plane.pln_harden); break; case 16: pr(" %d", plane.pln_ship); break; case 17: pr(" %d", plane.pln_land); break; case 18: pr(pln_is_in_orbit(&plane) ? " Y" : " N"); break; case 19: pr(pln_is_in_orbit(&plane) && (plane.pln_flags & PLN_SYNCHRONOUS) ? " Y" : " N"); break; case 20: if (getnuke(nuk_on_plane(&plane), &nuke)) { pr(" %.5s", nchr[nuke.nuk_type].n_name); break; } else pr(" N/A"); break; case 21: pr(" %c", plane.pln_flags & PLN_AIRBURST ? 'A' : 'G'); break; } } pr("\n"); } if (nplanes == 0) { if (player->argp[1]) pr("%s: No plane(s)\n", player->argp[1]); else pr("%s: No plane(s)\n", ""); return RET_FAIL; } else pr("%d plane%s\n", nplanes, splur(nplanes)); return RET_OK; }
/* * Describe an item up for sale. "tgp" is a union containing * the details of the generic item. * Return 1 on success, 0 on error */ int trade_desc(struct empobj *tgp) { i_type it; struct sctstr sect; struct nukstr *np; struct shpstr *sp; struct plnstr *pp; struct lndstr *lp; struct nstr_item ni; struct plnstr plane; struct lndstr land; struct nukstr nuke; switch (tgp->ef_type) { case EF_NUKE: np = (struct nukstr *)tgp; pr("(%3d) tech %d %d%% %s #%d", np->nuk_own, np->nuk_tech, np->nuk_effic, nchr[(int)np->nuk_type].n_name, np->nuk_uid); break; case EF_SHIP: sp = (struct shpstr *)tgp; pr("(%3d) tech %d %d%% %s [", sp->shp_own, sp->shp_tech, sp->shp_effic, prship(sp)); for (it = I_NONE + 1; it <= I_MAX; ++it) { if (sp->shp_item[it]) pr("%c:%d ", ichr[it].i_mnem, sp->shp_item[it]); } pr("] #%d", sp->shp_uid); snxtitem_cargo(&ni, EF_PLANE, EF_SHIP, sp->shp_uid); while (nxtitem(&ni, &plane)) { pr("\n\t\t\t\t tech %3d %3d%% %s #%d", plane.pln_tech, plane.pln_effic, plchr[(int)plane.pln_type].pl_name, plane.pln_uid); if (getnuke(nuk_on_plane(&plane), &nuke)) pr("(%s)", nchr[nuke.nuk_type].n_name); } snxtitem_cargo(&ni, EF_LAND, EF_SHIP, sp->shp_uid); while (nxtitem(&ni, &land)) { pr("\n\t\t\t\t tech %3d %3d%% %s #%d", land.lnd_tech, land.lnd_effic, lchr[(int)land.lnd_type].l_name, land.lnd_uid); if (pln_first_on_land(&land) >= 0) { snxtitem_cargo(&ni, EF_PLANE, EF_LAND, land.lnd_uid); while (nxtitem(&ni, &plane)) { pr("\n\t\t\t\t tech %3d %3d%% %s #%d", plane.pln_tech, plane.pln_effic, plchr[(int)plane.pln_type].pl_name, plane.pln_uid); if (getnuke(nuk_on_plane(&plane), &nuke)) pr("(%s)", nchr[nuke.nuk_type].n_name); } } } getsect(sp->shp_x, sp->shp_y, §); if (sect.sct_type != SCT_WATER) pr(" in a %s %s", cname(sect.sct_own), dchr[sect.sct_type].d_name); else pr(" at sea"); break; case EF_LAND: lp = (struct lndstr *)tgp; pr("(%3d) tech %d %d%% %s [", lp->lnd_own, lp->lnd_tech, lp->lnd_effic, lchr[(int)lp->lnd_type].l_name); for (it = I_NONE + 1; it <= I_MAX; ++it) { if (lp->lnd_item[it]) pr("%c:%d ", ichr[it].i_mnem, lp->lnd_item[it]); } pr("] #%d", lp->lnd_uid); break; case EF_PLANE: pp = (struct plnstr *)tgp; pr("(%3d) tech %d %d%% %s #%d", pp->pln_own, pp->pln_tech, pp->pln_effic, plchr[(int)pp->pln_type].pl_name, pp->pln_uid); if (getnuke(nuk_on_plane(pp), &nuke)) pr("(%s)", nchr[nuke.nuk_type].n_name); break; default: pr("flaky unit type %d", tgp->uid); break; } return 1; }
int work(void) { int nunits; struct nstr_item ni; struct sctstr sect; struct lndstr land; int work_amt, eff_amt, w; char *p; char buf[1024]; double cost; struct natstr *natp = getnatp(player->cnum); if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL)) return RET_SYN; p = getstarg(player->argp[2], "Amount: ", buf); if (!p || !*p) return RET_SYN; work_amt = atoi(p); if ((work_amt < 0) || (work_amt > land_mob_max)) { pr("Mobility used must be from 0 to %d\n", land_mob_max); return RET_FAIL; } nunits = 0; while (nxtitem(&ni, &land)) { if (!player->owner || land.lnd_own == 0) continue; if (!(lchr[(int)land.lnd_type].l_flags & L_ENGINEER)) continue; if (land.lnd_mobil <= 0) { pr("%s has no mobility!\n", prland(&land)); continue; } getsect(land.lnd_x, land.lnd_y, §); if (sect.sct_effic >= 100 && sect.sct_type == sect.sct_newtype) { pr("Nothing to do for %s in %s\n", prland(&land), xyas(sect.sct_x, sect.sct_y, player->cnum)); continue; } eff_amt = MIN(land.lnd_mobil, work_amt); w = (eff_amt * land.lnd_effic) / 600; if (w < 1) { pr("%s doesn't work enough to change efficiency (try increasing amount)\n", prland(&land)); continue; } cost = 0.0; w = buildeff(§, w, &cost); if (w == 0) { pr("%s can't change efficiency in %s\n", prland(&land), xyas(land.lnd_x, land.lnd_y, player->cnum)); continue; } if (player->dolcost + cost > natp->nat_money) { pr("You can't afford to work that much in %s!\n", xyas(land.lnd_x, land.lnd_y, player->cnum)); break; } player->dolcost += cost; land.lnd_mission = 0; land.lnd_mobil -= roundavg(w * 600.0 / land.lnd_effic); nunits++; pr("%s %s efficiency at %s to %d\n", prland(&land), sect.sct_type == sect.sct_newtype ? "raised" : "lowered", xyas(land.lnd_x, land.lnd_y, player->cnum), sect.sct_effic); putland(land.lnd_uid, &land); putsect(§); } if (nunits == 0) { if (player->argp[1]) pr("%s: No unit(s)\n", player->argp[1]); else pr("%s: No unit(s)\n", ""); return RET_FAIL; } else pr("%d unit%s\n", nunits, splur(nunits)); return RET_OK; }
int sona(void) { struct nstr_item ni, nit; struct sctstr sect; struct shpstr ship; struct shpstr targ; struct natstr *natp; struct mchrstr *mcp; struct mchrstr *tmcp; struct nstr_sect ns; int range; int visib, pingrange; int srange; int vrange; int dist; int x, y; int cx, cy; int changed = 0; int row; /* Where these are used are non-re-entrant, so we keep 'em around */ static char **rad = NULL; static char *radbuf = NULL; static signed char **vis = NULL; static signed char *visbuf = NULL; if (!snxtitem(&ni, EF_SHIP, player->argp[1], NULL)) return RET_SYN; if (!radbuf) radbuf = malloc(WORLD_Y * MAPWIDTH(1)); if (!visbuf) visbuf = malloc(WORLD_Y * MAPWIDTH(1)); if (!rad && radbuf) { rad = malloc(WORLD_Y * sizeof(char *)); if (rad) { for (x = 0; x < WORLD_Y; x++) { rad[x] = &radbuf[(WORLD_X + 1) * x]; } } } if (!vis && visbuf) { vis = malloc(WORLD_Y * sizeof(signed char *)); if (vis) { for (x = 0; x < WORLD_Y; x++) { vis[x] = &visbuf[(WORLD_X + 1) * x]; } } } if (!radbuf || !visbuf || !rad || !vis) { pr("Memory error, tell the deity.\n"); logerror("malloc failed in sona\n"); return RET_FAIL; } while (nxtitem(&ni, &ship)) { if (!player->owner) continue; mcp = &mchr[(int)ship.shp_type]; if (!(mcp->m_flags & M_SONAR)) continue; getsect(ship.shp_x, ship.shp_y, §); if (sect.sct_type != SCT_WATER) continue; range = (int)techfact(ship.shp_tech, mcp->m_vrnge); srange = MIN(7, 7 * range * ship.shp_effic / 200); pr("%s at %s efficiency %d%%, max range %d\n", prship(&ship), xyas(ship.shp_x, ship.shp_y, player->cnum), ship.shp_effic, srange); snxtsct_dist(&ns, ship.shp_x, ship.shp_y, srange); blankfill(radbuf, &ns.range, 1); while (nxtsct(&ns, §)) { if (player->owner || sect.sct_type == SCT_WATER) rad[ns.dy][ns.dx] = dchr[sect.sct_type].d_mnem; else { rad[ns.dy][ns.dx] = '?'; } } snxtsct_dist(&ns, ship.shp_x, ship.shp_y, srange); cx = deltx(&ns.range, ship.shp_x); cy = delty(&ns.range, ship.shp_y); while (nxtsct(&ns, §)) { if (!line_of_sight(rad, cx, cy, ns.dx, ns.dy)) { rad[ns.dy][ns.dx] = ' '; continue; } if (ship.shp_tech >= 310 && sect.sct_type == SCT_WATER) { if (sect.sct_mines) { pr("Sonar detects %d mines in %s!\n", sect.sct_mines, xyas(sect.sct_x, sect.sct_y, player->cnum)); rad[ns.dy][ns.dx] = 'X'; } } changed |= map_set(player->cnum, sect.sct_x, sect.sct_y, rad[ns.dy][ns.dx], 0); } memset(visbuf, 0, (WORLD_Y * (WORLD_X + 1))); snxtitem_dist(&nit, EF_SHIP, ship.shp_x, ship.shp_y, range); while (nxtitem(&nit, &targ)) { if (targ.shp_own == player->cnum || targ.shp_own == 0) continue; tmcp = &mchr[(int)targ.shp_type]; visib = shp_visib(&targ); pingrange = MIN(7, MAX(visib, 10) * range / 10); vrange = pingrange * ship.shp_effic / 200; dist = mapdist(targ.shp_x, targ.shp_y, ship.shp_x, ship.shp_y); pingrange = (MAX(pingrange, 2) * targ.shp_effic) / 100; if (dist > pingrange) continue; if (tmcp->m_flags & M_SONAR && targ.shp_own) { natp = getnatp(targ.shp_own); if (natp->nat_flags & NF_SONAR) wu(0, targ.shp_own, "Sonar ping from %s detected by %s!\n", xyas(ship.shp_x, ship.shp_y, targ.shp_own), prship(&targ)); if (targ.shp_rflags & RET_SONARED) retreat_ship(&targ, targ.shp_own, 's'); } if (dist > vrange) continue; x = deltx(&ns.range, (int)targ.shp_x); y = delty(&ns.range, (int)targ.shp_y); if (rad[y][x] != dchr[SCT_WATER].d_mnem && rad[y][x] != 'X') continue; if (tmcp->m_flags & M_SUB && relations_with(targ.shp_own, player->cnum) < FRIENDLY) { if (mcp->m_vrnge + visib < 8) pr("Sonar detects sub #%d @ %s\n", targ.shp_uid, xyas(targ.shp_x, targ.shp_y, player->cnum)); else if (mcp->m_vrnge + visib < 10) pr("Sonar detects %s @ %s\n", prship(&targ), xyas(targ.shp_x, targ.shp_y, player->cnum)); else pr("Sonar detects %s %s @ %s\n", cname(targ.shp_own), prship(&targ), xyas(targ.shp_x, targ.shp_y, player->cnum)); } else pr("Sonar detects %s %s @ %s\n", cname(targ.shp_own), prship(&targ), xyas(targ.shp_x, targ.shp_y, player->cnum)); if (visib > vis[y][x]) { vis[y][x] = visib; /* &~0x20 makes it a cap letter */ rad[y][x] = (*mchr[(int)targ.shp_type].m_name) & ~0x20; } } if (!player->argp[2]) { rad[cy][cx] = '0'; for (row = 0; row < ns.range.height; row++) if (!blankrow(rad[row])) pr("%s\n", rad[row]); } pr("\n"); } if (changed) writemap(player->cnum); return RET_OK; }
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; }
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; }
int load(void) { int noisy; int load_unload; int type; struct nstr_item nbst; struct ichrstr *ich; int nships; struct sctstr sect; struct shpstr ship; int retval; char *p; char buf[1024]; p = getstarg(player->argp[1], "What commodity (or 'plane' or 'land')? ", buf); if (!p || !*p) return RET_SYN; if (!strncmp(p, "plane", 5)) type = EF_PLANE; else if (!strncmp(p, "land", 4)) type = EF_LAND; else if (NULL != (ich = item_by_name(p))) type = EF_SECTOR; else { pr("Can't load '%s'\n", p); return RET_SYN; } p = getstarg(player->argp[2], "Ship(s): ", buf); if (!p || !*p) return RET_SYN; noisy = isdigit(*p); if (!snxtitem(&nbst, EF_SHIP, p, NULL)) return RET_SYN; load_unload = **player->argp == 'l' ? LOAD : UNLOAD; nships = 0; while (nxtitem(&nbst, &ship)) { if (!ship.shp_own) continue; if (!player->owner) { if (load_unload == UNLOAD || !noisy) continue; if (relations_with(ship.shp_own, player->cnum) < FRIENDLY) continue; } if (!getsect(ship.shp_x, ship.shp_y, §)) /* XXX */ continue; if (!sect.sct_own) continue; if (!player->owner) { if (ship.shp_own != player->cnum) continue; if (!sect_has_dock(§)) continue; if (load_unload == LOAD) { if (noisy) pr("You don't own %s\n", xyas(sect.sct_x, sect.sct_y, player->cnum)); continue; } } if (!sect_has_dock(§)) { if (noisy) pr("Sector %s is not a harbor or canal.\n", xyas(sect.sct_x, sect.sct_y, player->cnum)); continue; } if (load_unload == UNLOAD && !player->owner && relations_with(sect.sct_own, player->cnum) < FRIENDLY) { if (noisy) pr("You can't unload into an unfriendly %s\n", dchr[sect.sct_type].d_name); continue; } if (sect.sct_effic < 2) { if (noisy) pr("The %s at %s is not 2%% efficient yet.\n", dchr[sect.sct_type].d_name, xyas(sect.sct_x, sect.sct_y, player->cnum)); continue; } if (opt_MARKET) { if (ontradingblock(EF_SHIP, &ship)) { pr("You cannot load/unload an item on the trading block!\n"); continue; } } switch (type) { case EF_PLANE: retval = load_plane_ship(§, &ship, noisy, load_unload, &nships); if (retval != 0) return retval; break; case EF_LAND: retval = load_land_ship(§, &ship, noisy, load_unload, &nships); if (retval != 0) return retval; break; case EF_SECTOR: retval = load_comm_ship(§, &ship, ich, load_unload, &nships); if (retval != 0) return retval; } /* load/unload plague */ if (sect.sct_pstage == PLG_INFECT && ship.shp_pstage == PLG_HEALTHY) ship.shp_pstage = PLG_EXPOSED; if (ship.shp_pstage == PLG_INFECT && sect.sct_pstage == PLG_HEALTHY) sect.sct_pstage = PLG_EXPOSED; putsect(§); putship(ship.shp_uid, &ship); } if (!nships) pr("No ships affected\n"); else pr("%d ship%s %sloaded\n", nships, splur(nships), load_unload == UNLOAD ? "un" : ""); return RET_OK; }