just cleaning up a memleak i created, moving the parsing of the "newability" in transforms into the resolve rather then creating an object that might not be used.
This commit is contained in:
@@ -3928,11 +3928,11 @@ public:
|
|||||||
bool newtoughnessfound;
|
bool newtoughnessfound;
|
||||||
int oldtoughness;
|
int oldtoughness;
|
||||||
map<Damageable *, vector<MTGAbility *> > newAbilities;
|
map<Damageable *, vector<MTGAbility *> > newAbilities;
|
||||||
vector<MTGAbility *> newAbilitiesList;
|
vector<string> newAbilitiesList;
|
||||||
bool newAbilityFound;
|
bool newAbilityFound;
|
||||||
|
|
||||||
|
|
||||||
ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<MTGAbility *> newAbilitiesList,bool newAbilityFound = false);
|
ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<string> newAbilitiesList,bool newAbilityFound = false);
|
||||||
int addToGame();
|
int addToGame();
|
||||||
int destroy();
|
int destroy();
|
||||||
const char * getMenuText();
|
const char * getMenuText();
|
||||||
@@ -3955,11 +3955,11 @@ public:
|
|||||||
bool newtoughnessfound;
|
bool newtoughnessfound;
|
||||||
int oldtoughness;
|
int oldtoughness;
|
||||||
bool remove;
|
bool remove;
|
||||||
vector<MTGAbility *> newAbilitiesList;
|
vector<string> newAbilitiesList;
|
||||||
map<Damageable *, vector<MTGAbility *> > newAbilities;
|
map<Damageable *, vector<MTGAbility *> > newAbilities;
|
||||||
bool newAbilityFound;
|
bool newAbilityFound;
|
||||||
|
|
||||||
AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vector<MTGAbility*>newAbilitiesList = vector<MTGAbility*>(),bool newAbilityFound = false);
|
AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vector<string>newAbilitiesList = vector<string>(),bool newAbilityFound = false);
|
||||||
int addToGame();
|
int addToGame();
|
||||||
const char * getMenuText();
|
const char * getMenuText();
|
||||||
AForeverTransformer * clone() const;
|
AForeverTransformer * clone() const;
|
||||||
@@ -3975,11 +3975,11 @@ public:
|
|||||||
bool newpowerfound;
|
bool newpowerfound;
|
||||||
string newtoughness;
|
string newtoughness;
|
||||||
bool newtoughnessfound;
|
bool newtoughnessfound;
|
||||||
vector<MTGAbility *> newAbilitiesList;
|
vector<string> newAbilitiesList;
|
||||||
map<Damageable *, vector<MTGAbility *> > newAbilities;
|
map<Damageable *, vector<MTGAbility *> > newAbilities;
|
||||||
bool newAbilityFound;
|
bool newAbilityFound;
|
||||||
|
|
||||||
ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types = "", string abilities = "",string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vector<MTGAbility*>newAbilitiesList = vector<MTGAbility*>(),bool newAbilityFound = false);
|
ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types = "", string abilities = "",string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vector<string>newAbilitiesList = vector<string>(),bool newAbilityFound = false);
|
||||||
int resolve();
|
int resolve();
|
||||||
const char * getMenuText();
|
const char * getMenuText();
|
||||||
ATransformerUEOT * clone() const;
|
ATransformerUEOT * clone() const;
|
||||||
@@ -3995,11 +3995,11 @@ public:
|
|||||||
bool newpowerfound;
|
bool newpowerfound;
|
||||||
string newtoughness;
|
string newtoughness;
|
||||||
bool newtoughnessfound;
|
bool newtoughnessfound;
|
||||||
vector<MTGAbility *> newAbilitiesList;
|
vector<string> newAbilitiesList;
|
||||||
map<Damageable *, vector<MTGAbility *> > newAbilities;
|
map<Damageable *, vector<MTGAbility *> > newAbilities;
|
||||||
bool newAbilityFound;
|
bool newAbilityFound;
|
||||||
|
|
||||||
ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vector<MTGAbility*>newAbilitiesList = vector<MTGAbility*>(),bool newAbilityFound = false);
|
ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower = "",bool newpowerfound = false,string newtoughness = "",bool newtoughnessfound = false,vector<string>newAbilitiesList = vector<string>(),bool newAbilityFound = false);
|
||||||
int resolve();
|
int resolve();
|
||||||
const char * getMenuText();
|
const char * getMenuText();
|
||||||
ATransformerFOREVER * clone() const;
|
ATransformerFOREVER * clone() const;
|
||||||
|
|||||||
@@ -2210,7 +2210,7 @@ AAlterCost::~AAlterCost()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ATransformer
|
// ATransformer
|
||||||
ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<MTGAbility *> newAbilitiesList,bool newAbilityFound) :
|
ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<string> newAbilitiesList,bool newAbilityFound) :
|
||||||
MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound)
|
MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -2307,9 +2307,9 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t
|
|||||||
{
|
{
|
||||||
for (unsigned int k = 0 ; k < newAbilitiesList.size();k++)
|
for (unsigned int k = 0 ; k < newAbilitiesList.size();k++)
|
||||||
{
|
{
|
||||||
|
AbilityFactory af;
|
||||||
MTGAbility * aNew = newAbilitiesList[k]->clone();
|
MTGAbility * aNew = af.parseMagicLine(newAbilitiesList[k],NULL, NULL, _target);
|
||||||
|
aNew->isClone = 1;
|
||||||
GenericTargetAbility * gta = dynamic_cast<GenericTargetAbility*> (aNew);
|
GenericTargetAbility * gta = dynamic_cast<GenericTargetAbility*> (aNew);
|
||||||
if (gta)
|
if (gta)
|
||||||
{
|
{
|
||||||
@@ -2329,7 +2329,13 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t
|
|||||||
}
|
}
|
||||||
aNew->target = _target;
|
aNew->target = _target;
|
||||||
aNew->source = (MTGCardInstance *) _target;
|
aNew->source = (MTGCardInstance *) _target;
|
||||||
aNew->addToGame();
|
if(aNew->oneShot)
|
||||||
|
{
|
||||||
|
aNew->resolve();
|
||||||
|
delete aNew;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aNew->addToGame();
|
||||||
newAbilities[_target].push_back(aNew);
|
newAbilities[_target].push_back(aNew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2426,18 +2432,11 @@ ATransformer * ATransformer::clone() const
|
|||||||
|
|
||||||
ATransformer::~ATransformer()
|
ATransformer::~ATransformer()
|
||||||
{
|
{
|
||||||
if(!isClone)
|
|
||||||
{
|
|
||||||
for (unsigned int k = 0; k < newAbilitiesList.size();k++)
|
|
||||||
{
|
|
||||||
SAFE_DELETE(newAbilitiesList[k]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AForeverTransformer
|
// AForeverTransformer
|
||||||
AForeverTransformer::AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes,
|
AForeverTransformer::AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes,
|
||||||
string sabilities,string newpower,bool newpowerfound, string newtoughness,bool newtoughnessfound,vector<MTGAbility*> newAbilitiesList,bool newAbilityFound) :
|
string sabilities,string newpower,bool newpowerfound, string newtoughness,bool newtoughnessfound,vector<string> newAbilitiesList,bool newAbilityFound) :
|
||||||
MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound)
|
MTGAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound)
|
||||||
{
|
{
|
||||||
aType = MTGAbility::STANDARD_BECOMES;
|
aType = MTGAbility::STANDARD_BECOMES;
|
||||||
@@ -2492,8 +2491,9 @@ int AForeverTransformer::addToGame()
|
|||||||
{
|
{
|
||||||
for (unsigned int k = 0 ; k < newAbilitiesList.size();k++)
|
for (unsigned int k = 0 ; k < newAbilitiesList.size();k++)
|
||||||
{
|
{
|
||||||
|
AbilityFactory af;
|
||||||
MTGAbility * aNew = newAbilitiesList[k]->clone();
|
MTGAbility * aNew = af.parseMagicLine(newAbilitiesList[k],NULL, NULL, _target);
|
||||||
|
aNew->isClone = 1;
|
||||||
|
|
||||||
GenericTargetAbility * gta = dynamic_cast<GenericTargetAbility*> (aNew);
|
GenericTargetAbility * gta = dynamic_cast<GenericTargetAbility*> (aNew);
|
||||||
if (gta)
|
if (gta)
|
||||||
@@ -2514,6 +2514,12 @@ int AForeverTransformer::addToGame()
|
|||||||
}
|
}
|
||||||
aNew->target = _target;
|
aNew->target = _target;
|
||||||
aNew->source = (MTGCardInstance *) _target;
|
aNew->source = (MTGCardInstance *) _target;
|
||||||
|
if(aNew->oneShot)
|
||||||
|
{
|
||||||
|
aNew->resolve();
|
||||||
|
delete aNew;
|
||||||
|
}
|
||||||
|
else
|
||||||
aNew->addToGame();
|
aNew->addToGame();
|
||||||
newAbilities[_target].push_back(aNew);
|
newAbilities[_target].push_back(aNew);
|
||||||
}
|
}
|
||||||
@@ -2553,17 +2559,10 @@ AForeverTransformer * AForeverTransformer::clone() const
|
|||||||
}
|
}
|
||||||
AForeverTransformer::~AForeverTransformer()
|
AForeverTransformer::~AForeverTransformer()
|
||||||
{
|
{
|
||||||
if(!isClone)
|
|
||||||
{
|
|
||||||
for (unsigned int k = 0; k < newAbilitiesList.size();k++)
|
|
||||||
{
|
|
||||||
SAFE_DELETE(newAbilitiesList[k]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//ATransformerUEOT
|
//ATransformerUEOT
|
||||||
ATransformerUEOT::ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<MTGAbility*>newAbilitiesList,bool newAbilityFound) :
|
ATransformerUEOT::ATransformerUEOT(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<string>newAbilitiesList,bool newAbilityFound) :
|
||||||
InstantAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound)
|
InstantAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound)
|
||||||
{
|
{
|
||||||
ability = NEW ATransformer(id, source, target, types, abilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound);
|
ability = NEW ATransformer(id, source, target, types, abilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound);
|
||||||
@@ -2596,7 +2595,7 @@ ATransformerUEOT::~ATransformerUEOT()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ATransformerFOREVER
|
// ATransformerFOREVER
|
||||||
ATransformerFOREVER::ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<MTGAbility*>newAbilitiesList,bool newAbilityFound) :
|
ATransformerFOREVER::ATransformerFOREVER(int id, MTGCardInstance * source, MTGCardInstance * target, string types, string abilities,string newpower,bool newpowerfound,string newtoughness,bool newtoughnessfound,vector<string>newAbilitiesList,bool newAbilityFound) :
|
||||||
InstantAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound)
|
InstantAbility(id, source, target),newpower(newpower),newpowerfound(newpowerfound),newtoughness(newtoughness),newtoughnessfound(newtoughnessfound),newAbilitiesList(newAbilitiesList),newAbilityFound(newAbilityFound)
|
||||||
{
|
{
|
||||||
ability = NEW AForeverTransformer(id, source, target, types, abilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound);
|
ability = NEW AForeverTransformer(id, source, target, types, abilities,newpower,newpowerfound,newtoughness,newtoughnessfound,newAbilitiesList,newAbilityFound);
|
||||||
|
|||||||
@@ -2548,7 +2548,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
string newtoughness = "";
|
string newtoughness = "";
|
||||||
vector <string> abilities = split(sabilities, ',');
|
vector <string> abilities = split(sabilities, ',');
|
||||||
bool newAbilityFound = false;
|
bool newAbilityFound = false;
|
||||||
vector<MTGAbility *> newAbilitiesList;
|
vector<string> newAbilitiesList;
|
||||||
storedString.erase();
|
storedString.erase();
|
||||||
storedString.append(extraTransforms);
|
storedString.append(extraTransforms);
|
||||||
extraTransforms.erase();
|
extraTransforms.erase();
|
||||||
@@ -2571,7 +2571,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
newAbilityFound = true;
|
newAbilityFound = true;
|
||||||
size_t NewSkill = abilities[j].find("[");
|
size_t NewSkill = abilities[j].find("[");
|
||||||
string newAbilities = abilities[j].substr(NewSkill + 1,abilities[j].find(']') - 1);
|
string newAbilities = abilities[j].substr(NewSkill + 1,abilities[j].find(']') - 1);
|
||||||
newAbilitiesList.push_back(parseMagicLine(newAbilities, id, spell, card));
|
newAbilitiesList.push_back(newAbilities.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MTGAbility * a;
|
MTGAbility * a;
|
||||||
|
|||||||
Reference in New Issue
Block a user