From e06ebbc33fae83c4817a39af15fa0784ac233459 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 12 Jan 2014 14:23:46 +0300 Subject: fix using same pet from different items at same time. --- src/being/being.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/being/being.cpp') diff --git a/src/being/being.cpp b/src/being/being.cpp index 399b3883c..5c89ba579 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -177,6 +177,7 @@ Being::Being(const int id, const Type type, const uint16_t subtype, mPvpRank(0), mNumber(100), mLook(0), + mUsageCounter(1), mHairColor(0), mErased(false), mEnemy(false), @@ -3214,8 +3215,12 @@ void Being::addPet(const int id) if (!actorManager || !config.getBoolValue("usepets")) return; - if (findChildPet(id)) + Being *const pet = findChildPet(id); + if (pet) + { + pet->incUsage(); return; + } Being *const being = actorManager->createBeing( id, ActorSprite::PET, 0); @@ -3252,10 +3257,13 @@ void Being::removePet(const int id) Being *const pet = *it; if (pet && pet->mId == id) { - pet->setOwner(nullptr); - actorManager->erase(pet); - mPets.erase(it); - delete pet; + if (!pet->decUsage()) + { + pet->setOwner(nullptr); + actorManager->erase(pet); + mPets.erase(it); + delete pet; + } } } } -- cgit v1.2.3-60-g2f50