1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 11:23:51 +00:00

Fixes #417: Apply weather instantly when teleporting

Removed changing speed of weather transition introduced in previous
commit. Instead try to detect player "teleporting" (ie. coc),
and then switch instantly to the next weather type.

Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com>
This commit is contained in:
Lukasz Gromanowski 2013-12-29 12:47:44 +01:00
parent 100edda8c0
commit faf8011c48
4 changed files with 64 additions and 18 deletions

View file

@ -195,22 +195,7 @@ void WeatherManager::setWeather(const String& weather, bool instant)
}
mNextWeather = weather;
/**
* Issue #417:
*
* Change speed of weather transition from blight to other (twice fast as normal)
* and from other to blight (four times faster than normal)
*/
mRemainingTransitionTime = (mWeatherSettings[mCurrentWeather].mTransitionDelta * 24.f * 3600.f);
if (mCurrentWeather == "blight" && mNextWeather != "")
{
mRemainingTransitionTime *= 0.25f;
}
else if (mNextWeather == "blight")
{
mRemainingTransitionTime *= 0.5f;
}
mRemainingTransitionTime = mWeatherSettings[mCurrentWeather].mTransitionDelta * 24.f * 3600.f;
}
mFirstUpdate = false;
}
@ -722,3 +707,45 @@ float WeatherManager::getWindSpeed() const
{
return mWindSpeed;
}
void WeatherManager::switchToNextWeather(bool instantly)
{
const bool exterior = (MWBase::Environment::get().getWorld()->isCellExterior() || MWBase::Environment::get().getWorld()->isCellQuasiExterior());
if (!exterior)
{
mRendering->sunDisable(false);
mRendering->skyDisable();
mRendering->getSkyManager()->setLightningStrength(0.f);
stopSounds(true);
return;
}
// Exterior
std::string regionstr = Misc::StringUtils::lowerCase(MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell->mRegion);
if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion)
{
mCurrentRegion = regionstr;
mWeatherUpdateTime = mHoursBetweenWeatherChanges * 3600;
std::string weatherType = "clear";
if (mRegionOverrides.find(regionstr) != mRegionOverrides.end())
{
weatherType = mRegionOverrides[regionstr];
}
else
{
// get weather probabilities for the current region
const ESM::Region *region =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().search (regionstr);
if (region != 0)
{
weatherType = nextWeather(region);
}
}
setWeather(weatherType, instantly);
}
}

View file

@ -128,6 +128,7 @@ namespace MWWorld
* @param ID of the weather setting to shift to
*/
void changeWeather(const std::string& region, const unsigned int id);
void switchToNextWeather(bool instantly = true);
/**
* Per-frame update

View file

@ -1287,7 +1287,7 @@ namespace MWWorld
mRendering->playVideo(mFallback.getFallbackString("Movies_New_Game"), true);
}
mWeatherManager->update (duration);
updateWeather(duration);
mWorldScene->update (duration, paused);
@ -2244,4 +2244,22 @@ namespace MWWorld
actor.getClass().getCreatureStats(actor).getActiveSpells().purgeEffect(ESM::MagicEffect::Invisibility);
actor.getClass().getInventoryStore(actor).purgeEffect(ESM::MagicEffect::Invisibility);
}
void World::updateWeather(float duration)
{
static const float TELEPORTATION_STEP_THRESHOLD = 256.f;
static ESM::Position lastPlayerPos;
ESM::Position currentPos = mPlayer->getPlayer().getRefData().getPosition();
if (fabs(fabs(lastPlayerPos.pos[0]) - fabs(currentPos.pos[0])) >= TELEPORTATION_STEP_THRESHOLD
|| fabs(fabs(lastPlayerPos.pos[1]) - fabs(currentPos.pos[1])) >= TELEPORTATION_STEP_THRESHOLD)
{
lastPlayerPos = currentPos;
mWeatherManager->switchToNextWeather(true);
}
else
{
mWeatherManager->update (duration);
}
}
}

View file

@ -106,7 +106,7 @@ namespace MWWorld
};
std::map<MWWorld::Ptr, ProjectileState> mProjectiles;
void updateWeather(float duration);
int getDaysPerMonth (int month) const;
void rotateObjectImp (const Ptr& ptr, Ogre::Vector3 rot, bool adjust);