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; }
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 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; }
static void starv_sects(char *range) { struct nstr_sect nstr; struct sctstr sect; int nsect = 0; int s, save; if (!snxtsct(&nstr, range)) return; while (nxtsct(&nstr, §)) { if (!player->owner) continue; if (sect.sct_type == SCT_SANCT) continue; /* * Check for starvation. Suppress complaints about tiny * population without food by adding 1f just for the check. * That's okay because growfood() will grow at least that much * anyway. */ save = sect.sct_item[I_FOOD]; if (sect.sct_item[I_FOOD] == 0) sect.sct_item[I_FOOD] = 1; s = famine_victims(sect.sct_item, etu_per_update); sect.sct_item[I_FOOD] = save; if (s == 0) continue; if (nsect++ == 0) sect_hdr(); if (player->god) pr("%3d ", sect.sct_own); prxy("%4d,%-4d", nstr.x, nstr.y); pr(" %c", dchr[sect.sct_type].d_mnem); pr(" %c", sect.sct_own != sect.sct_oldown ? '*' : ' '); if (sect.sct_newtype != sect.sct_type) pr("%c", dchr[sect.sct_newtype].d_mnem); else pr(" "); pr("%4d%%", sect.sct_effic); starv_people(sect.sct_item, s); } if (nsect == 0) { if (player->argp[1]) pr("%s: No sector(s)\n", player->argp[1]); else pr("%s: No sector(s)\n", ""); return; } else pr("%d sector%s\n", nsect, splur(nsect)); return; }
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; }
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; }
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 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 mobq(void) { struct shpstr ship; char *cp, *oldmq; int good, mobquota, count = 0; struct nstr_item nstr; char buf[1024]; if (!opt_SAIL) { pr("The SAIL option is not enabled, so this command is not valid.\n"); return RET_FAIL; } if (!snxtitem(&nstr, EF_SHIP, player->argp[1], NULL)) return RET_SYN; oldmq = player->argp[2]; if (oldmq) { good = sscanf(oldmq, "%d", &mobquota); if (!good) return RET_SYN; if (mobquota < 0 || mobquota > ship_mob_max) { pr("Bad mobility quota value %d.\n", mobquota); return RET_SYN; } if (mobquota + (ship_mob_scale * (float)etu_per_update) > ship_mob_max) { pr("warning: %d less than optimal\n", mobquota); } } while (nxtitem(&nstr, &ship)) { if (!player->owner) continue; if (!oldmq) pr("Ship #%d at %s. Old value %d.\n", ship.shp_uid, xyas(ship.shp_x, ship.shp_y, player->cnum), ship.shp_mobquota); cp = getstarg(player->argp[2], "mobility quota? ", buf); if (!cp) return RET_SYN; if (!check_ship_ok(&ship)) continue; good = sscanf(cp, "%d", &mobquota); if (!good) { pr("Huh?\n"); continue; } if (!oldmq) { if (mobquota < 0 || mobquota > ship_mob_max) { pr("Bad mobility quota value %d.\n", mobquota); continue; } if (mobquota + (ship_mob_scale * (float)etu_per_update) > ship_mob_max) { pr("warning: %d less than optimal\n", mobquota); } } ship.shp_mobquota = mobquota; count++; putship(ship.shp_uid, &ship); } if (count == 0) { 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", count, splur(count)); return RET_OK; }
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; }
/* * survey type <sarg> ?cond * */ int surv(void) { int nsect; struct nstr_sect nstr; int y; struct valstr val; struct natstr *np; struct sctstr sect; struct range range; char *ptr; struct nscstr cond[NS_NCOND]; int ncond; int i; char buf[1024]; /* Note this is not re-entrant anyway, so we keep the buffers around */ static char *mapbuf = NULL; static char **map = NULL; nsect = 0; ptr = getstarg(player->argp[1], "commodity or variable? ", buf); if (!ptr || !*ptr) return RET_SYN; ptr = nstr_comp_val(ptr, &val, EF_SECTOR); if (!ptr) return RET_SYN; if (val.val_cat != NSC_OFF || nstr_promote(val.val_type) != NSC_LONG) { pr("Can't survey this\n"); return RET_SYN; } for (; isspace(*ptr); ++ptr) ; if (*ptr) return RET_SYN; if (!snxtsct(&nstr, player->argp[2])) return RET_SYN; if (!mapbuf) mapbuf = malloc(WORLD_Y * MAPWIDTH(1)); if (!map) { map = malloc(WORLD_Y * sizeof(char *)); if (map && mapbuf) { for (i = 0; i < WORLD_Y; i++) map[i] = &mapbuf[MAPWIDTH(1) * i]; } else if (map) { free(map); map = NULL; } } if (!mapbuf || !map) { pr("Memory error, tell the deity.\n"); logerror("malloc failed in sect\n"); return RET_FAIL; } ncond = nstr.ncond; memcpy(cond, nstr.cond, sizeof(struct nscstr) * ncond); nstr.ncond = 0; np = getnatp(player->cnum); xyrelrange(np, &nstr.range, &range); border(&range, " ", ""); blankfill(mapbuf, &nstr.range, 1); while (nxtsct(&nstr, §)) { if (!player->owner) continue; ptr = &map[nstr.dy][nstr.dx]; if (nstr_exec(cond, ncond, §)) { ++nsect; *ptr = 0x80 | code_char(val, §); } else { *ptr = dchr[sect.sct_type].d_mnem; } } for (y = nstr.range.ly, i = 0; i < nstr.range.height; y++, i++) { int yval; yval = yrel(np, y); pr("%4d %s %4d\n", yval, map[i], yval); if (y >= WORLD_Y) y -= WORLD_Y; } border(&range, " ", ""); if (nsect > 0) pr("\n%d sector%s.\n", nsect, splur(nsect)); return RET_OK; }
int lload(void) { int noisy; int load_unload; int type; struct nstr_item nbst; struct ichrstr *ich; int nunits; struct sctstr sect; struct lndstr land; 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], "Unit(s): ", buf); if (!p || !*p) return RET_SYN; noisy = isdigit(*p); if (!snxtitem(&nbst, EF_LAND, p, NULL)) return RET_SYN; load_unload = player->argp[0][1] == 'l' ? LOAD : UNLOAD; nunits = 0; while (nxtitem(&nbst, &land)) { if (land.lnd_own == 0) continue; if (!player->owner) { if (load_unload == UNLOAD || !noisy) continue; if (relations_with(land.lnd_own, player->cnum) != ALLIED) continue; } if (!getsect(land.lnd_x, land.lnd_y, §)) /* XXX */ continue; if (!player->owner) { if (land.lnd_own != player->cnum) continue; if (load_unload == LOAD) { if (noisy) pr("Sector %s is not yours.\n", xyas(sect.sct_x, sect.sct_y, player->cnum)); continue; } if (relations_with(sect.sct_own, player->cnum) != ALLIED) { pr("Sector %s is not yours.\n", xyas(sect.sct_x, sect.sct_y, player->cnum)); continue; } } if (opt_MARKET) { if (ontradingblock(EF_LAND, &land)) { pr("You cannot load/unload an item on the trading block!\n"); continue; } } switch (type) { case EF_LAND: retval = load_land_land(§, &land, noisy, load_unload, &nunits); if (retval != 0) return retval; break; case EF_PLANE: retval = load_plane_land(§, &land, noisy, load_unload, &nunits); if (retval != 0) return retval; break; case EF_SECTOR: retval = load_comm_land(§, &land, ich, load_unload, &nunits); if (retval != 0) return retval; } /* load/unload plague */ if (sect.sct_pstage == PLG_INFECT && land.lnd_pstage == PLG_HEALTHY) land.lnd_pstage = PLG_EXPOSED; if (land.lnd_pstage == PLG_INFECT && sect.sct_pstage == PLG_HEALTHY) sect.sct_pstage = PLG_EXPOSED; putsect(§); putland(land.lnd_uid, &land); } if (nunits == 0) pr("No units affected\n"); else pr("%d unit%s %sloaded\n", nunits, splur(nunits), load_unload == UNLOAD ? "un" : ""); return RET_OK; }
int news(void) { struct natstr *natp; time_t now; int page; time_t then; time_t delta; struct nwsstr nws; struct nstr_item nstr; int page_has_news[N_MAX_PAGE + 1]; int there_is_news = 0; short sectors_taken[MAXNOC][MAXNOC]; short sectors_delta; short max_delta = -1; short abs_delta; short k; int sectors_were_taken = 0; natid i, j; char num[128]; char *verb; if (!snxtitem(&nstr, EF_NEWS, "*", NULL)) return RET_SYN; memset(page_has_news, 0, sizeof(page_has_news)); memset(sectors_taken, 0, sizeof(sectors_taken)); (void)time(&now); natp = getnatp(player->cnum); then = natp->nat_newstim; if (player->argp[1]) { /* * We want to hide events before contact. Proper solution * would be to timestamp the contact. Cheesy approximation: * disable old news. */ if (opt_HIDDEN && !player->god) { pr("Sorry, argument doesn't work with HIDDEN enabled\n"); return RET_FAIL; } delta = days(atoi(player->argp[1])); then = now - delta; } natp->nat_newstim = now; head(); pr("\nThe details of Empire news since %s", ctime(&then)); while (nxtitem(&nstr, &nws)) { if (!nws.nws_vrb || CANT_HAPPEN(nws.nws_vrb > N_MAX_VERB)) continue; if (nws.nws_when < then) continue; if (opt_HIDDEN) { if (!player->god && !(getcontact(getnatp(player->cnum), nws.nws_ano) && getcontact(getnatp(player->cnum), nws.nws_vno))) continue; } ++page_has_news[rpt[(int)nws.nws_vrb].r_newspage]; ++there_is_news; } for (page = 1; page <= N_MAX_PAGE; page++) { if (!page_has_news[page]) continue; pr("\n\t === %s ===\n", page_headings[page].name); snxtitem_rewind(&nstr); while (nxtitem(&nstr, &nws)) { if (CANT_HAPPEN(nws.nws_vrb > N_MAX_VERB)) continue; if (rpt[(int)nws.nws_vrb].r_newspage != page) continue; if (nws.nws_when < then) continue; if (nws.nws_ntm == 0) nws.nws_ntm = 1; if (opt_HIDDEN) { if (!player->god && !(getcontact(getnatp(player->cnum), nws.nws_ano) && getcontact(getnatp(player->cnum), nws.nws_vno))) continue; } if (page == N_FRONT && (nws.nws_vrb == N_WON_SECT || nws.nws_vrb == N_AWON_SECT || nws.nws_vrb == N_PWON_SECT)) { sectors_taken[nws.nws_ano][nws.nws_vno] += nws.nws_ntm; sectors_were_taken += nws.nws_ntm; } preport(&nws); } } if (sectors_were_taken) { for (i = 0; i < MAXNOC; ++i) { for (j = 0; j < i; ++j) { sectors_delta = sectors_taken[i][j] - sectors_taken[j][i]; if (max_delta < abs(sectors_delta)) max_delta = abs(sectors_delta); } } pr("\n\t === The Bottom Line ==\n"); for (k = max_delta; k > 0; --k) { for (i = 0; i < MAXNOC; ++i) { for (j = 0; j < i; ++j) { sectors_delta = sectors_taken[i][j] - sectors_taken[j][i]; abs_delta = abs(sectors_delta); if (abs_delta != k) continue; if (abs_delta == 1) verb = "stole"; else if (abs_delta < 4) verb = "took"; else if (abs_delta < 8) verb = "captured"; else verb = "seized"; if (sectors_delta > 0) { numstr(num, abs_delta); pr("%s %s %s sector%s from %s\n", cname(i), verb, num, splur(sectors_delta), cname(j)); } else if (sectors_delta < 0) { numstr(num, abs_delta); pr("%s %s %s sector%s from %s\n", cname(j), verb, num, splur(-sectors_delta), cname(i)); } } } } } if (!there_is_news) pr("\nNo news at the moment...\n"); return 0; }
int payo(void) { struct sctstr sect; int nships; struct nstr_item ni; struct shpstr ship; struct mchrstr *mp; int dist; float cash = 0.0; if (!snxtitem(&ni, EF_SHIP, player->argp[1], NULL)) return RET_SYN; nships = 0; while (nxtitem(&ni, &ship)) { if (!player->owner || ship.shp_own == 0) continue; mp = &mchr[(int)ship.shp_type]; if (!(mp->m_flags & M_TRADE)) continue; if (nships++ == 0) { if (player->god) pr("own "); pr("shp# ship type orig x,y x,y dist $$\n"); } if (player->god) pr("%3d ", ship.shp_own); pr("%4d ", ni.cur); pr("%-16.16s ", mchr[(int)ship.shp_type].m_name); if (ship.shp_own != ship.shp_orig_own && !player->god) { /* Don't disclose construction site to pirates! */ pr(" ? "); prxy("%4d,%-4d ", ship.shp_x, ship.shp_y); pr(" ? $ ?\n"); continue; } prxy("%4d,%-4d ", ship.shp_orig_x, ship.shp_orig_y); prxy("%4d,%-4d ", ship.shp_x, ship.shp_y); getsect(ship.shp_x, ship.shp_y, §); dist = mapdist(ship.shp_x, ship.shp_y, ship.shp_orig_x, ship.shp_orig_y); pr("%4d ", dist); if (dist < trade_1_dist) cash = 0; else if (dist < trade_2_dist) cash = 1.0 + trade_1 * dist; else if (dist < trade_3_dist) cash = 1.0 + trade_2 * dist; else cash = 1.0 + trade_3 * dist; cash *= mp->m_cost; cash *= ship.shp_effic / 100.0; if (sect.sct_own && (sect.sct_own != ship.shp_own)) cash *= (1.0 + trade_ally_bonus); pr("$%6.2f\n", cash); } if (nships == 0) { 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; }
int foll(void) { struct shpstr ship; char *cp; int good, leader, count = 0; coord x, y; struct nstr_item nstr; char buf[1024]; if (!opt_SAIL) { pr("The SAIL option is not enabled, so this command is not valid.\n"); return RET_FAIL; } if (!snxtitem(&nstr, EF_SHIP, player->argp[1], NULL)) return RET_SYN; cp = getstarg(player->argp[2], "leader? ", buf); if (!cp) cp = ""; good = sscanf(cp, "%d", &leader); if (!good) return RET_SYN; getship(leader, &ship); if (relations_with(ship.shp_own, player->cnum) < FRIENDLY) { pr("That ship won't let you follow.\n"); return RET_FAIL; } x = ship.shp_x; y = ship.shp_y; while (nxtitem(&nstr, &ship)) { if (!player->owner) continue; if (ship.shp_x != x || ship.shp_y != y) { pr("Ship #%d not in same sector as #%d\n", ship.shp_uid, leader); continue; } if (ship.shp_uid == leader) { pr("Ship #%d can't follow itself!\n", leader); continue; } if ((ship.shp_autonav & AN_AUTONAV) && !(ship.shp_autonav & AN_STANDBY)) { pr("Ship #%d has other orders!\n", ship.shp_uid); continue; } count++; ship.shp_mission = 0; *ship.shp_path = 'f'; ship.shp_path[1] = 0; ship.shp_follow = leader; pr("Ship #%d follows #%d.\n", ship.shp_uid, leader); putship(ship.shp_uid, &ship); } if (count == 0) { 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", count, splur(count)); return RET_OK; }
int sorde(void) { int nships = 0; int len, updates; double c; 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 x,y start end " " len eta\n"); } nships++; if (player->god) pr("%3d ", ship.shp_own); pr("%4d", nb.cur); pr(" %-16.16s", mchr[(int)ship.shp_type].m_name); prxy(" %4d,%-4d", ship.shp_x, ship.shp_y); if (ship.shp_autonav & AN_AUTONAV) { /* Destination 1 */ prxy(" %4d,%-4d", ship.shp_destx[1], ship.shp_desty[1]); /* Destination 2 */ if ((ship.shp_destx[1] != ship.shp_destx[0]) || (ship.shp_desty[1] != ship.shp_desty[0])) { prxy(" %4d,%-4d", ship.shp_destx[0], ship.shp_desty[0]); } else pr(" "); if (ship.shp_autonav & AN_STANDBY) pr(" suspended"); else if (ship.shp_autonav & AN_LOADING) pr(" loading"); else { /* ETA calculation */ c = path_find(ship.shp_x, ship.shp_y, ship.shp_destx[0], ship.shp_desty[0], ship.shp_own, MOB_SAIL); if (c < 0) pr(" no route possible"); else if (c == 0) pr(" has arrived"); else { /* distance to destination */ len = (int)c; updates = eta_calc(&ship, len); pr(" %3d %4d", len, updates); } } 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; }
int cuto(void) { struct sctstr sect; int nsect; int n; struct nstr_sect nstr; char dirstr[12]; if (!snxtsct(&nstr, player->argp[1])) return RET_SYN; prdate(); (void)strcpy(dirstr, ". $"); for (n = 1; n <= 6; n++) dirstr[n] = dirch[n]; nsect = 0; while (nxtsct(&nstr, §)) { if (!player->owner) continue; if (nsect++ == 0) { pr("DELIVERY CUTOFF LEVELS\n"); if (player->god) pr("own"); pr(" sect cmufsgpidbolhr civ mil uw food sh gun pet irn dst bar oil lcm hcm rad\n"); } if (player->god) pr("%3d", sect.sct_own); prxy("%3d,%-3d", nstr.x, nstr.y); /* FIXME too narrow */ pr(" %c ", dchr[sect.sct_type].d_mnem); pr("%c", dirstr[sect.sct_del[I_CIVIL] & 0x7]); pr("%c", dirstr[sect.sct_del[I_MILIT] & 0x7]); pr("%c", dirstr[sect.sct_del[I_UW] & 0x7]); pr("%c", dirstr[sect.sct_del[I_FOOD] & 0x7]); pr("%c", dirstr[sect.sct_del[I_SHELL] & 0x7]); pr("%c", dirstr[sect.sct_del[I_GUN] & 0x7]); pr("%c", dirstr[sect.sct_del[I_PETROL] & 0x7]); pr("%c", dirstr[sect.sct_del[I_IRON] & 0x7]); pr("%c", dirstr[sect.sct_del[I_DUST] & 0x7]); pr("%c", dirstr[sect.sct_del[I_BAR] & 0x7]); pr("%c", dirstr[sect.sct_del[I_OIL] & 0x7]); pr("%c", dirstr[sect.sct_del[I_LCM] & 0x7]); pr("%c", dirstr[sect.sct_del[I_HCM] & 0x7]); pr("%c", dirstr[sect.sct_del[I_RAD] & 0x7]); pr("%4d", sect.sct_del[I_CIVIL] & ~0x7); pr("%4d", sect.sct_del[I_MILIT] & ~0x7); pr("%4d", sect.sct_del[I_UW] & ~0x7); pr("%4d", sect.sct_del[I_FOOD] & ~0x7); pr("%4d", sect.sct_del[I_SHELL] & ~0x7); pr("%4d", sect.sct_del[I_GUN] & ~0x7); pr("%4d", sect.sct_del[I_PETROL] & ~0x7); pr("%4d", sect.sct_del[I_IRON] & ~0x7); pr("%4d", sect.sct_del[I_DUST] & ~0x7); pr("%4d", sect.sct_del[I_BAR] & ~0x7); pr("%4d", sect.sct_del[I_OIL] & ~0x7); pr("%4d", sect.sct_del[I_LCM] & ~0x7); pr("%4d", sect.sct_del[I_HCM] & ~0x7); pr("%4d", sect.sct_del[I_RAD] & ~0x7); pr("\n"); } if (nsect == 0) { if (player->argp[1]) pr("%s: No sector(s)\n", player->argp[1]); else pr("%s: No sector(s)\n", ""); return RET_FAIL; } else pr("%d sector%s\n", nsect, splur(nsect)); return RET_OK; }
int newe(void) { struct natstr *natp; struct sctstr sect; struct nstr_sect nstr; double work, lcms, hcms; int nsect; int civs = 0; int uws = 0; int bwork; int twork; int type; int eff; int maxpop; if (!snxtsct(&nstr, player->argp[1])) return RET_SYN; player->simulation = 1; prdate(); nsect = 0; while (nxtsct(&nstr, §)) { if (!player->owner) continue; if (!sect.sct_off) { civs = (1.0 + obrate * etu_per_update) * sect.sct_item[I_CIVIL]; uws = (1.0 + uwbrate * etu_per_update) * sect.sct_item[I_UW]; natp = getnatp(sect.sct_own); maxpop = max_pop(natp->nat_level[NAT_RLEV], §); work = new_work(§, total_work(sect.sct_work, etu_per_update, civs, sect.sct_item[I_MILIT], uws, maxpop)); bwork = work / 2; type = sect.sct_type; eff = sect.sct_effic; if (sect.sct_newtype != type) { twork = (eff + 3) / 4; if (twork > bwork) { twork = bwork; } bwork -= twork; eff -= twork * 4; if (eff <= 0) { type = sect.sct_newtype; eff = 0; } twork = 100 - eff; if (twork > bwork) { twork = bwork; } if (dchr[type].d_lcms > 0) { lcms = sect.sct_item[I_LCM]; lcms = (int)(lcms / dchr[type].d_lcms); if (twork > lcms) twork = lcms; } if (dchr[type].d_hcms > 0) { hcms = sect.sct_item[I_HCM]; hcms = (int)(hcms / dchr[type].d_hcms); if (twork > hcms) twork = hcms; } eff += twork; } else if (eff < 100) { twork = 100 - eff; if (twork > bwork) { twork = bwork; } if (dchr[type].d_lcms > 0) { lcms = sect.sct_item[I_LCM]; lcms = (int)(lcms / dchr[type].d_lcms); if (twork > lcms) twork = lcms; } if (dchr[type].d_hcms > 0) { hcms = sect.sct_item[I_HCM]; hcms = (int)(hcms / dchr[type].d_hcms); if (twork > hcms) twork = hcms; } eff += twork; } } else { eff = sect.sct_effic; type = sect.sct_type; } if (nsect++ == 0) { pr("EFFICIENCY SIMULATION\n"); pr(" sect des projected eff\n"); } prxy("%4d,%-4d", nstr.x, nstr.y); pr(" %c", dchr[type].d_mnem); pr(" %3d%%\n", eff); } player->simulation = 0; if (nsect == 0) { if (player->argp[1]) pr("%s: No sector(s)\n", player->argp[1]); else pr("%s: No sector(s)\n", ""); return RET_FAIL; } else pr("%d sector%s\n", nsect, splur(nsect)); return RET_OK; }
int sdump(void) { int nships; struct nstr_item ni; struct shpstr ship; int field[128]; struct natstr *np; int n, i, npln, nch, nxl; time_t now; if (!snxtitem(&ni, EF_SHIP, player->argp[1], NULL)) return RET_SYN; prdate(); if (!player->argp[2]) { for (n = 1; n <= 34; 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("flt", player->argp[n])) { field[i++] = 4; } else if (!strcmp("eff", player->argp[n])) { field[i++] = 5; } else if (!strcmp("civ", player->argp[n])) { field[i++] = 6; } else if (!strcmp("mil", player->argp[n])) { field[i++] = 7; } else if (!strcmp("uw", player->argp[n])) { field[i++] = 8; } else if (!strcmp("food", player->argp[n])) { field[i++] = 9; } else if (!strcmp("pln", player->argp[n])) { field[i++] = 10; } else if (!strcmp("he", player->argp[n])) { field[i++] = 11; } else if (!strcmp("xl", player->argp[n])) { field[i++] = 12; } else if (!strcmp("land", player->argp[n])) { field[i++] = 13; } else if (!strcmp("mob", player->argp[n])) { field[i++] = 14; } else if (!strcmp("fuel", player->argp[n])) { field[i++] = 15; } else if (!strcmp("tech", player->argp[n])) { field[i++] = 16; } else if (!strcmp("shell", player->argp[n])) { field[i++] = 17; } else if (!strcmp("gun", player->argp[n])) { field[i++] = 18; } else if (!strcmp("petrol", player->argp[n])) { field[i++] = 19; } else if (!strcmp("iron", player->argp[n])) { field[i++] = 20; } else if (!strcmp("dust", player->argp[n])) { field[i++] = 21; } else if (!strcmp("bar", player->argp[n])) { field[i++] = 22; } else if (!strcmp("oil", player->argp[n])) { field[i++] = 23; } else if (!strcmp("lcm", player->argp[n])) { field[i++] = 24; } else if (!strcmp("hcm", player->argp[n])) { field[i++] = 25; } else if (!strcmp("rad", player->argp[n])) { field[i++] = 26; } else if (!strcmp("def", player->argp[n])) { field[i++] = 27; } else if (!strcmp("spd", player->argp[n])) { field[i++] = 28; } else if (!strcmp("vis", player->argp[n])) { field[i++] = 29; } else if (!strcmp("rng", player->argp[n])) { field[i++] = 30; } else if (!strcmp("fir", player->argp[n])) { field[i++] = 31; } else if (!strcmp("origx", player->argp[n])) { field[i++] = 32; } else if (!strcmp("origy", player->argp[n])) { field[i++] = 33; } else if (!strcmp("name", player->argp[n])) { field[i++] = 34; } 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 SHIPS %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(" flt"); break; case 5: pr(" eff"); break; case 6: pr(" civ"); break; case 7: pr(" mil"); break; case 8: pr(" uw"); break; case 9: pr(" food"); break; case 10: pr(" pln"); break; case 11: pr(" he"); break; case 12: pr(" xl"); break; case 13: pr(" land"); break; case 14: pr(" mob"); break; case 15: pr(" fuel"); break; case 16: pr(" tech"); break; case 17: pr(" shell"); break; case 18: pr(" gun"); break; case 19: pr(" petrol"); break; case 20: pr(" iron"); break; case 21: pr(" dust"); break; case 22: pr(" bar"); break; case 23: pr(" oil"); break; case 24: pr(" lcm"); break; case 25: pr(" hcm"); break; case 26: pr(" rad"); break; case 27: pr(" def"); break; case 28: pr(" spd"); break; case 29: pr(" vis"); break; case 30: pr(" rng"); break; case 31: pr(" fir"); break; case 32: pr(" origx"); break; case 33: pr(" origy"); break; case 34: pr(" name"); break; } n++; } pr("\n"); nships = 0; np = getnatp(player->cnum); while (nxtitem(&ni, &ship)) { if (!player->owner || ship.shp_own == 0) continue; nships++; npln = shp_nplane(&ship, &nch, &nxl, NULL); if (player->god) pr("%d ", ship.shp_own); pr("%d", ni.cur); n = 0; while (field[n]) { switch (field[n++]) { case 1: pr(" %.4s", mchr[(int)ship.shp_type].m_name); break; case 2: pr(" %d", xrel(np, ship.shp_x)); break; case 3: pr(" %d", yrel(np, ship.shp_y)); break; case 4: pr(" %c", ship.shp_fleet ? ship.shp_fleet : '~'); break; case 5: pr(" %d", ship.shp_effic); break; case 6: pr(" %d", ship.shp_item[I_CIVIL]); break; case 7: pr(" %d", ship.shp_item[I_MILIT]); break; case 8: pr(" %d", ship.shp_item[I_UW]); break; case 9: pr(" %d", ship.shp_item[I_FOOD]); break; case 10: pr(" %d", npln - nch - nxl); break; case 11: pr(" %d", nch); break; case 12: pr(" %d", nxl); break; case 13: pr(" %d", shp_nland(&ship)); break; case 14: pr(" %d", ship.shp_mobil); break; case 15: pr(" 0"); break; case 16: pr(" %d", ship.shp_tech); break; case 17: pr(" %d", ship.shp_item[I_SHELL]); break; case 18: pr(" %d", ship.shp_item[I_GUN]); break; case 19: pr(" %d", ship.shp_item[I_PETROL]); break; case 20: pr(" %d", ship.shp_item[I_IRON]); break; case 21: pr(" %d", ship.shp_item[I_DUST]); break; case 22: pr(" %d", ship.shp_item[I_BAR]); break; case 23: pr(" %d", ship.shp_item[I_OIL]); break; case 24: pr(" %d", ship.shp_item[I_LCM]); break; case 25: pr(" %d", ship.shp_item[I_HCM]); break; case 26: pr(" %d", ship.shp_item[I_RAD]); break; case 27: pr(" %d", shp_armor(&ship)); break; case 28: pr(" %d", shp_speed(&ship)); break; case 29: pr(" %d", shp_visib(&ship)); break; case 30: pr(" %d", shp_frnge(&ship)); break; case 31: pr(" %d", shp_glim(&ship)); break; case 32: /* * Disclosing construction site allows pirates to find * harbors. Disclose it only to the original owner * and to deities. Else dump illegal coordinates * 1,0 */ if (ship.shp_own == ship.shp_orig_own || player->god) pr(" %d", xrel(np, ship.shp_orig_x)); else pr(" 1"); break; case 33: /* see case 32 */ if (ship.shp_own == ship.shp_orig_own || player->god) pr(" %d", yrel(np, ship.shp_orig_y)); else pr(" 0"); break; case 34: pr(" %c%s%c", '"', ship.shp_name, '"'); break; } } pr("\n"); } if (nships == 0) { 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; }
int cens(void) { struct sctstr sect; int nsect; int n; struct nstr_sect nstr; char dirstr[20]; if (!snxtsct(&nstr, player->argp[1])) return RET_SYN; prdate(); for (n = 1; n <= 6; n++) dirstr[n] = dirch[n]; dirstr[0] = '.'; dirstr[7] = '$'; dirstr[8] = '\0'; nsect = 0; while (nxtsct(&nstr, §)) { if (!player->owner) continue; if (nsect++ == 0) cens_hdr(); if (player->god) pr("%3d ", sect.sct_own); prxy("%4d,%-4d", nstr.x, nstr.y); pr(" %c", dchr[sect.sct_type].d_mnem); if (sect.sct_newtype != sect.sct_type) pr("%c", dchr[sect.sct_newtype].d_mnem); else pr(" "); pr("%4d%%", sect.sct_effic); if (sect.sct_off) pr(" no "); else pr(" "); pr("%4d", sect.sct_mobil); pr(" %c", dirstr[sect.sct_del[I_UW] & 0x7]); pr("%c", dirstr[sect.sct_del[I_FOOD] & 0x7]); n = sect.sct_dist[I_UW] % 1000; pr(" %c", n == 0 ? '.' : '0' + (n / 100)); n = sect.sct_dist[I_FOOD] % 1000; pr("%c ", n == 0 ? '.' : '0' + (n / 100)); if (sect.sct_own != sect.sct_oldown) pr("%3d", sect.sct_oldown); else pr(" "); pr("%5d", sect.sct_item[I_CIVIL]); pr("%5d", sect.sct_item[I_MILIT]); pr("%5d", sect.sct_item[I_UW]); pr("%5d", sect.sct_item[I_FOOD]); pr("%4d%%", sect.sct_work); pr("%5d", sect.sct_avail); if (!player->god) { if (sect.sct_terr) pr("%4d", sect.sct_terr); else pr(" "); } pr("%5d", opt_FALLOUT ? sect.sct_fallout : 0); if (sect.sct_coastal) pr("%4d", sect.sct_coastal); pr("\n"); } if (nsect == 0) { if (player->argp[1]) pr("%s: No sector(s)\n", player->argp[1]); else pr("%s: No sector(s)\n", ""); return RET_FAIL; } else pr("%d sector%s\n", nsect, splur(nsect)); return 0; }
int scra(void) { struct nstr_item ni; union empobj_storage item; int type, n; struct sctstr sect; struct mchrstr *mp; struct plchrstr *pp; struct lchrstr *lp; char *p; i_type i; char prompt[128]; char buf[1024]; float eff; short *mvec; int amt; if (!(p = getstarg(player->argp[1], "Ship, land, or plane? ", buf))) return RET_SYN; switch (*p) { case 's': type = EF_SHIP; break; case 'p': type = EF_PLANE; break; case 'l': type = EF_LAND; break; default: pr("Ships, land units, or planes only! (s, l, p)\n"); return RET_SYN; } if (!snxtitem(&ni, type, player->argp[2], NULL)) return RET_SYN; n = 0; while (nxtitem(&ni, &item)) { if (!player->owner) continue; n++; } snprintf(prompt, sizeof(prompt), "Really scrap %d %s%s [n]? ", n, ef_nameof(type), splur(n)); if (!confirm(prompt)) return RET_FAIL; snxtitem_rewind(&ni); while (nxtitem(&ni, &item)) { if (!player->owner) continue; if (opt_MARKET) { if (ontradingblock(type, &item.ship)) { pr("You cannot scrap an item on the trading block!\n"); continue; } } getsect(item.gen.x, item.gen.y, §); if (type == EF_SHIP) { if (!player->owner && relations_with(sect.sct_own, player->cnum) < FRIENDLY) { pr("%s is not in a friendly harbor!\n", prship(&item.ship)); continue; } if (sect.sct_type != SCT_HARBR || sect.sct_effic < 60) { pr("%s is not in a 60%% efficient harbor!\n", prship(&item.ship)); continue; } if (mchr[item.ship.shp_type].m_flags & M_TRADE) { pr("WARNING: You only collect money from trade ships if you \"scuttle\" them!\n"); sprintf(prompt, "Are you really sure that you want to scrap %s (n)? ", prship(&item.ship)); if (!confirm(prompt)) { pr("%s not scrapped\n", prship(&item.ship)); continue; } } } else { if (!player->owner && relations_with(sect.sct_own, player->cnum) != ALLIED) { pr("%s is not in an allied sector!\n", unit_nameof(&item.gen)); continue; } if (type == EF_PLANE && (sect.sct_type != SCT_AIRPT || sect.sct_effic < 60)) { pr("%s is not in a 60%% efficient airfield!\n", prplane(&item.plane)); continue; } } pr("%s scrapped in %s\n", unit_nameof(&item.gen), xyas(item.gen.x, item.gen.y, player->cnum)); unit_drop_cargo(&item.gen, sect.sct_own); if (type == EF_SHIP) { eff = item.ship.shp_effic / 100.0; mp = &mchr[(int)item.ship.shp_type]; for (i = I_NONE + 1; i <= I_MAX; i++) { if (load_comm_ok(§, item.ship.shp_own, i, -item.ship.shp_item[i])) sect.sct_item[i] += item.ship.shp_item[i]; } mvec = mp->m_mat; if (item.ship.shp_pstage == PLG_INFECT && sect.sct_pstage == PLG_HEALTHY) sect.sct_pstage = PLG_EXPOSED; } else if (type == EF_LAND) { eff = item.land.lnd_effic / 100.0; lp = &lchr[(int)item.land.lnd_type]; for (i = I_NONE + 1; i <= I_MAX; i++) { if (load_comm_ok(§, item.land.lnd_own, i, -item.land.lnd_item[i])) sect.sct_item[i] += item.land.lnd_item[i]; } mvec = lp->l_mat; if (item.land.lnd_pstage == PLG_INFECT && sect.sct_pstage == PLG_HEALTHY) sect.sct_pstage = PLG_EXPOSED; } else { eff = item.land.lnd_effic / 100.0; pp = &plchr[(int)item.plane.pln_type]; mvec = pp->pl_mat; } item.gen.effic = 0; put_empobj(type, item.gen.uid, &item.gen); for (i = I_NONE + 1; i <= I_MAX; i++) { if (i == I_CIVIL || i == I_MILIT || i == I_UW) amt = sect.sct_item[i] + mvec[i] * eff; else amt = sect.sct_item[i] + mvec[i] * 2 / 3 * eff; if (amt > ITEM_MAX) amt = ITEM_MAX; sect.sct_item[i] = amt; } putsect(§); } return RET_OK; }
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; }
int dump(void) { struct sctstr sect; char dirstr[20]; int nsect; int n, i; struct nstr_sect nstr; int field[128]; struct natstr *np; time_t now; if (!snxtsct(&nstr, player->argp[1])) return RET_SYN; prdate(); (void)strcpy(dirstr, ". $"); for (n = 1; n <= 6; n++) dirstr[n] = dirch[n]; nsect = 0; np = getnatp(player->cnum); if (!player->argp[2]) { for (n = 1; n <= 80; n++) field[n - 1] = n; field[n - 1] = 0; } else { n = 2; i = 0; while (player->argp[n]) { if (!strcmp("des", player->argp[n])) { field[i++] = 1; } else if (!strcmp("sdes", player->argp[n])) { field[i++] = 2; } else if (!strcmp("eff", player->argp[n])) { field[i++] = 3; } else if (!strcmp("mob", player->argp[n])) { field[i++] = 4; } else if (!strcmp("*", player->argp[n])) { field[i++] = 5; } else if (!strcmp("off", player->argp[n])) { field[i++] = 6; } else if (!strcmp("min", player->argp[n])) { field[i++] = 7; } else if (!strcmp("gold", player->argp[n])) { field[i++] = 8; } else if (!strcmp("fert", player->argp[n])) { field[i++] = 9; } else if (!strcmp("ocontent", player->argp[n])) { field[i++] = 10; } else if (!strcmp("uran", player->argp[n])) { field[i++] = 11; } else if (!strcmp("work", player->argp[n])) { field[i++] = 12; } else if (!strcmp("avail", player->argp[n])) { field[i++] = 13; } else if (!strcmp("terr", player->argp[n])) { field[i++] = 14; } else if (!strcmp("civ", player->argp[n])) { field[i++] = 15; } else if (!strcmp("mil", player->argp[n])) { field[i++] = 16; } else if (!strcmp("uw", player->argp[n])) { field[i++] = 17; } else if (!strcmp("food", player->argp[n])) { field[i++] = 18; } else if (!strcmp("shell", player->argp[n])) { field[i++] = 19; } else if (!strcmp("gun", player->argp[n])) { field[i++] = 20; } else if (!strcmp("pet", player->argp[n])) { field[i++] = 21; } else if (!strcmp("iron", player->argp[n])) { field[i++] = 22; } else if (!strcmp("dust", player->argp[n])) { field[i++] = 23; } else if (!strcmp("bar", player->argp[n])) { field[i++] = 24; } else if (!strcmp("oil", player->argp[n])) { field[i++] = 25; } else if (!strcmp("lcm", player->argp[n])) { field[i++] = 26; } else if (!strcmp("hcm", player->argp[n])) { field[i++] = 27; } else if (!strcmp("rad", player->argp[n])) { field[i++] = 28; } else if (!strcmp("u_del", player->argp[n])) { field[i++] = 29; } else if (!strcmp("f_del", player->argp[n])) { field[i++] = 30; } else if (!strcmp("s_del", player->argp[n])) { field[i++] = 31; } else if (!strcmp("g_del", player->argp[n])) { field[i++] = 32; } else if (!strcmp("p_del", player->argp[n])) { field[i++] = 33; } else if (!strcmp("i_del", player->argp[n])) { field[i++] = 34; } else if (!strcmp("d_del", player->argp[n])) { field[i++] = 35; } else if (!strcmp("b_del", player->argp[n])) { field[i++] = 36; } else if (!strcmp("o_del", player->argp[n])) { field[i++] = 37; } else if (!strcmp("l_del", player->argp[n])) { field[i++] = 38; } else if (!strcmp("h_del", player->argp[n])) { field[i++] = 39; } else if (!strcmp("r_del", player->argp[n])) { field[i++] = 40; } else if (!strcmp("u_cut", player->argp[n])) { field[i++] = 41; } else if (!strcmp("f_cut", player->argp[n])) { field[i++] = 42; } else if (!strcmp("s_cut", player->argp[n])) { field[i++] = 43; } else if (!strcmp("g_cut", player->argp[n])) { field[i++] = 44; } else if (!strcmp("p_cut", player->argp[n])) { field[i++] = 45; } else if (!strcmp("i_cut", player->argp[n])) { field[i++] = 46; } else if (!strcmp("d_cut", player->argp[n])) { field[i++] = 47; } else if (!strcmp("b_cut", player->argp[n])) { field[i++] = 48; } else if (!strcmp("o_cut", player->argp[n])) { field[i++] = 49; } else if (!strcmp("l_cut", player->argp[n])) { field[i++] = 50; } else if (!strcmp("h_cut", player->argp[n])) { field[i++] = 51; } else if (!strcmp("r_cut", player->argp[n])) { field[i++] = 52; } else if (!strcmp("dist_x", player->argp[n])) { field[i++] = 53; } else if (!strcmp("dist_y", player->argp[n])) { field[i++] = 54; } else if (!strcmp("c_dist", player->argp[n])) { field[i++] = 55; } else if (!strcmp("m_dist", player->argp[n])) { field[i++] = 56; } else if (!strcmp("u_dist", player->argp[n])) { field[i++] = 57; } else if (!strcmp("f_dist", player->argp[n])) { field[i++] = 58; } else if (!strcmp("s_dist", player->argp[n])) { field[i++] = 59; } else if (!strcmp("g_dist", player->argp[n])) { field[i++] = 60; } else if (!strcmp("p_dist", player->argp[n])) { field[i++] = 61; } else if (!strcmp("i_dist", player->argp[n])) { field[i++] = 62; } else if (!strcmp("d_dist", player->argp[n])) { field[i++] = 63; } else if (!strcmp("b_dist", player->argp[n])) { field[i++] = 64; } else if (!strcmp("o_dist", player->argp[n])) { field[i++] = 65; } else if (!strcmp("l_dist", player->argp[n])) { field[i++] = 66; } else if (!strcmp("h_dist", player->argp[n])) { field[i++] = 67; } else if (!strcmp("r_dist", player->argp[n])) { field[i++] = 68; } else if (!strcmp("road", player->argp[n])) { field[i++] = 69; } else if (!strcmp("rail", player->argp[n])) { field[i++] = 70; } else if (!strcmp("defense", player->argp[n])) { field[i++] = 71; } else if (!strcmp("fallout", player->argp[n])) { field[i++] = 72; } else if (!strcmp("coast", player->argp[n])) { field[i++] = 73; } else if (!strcmp("c_del", player->argp[n])) { field[i++] = 74; } else if (!strcmp("m_del", player->argp[n])) { field[i++] = 75; } else if (!strcmp("c_cut", player->argp[n])) { field[i++] = 76; } else if (!strcmp("m_cut", player->argp[n])) { field[i++] = 77; } else if (!strcmp("terr1", player->argp[n])) { field[i++] = 78; } else if (!strcmp("terr2", player->argp[n])) { field[i++] = 79; } else if (!strcmp("terr3", player->argp[n])) { field[i++] = 80; } 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 SECTOR %ld\n", (long)now); if (player->god) pr("own "); pr("x y"); n = 0; while (field[n]) { pr(" "); switch (field[n]) { case 1: pr("des"); break; case 2: pr("sdes"); break; case 3: pr("eff"); break; case 4: pr("mob"); break; case 5: pr("*"); break; case 6: pr("off"); break; case 7: pr("min"); break; case 8: pr("gold"); break; case 9: pr("fert"); break; case 10: pr("ocontent"); break; case 11: pr("uran"); break; case 12: pr("work"); break; case 13: pr("avail"); break; case 14: pr("terr"); break; case 15: pr("civ"); break; case 16: pr("mil"); break; case 17: pr("uw"); break; case 18: pr("food"); break; case 19: pr("shell"); break; case 20: pr("gun"); break; case 21: pr("pet"); break; case 22: pr("iron"); break; case 23: pr("dust"); break; case 24: pr("bar"); break; case 25: pr("oil"); break; case 26: pr("lcm"); break; case 27: pr("hcm"); break; case 28: pr("rad"); break; case 29: pr("u_del"); break; case 30: pr("f_del"); break; case 31: pr("s_del"); break; case 32: pr("g_del"); break; case 33: pr("p_del"); break; case 34: pr("i_del"); break; case 35: pr("d_del"); break; case 36: pr("b_del"); break; case 37: pr("o_del"); break; case 38: pr("l_del"); break; case 39: pr("h_del"); break; case 40: pr("r_del"); break; case 41: pr("u_cut"); break; case 42: pr("f_cut"); break; case 43: pr("s_cut"); break; case 44: pr("g_cut"); break; case 45: pr("p_cut"); break; case 46: pr("i_cut"); break; case 47: pr("d_cut"); break; case 48: pr("b_cut"); break; case 49: pr("o_cut"); break; case 50: pr("l_cut"); break; case 51: pr("h_cut"); break; case 52: pr("r_cut"); break; case 53: pr("dist_x"); break; case 54: pr("dist_y"); break; case 55: pr("c_dist"); break; case 56: pr("m_dist"); break; case 57: pr("u_dist"); break; case 58: pr("f_dist"); break; case 59: pr("s_dist"); break; case 60: pr("g_dist"); break; case 61: pr("p_dist"); break; case 62: pr("i_dist"); break; case 63: pr("d_dist"); break; case 64: pr("b_dist"); break; case 65: pr("o_dist"); break; case 66: pr("l_dist"); break; case 67: pr("h_dist"); break; case 68: pr("r_dist"); break; case 69: pr("road"); break; case 70: pr("rail"); break; case 71: pr("defense"); break; case 72: pr("fallout"); break; case 73: pr("coast"); break; case 74: pr("c_del"); break; case 75: pr("m_del"); break; case 76: pr("c_cut"); break; case 77: pr("m_cut"); break; case 78: pr("terr1"); break; case 79: pr("terr2"); break; case 80: pr("terr3"); break; } n++; } pr("\n"); while (nxtsct(&nstr, §)) { if (!player->owner) continue; nsect++; /* census */ if (player->god) pr("%d ", sect.sct_own); pr("%d %d", xrel(np, nstr.x), yrel(np, nstr.y)); n = 0; while (field[n]) { pr(" "); switch (field[n++]) { case 1: pr("%c", dchr[sect.sct_type].d_mnem); break; case 2: if (sect.sct_newtype != sect.sct_type) pr("%c", dchr[sect.sct_newtype].d_mnem); else pr("_"); break; case 3: pr("%d", sect.sct_effic); break; case 4: pr("%d", sect.sct_mobil); break; case 5: pr("%c", sect.sct_own != sect.sct_oldown ? '*' : '.'); break; case 6: pr("%d", sect.sct_off); break; case 7: pr("%d", sect.sct_min); break; case 8: pr("%d", sect.sct_gmin); break; case 9: pr("%d", sect.sct_fertil); break; case 10: pr("%d", sect.sct_oil); break; case 11: pr("%d", sect.sct_uran); break; case 12: pr("%d", sect.sct_work); break; case 13: pr("%d", sect.sct_avail); break; case 14: pr("%d", sect.sct_terr); break; case 15: pr("%d", sect.sct_item[I_CIVIL]); break; case 16: pr("%d", sect.sct_item[I_MILIT]); break; case 17: pr("%d", sect.sct_item[I_UW]); break; case 18: pr("%d", sect.sct_item[I_FOOD]); break; /* commodity */ case 19: pr("%d", sect.sct_item[I_SHELL]); break; case 20: pr("%d", sect.sct_item[I_GUN]); break; case 21: pr("%d", sect.sct_item[I_PETROL]); break; case 22: pr("%d", sect.sct_item[I_IRON]); break; case 23: pr("%d", sect.sct_item[I_DUST]); break; case 24: pr("%d", sect.sct_item[I_BAR]); break; case 25: pr("%d", sect.sct_item[I_OIL]); break; case 26: pr("%d", sect.sct_item[I_LCM]); break; case 27: pr("%d", sect.sct_item[I_HCM]); break; case 28: pr("%d", sect.sct_item[I_RAD]); break; /* cutoff */ case 29: pr("%c", dirstr[sect.sct_del[I_UW] & 0x7]); break; case 30: pr("%c", dirstr[sect.sct_del[I_FOOD] & 0x7]); break; case 31: pr("%c", dirstr[sect.sct_del[I_SHELL] & 0x7]); break; case 32: pr("%c", dirstr[sect.sct_del[I_GUN] & 0x7]); break; case 33: pr("%c", dirstr[sect.sct_del[I_PETROL] & 0x7]); break; case 34: pr("%c", dirstr[sect.sct_del[I_IRON] & 0x7]); break; case 35: pr("%c", dirstr[sect.sct_del[I_DUST] & 0x7]); break; case 36: pr("%c", dirstr[sect.sct_del[I_BAR] & 0x7]); break; case 37: pr("%c", dirstr[sect.sct_del[I_OIL] & 0x7]); break; case 38: pr("%c", dirstr[sect.sct_del[I_LCM] & 0x7]); break; case 39: pr("%c", dirstr[sect.sct_del[I_HCM] & 0x7]); break; case 40: pr("%c", dirstr[sect.sct_del[I_RAD] & 0x7]); break; case 41: pr("%d", sect.sct_del[I_UW] & ~0x7); break; case 42: pr("%d", sect.sct_del[I_FOOD] & ~0x7); break; case 43: pr("%d", sect.sct_del[I_SHELL] & ~0x7); break; case 44: pr("%d", sect.sct_del[I_GUN] & ~0x7); break; case 45: pr("%d", sect.sct_del[I_PETROL] & ~0x7); break; case 46: pr("%d", sect.sct_del[I_IRON] & ~0x7); break; case 47: pr("%d", sect.sct_del[I_DUST] & ~0x7); break; case 48: pr("%d", sect.sct_del[I_BAR] & ~0x7); break; case 49: pr("%d", sect.sct_del[I_OIL] & ~0x7); break; case 50: pr("%d", sect.sct_del[I_LCM] & ~0x7); break; case 51: pr("%d", sect.sct_del[I_HCM] & ~0x7); break; case 52: pr("%d", sect.sct_del[I_RAD] & ~0x7); break; /* level */ case 53: pr("%d", xrel(getnatp(player->cnum), sect.sct_dist_x)); break; case 54: pr("%d", yrel(getnatp(player->cnum), sect.sct_dist_y)); break; case 55: pr("%d", sect.sct_dist[I_CIVIL]); break; case 56: pr("%d", sect.sct_dist[I_MILIT]); break; case 57: pr("%d", sect.sct_dist[I_UW]); break; case 58: pr("%d", sect.sct_dist[I_FOOD]); break; case 59: pr("%d", sect.sct_dist[I_SHELL]); break; case 60: pr("%d", sect.sct_dist[I_GUN]); break; case 61: pr("%d", sect.sct_dist[I_PETROL]); break; case 62: pr("%d", sect.sct_dist[I_IRON]); break; case 63: pr("%d", sect.sct_dist[I_DUST]); break; case 64: pr("%d", sect.sct_dist[I_BAR]); break; case 65: pr("%d", sect.sct_dist[I_OIL]); break; case 66: pr("%d", sect.sct_dist[I_LCM]); break; case 67: pr("%d", sect.sct_dist[I_HCM]); break; case 68: pr("%d", sect.sct_dist[I_RAD]); break; case 69: pr("%d", sect.sct_road); break; case 70: pr("%d", sect.sct_rail); break; case 71: pr("%d", SCT_DEFENSE(§)); break; case 72: if (opt_FALLOUT) pr("%d", sect.sct_fallout); else pr("0"); break; case 73: pr("%d", sect.sct_coastal); break; case 74: pr("%c", dirstr[sect.sct_del[I_CIVIL] & 0x7]); break; case 75: pr("%c", dirstr[sect.sct_del[I_MILIT] & 0x7]); break; case 76: pr("%d", sect.sct_del[I_CIVIL] & ~0x7); break; case 77: pr("%d", sect.sct_del[I_MILIT] & ~0x7); break; case 78: pr("%d", sect.sct_terr1); break; case 79: pr("%d", sect.sct_terr2); break; case 80: pr("%d", sect.sct_terr3); break; } } pr("\n"); } if (nsect == 0) { if (player->argp[1]) pr("%s: No sector(s)\n", player->argp[1]); else pr("%s: No sector(s)\n", ""); return RET_FAIL; } else pr("%d sector%s\n", nsect, splur(nsect)); return RET_OK; }