mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 09:53:54 +00:00
Avoid copying the region when looking for a sound to play
This commit is contained in:
parent
8c5f85ca83
commit
56c3b988cc
1 changed files with 9 additions and 13 deletions
|
@ -343,38 +343,34 @@ namespace MWSound
|
||||||
timePassed += duration;
|
timePassed += duration;
|
||||||
if((current->cell->data.flags & current->cell->Interior) || timePassed < 10)
|
if((current->cell->data.flags & current->cell->Interior) || timePassed < 10)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ESM::Region test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region));
|
|
||||||
|
|
||||||
timePassed = 0;
|
timePassed = 0;
|
||||||
|
|
||||||
if(regionName != current->cell->region)
|
if(regionName != current->cell->region)
|
||||||
{
|
{
|
||||||
regionName = current->cell->region;
|
regionName = current->cell->region;
|
||||||
total = 0;
|
total = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(test.soundList.size() == 0)
|
const ESM::Region *regn = mEnvironment.mWorld->getStore().regions.find(regionName);
|
||||||
|
if(regn->soundList.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::vector<ESM::Region::SoundRef>::iterator soundIter;
|
std::vector<ESM::Region::SoundRef>::const_iterator soundIter;
|
||||||
if(total == 0)
|
if(total == 0)
|
||||||
{
|
{
|
||||||
soundIter = test.soundList.begin();
|
soundIter = regn->soundList.begin();
|
||||||
while(soundIter != test.soundList.end())
|
while(soundIter != regn->soundList.end())
|
||||||
{
|
{
|
||||||
int chance = (int) soundIter->chance;
|
total += (int)soundIter->chance;
|
||||||
//ESM::NAME32 go = soundIter->sound;
|
|
||||||
//std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
|
|
||||||
soundIter++;
|
soundIter++;
|
||||||
total += chance;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int r = rand() % total; //old random code
|
int r = rand() % total; //old random code
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
soundIter = test.soundList.begin();
|
soundIter = regn->soundList.begin();
|
||||||
while(soundIter != test.soundList.end())
|
while(soundIter != regn->soundList.end())
|
||||||
{
|
{
|
||||||
const std::string go = soundIter->sound.toString();
|
const std::string go = soundIter->sound.toString();
|
||||||
int chance = (int) soundIter->chance;
|
int chance = (int) soundIter->chance;
|
||||||
|
|
Loading…
Reference in a new issue