mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-08 13:11:25 +00:00
Removed duplicate functions and moved pause check in weather.cpp
This commit is contained in:
parent
782e851eb1
commit
470d375177
4 changed files with 44 additions and 52 deletions
|
@ -348,11 +348,6 @@ void WeatherManager::transition(float factor)
|
||||||
mResult.mRainFrequency = current.mRainFrequency;
|
mResult.mRainFrequency = current.mRainFrequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WeatherManager::update(float duration)
|
|
||||||
{
|
|
||||||
this->update(duration, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WeatherManager::update(float duration, bool paused)
|
void WeatherManager::update(float duration, bool paused)
|
||||||
{
|
{
|
||||||
float timePassed = mTimePassed;
|
float timePassed = mTimePassed;
|
||||||
|
@ -488,52 +483,56 @@ void WeatherManager::update(float duration, bool paused)
|
||||||
mRendering->getSkyManager()->secundaDisable();
|
mRendering->getSkyManager()->secundaDisable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentWeather == "thunderstorm" && mNextWeather == "" && !paused)
|
if (!paused)
|
||||||
{
|
{
|
||||||
if (mThunderFlash > 0)
|
if (mCurrentWeather == "thunderstorm" && mNextWeather == "")
|
||||||
{
|
{
|
||||||
// play the sound after a delay
|
|
||||||
mThunderSoundDelay -= duration;
|
|
||||||
if (mThunderSoundDelay <= 0)
|
|
||||||
{
|
|
||||||
// pick a random sound
|
|
||||||
int sound = rand() % 4;
|
|
||||||
std::string* soundName = NULL;
|
|
||||||
if (sound == 0) soundName = &mThunderSoundID0;
|
|
||||||
else if (sound == 1) soundName = &mThunderSoundID1;
|
|
||||||
else if (sound == 2) soundName = &mThunderSoundID2;
|
|
||||||
else if (sound == 3) soundName = &mThunderSoundID3;
|
|
||||||
if (soundName)
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound(*soundName, 1.0, 1.0);
|
|
||||||
mThunderSoundDelay = 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
mThunderFlash -= duration;
|
|
||||||
if (mThunderFlash > 0)
|
if (mThunderFlash > 0)
|
||||||
mRendering->getSkyManager()->setLightningStrength( mThunderFlash / mThunderThreshold );
|
{
|
||||||
|
// play the sound after a delay
|
||||||
|
mThunderSoundDelay -= duration;
|
||||||
|
if (mThunderSoundDelay <= 0)
|
||||||
|
{
|
||||||
|
// pick a random sound
|
||||||
|
int sound = rand() % 4;
|
||||||
|
std::string* soundName = NULL;
|
||||||
|
if (sound == 0) soundName = &mThunderSoundID0;
|
||||||
|
else if (sound == 1) soundName = &mThunderSoundID1;
|
||||||
|
else if (sound == 2) soundName = &mThunderSoundID2;
|
||||||
|
else if (sound == 3) soundName = &mThunderSoundID3;
|
||||||
|
if (soundName)
|
||||||
|
MWBase::Environment::get().getSoundManager()->playSound(*soundName, 1.0, 1.0);
|
||||||
|
mThunderSoundDelay = 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
mThunderFlash -= duration;
|
||||||
|
if (mThunderFlash > 0)
|
||||||
|
mRendering->getSkyManager()->setLightningStrength( mThunderFlash / mThunderThreshold );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mThunderChanceNeeded = rand() % 100;
|
||||||
|
mThunderChance = 0;
|
||||||
|
mRendering->getSkyManager()->setLightningStrength( 0.f );
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mThunderChanceNeeded = rand() % 100;
|
// no thunder active
|
||||||
mThunderChance = 0;
|
mThunderChance += duration*4; // chance increases by 4 percent every second
|
||||||
mRendering->getSkyManager()->setLightningStrength( 0.f );
|
if (mThunderChance >= mThunderChanceNeeded)
|
||||||
|
{
|
||||||
|
mThunderFlash = mThunderThreshold;
|
||||||
|
|
||||||
|
mRendering->getSkyManager()->setLightningStrength( mThunderFlash / mThunderThreshold );
|
||||||
|
|
||||||
|
mThunderSoundDelay = 0.25;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
mRendering->getSkyManager()->setLightningStrength(0.f);
|
||||||
// no thunder active
|
|
||||||
mThunderChance += duration*4; // chance increases by 4 percent every second
|
|
||||||
if (mThunderChance >= mThunderChanceNeeded)
|
|
||||||
{
|
|
||||||
mThunderFlash = mThunderThreshold;
|
|
||||||
|
|
||||||
mRendering->getSkyManager()->setLightningStrength( mThunderFlash / mThunderThreshold );
|
|
||||||
|
|
||||||
mThunderSoundDelay = 0.25;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
mRendering->getSkyManager()->setLightningStrength(0.f);
|
|
||||||
|
|
||||||
mRendering->setAmbientColour(mResult.mAmbientColor);
|
mRendering->setAmbientColour(mResult.mAmbientColor);
|
||||||
mRendering->sunEnable(false);
|
mRendering->sunEnable(false);
|
||||||
|
|
|
@ -169,9 +169,9 @@ namespace MWWorld
|
||||||
/**
|
/**
|
||||||
* Per-frame update
|
* Per-frame update
|
||||||
* @param duration
|
* @param duration
|
||||||
|
* @param paused
|
||||||
*/
|
*/
|
||||||
void update(float duration);
|
void update(float duration, bool paused = false);
|
||||||
void update(float duration, bool paused);
|
|
||||||
|
|
||||||
void stopSounds(bool stopAll);
|
void stopSounds(bool stopAll);
|
||||||
|
|
||||||
|
|
|
@ -2634,12 +2634,6 @@ namespace MWWorld
|
||||||
MWWorld::ActionTeleport action("", closestMarker.getRefData().getPosition());
|
MWWorld::ActionTeleport action("", closestMarker.getRefData().getPosition());
|
||||||
action.execute(ptr);
|
action.execute(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::updateWeather(float duration)
|
|
||||||
{
|
|
||||||
// Implement original behavior:
|
|
||||||
this->updateWeather(duration, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void World::updateWeather(float duration, bool paused)
|
void World::updateWeather(float duration, bool paused)
|
||||||
{
|
{
|
||||||
|
|
|
@ -99,8 +99,7 @@ namespace MWWorld
|
||||||
|
|
||||||
std::string mStartCell;
|
std::string mStartCell;
|
||||||
|
|
||||||
void updateWeather(float duration);
|
void updateWeather(float duration, bool paused = false);
|
||||||
void updateWeather(float duration, bool paused);
|
|
||||||
int getDaysPerMonth (int month) const;
|
int getDaysPerMonth (int month) const;
|
||||||
|
|
||||||
void rotateObjectImp (const Ptr& ptr, Ogre::Vector3 rot, bool adjust);
|
void rotateObjectImp (const Ptr& ptr, Ogre::Vector3 rot, bool adjust);
|
||||||
|
|
Loading…
Reference in a new issue