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
+22 -13
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,11 +1028,14 @@ 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";
js = WResourceManager::Instance()->RetrieveSample(type); if(getObserver() && getObserver()->getResourceManager())
if (js)
{ {
sample = string(type); js = WResourceManager::Instance()->RetrieveSample(type);
return js; if (js)
{
sample = string(type);
return js;
}
} }
} }
@@ -1044,11 +1047,14 @@ JSample * MTGCardInstance::getSample()
continue; continue;
string type = Constants::MTGBasicAbilities[x]; string type = Constants::MTGBasicAbilities[x];
type = type + ".wav"; type = type + ".wav";
js = WResourceManager::Instance()->RetrieveSample(type); if(getObserver() && getObserver()->getResourceManager())
if (js)
{ {
sample = string(type); js = WResourceManager::Instance()->RetrieveSample(type);
return js; if (js)
{
sample = string(type);
return js;
}
} }
} }
} }
@@ -1059,11 +1065,14 @@ 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");
js = WResourceManager::Instance()->RetrieveSample(type); if(getObserver() && getObserver()->getResourceManager())
if (js)
{ {
sample = string(type); js = WResourceManager::Instance()->RetrieveSample(type);
return js; if (js)
{
sample = string(type);
return js;
}
} }
return NULL; return NULL;