|
|
|
@ -73,84 +73,82 @@ void OMW::Engine::executeLocalScripts()
|
|
|
|
|
mEnvironment.mWorld->getLocalScripts().setIgnore (MWWorld::Ptr());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|
|
|
|
{
|
|
|
|
|
if(mShowFPS)
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
mEnvironment.mWindowManager->wmSetFPS(mOgre.getFPS());
|
|
|
|
|
}
|
|
|
|
|
if(mShowFPS)
|
|
|
|
|
{
|
|
|
|
|
mEnvironment.mWindowManager->wmSetFPS(mOgre.getFPS());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(mUseSound && !(mEnvironment.mSoundManager->isMusicPlaying()))
|
|
|
|
|
{
|
|
|
|
|
// Play some good 'ol tunes
|
|
|
|
|
mEnvironment.mSoundManager->startRandomTitle();
|
|
|
|
|
}
|
|
|
|
|
if(mUseSound && !(mEnvironment.mSoundManager->isMusicPlaying()))
|
|
|
|
|
{
|
|
|
|
|
// Play some good 'ol tunes
|
|
|
|
|
mEnvironment.mSoundManager->startRandomTitle();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string effect;
|
|
|
|
|
std::string effect;
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell();
|
|
|
|
|
MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayer().getPlayer().getCell();
|
|
|
|
|
|
|
|
|
|
//If the region has changed
|
|
|
|
|
if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){
|
|
|
|
|
timer.restart();
|
|
|
|
|
if (test.name != current->cell->region)
|
|
|
|
|
{
|
|
|
|
|
total = 0;
|
|
|
|
|
test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//If the region has changed
|
|
|
|
|
if(!(current->cell->data.flags & current->cell->Interior) && timer.elapsed() >= 10){
|
|
|
|
|
timer.restart();
|
|
|
|
|
if (test.name != current->cell->region)
|
|
|
|
|
{
|
|
|
|
|
total = 0;
|
|
|
|
|
test = (ESM::Region) *(mEnvironment.mWorld->getStore().regions.find(current->cell->region));
|
|
|
|
|
}
|
|
|
|
|
if(test.soundList.size() > 0)
|
|
|
|
|
{
|
|
|
|
|
std::vector<ESM::Region::SoundRef>::iterator soundIter = test.soundList.begin();
|
|
|
|
|
//mEnvironment.mSoundManager
|
|
|
|
|
if(total == 0){
|
|
|
|
|
while (!(soundIter == test.soundList.end()))
|
|
|
|
|
{
|
|
|
|
|
ESM::NAME32 go = soundIter->sound;
|
|
|
|
|
int chance = (int) soundIter->chance;
|
|
|
|
|
//std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
|
|
|
|
|
soundIter++;
|
|
|
|
|
total += chance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(test.soundList.size() > 0)
|
|
|
|
|
{
|
|
|
|
|
std::vector<ESM::Region::SoundRef>::iterator soundIter = test.soundList.begin();
|
|
|
|
|
//mEnvironment.mSoundManager
|
|
|
|
|
if(total == 0){
|
|
|
|
|
srand ( time(NULL) );
|
|
|
|
|
int r = rand() % total; //old random code
|
|
|
|
|
int pos = 0;
|
|
|
|
|
soundIter = test.soundList.begin();
|
|
|
|
|
while (!(soundIter == test.soundList.end()))
|
|
|
|
|
{
|
|
|
|
|
ESM::NAME32 go = soundIter->sound;
|
|
|
|
|
const ESM::NAME32 go = soundIter->sound;
|
|
|
|
|
int chance = (int) soundIter->chance;
|
|
|
|
|
//std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
|
|
|
|
|
soundIter++;
|
|
|
|
|
total += chance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srand ( time(NULL) );
|
|
|
|
|
int r = rand() % total; //old random code
|
|
|
|
|
int pos = 0;
|
|
|
|
|
soundIter = test.soundList.begin();
|
|
|
|
|
while (!(soundIter == test.soundList.end()))
|
|
|
|
|
{
|
|
|
|
|
const ESM::NAME32 go = soundIter->sound;
|
|
|
|
|
int chance = (int) soundIter->chance;
|
|
|
|
|
//std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
|
|
|
|
|
soundIter++;
|
|
|
|
|
if( r - pos < chance)
|
|
|
|
|
{
|
|
|
|
|
effect = go.name;
|
|
|
|
|
//play sound
|
|
|
|
|
std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
|
|
|
|
|
mEnvironment.mSoundManager->playSound(effect, 20.0, 1.0);
|
|
|
|
|
if( r - pos < chance)
|
|
|
|
|
{
|
|
|
|
|
effect = go.name;
|
|
|
|
|
//play sound
|
|
|
|
|
std::cout << "Sound: " << go.name <<" Chance:" << chance << "\n";
|
|
|
|
|
mEnvironment.mSoundManager->playSound(effect, 20.0, 1.0);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
pos += chance;
|
|
|
|
|
}
|
|
|
|
|
pos += chance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//mEnvironment.mSoundManager->playSound(effect, 1.0, 1.0);
|
|
|
|
|
//printf("REGION: %s\n", test.name);
|
|
|
|
|
//mEnvironment.mSoundManager->playSound(effect, 1.0, 1.0);
|
|
|
|
|
//printf("REGION: %s\n", test.name);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if(current->cell->data.flags & current->cell->Interior)
|
|
|
|
|
{
|
|
|
|
|
test.name = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(current->cell->data.flags & current->cell->Interior)
|
|
|
|
|
{
|
|
|
|
|
test.name = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
mEnvironment.mFrameDuration = evt.timeSinceLastFrame;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
@ -205,7 +203,6 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|
|
|
|
{
|
|
|
|
|
std::cerr << "Error in framelistener: " << e.what() << std::endl;
|
|
|
|
|
}
|
|
|
|
|
//std::cout << "TESTING2";
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|