fixed a heap corruption caused in atransformer was a mistake in the code.

also, if ai is adding counters and we're greater then or equal to the max amount that counter ability allows, eff = o.
This commit is contained in:
omegablast2002@yahoo.com
2011-07-13 18:39:51 +00:00
parent 69e55dfcbf
commit a8837e95c6
2 changed files with 15 additions and 5 deletions
+5 -3
View File
@@ -439,20 +439,22 @@ int AIAction::getEfficiency()
{ {
if(cc && _target) if(cc && _target)
{ {
if(_target && _target->controller() == p && cc->toughness>=0) if(_target->controller() == p && cc->toughness>=0)
{ {
efficiency = 90; efficiency = 90;
} }
if(_target && _target->controller() != p && ((_target->toughness + cc->toughness <= 0 && _target->toughness) || (cc->toughness < 0 && cc->power < 0))) if(_target->controller() != p && ((_target->toughness + cc->toughness <= 0 && _target->toughness) || (cc->toughness < 0 && cc->power < 0)))
{ {
efficiency = 90; efficiency = 90;
} }
if(_target && _target->counters && _target->counters->counters && _target->counters->hasCounter(cc->power,cc->toughness) && _target->counters->hasCounter(cc->power,cc->toughness)->nb > 15) if(_target->counters && _target->counters->counters && _target->counters->hasCounter(cc->power,cc->toughness) && _target->counters->hasCounter(cc->power,cc->toughness)->nb > 15)
{ {
efficiency = _target->counters->hasCounter(cc->power,cc->toughness)->nb; efficiency = _target->counters->hasCounter(cc->power,cc->toughness)->nb;
} }
if(cc->maxNb && _target->counters && _target->counters->counters && _target->counters->hasCounter(cc->power,cc->toughness)->nb >= cc->maxNb)
efficiency = 0;
} }
} }
break; break;
+10 -2
View File
@@ -2559,6 +2559,8 @@ int ATransformer::addToGame()
{ {
AbilityFactory af; AbilityFactory af;
MTGAbility * aNew = af.parseMagicLine(newAbilitiesList[k], 0, NULL, _target); MTGAbility * aNew = af.parseMagicLine(newAbilitiesList[k], 0, NULL, _target);
if(!aNew)
continue;
aNew->isClone = 1; aNew->isClone = 1;
GenericTargetAbility * gta = dynamic_cast<GenericTargetAbility*> (aNew); GenericTargetAbility * gta = dynamic_cast<GenericTargetAbility*> (aNew);
if (gta) if (gta)
@@ -2578,6 +2580,7 @@ int ATransformer::addToGame()
((MultiAbility *)aNew)->source = _target; ((MultiAbility *)aNew)->source = _target;
((MultiAbility *)aNew)->abilities[0]->source = _target; ((MultiAbility *)aNew)->abilities[0]->source = _target;
} }
aNew->target = _target; aNew->target = _target;
aNew->source = (MTGCardInstance *) _target; aNew->source = (MTGCardInstance *) _target;
if(aNew->oneShot) if(aNew->oneShot)
@@ -2586,8 +2589,10 @@ int ATransformer::addToGame()
delete aNew; delete aNew;
} }
else else
{
aNew->addToGame(); aNew->addToGame();
newAbilities[_target].push_back(aNew); newAbilities[_target].push_back(aNew);
}
} }
} }
if(newpowerfound ) if(newpowerfound )
@@ -2691,7 +2696,10 @@ int ATransformer::destroy()
{ {
for (unsigned int i = 0;i < newAbilities[_target].size(); i++) for (unsigned int i = 0;i < newAbilities[_target].size(); i++)
{ {
newAbilities[_target].at(i)->forceDestroy = 1; if(newAbilities[_target].at(i))
{
newAbilities[_target].at(i)->forceDestroy = 1;
}
} }
if (newAbilities.find(_target) != newAbilities.end()) if (newAbilities.find(_target) != newAbilities.end())
{ {