Erwan
- fixed divergent growth (issue 243). Unfortunately the underlying issue is quite complex, and Wagic doesn't handle it very well. Basically, all "until end of turn" effects run the risk of being partially deleted before the end of the turn, leading to segfaults or memory leaks. This is because some abilities' "clone" method doesn't actually clone them entirely... The fix for divergent growth is a hack that works only for lords+mana producer combination, but I need a more "generic fix" in the long run...
This commit is contained in:
@@ -155,6 +155,7 @@ death_grasp.txt
|
||||
death_ward.txt
|
||||
deja_vu.txt
|
||||
dingus_egg.txt
|
||||
divergent_growth.txt
|
||||
doomed_necromancer.txt
|
||||
double_strike_i145.txt
|
||||
double_strike2_i145.txt
|
||||
|
||||
21
projects/mtg/bin/Res/test/divergent_growth.txt
Normal file
21
projects/mtg/bin/Res/test/divergent_growth.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
#Bug Divergent growth
|
||||
#see http://code.google.com/p/wagic/issues/detail?id=243
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:divergent growth
|
||||
manapool:{G}
|
||||
inplay:forest
|
||||
[PLAYER2]
|
||||
[DO]
|
||||
divergent growth
|
||||
forest
|
||||
choice 2
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
graveyard:divergent growth
|
||||
inplay:forest
|
||||
manapool:{W}
|
||||
[PLAYER2]
|
||||
[END]
|
||||
@@ -1366,7 +1366,30 @@ class APowerToughnessModifierUntilEndOfTurn: public ActivatedAbility{
|
||||
};
|
||||
|
||||
|
||||
class GenericInstantAbility: public InstantAbility{
|
||||
public:
|
||||
MTGAbility * ability;
|
||||
GenericInstantAbility(int _id, MTGCardInstance * _source, Damageable * _target, MTGAbility * ability): InstantAbility(_id, _source, _target), ability(ability){
|
||||
}
|
||||
|
||||
int addToGame(){
|
||||
ability->forceDestroy = -1;
|
||||
ability->addToGame();
|
||||
return InstantAbility::addToGame();
|
||||
}
|
||||
|
||||
int destroy(){
|
||||
ability->forceDestroy = 0;
|
||||
return InstantAbility::destroy();
|
||||
}
|
||||
|
||||
GenericInstantAbility * clone() const{
|
||||
GenericInstantAbility * a = NEW GenericInstantAbility(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//Untap Blockers with simple Mana Mechanism
|
||||
@@ -1785,8 +1808,13 @@ class ALord:public ListMaintainerAbility{
|
||||
if (d->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE){
|
||||
a->source = (MTGCardInstance *)d;
|
||||
}
|
||||
a->addToGame();
|
||||
abilities[d] = a;
|
||||
if (oneShot){
|
||||
MTGAbility * wrapper = NEW GenericInstantAbility(1,source,d,a);
|
||||
wrapper->addToGame();
|
||||
}else{
|
||||
a->addToGame();
|
||||
abilities[d] = a;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2247,7 +2247,6 @@ AManaProducer::AManaProducer(int id, MTGCardInstance * card, Targetable * t, Man
|
||||
|
||||
|
||||
AManaProducer::~AManaProducer(){
|
||||
if (isClone) return;
|
||||
LOG("==Destroying ManaProducer Object");
|
||||
SAFE_DELETE(cost);
|
||||
SAFE_DELETE(output);
|
||||
@@ -2256,6 +2255,10 @@ AManaProducer::AManaProducer(int id, MTGCardInstance * card, Targetable * t, Man
|
||||
|
||||
AManaProducer * AManaProducer::clone() const{
|
||||
AManaProducer * a = NEW AManaProducer(*this);
|
||||
a->cost = NEW ManaCost();
|
||||
a->output = NEW ManaCost();
|
||||
a->cost->copy(cost);
|
||||
a->output->copy(output);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -153,6 +153,7 @@ void ManaCost::init(){
|
||||
|
||||
|
||||
void ManaCost::copy(ManaCost * _manaCost){
|
||||
if (!_manaCost) return;
|
||||
for (unsigned int i = 0; i <= Constants::MTG_NB_COLORS; i++){
|
||||
cost[i] = _manaCost->getCost(i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user