From b05c2564e52e212076d62568b36eba9c24d67c5f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Feb 2017 13:22:44 +0100 Subject: [PATCH 1/3] make att_modification not crash when a good/bad dream curse has no magician. --- clibs | 2 +- conf/e2/locales.xml | 12 ++++++++++++ src/kernel/curse.h | 2 +- src/kernel/unit.c | 2 +- src/spells.c | 6 +++--- 5 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 conf/e2/locales.xml diff --git a/clibs b/clibs index f91ef37f0..27c8b3202 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit f91ef37f08c5244bf616f1836c0aa9caaf36805c +Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 diff --git a/conf/e2/locales.xml b/conf/e2/locales.xml new file mode 100644 index 000000000..f71525343 --- /dev/null +++ b/conf/e2/locales.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/kernel/curse.h b/src/kernel/curse.h index 4cff4f9a1..543755c2b 100644 --- a/src/kernel/curse.h +++ b/src/kernel/curse.h @@ -210,7 +210,7 @@ extern "C" { typedef struct curse { variant data; /* pointer auf spezielle curse-unterstructs */ struct curse *nexthash; - const curse_type *type; /* Zeiger auf ein curse_type-struct */ + const curse_type *type; /* Zeiger auf ein curse_type-struct */ struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */ double vigour; /* Stärke der Verzauberung, Widerstand gegen Antimagie */ double effect; diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 27a296a15..f92916b2f 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1301,7 +1301,7 @@ static int att_modification(const unit * u, skill_t sk) while (a && a->type == &at_curse) { curse *c = (curse *)a->data.v; - if (curse_active(c) && c->type == gbdream_ct) { + if (c->magician && curse_active(c) && c->type == gbdream_ct) { int effect = curse_geteffect_int(c); bool allied = alliedunit(c->magician, u->faction, HELP_GUARD); if (allied) { diff --git a/src/spells.c b/src/spells.c index e936a46a2..19c1e81f8 100644 --- a/src/spells.c +++ b/src/spells.c @@ -4726,7 +4726,7 @@ static int sp_gbdreams(castorder * co, const char *curse_name, int effect) /* Erfolg melden */ ADDMSG(&mage->faction->msgs, msg_message("regionmagic_effect", - "unit region command", c->magician, mage->region, co->order)); + "unit region command", mage, mage->region, co->order)); return cast_level; } @@ -4867,7 +4867,7 @@ int sp_sweetdreams(castorder * co) effect = 0.05f; c = create_curse(mage, &u->attribs, ct_find("orcish"), power, duration, effect, men); - msg = msg_message("sp_sweetdreams_effect", "mage unit region", c->magician, u, r); + msg = msg_message("sp_sweetdreams_effect", "mage unit region", mage, u, r); r_addmessage(r, mage->faction, msg); if (u->faction != mage->faction) { r_addmessage(r, u->faction, msg); @@ -4892,7 +4892,7 @@ int sp_disturbingdreams(castorder * co) c = create_curse(mage, &r->attribs, ct_find("badlearn"), power, duration, effect, 0); ADDMSG(&mage->faction->msgs, msg_message("sp_disturbingdreams_effect", - "mage region", c->magician, r)); + "mage region", mage, r)); return cast_level; } From 4828045fd7edc52ffba69ca1081be2047f7cd0f2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Feb 2017 18:52:41 +0100 Subject: [PATCH 2/3] there is no NEWATSROI, remove dead code --- src/give.c | 2 +- src/kernel/unit.c | 27 --------------------------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/give.c b/src/give.c index 4f8417bf2..d1a9d75f4 100644 --- a/src/give.c +++ b/src/give.c @@ -227,7 +227,7 @@ static bool can_give_men(const unit *u, const unit *dst, order *ord, message **m if (unit_has_cursed_item(u)) { if (msg) *msg = msg_error(u, ord, 78); } - else if (dst && (has_skill(u, SK_MAGIC) && dst->number > 0)) { + else if (has_skill(u, SK_MAGIC)) { /* cannot give units to and from magicians */ if (msg) *msg = msg_error(u, ord, 158); } diff --git a/src/kernel/unit.c b/src/kernel/unit.c index f92916b2f..2f38a0836 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1245,24 +1245,6 @@ static int item_invis(const unit *u) { + (rsphere ? i_get(u->items, rsphere->itype) * 100 : 0); } -#ifdef NEWATSROI -static int item_modification(const unit * u, skill_t sk, int val) -{ - if (sk == SK_STEALTH) { - if (item_invis(u) >= u->number) { - val += ROIBONUS; - } - } - if (sk == SK_PERCEPTION) { - const struct resource_type *rtype = get_resourcetype(R_AMULET_OF_TRUE_SEEING); - if (i_get(u->items, rtype->itype) >= u->number) { - val += ATSBONUS; - } - } - return val; -} -#endif - static int att_modification(const unit * u, skill_t sk) { double result = 0; @@ -1335,11 +1317,6 @@ int get_modifier(const unit * u, skill_t sk, int level, const region * r, bool n skill += rc_skillmod(u_race(u), r, sk); skill += att_modification(u, sk); -#ifdef NEWATSROI - if (!noitem) { - skill = item_modification(u, sk, skill); - } -#endif skill = skillmod(u->attribs, u, r, sk, skill, SMF_ALWAYS); if (fval(u, UFL_HUNGER)) { @@ -1382,9 +1359,6 @@ int effskill_study(const unit * u, skill_t sk, const region * r) int invisible(const unit * target, const unit * viewer) { -#ifdef NEWATSROI - return 0; -#else if (viewer && viewer->faction == target->faction) return 0; else { @@ -1398,7 +1372,6 @@ int invisible(const unit * target, const unit * viewer) } return hidden; } -#endif } /** remove the unit from memory. From 182fc3fa3c2f574685600498586972bfde848ece Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 12 Feb 2017 19:32:27 +0100 Subject: [PATCH 3/3] remove test for bug 2253 --- src/give.test.c | 6 ------ src/spells.c | 11 ++++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/give.test.c b/src/give.test.c index 029ee7c44..7da787c87 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -124,12 +124,6 @@ static void test_give_men_magicians(CuTest * tc) { CuAssertIntEquals(tc, 1, env.src->number); msg_release(msg); - - set_number(env.dst, 0); - CuAssertPtrEquals(tc, NULL, give_men(1, env.src, env.dst, NULL)); - CuAssertIntEquals(tc, 1, env.dst->number); - CuAssertIntEquals(tc, 0, env.src->number); - p = rpeasants(env.r); CuAssertPtrNotNull(tc, msg = disband_men(1, env.dst, NULL)); CuAssertStrEquals(tc, "give_person_peasants", (const char *)msg->parameters[0].v); diff --git a/src/spells.c b/src/spells.c index 19c1e81f8..b40192016 100644 --- a/src/spells.c +++ b/src/spells.c @@ -4714,7 +4714,6 @@ static int sp_gbdreams(castorder * co, const char *curse_name, int effect) int cast_level = co->level; double power = co->force; region *r = co_get_region(co); - curse *c; /* wirkt erst in der Folgerunde, soll mindestens eine Runde wirken, * also duration+2 */ @@ -4722,8 +4721,8 @@ static int sp_gbdreams(castorder * co, const char *curse_name, int effect) duration = 2 + rng_int() % duration; /* Nichts machen als ein entsprechendes Attribut in die Region legen. */ - c = create_curse(mage, &r->attribs, ct_find(curse_name), power, duration, effect, 0); - + create_curse(mage, &r->attribs, ct_find(curse_name), power, duration, effect, 0); + /* Erfolg melden */ ADDMSG(&mage->faction->msgs, msg_message("regionmagic_effect", "unit region command", mage, mage->region, co->order)); @@ -4841,7 +4840,6 @@ int sp_sweetdreams(castorder * co) /* Schleife ueber alle angegebenen Einheiten */ for (n = 0; n < pa->length; n++) { - curse *c; unit *u; double effect; message *msg; @@ -4865,7 +4863,7 @@ int sp_sweetdreams(castorder * co) /* Nichts machen als ein entsprechendes Attribut an die Einheit legen. */ effect = 0.05f; - c = create_curse(mage, &u->attribs, ct_find("orcish"), power, duration, effect, men); + create_curse(mage, &u->attribs, ct_find("orcish"), power, duration, effect, men); msg = msg_message("sp_sweetdreams_effect", "mage unit region", mage, u, r); r_addmessage(r, mage->faction, msg); @@ -4886,10 +4884,9 @@ int sp_disturbingdreams(castorder * co) double power = co->force; int duration = 1 + (int)(power / 6); double effect; - curse *c; effect = 10; - c = create_curse(mage, &r->attribs, ct_find("badlearn"), power, duration, effect, 0); + create_curse(mage, &r->attribs, ct_find("badlearn"), power, duration, effect, 0); ADDMSG(&mage->faction->msgs, msg_message("sp_disturbingdreams_effect", "mage region", mage, r));