- Fix for issue 660 (changelings have become slower)
-- I removed the string comparison, which was expensive (the test is not necessary anymore, since it was "shielding" us from fake types (names), which are not creature subtypes, and therefore do not go through). I also moved one function call outside of the loop, just in case that wasn't optimized by the compiler. - Removed unused Subtypes.cpp function (I don't really want people to use it, it can be quite expensive if used incorrectly) - moved a test for issue 501 that has been fixed a while ago (we forgot to add the test to the test suite)
This commit is contained in:
@@ -6,6 +6,7 @@ generic/becomes_transform_i559.txt
|
||||
generic/becomes_transform_i559_2.txt
|
||||
generic/bushido_1.txt
|
||||
generic/bushido_2.txt
|
||||
generic/changeling_i501.txt
|
||||
generic/cycling.txt
|
||||
generic/cycling2.txt
|
||||
generic/deathtouch.txt
|
||||
|
||||
@@ -41,7 +41,6 @@ public:
|
||||
Subtypes();
|
||||
int find(string subtype, bool forceAdd = true);
|
||||
string find(unsigned int id);
|
||||
bool isSubtypeOfType(string subtype, string type);
|
||||
bool isSubtypeOfType(unsigned int subtype, unsigned int type);
|
||||
bool isSuperType(unsigned int type);
|
||||
bool isType(unsigned int type);
|
||||
|
||||
@@ -2426,18 +2426,12 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t
|
||||
|
||||
if (stypes.find("allsubtypes") != string::npos || stypes.find("removecreaturesubtypes") != string::npos)
|
||||
{
|
||||
for (size_t i = 0; i <Subtypes::subtypesList->getValuesById().size(); ++i)
|
||||
const vector<string> values = Subtypes::subtypesList->getValuesById();
|
||||
for (size_t i = 0; i <values.size(); ++i)
|
||||
{
|
||||
if (!Subtypes::subtypesList->isSubtypeOfType(i,Subtypes::TYPE_CREATURE))
|
||||
continue;
|
||||
|
||||
//Erwan 2011/5/6 String comparison is expensive. Any way to do this in a cleaner way?
|
||||
//this check is related to targetchooser instances of cards dynamically loaded subtypes.
|
||||
//example(foreach(arbor elf)) adds this as a subtype for list ment.
|
||||
//TODO find cheaper method
|
||||
string s = Subtypes::subtypesList->find(i);
|
||||
if (s.find(" ") != string::npos)
|
||||
continue;
|
||||
types.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,23 +173,14 @@ void MTGCardInstance::initMTGCI()
|
||||
|
||||
if (basicAbilities[(int)Constants::CHANGELING])
|
||||
{//if the card is a changeling, it gains all creature subtypes
|
||||
for (size_t i = 0; i <Subtypes::subtypesList->getValuesById().size(); ++i)
|
||||
const vector<string> values = Subtypes::subtypesList->getValuesById();
|
||||
for (size_t i = 0; i < values.size(); ++i)
|
||||
{
|
||||
if (hasSubtype(i))
|
||||
continue;
|
||||
|
||||
if (!Subtypes::subtypesList->isSubtypeOfType(i,Subtypes::TYPE_CREATURE))
|
||||
continue;
|
||||
|
||||
//Erwan 2011/5/6 String comparison is expensive. Any way to do this in a cleaner way?
|
||||
//this check is related to targetchooser instances of cards dynamically loaded subtypes.
|
||||
//example(foreach(arbor elf)) adds this as a subtype for list ment.
|
||||
//TODO find cheaper method
|
||||
string s = Subtypes::subtypesList->find(i);
|
||||
if (s.find(" ") != string::npos)
|
||||
continue;
|
||||
|
||||
addType(i);
|
||||
//Don' want to send any event to the gameObserver inside of initMCGI, so calling the parent addType method instead of mine
|
||||
CardPrimitive::addType(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,12 +63,6 @@ string Subtypes::find(unsigned int id)
|
||||
return valuesById[id - 1];
|
||||
}
|
||||
|
||||
bool Subtypes::isSubtypeOfType(string subtype, string type)
|
||||
{
|
||||
unsigned int subtypeInt = find(subtype);
|
||||
unsigned int typeInt = find(type);
|
||||
return isSubtypeOfType(subtypeInt, typeInt);
|
||||
}
|
||||
bool Subtypes::isSubtypeOfType(unsigned int subtype, unsigned int type)
|
||||
{
|
||||
return (subtypesToType[subtype] == type);
|
||||
|
||||
Reference in New Issue
Block a user