static int still_ok_land(struct sctstr *sectp, struct lndstr *landp) { if (!check_sect_ok(sectp)) return 0; if (!check_land_ok(landp)) return 0; return 1; }
static int still_ok_ship(struct sctstr *sectp, struct shpstr *shipp) { if (!check_sect_ok(sectp)) return 0; if (!check_ship_ok(shipp)) return 0; return 1; }
/* * threshold <COMM> <SECTS> <THRESH> */ int thre(void) { struct sctstr sect; struct nstr_sect nstr; int val; struct ichrstr *ip; char *p; int thresh; i_type type; char prompt[128]; char buf[128]; if (!(ip = whatitem(player->argp[1], "What commodity? "))) return RET_SYN; if (!snxtsct(&nstr, player->argp[2])) return RET_SYN; type = ip->i_uid; while (nxtsct(&nstr, §)) { if (!player->owner) continue; val = sect.sct_dist[type]; if (val > 0) sprintf(prompt, "%s %s old threshold %d new? ", xyas(nstr.x, nstr.y, player->cnum), dchr[sect.sct_type].d_name, val); else sprintf(prompt, "%s %s threshold? ", xyas(nstr.x, nstr.y, player->cnum), dchr[sect.sct_type].d_name); if (!(p = getstarg(player->argp[3], prompt, buf))) return RET_FAIL; if (!*p) continue; if (!check_sect_ok(§)) return RET_FAIL; thresh = atoi(p); if (thresh < 0) return RET_FAIL; if (thresh > ITEM_MAX) thresh = ITEM_MAX; if ((val > 0) && (val == thresh)) { pr("%s threshold unchanged (left at %d)\n", xyas(nstr.x, nstr.y, player->cnum), val); continue; } if (val > 0 && player->argp[3] && *player->argp[3]) pr("%s old threshold %d\n", xyas(nstr.x, nstr.y, player->cnum), val); sect.sct_dist[type] = thresh; putsect(§); } return RET_OK; }
int desi(void) { int n; char *p; int des; struct nstr_sect nstr; struct sctstr sect; struct natstr *natp; char prompt[128]; char buf[1024]; int changed = 0; int rc = RET_OK; if (!snxtsct(&nstr, player->argp[1])) return RET_SYN; natp = getnatp(player->cnum); while (nxtsct(&nstr, §)) { if (!player->owner) continue; if (!player->god && dchr[sect.sct_type].d_cost < 0) continue; sprintf(prompt, "%s %d%% %s desig? ", xyas(sect.sct_x, sect.sct_y, player->cnum), sect.sct_effic, dchr[sect.sct_type].d_name); if (!(p = getstarg(player->argp[2], prompt, buf))) { rc = RET_FAIL; break; } if (!check_sect_ok(§)) continue; des = sct_typematch(p); if (des < 0) { pr("No such designation\n" "See \"info Sector-types\" for possible designations\n"); rc = RET_FAIL; break; } if (!player->god) { if (des == SCT_WASTE) { pr("Only a nuclear device (or %s) can make a %s!\n", cname(0), dchr[des].d_name); rc = RET_FAIL; break; } if (dchr[des].d_cost < 0) { pr("Only %s can designate a %s!\n", cname(0), dchr[des].d_name); rc = RET_FAIL; break; } if (dchr[des].d_terrain != dchr[sect.sct_type].d_terrain) { pr("You can't change a %s into a %s\n", dchr[sect.sct_type].d_name, dchr[des].d_name); continue; } } if (sect.sct_type == des && sect.sct_newtype == des) continue; if ((des == SCT_HARBR || des == SCT_BHEAD) && !sect.sct_coastal) { pr("%s does not border on water.\n", xyas(nstr.x, nstr.y, player->cnum)); if (player->god) pr("But if it's what you want ...\n"); else continue; } if (sect.sct_type == SCT_SANCT && !player->god) continue; n = sect.sct_type; if ((sect.sct_newtype != des) && (sect.sct_type != des) && dchr[des].d_cost > 0) { if (natp->nat_money < player->dolcost + dchr[des].d_cost) { pr("You can't afford a %s!\n", dchr[des].d_name); rc = RET_FAIL; break; } player->dolcost += dchr[des].d_cost; } if (sect.sct_type != des && (sect.sct_effic < 5 || player->god)) { if (player->god) set_coastal(§, sect.sct_type, des); sect.sct_type = des; sect.sct_effic = 0; changed += map_set(player->cnum, sect.sct_x, sect.sct_y, dchr[des].d_mnem, 0); } sect.sct_newtype = des; putsect(§); if (!player->god && sect.sct_x == natp->nat_xcap && sect.sct_y == natp->nat_ycap && des != SCT_CAPIT && des != SCT_SANCT && des != SCT_MOUNT) pr("You have redesignated your capital!\n"); if (opt_EASY_BRIDGES == 0) { /* may cause a bridge fall */ if (n != SCT_BHEAD) continue; bridgefall(§); } } if (changed) writemap(player->cnum); return rc; }