BUG 2353: Segen der Erde produziert zu viel Silber

https://bugs.eressea.de/view.php?id=2353
In E3 gibt es legazy-attribute mit falschem Effekt, ignorieren.
This commit is contained in:
Enno Rehling 2017-08-06 18:52:09 +02:00
parent 3445e376e0
commit 4291c4de3d
5 changed files with 33 additions and 27 deletions

View File

@ -69,6 +69,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <attributes/reduceproduction.h> #include <attributes/reduceproduction.h>
#include <attributes/racename.h> #include <attributes/racename.h>
#include <spells/regioncurse.h>
/* libs includes */ /* libs includes */
#include <math.h> #include <math.h>
@ -2653,14 +2654,10 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
jobs = rpeasants(r); jobs = rpeasants(r);
} }
earnings = jobs * p_wage; earnings = jobs * p_wage;
if (r->attribs && rule_blessed_harvest() == HARVEST_TAXES) { if (jobs > 0 && r->attribs && rule_blessed_harvest() == HARVEST_TAXES) {
/* E3 rules */ /* E3 rules */
const curse_type *blessedharvest_ct = ct_find("blessedharvest"); int happy = harvest_effect(r);
if (blessedharvest_ct) { earnings += happy * jobs;
int happy =
(int)(jobs * curse_geteffect(get_curse(r->attribs, blessedharvest_ct)));
earnings += happy;
}
} }
rsetmoney(r, money + earnings); rsetmoney(r, money + earnings);
} }

View File

@ -55,6 +55,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <limits.h> #include <limits.h>
/* attributes includes */ /* attributes includes */
#include <spells/regioncurse.h>
#include <attributes/reduceproduction.h> #include <attributes/reduceproduction.h>
typedef struct building_typelist { typedef struct building_typelist {
@ -710,7 +711,7 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
} }
if (r->attribs && rule_blessed_harvest() == HARVEST_WORK) { if (r->attribs && rule_blessed_harvest() == HARVEST_WORK) {
/* E1 rules */ /* E1 rules */
wage += curse_geteffect(get_curse(r->attribs, ct_find("blessedharvest"))); wage += harvest_effect(r);
} }
} }

View File

@ -596,29 +596,24 @@ curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct,
if (ct->mergeflags & M_DURATION) { if (ct->mergeflags & M_DURATION) {
c->duration = MAX(c->duration, duration); c->duration = MAX(c->duration, duration);
} }
if (ct->mergeflags & M_SUMDURATION) { else if (ct->mergeflags & M_SUMDURATION) {
c->duration += duration; c->duration += duration;
} }
if (ct->mergeflags & M_SUMEFFECT) {
c->effect += effect;
}
if (ct->mergeflags & M_MAXEFFECT) { if (ct->mergeflags & M_MAXEFFECT) {
c->effect = MAX(c->effect, effect); c->effect = MAX(c->effect, effect);
} }
else if (ct->mergeflags & M_SUMEFFECT) {
c->effect += effect;
}
if (ct->mergeflags & M_VIGOUR) { if (ct->mergeflags & M_VIGOUR) {
c->vigour = MAX(vigour, c->vigour); c->vigour = MAX(vigour, c->vigour);
} }
if (ct->mergeflags & M_VIGOUR_ADD) { else if (ct->mergeflags & M_VIGOUR_ADD) {
c->vigour = vigour + c->vigour; c->vigour = vigour + c->vigour;
} }
if (ct->mergeflags & M_MEN) { if (ct->mergeflags & M_MEN && ct->typ == CURSETYP_UNIT) {
switch (ct->typ) {
case CURSETYP_UNIT:
{
c->data.i += men; c->data.i += men;
} }
}
}
set_curseingmagician(magician, *ap, ct); set_curseingmagician(magician, *ap, ct);
} }
else { else {

View File

@ -24,6 +24,7 @@
#include <kernel/unit.h> #include <kernel/unit.h>
/* util includes */ /* util includes */
#include <util/log.h>
#include <util/nrmessage.h> #include <util/nrmessage.h>
#include <util/message.h> #include <util/message.h>
#include <util/functions.h> #include <util/functions.h>
@ -33,10 +34,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
/* --------------------------------------------------------------------- */
/* CurseInfo mit Spezialabfragen
*/
/* /*
* godcursezone * godcursezone
*/ */
@ -206,6 +203,22 @@ static struct curse_type ct_blessedharvest = {
cinfo_simple cinfo_simple
}; };
int harvest_effect(const struct region *r) {
if (r->attribs) {
curse *c = get_curse(r->attribs, &ct_blessedharvest);
if (c) {
int happy = curse_geteffect_int(c);
if (happy != 1) {
/* https://bugs.eressea.de/view.php?id=2353 detect and fix bad harvest */
log_error("blessedharvest curse %d has effect=%d, duration=%d", c->no, happy, c->duration);
c->effect = 1.0;
}
return happy;
}
}
return 0;
}
static struct curse_type ct_drought = { static struct curse_type ct_drought = {
"drought", "drought",
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR), CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),

View File

@ -17,10 +17,10 @@
extern "C" { extern "C" {
#endif #endif
struct curse; struct region;
struct locale;
extern void register_regioncurse(void); int harvest_effect(const struct region *r);
void register_regioncurse(void);
#ifdef __cplusplus #ifdef __cplusplus
} }