couple tweaks to transforms to it doesn't add subkeywords as types....

2nd, removed a peice of code which was originally added i imagine before list mentioner was created which added cards whos names ended in "s" to the subtypes list, this is completely unrelated to the "s" charector added to targetchooser. this was actually a really nasty hack....
previous subtypes list contained 1200 variables...the new one after this removel is about 237ish....

this does not impact foreach, or any targetchoosers ability to target a card by name, targetchooser is coded to add card names to the subtypes list as it needs them, so using foreach(arbor elf) will add this to subtypes list for targeting purposes, in the future we might want to have this kind of check done and handled outside of the subtypes list, adding card names to that list for the purpose of targeting is just dirty.

this fixes a ugly lag spike introduced with the change to subtypes...for now...we need to consider a better way to sort these in the future to avoid this returning as subtypeslist gets bigger.
This commit is contained in:
omegablast2002@yahoo.com
2011-05-09 18:10:10 +00:00
parent 6d4f0c024c
commit 8737aec005
3 changed files with 26 additions and 30 deletions

View File

@@ -2420,7 +2420,7 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t
//this subkeyword adds a color without removing the existing colors. //this subkeyword adds a color without removing the existing colors.
addNewColors = (sabilities.find("newcolors") != string::npos); addNewColors = (sabilities.find("newcolors") != string::npos);
remove = (stypes.find("removesubtypes") != string::npos); remove = (stypes.find("removealltypes") != string::npos);
removeCreatureSubtypes = (stypes.find("removecreaturesubtypes") != string::npos); removeCreatureSubtypes = (stypes.find("removecreaturesubtypes") != string::npos);
removeTypes = (stypes.find("removetypes") != string::npos); removeTypes = (stypes.find("removetypes") != string::npos);
@@ -2432,8 +2432,9 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t
continue; continue;
//Erwan 2011/5/6 String comparison is expensive. Any way to do this in a cleaner way? //Erwan 2011/5/6 String comparison is expensive. Any way to do this in a cleaner way?
//I think this is releated to the fact that "Pestilence Rats" is a type for some reason, maybe we don't need that anymore //this check is related to targetchooser instances of cards dynamically loaded subtypes.
//TODO Remove the following block if possible //example(foreach(arbor elf)) adds this as a subtype for list ment.
//TODO find cheaper method
string s = Subtypes::subtypesList->find(i); string s = Subtypes::subtypesList->find(i);
if (s.find(" ") != string::npos) if (s.find(" ") != string::npos)
continue; continue;
@@ -2502,27 +2503,29 @@ int ATransformer::addToGame()
_target->removeType(*it); _target->removeType(*it);
} }
} }
for (it = types.begin(); it != types.end(); it++) else
{ {
if(removeCreatureSubtypes) for (it = types.begin(); it != types.end(); it++)
{ {
_target->removeType(*it); if(removeCreatureSubtypes)
} {
else if(_target->hasSubtype(*it)) _target->removeType(*it);
{ }
//we generally don't want to give a creature type creature again else if(_target->hasSubtype(*it))
//all it does is create a sloppy mess of the subtype line on alternative quads {
//also creates instances where a card gained a type from an ability like this one //we generally don't want to give a creature type creature again
//then loses the type through another ability, when this effect is destroyed the creature regains //all it does is create a sloppy mess of the subtype line on alternative quads
//the type, which is wrong. //also creates instances where a card gained a type from an ability like this one
dontremove.push_back(*it); //then loses the type through another ability, when this effect is destroyed the creature regains
} //the type, which is wrong.
else dontremove.push_back(*it);
{ }
_target->addType(*it); else
{
_target->addType(*it);
}
} }
} }
for (it = colors.begin(); it != colors.end(); it++) for (it = colors.begin(); it != colors.end(); it++)
{ {
_target->setColor(*it); _target->setColor(*it);
@@ -2663,7 +2666,6 @@ int ATransformer::destroy()
{ {
for (it = oldtypes.begin(); it != oldtypes.end(); it++) for (it = oldtypes.begin(); it != oldtypes.end(); it++)
{ {
if (!_target->hasSubtype(*it))
_target->addType(*it); _target->addType(*it);
} }
} }

View File

@@ -272,10 +272,6 @@ void CardPrimitive::setName(const string& value)
name = value; name = value;
lcname = value; lcname = value;
std::transform(lcname.begin(), lcname.end(), lcname.begin(), ::tolower); std::transform(lcname.begin(), lcname.end(), lcname.begin(), ::tolower);
//This is a bug fix for plague rats and the "foreach ability"
//Right now we add names as types, so that they get recognized
if (value.length() && lcname.at(value.length() - 1) == 's')
Subtypes::subtypesList->find(lcname);
} }
const string& CardPrimitive::getName() const const string& CardPrimitive::getName() const

View File

@@ -182,14 +182,12 @@ void MTGCardInstance::initMTGCI()
continue; continue;
//Erwan 2011/5/6 String comparison is expensive. Any way to do this in a cleaner way? //Erwan 2011/5/6 String comparison is expensive. Any way to do this in a cleaner way?
//I think this is releated to the fact that "Pestilence Rats" is a type for some reason, maybe we don't need that anymore //this check is related to targetchooser instances of cards dynamically loaded subtypes.
//TODO Remove the following block if possible //example(foreach(arbor elf)) adds this as a subtype for list ment.
{ //TODO find cheaper method
string s = Subtypes::subtypesList->find(i); string s = Subtypes::subtypesList->find(i);
if (s.find(" ") != string::npos) if (s.find(" ") != string::npos)
continue; continue;
}
addType(i); addType(i);
} }