Hid Subtypes behind MTGAllCards and added a mutex to be able to use both singleton from several threads.

This commit is contained in:
Xawotihs@gmail.com
2012-02-12 22:20:05 +00:00
parent ebc4eb331f
commit bd1afebbea
15 changed files with 74 additions and 54 deletions

View File

@@ -419,12 +419,6 @@ MTGAllCards::MTGAllCards()
init();
}
MTGAllCards::MTGAllCards(const char * config_file, const char * set_name)
{
init();
load(config_file, set_name, 0);
}
MTGAllCards::~MTGAllCards()
{
for (map<int, MTGCard *>::iterator it = collection.begin(); it != collection.end(); it++)
@@ -637,6 +631,7 @@ void MTGAllCards::prefetchCardNameCache()
MTGCard * MTGAllCards::getCardByName(string nameDescriptor)
{
boost::mutex::scoped_lock lock(instance->mMutex);
if (!nameDescriptor.size()) return NULL;
if (nameDescriptor[0] == '#') return NULL;
@@ -1085,7 +1080,7 @@ void MTGDeck::printDetailedDeckText(std::ofstream& file )
// Add the card's types
vector<int>::iterator typeIter;
for ( typeIter = card->data->types.begin(); typeIter != card->data->types.end(); ++typeIter )
types << Subtypes::subtypesList->find( *typeIter ) << " ";
types << MTGAllCards::findType( *typeIter ) << " ";
currentCard << trim(types.str()) << ", ";
types.str(""); // reset the buffer.