unusual potion delay attribute can use a potion in another region? unclear what this code does, but fixing my bad assumption.

This commit is contained in:
Enno Rehling 2015-11-22 14:36:05 +01:00
parent c6bac1e49e
commit 17068af332
2 changed files with 6 additions and 8 deletions

View File

@ -122,8 +122,7 @@ static void end_potion(unit * u, const potion_type * ptype, int amount)
"unit potion", u, ptype->itype->rtype)); "unit potion", u, ptype->itype->rtype));
} }
static int potion_water_of_life(unit * u, int amount) { static int potion_water_of_life(unit * u, region *r, int amount) {
region *r = u->region;
int wood = 0; int wood = 0;
int tree_type = config_get_int("rules.magic.wol_type", 1); int tree_type = config_get_int("rules.magic.wol_type", 1);
int tree_count = config_get_int("rules.magic.wol_effect", 10); 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; return amount;
} }
static int potion_luck(unit *u, attrib_type *atype, int amount) { static int potion_luck(unit *u, region *r, attrib_type *atype, int amount) {
region *r = u->region;
attrib *a = (attrib *)a_find(r->attribs, atype); attrib *a = (attrib *)a_find(r->attribs, atype);
if (!a) { if (!a) {
a = a_add(&r->attribs, a_new(atype)); 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) 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]) { 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]) { else if (ptype == oldpotiontype[P_HEILWASSER]) {
return potion_healing(u, amount); return potion_healing(u, amount);
} }
else if (ptype == oldpotiontype[P_PEOPLE]) { 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]) { 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]) { else if (ptype == oldpotiontype[P_WAHRHEIT]) {
return potion_truth(u); return potion_truth(u);

View File

@ -42,6 +42,7 @@ static void test_readwrite_unit(CuTest * tc)
sprintf(path, "%s/%s", datapath(), filename); sprintf(path, "%s/%s", datapath(), filename);
data = gamedata_open(path, "wb"); data = gamedata_open(path, "wb");
CuAssertPtrNotNull(tc, data); // TODO: intermittent test
write_unit(data, u); write_unit(data, u);
gamedata_close(data); gamedata_close(data);