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/racename.h>
#include <spells/regioncurse.h>
/* libs includes */
#include <math.h>
@ -2653,14 +2654,10 @@ expandwork(region * r, request * work_begin, request * work_end, int maxwork)
jobs = rpeasants(r);
}
earnings = jobs * p_wage;
if (r->attribs && rule_blessed_harvest() == HARVEST_TAXES) {
if (jobs > 0 && r->attribs && rule_blessed_harvest() == HARVEST_TAXES) {
/* E3 rules */
const curse_type *blessedharvest_ct = ct_find("blessedharvest");
if (blessedharvest_ct) {
int happy =
(int)(jobs * curse_geteffect(get_curse(r->attribs, blessedharvest_ct)));
earnings += happy;
}
int happy = harvest_effect(r);
earnings += happy * jobs;
}
rsetmoney(r, money + earnings);
}

View File

@ -55,6 +55,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <limits.h>
/* attributes includes */
#include <spells/regioncurse.h>
#include <attributes/reduceproduction.h>
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) {
/* 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) {
c->duration = MAX(c->duration, duration);
}
if (ct->mergeflags & M_SUMDURATION) {
else if (ct->mergeflags & M_SUMDURATION) {
c->duration += duration;
}
if (ct->mergeflags & M_SUMEFFECT) {
c->effect += effect;
}
if (ct->mergeflags & M_MAXEFFECT) {
c->effect = MAX(c->effect, effect);
}
else if (ct->mergeflags & M_SUMEFFECT) {
c->effect += effect;
}
if (ct->mergeflags & M_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;
}
if (ct->mergeflags & M_MEN) {
switch (ct->typ) {
case CURSETYP_UNIT:
{
if (ct->mergeflags & M_MEN && ct->typ == CURSETYP_UNIT) {
c->data.i += men;
}
}
}
set_curseingmagician(magician, *ap, ct);
}
else {

View File

@ -24,6 +24,7 @@
#include <kernel/unit.h>
/* util includes */
#include <util/log.h>
#include <util/nrmessage.h>
#include <util/message.h>
#include <util/functions.h>
@ -33,10 +34,6 @@
#include <stdlib.h>
#include <assert.h>
/* --------------------------------------------------------------------- */
/* CurseInfo mit Spezialabfragen
*/
/*
* godcursezone
*/
@ -206,6 +203,22 @@ static struct curse_type ct_blessedharvest = {
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 = {
"drought",
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),

View File

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