fixed a issue with dredge where it was entering the stack even tho dredging itself is a replacement effect.

This commit is contained in:
zethfoxster
2016-07-06 20:26:18 -04:00
parent 7b8b197a35
commit 8265253388
+14 -7
View File
@@ -2774,11 +2774,9 @@ WEvent * MTGDredgeRule::replace(WEvent * event)
Player * p = game->players[i]; Player * p = game->players[i];
if (e->player == p) if (e->player == p)
{ {
int Dredgers = 0;
for(int draw = 0;draw < e->nb_cards;draw++) for(int draw = 0;draw < e->nb_cards;draw++)
{ {
tcb = tf.createTargetChooser("dredgeable",card);
tcb->targetter = NULL;
vector<MTGAbility*>selection; vector<MTGAbility*>selection;
//look for other draw replacement effects //look for other draw replacement effects
list<ReplacementEffect *>::iterator it; list<ReplacementEffect *>::iterator it;
@@ -2802,13 +2800,20 @@ WEvent * MTGDredgeRule::replace(WEvent * event)
} }
} }
//there is a memleak here that i have no idea what causes it. //there is a memleak here that i have no idea what causes it. got it reduced to just 4 bytes but its still bothering me.
if (Dredgers < e->nb_cards)
{
tcb = tf.createTargetChooser("dredgeable", card);
tcb->targetter = NULL;
dredgeAbility = NEW dredgeCard(game, game->mLayers->actionLayer()->getMaxId(), card, NULL); dredgeAbility = NEW dredgeCard(game, game->mLayers->actionLayer()->getMaxId(), card, NULL);
dredgeAbility->oneShot = true; dredgeAbility->oneShot = true;
dredgeAbility->canBeInterrupted = false;
targetAbility = NEW GenericTargetAbility(game, "Dredge A Card", "", game->mLayers->actionLayer()->getMaxId(), card, tcb->clone(), dredgeAbility->clone()); targetAbility = NEW GenericTargetAbility(game, "Dredge A Card", "", game->mLayers->actionLayer()->getMaxId(), card, tcb->clone(), dredgeAbility->clone());
targetAbility->oneShot = true; SAFE_DELETE(tcb);
SAFE_DELETE(dredgeAbility); SAFE_DELETE(dredgeAbility);
targetAbility->oneShot = true;
targetAbility->canBeInterrupted = false;
targetAbilityAdder = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), card, NULL, targetAbility->clone()); targetAbilityAdder = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), card, NULL, targetAbility->clone());
targetAbilityAdder->oneShot = true; targetAbilityAdder->oneShot = true;
SAFE_DELETE(targetAbility); SAFE_DELETE(targetAbility);
@@ -2818,11 +2823,13 @@ WEvent * MTGDredgeRule::replace(WEvent * event)
selection.push_back(setDredge); selection.push_back(setDredge);
targetAbility1 = NEW AADrawer(game, this->GetId(), card, card, NULL, "1", TargetChooser::CONTROLLER, true); targetAbility1 = NEW AADrawer(game, this->GetId(), card, card, NULL, "1", TargetChooser::CONTROLLER, true);
targetAbility1->canBeInterrupted = false;
selection.push_back(targetAbility1); selection.push_back(targetAbility1);
MTGAbility * menuChoice = NEW MenuAbility(game, this->GetId(), card, card, true, selection, card->controller(), "Dredge or Draw"); MTGAbility * menuChoice = NEW MenuAbility(game, this->GetId(), card, card, true, selection, card->controller(), "Dredge or Draw");
menuChoice->addToGame(); menuChoice->addToGame();
SAFE_DELETE(tcb);
}
} }
SAFE_DELETE(event); SAFE_DELETE(event);