From 17068af3324372b1b043f760693bd4ae2e4a3290 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 22 Nov 2015 14:36:05 +0100 Subject: [PATCH] unusual potion delay attribute can use a potion in another region? unclear what this code does, but fixing my bad assumption. --- src/alchemy.c | 13 +++++-------- src/kernel/save.test.c | 1 + 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/alchemy.c b/src/alchemy.c index 8b8220136..406d39fd6 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -122,8 +122,7 @@ static void end_potion(unit * u, const potion_type * ptype, int amount) "unit potion", u, ptype->itype->rtype)); } -static int potion_water_of_life(unit * u, int amount) { - region *r = u->region; +static int potion_water_of_life(unit * u, region *r, int amount) { int wood = 0; int tree_type = config_get_int("rules.magic.wol_type", 1); int tree_count = config_get_int("rules.magic.wol_effect", 10); @@ -156,8 +155,7 @@ static int potion_healing(unit * u, int amount) { return amount; } -static int potion_luck(unit *u, attrib_type *atype, int amount) { - region *r = u->region; +static int potion_luck(unit *u, region *r, attrib_type *atype, int amount) { attrib *a = (attrib *)a_find(r->attribs, atype); if (!a) { a = a_add(&r->attribs, a_new(atype)); @@ -184,18 +182,17 @@ static int potion_power(unit *u, int amount) { static int do_potion(unit * u, region *r, const potion_type * ptype, int amount) { - assert(r == u->region); // TODO: is r an unnecessary argument? if (ptype == oldpotiontype[P_LIFE]) { - return potion_water_of_life(u, amount); + return potion_water_of_life(u, r, amount); } else if (ptype == oldpotiontype[P_HEILWASSER]) { return potion_healing(u, amount); } else if (ptype == oldpotiontype[P_PEOPLE]) { - return potion_luck(u, &at_peasantluck, amount); + return potion_luck(u, r, &at_peasantluck, amount); } else if (ptype == oldpotiontype[P_HORSE]) { - return potion_luck(u, &at_horseluck, amount); + return potion_luck(u, r, &at_horseluck, amount); } else if (ptype == oldpotiontype[P_WAHRHEIT]) { return potion_truth(u); diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index 403eaa059..35e07325b 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -42,6 +42,7 @@ static void test_readwrite_unit(CuTest * tc) sprintf(path, "%s/%s", datapath(), filename); data = gamedata_open(path, "wb"); + CuAssertPtrNotNull(tc, data); // TODO: intermittent test write_unit(data, u); gamedata_close(data);