Fixed a problem when running the multithreaded testsuite with sound.

This commit is contained in:
Xawotihs
2012-01-11 20:13:24 +00:00
parent f388414f3f
commit cb7f3b070f
+10 -1
View File
@@ -1018,7 +1018,7 @@ int MTGCardInstance::cantBeBlockedBy(MTGCardInstance * card)
/* Choose a sound sample to associate to that card */ /* Choose a sound sample to associate to that card */
JSample * MTGCardInstance::getSample() JSample * MTGCardInstance::getSample()
{ {
JSample * js; JSample * js = 0;
if (sample.size()) if (sample.size())
return WResourceManager::Instance()->RetrieveSample(sample); return WResourceManager::Instance()->RetrieveSample(sample);
@@ -1028,6 +1028,8 @@ JSample * MTGCardInstance::getSample()
string type = Subtypes::subtypesList->find(types[i]); string type = Subtypes::subtypesList->find(types[i]);
std::transform(type.begin(), type.end(), type.begin(), ::tolower); std::transform(type.begin(), type.end(), type.begin(), ::tolower);
type = type + ".wav"; type = type + ".wav";
if(getObserver() && getObserver()->getResourceManager())
{
js = WResourceManager::Instance()->RetrieveSample(type); js = WResourceManager::Instance()->RetrieveSample(type);
if (js) if (js)
{ {
@@ -1035,6 +1037,7 @@ JSample * MTGCardInstance::getSample()
return js; return js;
} }
} }
}
if (basicAbilities.any()) if (basicAbilities.any())
{ {
@@ -1044,6 +1047,8 @@ JSample * MTGCardInstance::getSample()
continue; continue;
string type = Constants::MTGBasicAbilities[x]; string type = Constants::MTGBasicAbilities[x];
type = type + ".wav"; type = type + ".wav";
if(getObserver() && getObserver()->getResourceManager())
{
js = WResourceManager::Instance()->RetrieveSample(type); js = WResourceManager::Instance()->RetrieveSample(type);
if (js) if (js)
{ {
@@ -1052,6 +1057,7 @@ JSample * MTGCardInstance::getSample()
} }
} }
} }
}
string type = ""; string type = "";
if(!types.size()) if(!types.size())
@@ -1059,12 +1065,15 @@ JSample * MTGCardInstance::getSample()
type = Subtypes::subtypesList->find(types[0]); type = Subtypes::subtypesList->find(types[0]);
std::transform(type.begin(), type.end(), type.begin(), ::tolower); std::transform(type.begin(), type.end(), type.begin(), ::tolower);
type.append(".wav"); type.append(".wav");
if(getObserver() && getObserver()->getResourceManager())
{
js = WResourceManager::Instance()->RetrieveSample(type); js = WResourceManager::Instance()->RetrieveSample(type);
if (js) if (js)
{ {
sample = string(type); sample = string(type);
return js; return js;
} }
}
return NULL; return NULL;
} }