From da1ec8eed31ada0b180ea046a45e848da56c5805 Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Mon, 9 May 2011 19:42:30 +0000 Subject: [PATCH] moved the readding of types below the removel of abilities incase a becomes would be used as a newability. 2nd, found a infinate loop is created when you cast a loseabilities on a card which has loseabilities, when the 2 effect ends it readds the first one, before it is removed, making the first one remove the 2nd one and repeat forever.... this is only a half fix, it created a memleak in the place of the loop :/ so wololo please review!!! --- projects/mtg/src/AllAbilities.cpp | 37 +++++++++++++++++++------------ 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index dfb2a1727..4d288685f 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -2662,13 +2662,6 @@ int ATransformer::destroy() _target->setColor(*it); } - if (remove) - { - for (it = oldtypes.begin(); it != oldtypes.end(); it++) - { - _target->addType(*it); - } - } if(newpowerfound ) { _target->power = oldpower; @@ -2688,7 +2681,14 @@ int ATransformer::destroy() newAbilities.erase(_target); } } - //we reset the name in the case that we removed or added types to a card, so that it retains its original name when the effect is removed. + if (remove) + { + for (it = oldtypes.begin(); it != oldtypes.end(); it++) + { + _target->addType(*it); + } + } + //n the case that we removed or added types to a card, so that it retains its original name when the effect is removed. _target->name.clear(); _target->setName(_target->model->data->name.c_str()); } @@ -2853,12 +2853,21 @@ int ALoseAbilities::destroy() MTGAbility * a = storedAbilities[i]; //OneShot abilities are not supposed to stay in the game for long. // If we copied one, something wrong probably happened - if (a->oneShot) - { - DebugTrace("ALL_ABILITIES: Ability should not be one shot"); - continue; - } - a->addToGame(); + ALoseAbilities * la = dynamic_cast (a); + if (a->oneShot||la) + { + if(la) + { + DebugTrace("Dangerous chance of infinate loop avoided!"); + continue; + } + else + { + DebugTrace("ALLABILITIES: Ability should not be one shot"); + continue; + } + } + a->addToGame(); } storedAbilities.clear(); return 1;