- revert r3645
- fix memory leak in GenericInstantAbility
This commit is contained in:
@@ -825,20 +825,6 @@ public:
|
||||
return a;
|
||||
}
|
||||
};
|
||||
|
||||
//make instant ability out of anything
|
||||
class AGenericInstantWrapper: public InstantAbility
|
||||
{
|
||||
public:
|
||||
MTGAbility * ability;
|
||||
|
||||
AGenericInstantWrapper(int id, MTGCardInstance * source, Damageable * target,MTGAbility * wrapThis);
|
||||
int resolve();
|
||||
const char * getMenuText();
|
||||
AGenericInstantWrapper * clone() const;
|
||||
~AGenericInstantWrapper();
|
||||
};
|
||||
|
||||
//counters
|
||||
class AACounter: public ActivatedAbility
|
||||
{
|
||||
@@ -1773,16 +1759,25 @@ public:
|
||||
|
||||
int destroy()
|
||||
{
|
||||
ability->forceDestroy = 1;
|
||||
if (game->removeObserver(ability))
|
||||
ability = NULL;
|
||||
else
|
||||
SAFE_DELETE(ability);
|
||||
return InstantAbility::destroy();
|
||||
}
|
||||
|
||||
GenericInstantAbility * clone() const
|
||||
{
|
||||
GenericInstantAbility * a = NEW GenericInstantAbility(*this);
|
||||
a->ability = ability->clone();
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
~GenericInstantAbility()
|
||||
{
|
||||
SAFE_DELETE(ability);
|
||||
}
|
||||
};
|
||||
|
||||
//Circle of Protections
|
||||
|
||||
@@ -112,6 +112,14 @@ void ActionLayer::Update(float dt)
|
||||
GameObserver* game = GameObserver::GetInstance();
|
||||
for (int i = mCount - 1; i >= 0; i--)
|
||||
{
|
||||
//a dirty hack, there might be cases when the mObject array gets reshaped if an ability removes some of its children abilites
|
||||
if ((int) mObjects.size() <= i)
|
||||
{
|
||||
i = (int) (mObjects.size()) - 1;
|
||||
if (i<0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (mObjects[i] != NULL)
|
||||
{
|
||||
ActionElement * currentAction = (ActionElement *) mObjects[i];
|
||||
@@ -364,10 +372,8 @@ ActionLayer::ActionLayer()
|
||||
|
||||
ActionLayer::~ActionLayer()
|
||||
{
|
||||
for (int i = mCount - 1; i >= 0; i--)
|
||||
{
|
||||
moveToGarbage((ActionElement *) mObjects[i]);
|
||||
}
|
||||
while(mObjects.size())
|
||||
moveToGarbage((ActionElement *) mObjects[mObjects.size() - 1]);
|
||||
SAFE_DELETE(abilitiesMenu);
|
||||
cleanGarbage();
|
||||
}
|
||||
|
||||
@@ -69,39 +69,6 @@ GenericActivatedAbility::~GenericActivatedAbility()
|
||||
SAFE_DELETE(ability);
|
||||
}
|
||||
|
||||
//a generic instant wrapper
|
||||
//this turns any MTGAbility object into an instant ability.
|
||||
AGenericInstantWrapper::AGenericInstantWrapper(int id, MTGCardInstance * source, Damageable * target,MTGAbility * wrapThis) :
|
||||
InstantAbility(id, source, target)
|
||||
{
|
||||
ability = wrapThis;
|
||||
}
|
||||
|
||||
int AGenericInstantWrapper::resolve()
|
||||
{
|
||||
MTGAbility * a = ability->clone();
|
||||
GenericInstantAbility * wrapper = NEW GenericInstantAbility(1, source, (Damageable *) (this->target), a);
|
||||
wrapper->addToGame();
|
||||
return 1;
|
||||
}
|
||||
const char * AGenericInstantWrapper::getMenuText()
|
||||
{
|
||||
return ability->getMenuText();
|
||||
}
|
||||
|
||||
AGenericInstantWrapper * AGenericInstantWrapper::clone() const
|
||||
{
|
||||
AGenericInstantWrapper * a = NEW AGenericInstantWrapper(*this);
|
||||
a->ability = this->ability->clone();
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
AGenericInstantWrapper::~AGenericInstantWrapper()
|
||||
{
|
||||
SAFE_DELETE(ability);
|
||||
}
|
||||
|
||||
//AA Alter Poison
|
||||
AAAlterPoison::AAAlterPoison(int _id, MTGCardInstance * _source, Targetable * _target, int poison, ManaCost * _cost,
|
||||
int who) :
|
||||
|
||||
@@ -909,7 +909,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
if (!a1)
|
||||
return NULL;
|
||||
|
||||
return NEW AGenericInstantWrapper(1, card, (Damageable *) target, a1);
|
||||
return NEW GenericInstantAbility(1, card, (Damageable *) target, a1);
|
||||
}
|
||||
|
||||
//Upkeep Cost
|
||||
|
||||
Reference in New Issue
Block a user