build: Report missing stuff more nicely for bridges
By switching build_nuke() to sector_can_build(), build_charge(). Report missing available work, or else missing materials, or else missing money, for consistency with the other things you can build. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
1c0315048a
commit
e44578038f
2 changed files with 25 additions and 66 deletions
|
@ -472,11 +472,11 @@ build_bridge(char what)
|
||||||
static int
|
static int
|
||||||
build_bspan(struct sctstr *sp)
|
build_bspan(struct sctstr *sp)
|
||||||
{
|
{
|
||||||
short *vec = sp->sct_item;
|
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
|
short mat[I_MAX+1];
|
||||||
|
int work;
|
||||||
int val;
|
int val;
|
||||||
int newx, newy;
|
int newx, newy;
|
||||||
int avail;
|
|
||||||
int nx, ny, i, good = 0;
|
int nx, ny, i, good = 0;
|
||||||
char *p;
|
char *p;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
@ -490,29 +490,14 @@ build_bspan(struct sctstr *sp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sp->sct_effic < 60 && !player->god) {
|
memset(mat, 0, sizeof(mat));
|
||||||
pr("Sector %s is not 60%% efficient.\n",
|
mat[I_HCM] = buil_bh;
|
||||||
xyas(sp->sct_x, sp->sct_y, player->cnum));
|
work = (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vec[I_HCM] < buil_bh) {
|
if (!sector_can_build(sp, mat, work, 100, dchr[SCT_BSPAN].d_name))
|
||||||
pr("%s only has %d unit%s of hcm,\n",
|
|
||||||
xyas(sp->sct_x, sp->sct_y, player->cnum),
|
|
||||||
vec[I_HCM], vec[I_HCM] > 1 ? "s" : "");
|
|
||||||
pr("(a bridge span requires %d)\n", buil_bh);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (!build_can_afford(buil_bc, 100, dchr[SCT_BSPAN].d_name))
|
if (!build_can_afford(buil_bc, 100, dchr[SCT_BSPAN].d_name))
|
||||||
return 0;
|
return 0;
|
||||||
avail = (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100;
|
|
||||||
if (sp->sct_avail < avail) {
|
|
||||||
pr("Not enough available work in %s to build a bridge\n",
|
|
||||||
xyas(sp->sct_x, sp->sct_y, player->cnum));
|
|
||||||
pr(" (%d available work required)\n", avail);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!player->argp[3]) {
|
if (!player->argp[3]) {
|
||||||
pr("Bridge head at %s\n",
|
pr("Bridge head at %s\n",
|
||||||
xyas(sp->sct_x, sp->sct_y, player->cnum));
|
xyas(sp->sct_x, sp->sct_y, player->cnum));
|
||||||
|
@ -522,7 +507,6 @@ build_bspan(struct sctstr *sp)
|
||||||
if (!p || !*p) {
|
if (!p || !*p) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Sanity check time */
|
|
||||||
if (!check_sect_ok(sp))
|
if (!check_sect_ok(sp))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -554,8 +538,8 @@ build_bspan(struct sctstr *sp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} /* end EASY_BRIDGES */
|
} /* end EASY_BRIDGES */
|
||||||
sp->sct_avail -= avail;
|
build_charge(sp, mat, work, buil_bc, 100);
|
||||||
player->dolcost += buil_bc;
|
|
||||||
sect.sct_type = SCT_BSPAN;
|
sect.sct_type = SCT_BSPAN;
|
||||||
sect.sct_newtype = SCT_BSPAN;
|
sect.sct_newtype = SCT_BSPAN;
|
||||||
sect.sct_effic = SCT_MINEFF;
|
sect.sct_effic = SCT_MINEFF;
|
||||||
|
@ -574,18 +558,17 @@ build_bspan(struct sctstr *sp)
|
||||||
putsect(§);
|
putsect(§);
|
||||||
pr("Bridge span built over %s\n",
|
pr("Bridge span built over %s\n",
|
||||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||||
vec[I_HCM] -= buil_bh;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
build_btower(struct sctstr *sp)
|
build_btower(struct sctstr *sp)
|
||||||
{
|
{
|
||||||
short *vec = sp->sct_item;
|
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
|
short mat[I_MAX+1];
|
||||||
|
int work;
|
||||||
int val;
|
int val;
|
||||||
int newx, newy;
|
int newx, newy;
|
||||||
int avail;
|
|
||||||
char *p;
|
char *p;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
int i;
|
int i;
|
||||||
|
@ -597,29 +580,14 @@ build_btower(struct sctstr *sp)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sp->sct_effic < 60 && !player->god) {
|
memset(mat, 0, sizeof(mat));
|
||||||
pr("Sector %s is not 60%% efficient.\n",
|
mat[I_HCM] = buil_tower_bh;
|
||||||
xyas(sp->sct_x, sp->sct_y, player->cnum));
|
work = (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vec[I_HCM] < buil_tower_bh) {
|
if (!sector_can_build(sp, mat, work, 100, dchr[SCT_BTOWER].d_name))
|
||||||
pr("%s only has %d unit%s of hcm,\n",
|
|
||||||
xyas(sp->sct_x, sp->sct_y, player->cnum),
|
|
||||||
vec[I_HCM], vec[I_HCM] > 1 ? "s" : "");
|
|
||||||
pr("(a bridge tower requires %d)\n", buil_tower_bh);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (!build_can_afford(buil_tower_bc, 100, dchr[SCT_BTOWER].d_name))
|
if (!build_can_afford(buil_tower_bc, 100, dchr[SCT_BTOWER].d_name))
|
||||||
return 0;
|
return 0;
|
||||||
avail = (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100;
|
|
||||||
if (sp->sct_avail < avail) {
|
|
||||||
pr("Not enough available work in %s to build a bridge tower\n",
|
|
||||||
xyas(sp->sct_x, sp->sct_y, player->cnum));
|
|
||||||
pr(" (%d available work required)\n", avail);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!player->argp[3]) {
|
if (!player->argp[3]) {
|
||||||
pr("Building from %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
|
pr("Building from %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
|
||||||
nav_map(sp->sct_x, sp->sct_y, 1);
|
nav_map(sp->sct_x, sp->sct_y, 1);
|
||||||
|
@ -628,7 +596,6 @@ build_btower(struct sctstr *sp)
|
||||||
if (!p || !*p) {
|
if (!p || !*p) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* Sanity check time */
|
|
||||||
if (!check_sect_ok(sp))
|
if (!check_sect_ok(sp))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -659,8 +626,8 @@ build_btower(struct sctstr *sp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sp->sct_avail -= avail;
|
build_charge(sp, mat, work, buil_tower_bc, 100);
|
||||||
player->dolcost += buil_tower_bc;
|
|
||||||
sect.sct_type = SCT_BTOWER;
|
sect.sct_type = SCT_BTOWER;
|
||||||
sect.sct_newtype = SCT_BTOWER;
|
sect.sct_newtype = SCT_BTOWER;
|
||||||
sect.sct_effic = SCT_MINEFF;
|
sect.sct_effic = SCT_MINEFF;
|
||||||
|
@ -679,7 +646,6 @@ build_btower(struct sctstr *sp)
|
||||||
putsect(§);
|
putsect(§);
|
||||||
pr("Bridge tower built in %s\n",
|
pr("Bridge tower built in %s\n",
|
||||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||||
vec[I_HCM] -= buil_tower_bh;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -777,8 +777,7 @@
|
||||||
Play#5 output Play#5 6 0 639
|
Play#5 output Play#5 6 0 639
|
||||||
Play#5 input build b 4:6,4 n
|
Play#5 input build b 4:6,4 n
|
||||||
Play#5 command build
|
Play#5 command build
|
||||||
Play#5 output Play#5 1 4,4 only has 0 unit of hcm,
|
Play#5 output Play#5 1 Not enough heavy products in 4,4 (need 100 more)
|
||||||
Play#5 output Play#5 1 (a bridge span requires 100)
|
|
||||||
Play#5 output Play#5 1 Sector 6,4 is not 60% efficient.
|
Play#5 output Play#5 1 Sector 6,4 is not 60% efficient.
|
||||||
Play#5 output Play#5 6 0 638
|
Play#5 output Play#5 6 0 638
|
||||||
Play#5 input move h 0,4 99 ggh
|
Play#5 input move h 0,4 99 ggh
|
||||||
|
@ -788,8 +787,7 @@
|
||||||
Play#5 output Play#5 6 0 637
|
Play#5 output Play#5 6 0 637
|
||||||
Play#5 input build b -4,4 n
|
Play#5 input build b -4,4 n
|
||||||
Play#5 command build
|
Play#5 command build
|
||||||
Play#5 output Play#5 1 -4,4 only has 99 units of hcm,
|
Play#5 output Play#5 1 Not enough heavy products in -4,4 (need 1 more)
|
||||||
Play#5 output Play#5 1 (a bridge span requires 100)
|
|
||||||
Play#5 output Play#5 6 0 636
|
Play#5 output Play#5 6 0 636
|
||||||
Play#5 input move h 0,4 201 ggh
|
Play#5 input move h 0,4 201 ggh
|
||||||
Play#5 command move
|
Play#5 command move
|
||||||
|
@ -847,10 +845,9 @@
|
||||||
Play#5 output Play#5 6 0 629
|
Play#5 output Play#5 6 0 629
|
||||||
Play#5 input build b -4:4,4 ?des#c&des#w b
|
Play#5 input build b -4:4,4 ?des#c&des#w b
|
||||||
Play#5 command build
|
Play#5 command build
|
||||||
Play#5 output Play#5 1 Not enough available work in -4,4 to build a bridge
|
Play#5 output Play#5 1 Not enough available work in -4,4 to build a bridge span
|
||||||
Play#5 output Play#5 1 (40 available work required)
|
Play#5 output Play#5 1 (40 available work required)
|
||||||
Play#5 output Play#5 1 2,4 only has 0 unit of hcm,
|
Play#5 output Play#5 1 Not enough heavy products in 2,4 (need 100 more)
|
||||||
Play#5 output Play#5 1 (a bridge span requires 100)
|
|
||||||
Play#5 output Play#5 1 Bridge span built over 3,5
|
Play#5 output Play#5 1 Bridge span built over 3,5
|
||||||
Play#5 output Play#5 1 That just cost you $1000.00
|
Play#5 output Play#5 1 That just cost you $1000.00
|
||||||
Play#5 output Play#5 6 0 628
|
Play#5 output Play#5 6 0 628
|
||||||
|
@ -934,8 +931,7 @@
|
||||||
Play#9 input build t -9:-8,-5:-4 b
|
Play#9 input build t -9:-8,-5:-4 b
|
||||||
Play#9 command build
|
Play#9 command build
|
||||||
Play#9 output Play#9 1 Sector -9,-5 is not 60% efficient.
|
Play#9 output Play#9 1 Sector -9,-5 is not 60% efficient.
|
||||||
Play#9 output Play#9 1 -8,-4 only has 0 unit of hcm,
|
Play#9 output Play#9 1 Not enough heavy products in -8,-4 (need 300 more)
|
||||||
Play#9 output Play#9 1 (a bridge tower requires 300)
|
|
||||||
Play#9 output Play#9 6 0 638
|
Play#9 output Play#9 6 0 638
|
||||||
Play#9 input move h 0,-4 299 gyggbh
|
Play#9 input move h 0,-4 299 gyggbh
|
||||||
Play#9 command move
|
Play#9 command move
|
||||||
|
@ -944,8 +940,7 @@
|
||||||
Play#9 output Play#9 6 0 637
|
Play#9 output Play#9 6 0 637
|
||||||
Play#9 input build t -8,-4 g
|
Play#9 input build t -8,-4 g
|
||||||
Play#9 command build
|
Play#9 command build
|
||||||
Play#9 output Play#9 1 -8,-4 only has 299 units of hcm,
|
Play#9 output Play#9 1 Not enough heavy products in -8,-4 (need 1 more)
|
||||||
Play#9 output Play#9 1 (a bridge tower requires 300)
|
|
||||||
Play#9 output Play#9 6 0 636
|
Play#9 output Play#9 6 0 636
|
||||||
Play#9 input move h 0,-4 601 gyggbh
|
Play#9 input move h 0,-4 601 gyggbh
|
||||||
Play#9 command move
|
Play#9 command move
|
||||||
|
@ -1062,8 +1057,7 @@
|
||||||
Play#7 output Play#7 6 0 638
|
Play#7 output Play#7 6 0 638
|
||||||
Play#7 input build b 4:6,-2 u
|
Play#7 input build b 4:6,-2 u
|
||||||
Play#7 command build
|
Play#7 command build
|
||||||
Play#7 output Play#7 1 4,-2 only has 0 unit of hcm,
|
Play#7 output Play#7 1 Not enough heavy products in 4,-2 (need 100 more)
|
||||||
Play#7 output Play#7 1 (a bridge span requires 100)
|
|
||||||
Play#7 output Play#7 1 Sector 6,-2 is not 60% efficient.
|
Play#7 output Play#7 1 Sector 6,-2 is not 60% efficient.
|
||||||
Play#7 output Play#7 6 0 637
|
Play#7 output Play#7 6 0 637
|
||||||
Play#7 input move h 0,-2 99 jh
|
Play#7 input move h 0,-2 99 jh
|
||||||
|
@ -1073,8 +1067,7 @@
|
||||||
Play#7 output Play#7 6 0 636
|
Play#7 output Play#7 6 0 636
|
||||||
Play#7 input build b 2,-2 u
|
Play#7 input build b 2,-2 u
|
||||||
Play#7 command build
|
Play#7 command build
|
||||||
Play#7 output Play#7 1 2,-2 only has 99 units of hcm,
|
Play#7 output Play#7 1 Not enough heavy products in 2,-2 (need 1 more)
|
||||||
Play#7 output Play#7 1 (a bridge span requires 100)
|
|
||||||
Play#7 output Play#7 6 0 635
|
Play#7 output Play#7 6 0 635
|
||||||
Play#7 input move h 0,-2 201 jh
|
Play#7 input move h 0,-2 201 jh
|
||||||
Play#7 command move
|
Play#7 command move
|
||||||
|
@ -1123,7 +1116,7 @@
|
||||||
Play#7 output Play#7 6 0 628
|
Play#7 output Play#7 6 0 628
|
||||||
Play#7 input build b 2:4,-2
|
Play#7 input build b 2:4,-2
|
||||||
Play#7 command build
|
Play#7 command build
|
||||||
Play#7 output Play#7 1 Not enough available work in 2,-2 to build a bridge
|
Play#7 output Play#7 1 Not enough available work in 2,-2 to build a bridge span
|
||||||
Play#7 output Play#7 1 (40 available work required)
|
Play#7 output Play#7 1 (40 available work required)
|
||||||
Play#7 output Play#7 1 Bridge head at 4,-2
|
Play#7 output Play#7 1 Bridge head at 4,-2
|
||||||
Play#7 output Play#7 1 . .
|
Play#7 output Play#7 1 . .
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue