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

View File

@@ -439,20 +439,22 @@ int AIAction::getEfficiency()
{
if(cc && _target)
{
if(_target && _target->controller() == p && cc->toughness>=0)
if(_target->controller() == p && cc->toughness>=0)
{
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;
}
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;
}
if(cc->maxNb && _target->counters && _target->counters->counters && _target->counters->hasCounter(cc->power,cc->toughness)->nb >= cc->maxNb)
efficiency = 0;
}
}
break;

View File

@@ -2559,6 +2559,8 @@ int ATransformer::addToGame()
{
AbilityFactory af;
MTGAbility * aNew = af.parseMagicLine(newAbilitiesList[k], 0, NULL, _target);
if(!aNew)
continue;
aNew->isClone = 1;
GenericTargetAbility * gta = dynamic_cast<GenericTargetAbility*> (aNew);
if (gta)
@@ -2578,6 +2580,7 @@ int ATransformer::addToGame()
((MultiAbility *)aNew)->source = _target;
((MultiAbility *)aNew)->abilities[0]->source = _target;
}
aNew->target = _target;
aNew->source = (MTGCardInstance *) _target;
if(aNew->oneShot)
@@ -2586,8 +2589,10 @@ int ATransformer::addToGame()
delete aNew;
}
else
{
aNew->addToGame();
newAbilities[_target].push_back(aNew);
newAbilities[_target].push_back(aNew);
}
}
}
if(newpowerfound )
@@ -2691,7 +2696,10 @@ int ATransformer::destroy()
{
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())
{