Erwan
- changed "putInPlay" to return "NULL" if the card cannot be found in the "from" zone. The behavior of the function before that prevented to see that we broke the "alternate" cost feature (see test Vine Dryad) - Fixed some memory leaks introduced in r2922
This commit is contained in:
@@ -1371,6 +1371,7 @@ public:
|
|||||||
{
|
{
|
||||||
if(!starfound.empty())
|
if(!starfound.empty())
|
||||||
{
|
{
|
||||||
|
SAFE_DELETE(multiplier);
|
||||||
multiplier = NEW WParsedInt(starfound, NULL, (MTGCardInstance *)source);
|
multiplier = NEW WParsedInt(starfound, NULL, (MTGCardInstance *)source);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < multiplier->getValue(); ++i)
|
for (int i = 0; i < multiplier->getValue(); ++i)
|
||||||
@@ -1523,17 +1524,14 @@ public:
|
|||||||
ATokenCreator * clone() const
|
ATokenCreator * clone() const
|
||||||
{
|
{
|
||||||
ATokenCreator * a = NEW ATokenCreator(*this);
|
ATokenCreator * a = NEW ATokenCreator(*this);
|
||||||
|
a->multiplier = NEW WParsedInt(*(multiplier));
|
||||||
a->isClone = 1;
|
a->isClone = 1;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
~ATokenCreator()
|
~ATokenCreator()
|
||||||
{
|
{
|
||||||
if (!isClone)
|
SAFE_DELETE(multiplier);
|
||||||
{
|
|
||||||
if(multiplier != NULL)
|
|
||||||
delete (multiplier);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -685,14 +685,13 @@ const char * AADrawer::getMenuText()
|
|||||||
AADrawer * AADrawer::clone() const
|
AADrawer * AADrawer::clone() const
|
||||||
{
|
{
|
||||||
AADrawer * a = NEW AADrawer(*this);
|
AADrawer * a = NEW AADrawer(*this);
|
||||||
a->nbcards = NEW WParsedInt(*(a->nbcards));
|
a->nbcards = NEW WParsedInt(*(this->nbcards));
|
||||||
a->isClone = 1;
|
a->isClone = 1;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
AADrawer::~AADrawer()
|
AADrawer::~AADrawer()
|
||||||
{
|
{
|
||||||
if(!isClone)
|
|
||||||
SAFE_DELETE(nbcards);
|
SAFE_DELETE(nbcards);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -367,6 +367,8 @@ MTGCardInstance * MTGPlayerCards::putInBattlefield(MTGCardInstance * card)
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Moves a card from one zone to another
|
||||||
|
// If the card is not actually in the expected "from" zone, does nothing and returns null
|
||||||
MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone * from, MTGGameZone * to)
|
MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone * from, MTGGameZone * to)
|
||||||
{
|
{
|
||||||
MTGCardInstance * copy = NULL;
|
MTGCardInstance * copy = NULL;
|
||||||
@@ -382,8 +384,9 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
|||||||
doCopy = 0;
|
doCopy = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((copy = from->removeCard(card, doCopy)))
|
if (!(copy = from->removeCard(card, doCopy)))
|
||||||
{
|
return NULL; //ERROR
|
||||||
|
|
||||||
if (options[Options::SFXVOLUME].number > 0)
|
if (options[Options::SFXVOLUME].number > 0)
|
||||||
{
|
{
|
||||||
if (to == g->players[0]->game->graveyard || to == g->players[1]->game->graveyard)
|
if (to == g->players[0]->game->graveyard || to == g->players[1]->game->graveyard)
|
||||||
@@ -432,8 +435,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
|||||||
g->receiveEvent(e);
|
g->receiveEvent(e);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
return card; //Error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MTGPlayerCards::discardRandom(MTGGameZone * from, MTGCardInstance * source)
|
void MTGPlayerCards::discardRandom(MTGGameZone * from, MTGCardInstance * source)
|
||||||
|
|||||||
@@ -1375,6 +1375,11 @@ int MTGPersistRule::receiveEvent(WEvent * event)
|
|||||||
if (e->to == p->game->graveyard)
|
if (e->to == p->game->graveyard)
|
||||||
{
|
{
|
||||||
MTGCardInstance * copy = p->game->putInZone(e->card, p->game->graveyard, e->card->owner->game->stack);
|
MTGCardInstance * copy = p->game->putInZone(e->card, p->game->graveyard, e->card->owner->game->stack);
|
||||||
|
if (!copy)
|
||||||
|
{
|
||||||
|
DebugTrace("MTGRULES: couldn't move card for persist");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Spell * spell = NEW Spell(copy);
|
Spell * spell = NEW Spell(copy);
|
||||||
spell->resolve();
|
spell->resolve();
|
||||||
spell->source->counters->addCounter(-1, -1);
|
spell->source->counters->addCounter(-1, -1);
|
||||||
|
|||||||
Reference in New Issue
Block a user