Only use potions that we have the resources for.
This commit is contained in:
Enno Rehling 2011-04-29 22:49:29 -07:00
parent 17d339b196
commit 817f396467

View file

@ -120,7 +120,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));
} }
void do_potion(unit * u, const potion_type * ptype, int amount) static int do_potion(unit * u, const potion_type * ptype, int amount)
{ {
if (ptype == oldpotiontype[P_LIFE]) { if (ptype == oldpotiontype[P_LIFE]) {
region *r = u->region; region *r = u->region;
@ -175,6 +175,7 @@ void do_potion(unit * u, const potion_type * ptype, int amount)
} else { } else {
change_effect(u, ptype, 10 * amount); change_effect(u, ptype, 10 * amount);
} }
return amount;
} }
int use_potion(unit * u, const item_type * itype, int amount, struct order *ord) int use_potion(unit * u, const item_type * itype, int amount, struct order *ord)
@ -187,7 +188,7 @@ int use_potion(unit * u, const item_type * itype, int amount, struct order *ord)
int result = begin_potion(u, ptype, ord); int result = begin_potion(u, ptype, ord);
if (result) if (result)
return result; return result;
do_potion(u, ptype, amount); amount = do_potion(u, ptype, amount);
end_potion(u, ptype, amount); end_potion(u, ptype, amount);
} }
return 0; return 0;
@ -212,7 +213,7 @@ static void free_potiondelay(attrib * a)
static int age_potiondelay(attrib * a) static int age_potiondelay(attrib * a)
{ {
potiondelay *pd = (potiondelay *) a->data.v; potiondelay *pd = (potiondelay *) a->data.v;
do_potion(pd->u, pd->ptype, pd->amount); pd->amount = do_potion(pd->u, pd->ptype, pd->amount);
return AT_AGE_REMOVE; return AT_AGE_REMOVE;
} }