Indented with src/scripts/indent-emp.
This commit is contained in:
parent
5f263a7753
commit
9b7adfbecc
437 changed files with 52211 additions and 51052 deletions
|
@ -45,195 +45,199 @@
|
|||
#include "optlist.h"
|
||||
#include "commands.h"
|
||||
|
||||
long do_desi(struct natstr *natp, s_char *sects, s_char *deschar, long int cash, int for_real);
|
||||
long do_desi(struct natstr *natp, s_char *sects, s_char *deschar,
|
||||
long int cash, int for_real);
|
||||
|
||||
int
|
||||
desi(void)
|
||||
{
|
||||
long cash;
|
||||
long cost;
|
||||
struct natstr *natp;
|
||||
long cash;
|
||||
long cost;
|
||||
struct natstr *natp;
|
||||
|
||||
natp = getnatp(player->cnum);
|
||||
cash = natp->nat_money;
|
||||
if (player->argp[2]) {
|
||||
cost = do_desi(natp, player->argp[1], player->argp[2], cash, 0);
|
||||
if (cost < 0)
|
||||
return (int)(-cost);
|
||||
if (chkmoney(cost, cash, player->argp[3]))
|
||||
return RET_SYN;
|
||||
}
|
||||
return (int)do_desi(natp, player->argp[1], player->argp[2], cash, 1);
|
||||
natp = getnatp(player->cnum);
|
||||
cash = natp->nat_money;
|
||||
if (player->argp[2]) {
|
||||
cost = do_desi(natp, player->argp[1], player->argp[2], cash, 0);
|
||||
if (cost < 0)
|
||||
return (int)(-cost);
|
||||
if (chkmoney(cost, cash, player->argp[3]))
|
||||
return RET_SYN;
|
||||
}
|
||||
return (int)do_desi(natp, player->argp[1], player->argp[2], cash, 1);
|
||||
}
|
||||
|
||||
long
|
||||
do_desi(struct natstr *natp, s_char *sects, s_char *deschar, long int cash, int for_real)
|
||||
do_desi(struct natstr *natp, s_char *sects, s_char *deschar, long int cash,
|
||||
int for_real)
|
||||
{
|
||||
extern int opt_NO_LCMS;
|
||||
extern int opt_NO_HCMS;
|
||||
register int n;
|
||||
s_char *p;
|
||||
int breaksanct;
|
||||
int cap_x;
|
||||
int cap_y;
|
||||
int des;
|
||||
struct nstr_sect nstr;
|
||||
struct sctstr sect;
|
||||
struct sctstr check;
|
||||
s_char prompt[128];
|
||||
s_char buf[1024];
|
||||
long cost = 0;
|
||||
int changed = 0;
|
||||
int warned = 0;
|
||||
extern int opt_NO_LCMS;
|
||||
extern int opt_NO_HCMS;
|
||||
register int n;
|
||||
s_char *p;
|
||||
int breaksanct;
|
||||
int cap_x;
|
||||
int cap_y;
|
||||
int des;
|
||||
struct nstr_sect nstr;
|
||||
struct sctstr sect;
|
||||
struct sctstr check;
|
||||
s_char prompt[128];
|
||||
s_char buf[1024];
|
||||
long cost = 0;
|
||||
int changed = 0;
|
||||
int warned = 0;
|
||||
|
||||
breaksanct = 0;
|
||||
if (!snxtsct(&nstr, sects)) {
|
||||
breaksanct = 0;
|
||||
if (!snxtsct(&nstr, sects)) {
|
||||
if (for_real)
|
||||
return (long)RET_SYN;
|
||||
else
|
||||
return (long)-RET_SYN;
|
||||
}
|
||||
cap_x = natp->nat_xcap;
|
||||
cap_y = natp->nat_ycap;
|
||||
while (!player->aborted && nxtsct(&nstr, §)) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
if (!player->god) {
|
||||
if (sect.sct_type == SCT_MOUNT ||
|
||||
sect.sct_type == SCT_BTOWER ||
|
||||
sect.sct_type == SCT_BSPAN ||
|
||||
sect.sct_type == SCT_WASTE ||
|
||||
sect.sct_type == SCT_PLAINS ||
|
||||
(opt_NO_LCMS && sect.sct_type == SCT_LIGHT) ||
|
||||
(opt_NO_HCMS && sect.sct_type == SCT_HEAVY) ||
|
||||
(opt_NO_OIL && sect.sct_type == SCT_OIL) ||
|
||||
(opt_NO_OIL && sect.sct_type == SCT_REFINE))
|
||||
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(deschar, prompt, buf)) == 0)
|
||||
continue;
|
||||
|
||||
if (!check_sect_ok(§))
|
||||
continue;
|
||||
|
||||
des = typematch(p, EF_SECTOR);
|
||||
if (des < 0 || (((des == SCT_BSPAN) || (des == SCT_BTOWER)) &&
|
||||
!player->god)) {
|
||||
pr("See \"info Sector-types\"\n");
|
||||
if (for_real)
|
||||
return (long)RET_FAIL;
|
||||
else
|
||||
return (long)-RET_FAIL;
|
||||
}
|
||||
if (!player->god) {
|
||||
if (des == SCT_WATER || des == SCT_MOUNT ||
|
||||
des == SCT_SANCT || des == SCT_PLAINS ||
|
||||
(opt_NO_LCMS && des == SCT_LIGHT) ||
|
||||
(opt_NO_HCMS && des == SCT_HEAVY) ||
|
||||
(opt_NO_OIL && des == SCT_OIL) ||
|
||||
(opt_NO_OIL && des == SCT_REFINE)) {
|
||||
pr("Only %s can make a %s!\n", cname(0), dchr[des].d_name);
|
||||
continue;
|
||||
}
|
||||
if (des == SCT_WASTE) {
|
||||
pr("Only a nuclear device (or %s) can make a %s!\n",
|
||||
cname(0), dchr[des].d_name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (sect.sct_type == des && sect.sct_newtype == des)
|
||||
continue;
|
||||
if (sect.sct_type == SCT_SANCT)
|
||||
breaksanct++;
|
||||
if (sect.sct_x == cap_x && sect.sct_y == cap_y &&
|
||||
des != SCT_CAPIT && des != SCT_SANCT &&
|
||||
des != SCT_MOUNT && for_real)
|
||||
pr("You have redesignated your capital!\n");
|
||||
if (des == SCT_HARBR) {
|
||||
for (n = 1; n <= 6; n++) {
|
||||
getsect(nstr.x + diroff[n][0],
|
||||
nstr.y + diroff[n][1], &check);
|
||||
if (check.sct_type == SCT_WATER)
|
||||
break;
|
||||
if (check.sct_type == SCT_BSPAN)
|
||||
break;
|
||||
if (check.sct_type == SCT_BTOWER)
|
||||
break;
|
||||
}
|
||||
if (n > 6) {
|
||||
if (for_real)
|
||||
return (long)RET_SYN;
|
||||
else
|
||||
return (long)-RET_SYN;
|
||||
}
|
||||
cap_x = natp->nat_xcap;
|
||||
cap_y = natp->nat_ycap;
|
||||
while (!player->aborted && nxtsct(&nstr, §)) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
if (!player->god) {
|
||||
if (sect.sct_type == SCT_MOUNT ||
|
||||
sect.sct_type == SCT_BTOWER ||
|
||||
sect.sct_type == SCT_BSPAN ||
|
||||
sect.sct_type == SCT_WASTE ||
|
||||
sect.sct_type == SCT_PLAINS ||
|
||||
(opt_NO_LCMS && sect.sct_type == SCT_LIGHT) ||
|
||||
(opt_NO_HCMS && sect.sct_type == SCT_HEAVY) ||
|
||||
(opt_NO_OIL && sect.sct_type == SCT_OIL) ||
|
||||
(opt_NO_OIL && sect.sct_type == SCT_REFINE))
|
||||
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(deschar, prompt, buf)) == 0)
|
||||
continue;
|
||||
|
||||
if (!check_sect_ok(§))
|
||||
pr("%s does not border on water.\n",
|
||||
xyas(nstr.x, nstr.y, player->cnum));
|
||||
if (player->god) {
|
||||
if (for_real)
|
||||
pr("But if it's what you want ...\n");
|
||||
} else
|
||||
continue;
|
||||
|
||||
des = typematch(p, EF_SECTOR);
|
||||
if (des < 0 || (((des == SCT_BSPAN) || (des == SCT_BTOWER)) &&
|
||||
!player->god)) {
|
||||
pr("See \"info Sector-types\"\n");
|
||||
if (for_real)
|
||||
return (long)RET_FAIL;
|
||||
else
|
||||
return (long)-RET_FAIL;
|
||||
}
|
||||
if (!player->god) {
|
||||
if (des == SCT_WATER || des == SCT_MOUNT ||
|
||||
des == SCT_SANCT || des == SCT_PLAINS ||
|
||||
(opt_NO_LCMS && des == SCT_LIGHT) ||
|
||||
(opt_NO_HCMS && des == SCT_HEAVY) ||
|
||||
(opt_NO_OIL && des == SCT_OIL) ||
|
||||
(opt_NO_OIL && des == SCT_REFINE)) {
|
||||
pr("Only %s can make a %s!\n", cname(0),
|
||||
dchr[des].d_name);
|
||||
continue;
|
||||
}
|
||||
if (des == SCT_WASTE) {
|
||||
pr("Only a nuclear device (or %s) can make a %s!\n",
|
||||
cname(0), dchr[des].d_name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (sect.sct_type == des && sect.sct_newtype == des)
|
||||
continue;
|
||||
if (sect.sct_type == SCT_SANCT)
|
||||
breaksanct++;
|
||||
if (sect.sct_x == cap_x && sect.sct_y == cap_y &&
|
||||
des != SCT_CAPIT && des != SCT_SANCT &&
|
||||
des != SCT_MOUNT && for_real)
|
||||
pr("You have redesignated your capital!\n");
|
||||
if (des == SCT_HARBR) {
|
||||
for (n = 1; n <= 6; n++) {
|
||||
getsect(nstr.x + diroff[n][0],
|
||||
nstr.y + diroff[n][1], &check);
|
||||
if (check.sct_type == SCT_WATER)
|
||||
break;
|
||||
if (check.sct_type == SCT_BSPAN)
|
||||
break;
|
||||
if (check.sct_type == SCT_BTOWER)
|
||||
break;
|
||||
}
|
||||
if (n > 6) {
|
||||
if (for_real)
|
||||
pr("%s does not border on water.\n",
|
||||
xyas(nstr.x, nstr.y, player->cnum));
|
||||
if (player->god) {
|
||||
if (for_real)
|
||||
pr("But if it's what you want ...\n");
|
||||
} else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (des == SCT_BHEAD) {
|
||||
for (n = 1; n <= 6; n++) {
|
||||
getsect(nstr.x + diroff[n][0],
|
||||
nstr.y + diroff[n][1], &check);
|
||||
if (check.sct_type == SCT_WATER)
|
||||
break;
|
||||
if (check.sct_type == SCT_BSPAN)
|
||||
break;
|
||||
if (check.sct_type == SCT_BTOWER)
|
||||
break;
|
||||
}
|
||||
if (n > 6) {
|
||||
if (for_real)
|
||||
pr("%s does not border on water.\n",
|
||||
xyas(nstr.x, nstr.y,player->cnum));
|
||||
if (player->god) {
|
||||
if (for_real)
|
||||
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) {
|
||||
if (for_real) {
|
||||
if (check_cost(!deschar, dchr[des].d_cost, cash, &warned, player->argp[3]))
|
||||
break;
|
||||
} else {
|
||||
cost += dchr[des].d_cost;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (sect.sct_effic < 5 || player->god) {
|
||||
sect.sct_type = des;
|
||||
sect.sct_effic = 0;
|
||||
/* No longer tear down infrasturcture
|
||||
sect.sct_road = 0;
|
||||
sect.sct_defense = 0;
|
||||
*/
|
||||
changed += map_set(player->cnum, sect.sct_x, sect.sct_y,
|
||||
dchr[des].d_mnem, 0);
|
||||
}
|
||||
sect.sct_newtype = des;
|
||||
putsect(§);
|
||||
if (opt_EASY_BRIDGES == 0) { /* may cause a bridge fall */
|
||||
if (n != SCT_BHEAD)
|
||||
continue;
|
||||
bridgefall(§, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (for_real) {
|
||||
if (changed)
|
||||
writemap(player->cnum);
|
||||
if (breaksanct)
|
||||
bsanct();
|
||||
return (long)RET_OK;
|
||||
} else {
|
||||
return cost;
|
||||
if (des == SCT_BHEAD) {
|
||||
for (n = 1; n <= 6; n++) {
|
||||
getsect(nstr.x + diroff[n][0],
|
||||
nstr.y + diroff[n][1], &check);
|
||||
if (check.sct_type == SCT_WATER)
|
||||
break;
|
||||
if (check.sct_type == SCT_BSPAN)
|
||||
break;
|
||||
if (check.sct_type == SCT_BTOWER)
|
||||
break;
|
||||
}
|
||||
if (n > 6) {
|
||||
if (for_real)
|
||||
pr("%s does not border on water.\n",
|
||||
xyas(nstr.x, nstr.y, player->cnum));
|
||||
if (player->god) {
|
||||
if (for_real)
|
||||
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) {
|
||||
if (for_real) {
|
||||
if (check_cost
|
||||
(!deschar, dchr[des].d_cost, cash, &warned,
|
||||
player->argp[3]))
|
||||
break;
|
||||
} else {
|
||||
cost += dchr[des].d_cost;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (sect.sct_effic < 5 || player->god) {
|
||||
sect.sct_type = des;
|
||||
sect.sct_effic = 0;
|
||||
/* No longer tear down infrasturcture
|
||||
sect.sct_road = 0;
|
||||
sect.sct_defense = 0;
|
||||
*/
|
||||
changed += map_set(player->cnum, sect.sct_x, sect.sct_y,
|
||||
dchr[des].d_mnem, 0);
|
||||
}
|
||||
sect.sct_newtype = des;
|
||||
putsect(§);
|
||||
if (opt_EASY_BRIDGES == 0) { /* may cause a bridge fall */
|
||||
if (n != SCT_BHEAD)
|
||||
continue;
|
||||
bridgefall(§, 0);
|
||||
}
|
||||
}
|
||||
if (for_real) {
|
||||
if (changed)
|
||||
writemap(player->cnum);
|
||||
if (breaksanct)
|
||||
bsanct();
|
||||
return (long)RET_OK;
|
||||
} else {
|
||||
return cost;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue