neweff production work: Fix crash for sea sector
The work required for building sea sectors is zero in sect.config.
When a deity runs neweff or production on a sea sector, e.g. with
"neweff *", buildeff() divides by zero. Same when a player or deity
runs work with an engineer in a sea sector. Broken in commit
2ffd7b948
"config: Make work to build sectors configurable", v4.4.0
Fix buildeff() to avoid the division. Change the required work to 100
in sect.config for good measure.
Cover deity use of neweff and production in tests/update.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
223add6a92
commit
5f3c64c062
6 changed files with 1109 additions and 6 deletions
|
@ -65,7 +65,7 @@
|
||||||
|
|
||||||
config sect-chr
|
config sect-chr
|
||||||
uid mnem prd peff l_b h_b bwork cost maint name ...
|
uid mnem prd peff l_b h_b bwork cost maint name ...
|
||||||
0 "." -1 0 0 0 0 0 0 "sea"
|
0 "." -1 0 0 0 100 0 0 "sea"
|
||||||
1 "^" dust 100 0 0 100 100 0 "mountain"
|
1 "^" dust 100 0 0 100 100 0 "mountain"
|
||||||
2 "s" -1 0 0 0 100 0 0 "sanctuary"
|
2 "s" -1 0 0 0 100 0 0 "sanctuary"
|
||||||
3 "\134" -1 0 0 0 100 0 0 "wasteland"
|
3 "\134" -1 0 0 0 100 0 0 "wasteland"
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
* Known contributors to this file:
|
* Known contributors to this file:
|
||||||
* Dave Pare, 1986
|
* Dave Pare, 1986
|
||||||
* Steve McClure, 1996
|
* Steve McClure, 1996
|
||||||
* Markus Armbruster, 2004-2016
|
* Markus Armbruster, 2004-2021
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -58,7 +58,7 @@ buildeff(struct sctstr *sp)
|
||||||
* Easier to destroy than to build.
|
* Easier to destroy than to build.
|
||||||
*/
|
*/
|
||||||
dcp = &dchr[sp->sct_type];
|
dcp = &dchr[sp->sct_type];
|
||||||
build = 4 * avail / dcp->d_bwork;
|
build = dcp->d_bwork > 0 ? 4 * avail / dcp->d_bwork : 100;
|
||||||
if (build <= sp->sct_effic)
|
if (build <= sp->sct_effic)
|
||||||
sp->sct_effic -= build;
|
sp->sct_effic -= build;
|
||||||
else {
|
else {
|
||||||
|
@ -72,7 +72,7 @@ buildeff(struct sctstr *sp)
|
||||||
|
|
||||||
if (sp->sct_type == sp->sct_newtype) {
|
if (sp->sct_type == sp->sct_newtype) {
|
||||||
dcp = &dchr[sp->sct_type];
|
dcp = &dchr[sp->sct_type];
|
||||||
delta = avail / dcp->d_bwork;
|
delta = dcp->d_bwork > 0 ? avail / dcp->d_bwork : 100;
|
||||||
if (delta > 100 - sp->sct_effic)
|
if (delta > 100 - sp->sct_effic)
|
||||||
delta = 100 - sp->sct_effic;
|
delta = 100 - sp->sct_effic;
|
||||||
build = get_materials(sp, dcp->d_mat, delta);
|
build = get_materials(sp, dcp->d_mat, delta);
|
||||||
|
|
|
@ -2,6 +2,7 @@ budget
|
||||||
| Note: f1#100 not actually built (plague kills off mil)
|
| Note: f1#100 not actually built (plague kills off mil)
|
||||||
| TODO is it accurate?
|
| TODO is it accurate?
|
||||||
neweff * ?newd#-
|
neweff * ?newd#-
|
||||||
|
| TODO is it accurate?
|
||||||
production *
|
production *
|
||||||
| TODO is it accurate?
|
| TODO is it accurate?
|
||||||
starvation
|
starvation
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
production *
|
||||||
|
| TODO is it accurate?
|
||||||
|
neweff *
|
||||||
|
| TODO is it accurate?
|
||||||
|
__cmd added 2 0 0
|
||||||
force
|
force
|
||||||
show updates
|
show updates
|
||||||
power
|
power
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1837,7 +1837,7 @@
|
||||||
Play#0 input xdump sect-chr *
|
Play#0 input xdump sect-chr *
|
||||||
Play#0 command xdump
|
Play#0 command xdump
|
||||||
Play#0 output Play#0 1 XDUMP sect-chr 0
|
Play#0 output Play#0 1 XDUMP sect-chr 0
|
||||||
Play#0 output Play#0 1 0 "sea" "." 0 -1 0 -1.00000 -1.00000 1 1 0.00000 0.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
|
Play#0 output Play#0 1 0 "sea" "." 0 -1 0 -1.00000 -1.00000 1 1 0.00000 0.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 1
|
||||||
Play#0 output Play#0 1 1 "mountain" "^" 1 1 100 2.40000 1.20000 0 1 1.00000 4.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 100 0 100 1
|
Play#0 output Play#0 1 1 "mountain" "^" 1 1 100 2.40000 1.20000 0 1 1.00000 4.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 100 0 100 1
|
||||||
Play#0 output Play#0 1 2 "sanctuary" "s" 4 -1 0 -1.00000 -1.00000 0 1 0.00000 99.0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 1000 1
|
Play#0 output Play#0 1 2 "sanctuary" "s" 4 -1 0 -1.00000 -1.00000 0 1 0.00000 99.0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 1000 1
|
||||||
Play#0 output Play#0 1 3 "wasteland" "\\134" 3 -1 0 -1.00000 -1.00000 0 1 0.00000 99.0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 1
|
Play#0 output Play#0 1 3 "wasteland" "\\134" 3 -1 0 -1.00000 -1.00000 0 1 0.00000 99.0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 1
|
||||||
|
@ -2553,7 +2553,7 @@
|
||||||
Play#1 input xdump sect-chr *
|
Play#1 input xdump sect-chr *
|
||||||
Play#1 command xdump
|
Play#1 command xdump
|
||||||
Play#1 output Play#1 1 XDUMP sect-chr 0
|
Play#1 output Play#1 1 XDUMP sect-chr 0
|
||||||
Play#1 output Play#1 1 0 "sea" "." 0 -1 0 -1.00000 -1.00000 1 1 0.00000 0.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
|
Play#1 output Play#1 1 0 "sea" "." 0 -1 0 -1.00000 -1.00000 1 1 0.00000 0.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 1
|
||||||
Play#1 output Play#1 1 1 "mountain" "^" 1 1 100 2.40000 1.20000 0 1 1.00000 4.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 100 0 100 1
|
Play#1 output Play#1 1 1 "mountain" "^" 1 1 100 2.40000 1.20000 0 1 1.00000 4.00000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 100 0 100 1
|
||||||
Play#1 output Play#1 1 2 "sanctuary" "s" 4 -1 0 -1.00000 -1.00000 0 1 0.00000 99.0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 1000 1
|
Play#1 output Play#1 1 2 "sanctuary" "s" 4 -1 0 -1.00000 -1.00000 0 1 0.00000 99.0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 1000 1
|
||||||
Play#1 output Play#1 1 3 "wasteland" "\\134" 3 -1 0 -1.00000 -1.00000 0 1 0.00000 99.0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 1
|
Play#1 output Play#1 1 3 "wasteland" "\\134" 3 -1 0 -1.00000 -1.00000 0 1 0.00000 99.0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 0 0 0 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue