mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Merge branch 'master' into terrainbleeding
This commit is contained in:
commit
a747318c90
@ -1,6 +1,8 @@
|
||||
0.45.0
|
||||
------
|
||||
|
||||
Bug #1990: Sunrise/sunset not set correct
|
||||
Bug #2326: After a bound item expires the last equipped item of that type is not automatically re-equipped
|
||||
Bug #2835: Player able to slowly move when overencumbered
|
||||
Bug #3374: Touch spells not hitting kwama foragers
|
||||
Bug #3591: Angled hit distance too low
|
||||
@ -23,6 +25,7 @@
|
||||
Bug #4432: Guards behaviour is incorrect if they do not have AI packages
|
||||
Bug #4433: Guard behaviour is incorrect with Alarm = 0
|
||||
Bug #4452: Default terrain texture bleeds through texture transitions
|
||||
Feature #4324: Add CFBundleIdentifier in Info.plist to allow for macOS function key shortcuts
|
||||
Feature #4345: Add equivalents for the command line commands to Launcher
|
||||
Feature #4444: Per-group KF-animation files support
|
||||
|
||||
|
@ -50,27 +50,36 @@ bool isConscious(const MWWorld::Ptr& ptr)
|
||||
return !stats.isDead() && !stats.getKnockedDown();
|
||||
}
|
||||
|
||||
void adjustBoundItem (const std::string& item, bool bound, const MWWorld::Ptr& actor)
|
||||
int getBoundItemSlot (const std::string& itemId)
|
||||
{
|
||||
if (bound)
|
||||
static std::map<std::string, int> boundItemsMap;
|
||||
if (boundItemsMap.empty())
|
||||
{
|
||||
if (actor.getClass().getContainerStore(actor).count(item) == 0)
|
||||
{
|
||||
MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor);
|
||||
MWWorld::Ptr newPtr = *store.MWWorld::ContainerStore::add(item, 1, actor);
|
||||
MWWorld::ActionEquip action(newPtr);
|
||||
action.execute(actor);
|
||||
MWWorld::ConstContainerStoreIterator rightHand = store.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
// change draw state only if the item is in player's right hand
|
||||
if (actor == MWMechanics::getPlayer()
|
||||
&& rightHand != store.end() && newPtr == *rightHand)
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->getPlayer().setDrawState(MWMechanics::DrawState_Weapon);
|
||||
}
|
||||
}
|
||||
std::string boundId = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sMagicBoundBootsID")->getString();
|
||||
boundItemsMap[boundId] = MWWorld::InventoryStore::Slot_Boots;
|
||||
|
||||
boundId = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sMagicBoundCuirassID")->getString();
|
||||
boundItemsMap[boundId] = MWWorld::InventoryStore::Slot_Cuirass;
|
||||
|
||||
boundId = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sMagicBoundLeftGauntletID")->getString();
|
||||
boundItemsMap[boundId] = MWWorld::InventoryStore::Slot_LeftGauntlet;
|
||||
|
||||
boundId = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sMagicBoundRightGauntletID")->getString();
|
||||
boundItemsMap[boundId] = MWWorld::InventoryStore::Slot_RightGauntlet;
|
||||
|
||||
boundId = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sMagicBoundHelmID")->getString();
|
||||
boundItemsMap[boundId] = MWWorld::InventoryStore::Slot_Helmet;
|
||||
|
||||
boundId = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sMagicBoundShieldID")->getString();
|
||||
boundItemsMap[boundId] = MWWorld::InventoryStore::Slot_CarriedLeft;
|
||||
}
|
||||
else
|
||||
actor.getClass().getInventoryStore(actor).remove(item, 1, actor, true);
|
||||
|
||||
int slot = MWWorld::InventoryStore::Slot_CarriedRight;
|
||||
std::map<std::string, int>::iterator it = boundItemsMap.find(itemId);
|
||||
if (it != boundItemsMap.end())
|
||||
slot = it->second;
|
||||
|
||||
return slot;
|
||||
}
|
||||
|
||||
class CheckActorCommanded : public MWMechanics::EffectSourceVisitor
|
||||
@ -139,7 +148,6 @@ void getRestorationPerHourOfSleep (const MWWorld::Ptr& ptr, float& health, float
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
|
||||
const float aiProcessingDistance = 7168;
|
||||
const float sqrAiProcessingDistance = aiProcessingDistance*aiProcessingDistance;
|
||||
|
||||
@ -227,6 +235,83 @@ namespace MWMechanics
|
||||
}
|
||||
};
|
||||
|
||||
void Actors::addBoundItem (const std::string& itemId, const MWWorld::Ptr& actor)
|
||||
{
|
||||
MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor);
|
||||
int slot = getBoundItemSlot(itemId);
|
||||
|
||||
if (actor.getClass().getContainerStore(actor).count(itemId) != 0)
|
||||
return;
|
||||
|
||||
MWWorld::ContainerStoreIterator prevItem = store.getSlot(slot);
|
||||
|
||||
MWWorld::Ptr boundPtr = *store.MWWorld::ContainerStore::add(itemId, 1, actor);
|
||||
MWWorld::ActionEquip action(boundPtr);
|
||||
action.execute(actor);
|
||||
|
||||
if (actor != MWMechanics::getPlayer())
|
||||
return;
|
||||
|
||||
MWWorld::Ptr newItem = *store.getSlot(slot);
|
||||
|
||||
if (newItem.isEmpty() || boundPtr != newItem)
|
||||
return;
|
||||
|
||||
MWWorld::Player& player = MWBase::Environment::get().getWorld()->getPlayer();
|
||||
|
||||
// change draw state only if the item is in player's right hand
|
||||
if (slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
||||
player.setDrawState(MWMechanics::DrawState_Weapon);
|
||||
|
||||
if (prevItem != store.end())
|
||||
player.setPreviousItem(itemId, prevItem->getCellRef().getRefId());
|
||||
}
|
||||
|
||||
void Actors::removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor)
|
||||
{
|
||||
MWWorld::InventoryStore& store = actor.getClass().getInventoryStore(actor);
|
||||
int slot = getBoundItemSlot(itemId);
|
||||
|
||||
MWWorld::ContainerStoreIterator currentItem = store.getSlot(slot);
|
||||
|
||||
bool wasEquipped = currentItem != store.end() && Misc::StringUtils::ciEqual(currentItem->getCellRef().getRefId(), itemId);
|
||||
|
||||
store.remove(itemId, 1, actor, true);
|
||||
|
||||
if (actor != MWMechanics::getPlayer())
|
||||
return;
|
||||
|
||||
MWWorld::Player& player = MWBase::Environment::get().getWorld()->getPlayer();
|
||||
std::string prevItemId = player.getPreviousItem(itemId);
|
||||
player.erasePreviousItem(itemId);
|
||||
|
||||
if (prevItemId.empty())
|
||||
return;
|
||||
|
||||
// Find the item by id
|
||||
MWWorld::Ptr item;
|
||||
for (MWWorld::ContainerStoreIterator iter = store.begin(); iter != store.end(); ++iter)
|
||||
{
|
||||
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), prevItemId))
|
||||
{
|
||||
if (item.isEmpty() ||
|
||||
// Prefer the stack with the lowest remaining uses
|
||||
!item.getClass().hasItemHealth(*iter) ||
|
||||
iter->getClass().getItemHealth(*iter) < item.getClass().getItemHealth(item))
|
||||
{
|
||||
item = *iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// we should equip previous item only if expired bound item was equipped.
|
||||
if (item.isEmpty() || !wasEquipped)
|
||||
return;
|
||||
|
||||
MWWorld::ActionEquip action(item);
|
||||
action.execute(actor);
|
||||
}
|
||||
|
||||
void Actors::updateActor (const MWWorld::Ptr& ptr, float duration)
|
||||
{
|
||||
// magic effects
|
||||
@ -756,25 +841,23 @@ namespace MWMechanics
|
||||
float magnitude = effects.get(it->first).getMagnitude();
|
||||
if (found != (magnitude > 0))
|
||||
{
|
||||
std::string itemGmst = it->second;
|
||||
std::string item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
||||
itemGmst)->getString();
|
||||
if (it->first == ESM::MagicEffect::BoundGloves)
|
||||
{
|
||||
item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
||||
"sMagicBoundLeftGauntletID")->getString();
|
||||
adjustBoundItem(item, magnitude > 0, ptr);
|
||||
item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
||||
"sMagicBoundRightGauntletID")->getString();
|
||||
adjustBoundItem(item, magnitude > 0, ptr);
|
||||
}
|
||||
else
|
||||
adjustBoundItem(item, magnitude > 0, ptr);
|
||||
|
||||
if (magnitude > 0)
|
||||
creatureStats.mBoundItems.insert(it->first);
|
||||
else
|
||||
creatureStats.mBoundItems.erase(it->first);
|
||||
|
||||
std::string itemGmst = it->second;
|
||||
std::string item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
||||
itemGmst)->getString();
|
||||
|
||||
magnitude > 0 ? addBoundItem(item, ptr) : removeBoundItem(item, ptr);
|
||||
|
||||
if (it->first == ESM::MagicEffect::BoundGloves)
|
||||
{
|
||||
item = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(
|
||||
"sMagicBoundRightGauntletID")->getString();
|
||||
magnitude > 0 ? addBoundItem(item, ptr) : removeBoundItem(item, ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
#include "../mwbase/world.hpp"
|
||||
@ -26,6 +25,9 @@ namespace MWMechanics
|
||||
{
|
||||
std::map<std::string, int> mDeathCount;
|
||||
|
||||
void addBoundItem (const std::string& itemId, const MWWorld::Ptr& actor);
|
||||
void removeBoundItem (const std::string& itemId, const MWWorld::Ptr& actor);
|
||||
|
||||
void updateNpc(const MWWorld::Ptr &ptr, float duration);
|
||||
|
||||
void adjustMagicEffects (const MWWorld::Ptr& creature);
|
||||
|
@ -287,6 +287,7 @@ namespace MWWorld
|
||||
mAttackingOrSpell = false;
|
||||
mCurrentCrimeId = -1;
|
||||
mPaidCrimeId = -1;
|
||||
mPreviousItems.clear();
|
||||
mLastKnownExteriorPosition = osg::Vec3f(0,0,0);
|
||||
|
||||
for (int i=0; i<ESM::Skill::Length; ++i)
|
||||
@ -341,6 +342,8 @@ namespace MWWorld
|
||||
for (int i=0; i<ESM::Skill::Length; ++i)
|
||||
mSaveSkills[i].writeState(player.mSaveSkills[i]);
|
||||
|
||||
player.mPreviousItems = mPreviousItems;
|
||||
|
||||
writer.startRecord (ESM::REC_PLAY);
|
||||
player.save (writer);
|
||||
writer.endRecord (ESM::REC_PLAY);
|
||||
@ -441,6 +444,8 @@ namespace MWWorld
|
||||
mForwardBackward = 0;
|
||||
mTeleported = false;
|
||||
|
||||
mPreviousItems = player.mPreviousItems;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -461,4 +466,19 @@ namespace MWWorld
|
||||
{
|
||||
return mPaidCrimeId;
|
||||
}
|
||||
|
||||
void Player::setPreviousItem(const std::string& boundItemId, const std::string& previousItemId)
|
||||
{
|
||||
mPreviousItems[boundItemId] = previousItemId;
|
||||
}
|
||||
|
||||
std::string Player::getPreviousItem(const std::string& boundItemId)
|
||||
{
|
||||
return mPreviousItems[boundItemId];
|
||||
}
|
||||
|
||||
void Player::erasePreviousItem(const std::string& boundItemId)
|
||||
{
|
||||
mPreviousItems.erase(boundItemId);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef GAME_MWWORLD_PLAYER_H
|
||||
#define GAME_MWWORLD_PLAYER_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "../mwworld/refdata.hpp"
|
||||
#include "../mwworld/livecellref.hpp"
|
||||
|
||||
@ -46,6 +48,9 @@ namespace MWWorld
|
||||
int mCurrentCrimeId; // the id assigned witnesses
|
||||
int mPaidCrimeId; // the last id paid off (0 bounty)
|
||||
|
||||
typedef std::map<std::string, std::string> PreviousItems; // previous equipped items, needed for bound spells
|
||||
PreviousItems mPreviousItems;
|
||||
|
||||
// Saved stats prior to becoming a werewolf
|
||||
MWMechanics::SkillValue mSaveSkills[ESM::Skill::Length];
|
||||
MWMechanics::AttributeValue mSaveAttributes[ESM::Attribute::Length];
|
||||
@ -120,6 +125,10 @@ namespace MWWorld
|
||||
int getNewCrimeId(); // get new id for witnesses
|
||||
void recordCrimeId(); // record the paid crime id when bounty is 0
|
||||
int getCrimeId() const; // get the last paid crime id
|
||||
|
||||
void setPreviousItem(const std::string& boundItemId, const std::string& previousItemId);
|
||||
std::string getPreviousItem(const std::string& boundItemId);
|
||||
void erasePreviousItem(const std::string& boundItemId);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include <components/esm/esmwriter.hpp>
|
||||
#include <components/esm/savedgame.hpp>
|
||||
#include <components/esm/weatherstate.hpp>
|
||||
#include <components/fallback/fallback.hpp>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
@ -43,49 +42,67 @@ namespace
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T TimeOfDayInterpolator<T>::getValue(const float gameHour, const TimeOfDaySettings& timeSettings) const
|
||||
T TimeOfDayInterpolator<T>::getValue(const float gameHour, const TimeOfDaySettings& timeSettings, const std::string& prefix) const
|
||||
{
|
||||
// TODO: use pre/post sunset/sunrise time values in [Weather] section
|
||||
WeatherSetting setting = timeSettings.getSetting(prefix);
|
||||
float preSunriseTime = setting.mPreSunriseTime;
|
||||
float postSunriseTime = setting.mPostSunriseTime;
|
||||
float preSunsetTime = setting.mPreSunsetTime;
|
||||
float postSunsetTime = setting.mPostSunsetTime;
|
||||
|
||||
// night
|
||||
if (gameHour <= timeSettings.mNightEnd || gameHour >= timeSettings.mNightStart + 1)
|
||||
if (gameHour < timeSettings.mNightEnd - preSunriseTime || gameHour > timeSettings.mNightStart + postSunsetTime)
|
||||
return mNightValue;
|
||||
// sunrise
|
||||
else if (gameHour >= timeSettings.mNightEnd && gameHour <= timeSettings.mDayStart + 1)
|
||||
else if (gameHour >= timeSettings.mNightEnd - preSunriseTime && gameHour <= timeSettings.mDayStart + postSunriseTime)
|
||||
{
|
||||
if (gameHour <= timeSettings.mSunriseTime)
|
||||
float duration = timeSettings.mDayStart + postSunriseTime - timeSettings.mNightEnd + preSunriseTime;
|
||||
float middle = timeSettings.mNightEnd - preSunriseTime + duration / 2.f;
|
||||
|
||||
if (gameHour <= middle)
|
||||
{
|
||||
// fade in
|
||||
float advance = timeSettings.mSunriseTime - gameHour;
|
||||
float factor = advance / 0.5f;
|
||||
float advance = middle - gameHour;
|
||||
float factor = 0.f;
|
||||
if (duration > 0)
|
||||
factor = advance / duration * 2;
|
||||
return lerp(mSunriseValue, mNightValue, factor);
|
||||
}
|
||||
else
|
||||
{
|
||||
// fade out
|
||||
float advance = gameHour - timeSettings.mSunriseTime;
|
||||
float factor = advance / 3.f;
|
||||
float advance = gameHour - middle;
|
||||
float factor = 1.f;
|
||||
if (duration > 0)
|
||||
factor = advance / duration * 2;
|
||||
return lerp(mSunriseValue, mDayValue, factor);
|
||||
}
|
||||
}
|
||||
// day
|
||||
else if (gameHour >= timeSettings.mDayStart + 1 && gameHour <= timeSettings.mDayEnd - 1)
|
||||
else if (gameHour > timeSettings.mDayStart + postSunriseTime && gameHour < timeSettings.mDayEnd - preSunsetTime)
|
||||
return mDayValue;
|
||||
// sunset
|
||||
else if (gameHour >= timeSettings.mDayEnd - 1 && gameHour <= timeSettings.mNightStart + 1)
|
||||
else if (gameHour >= timeSettings.mDayEnd - preSunsetTime && gameHour <= timeSettings.mNightStart + postSunsetTime)
|
||||
{
|
||||
if (gameHour <= timeSettings.mDayEnd + 1)
|
||||
float duration = timeSettings.mNightStart + postSunsetTime - timeSettings.mDayEnd + preSunsetTime;
|
||||
float middle = timeSettings.mDayEnd - preSunsetTime + duration / 2.f;
|
||||
|
||||
if (gameHour <= middle)
|
||||
{
|
||||
// fade in
|
||||
float advance = (timeSettings.mDayEnd + 1) - gameHour;
|
||||
float factor = (advance / 2);
|
||||
float advance = middle - gameHour;
|
||||
float factor = 0.f;
|
||||
if (duration > 0)
|
||||
factor = advance / duration * 2;
|
||||
return lerp(mSunsetValue, mDayValue, factor);
|
||||
}
|
||||
else
|
||||
{
|
||||
// fade out
|
||||
float advance = gameHour - (timeSettings.mDayEnd + 1);
|
||||
float factor = advance / 2.f;
|
||||
float advance = gameHour - middle;
|
||||
float factor = 1.f;
|
||||
if (duration > 0)
|
||||
factor = advance / duration * 2;
|
||||
return lerp(mSunsetValue, mNightValue, factor);
|
||||
}
|
||||
}
|
||||
@ -539,10 +556,28 @@ WeatherManager::WeatherManager(MWRender::RenderingManager& rendering, const Fall
|
||||
, mPlayingSoundID()
|
||||
{
|
||||
mTimeSettings.mNightStart = mSunsetTime + mSunsetDuration;
|
||||
mTimeSettings.mNightEnd = mSunriseTime - 0.5f;
|
||||
mTimeSettings.mNightEnd = mSunriseTime;
|
||||
mTimeSettings.mDayStart = mSunriseTime + mSunriseDuration;
|
||||
mTimeSettings.mDayEnd = mSunsetTime;
|
||||
mTimeSettings.mSunriseTime = mSunriseTime;
|
||||
|
||||
mTimeSettings.addSetting(fallback, "Sky");
|
||||
mTimeSettings.addSetting(fallback, "Ambient");
|
||||
mTimeSettings.addSetting(fallback, "Fog");
|
||||
mTimeSettings.addSetting(fallback, "Sun");
|
||||
|
||||
// Morrowind handles stars settings differently for other ones
|
||||
mTimeSettings.mStarsPostSunsetStart = fallback.getFallbackFloat("Weather_Stars_Post-Sunset_Start");
|
||||
mTimeSettings.mStarsPreSunriseFinish = fallback.getFallbackFloat("Weather_Stars_Pre-Sunrise_Finish");
|
||||
mTimeSettings.mStarsFadingDuration = fallback.getFallbackFloat("Weather_Stars_Fading_Duration");
|
||||
|
||||
WeatherSetting starSetting = {
|
||||
mTimeSettings.mStarsPreSunriseFinish,
|
||||
mTimeSettings.mStarsFadingDuration - mTimeSettings.mStarsPreSunriseFinish,
|
||||
mTimeSettings.mStarsPostSunsetStart,
|
||||
mTimeSettings.mStarsFadingDuration - mTimeSettings.mStarsPostSunsetStart
|
||||
};
|
||||
|
||||
mTimeSettings.mSunriseTransitions["Stars"] = starSetting;
|
||||
|
||||
mWeatherSettings.reserve(10);
|
||||
// These distant land fog factor and offset values are the defaults MGE XE provides. Should be
|
||||
@ -698,10 +733,13 @@ void WeatherManager::update(float duration, bool paused, const TimeStamp& time,
|
||||
const float nightDuration = 24.f - dayDuration;
|
||||
|
||||
double theta;
|
||||
if ( !is_night ) {
|
||||
if ( !is_night )
|
||||
{
|
||||
theta = static_cast<float>(osg::PI) * (adjustedHour - mSunriseTime) / dayDuration;
|
||||
} else {
|
||||
theta = static_cast<float>(osg::PI) * (1.f - (adjustedHour - adjustedNightStart) / nightDuration);
|
||||
}
|
||||
else
|
||||
{
|
||||
theta = static_cast<float>(osg::PI) + static_cast<float>(osg::PI) * (adjustedHour - adjustedNightStart) / nightDuration;
|
||||
}
|
||||
|
||||
osg::Vec3f final(
|
||||
@ -711,7 +749,7 @@ void WeatherManager::update(float duration, bool paused, const TimeStamp& time,
|
||||
mRendering.setSunDirection( final * -1 );
|
||||
}
|
||||
|
||||
float underwaterFog = mUnderwaterFog.getValue(time.getHour(), mTimeSettings);
|
||||
float underwaterFog = mUnderwaterFog.getValue(time.getHour(), mTimeSettings, "Fog");
|
||||
|
||||
float peakHour = mSunriseTime + (mSunsetTime - mSunriseTime) / 2;
|
||||
if (time.getHour() < mSunriseTime || time.getHour() > mSunsetTime)
|
||||
@ -784,7 +822,7 @@ unsigned int WeatherManager::getWeatherID() const
|
||||
|
||||
bool WeatherManager::useTorches(float hour) const
|
||||
{
|
||||
bool isDark = hour < mSunriseTime || hour > mTimeSettings.mNightStart - 1;
|
||||
bool isDark = hour < mSunriseTime || hour > mTimeSettings.mNightStart;
|
||||
|
||||
return isDark && !mPrecipitation;
|
||||
}
|
||||
@ -1060,20 +1098,25 @@ inline void WeatherManager::calculateResult(const int weatherID, const float gam
|
||||
mResult.mParticleEffect = current.mParticleEffect;
|
||||
mResult.mRainEffect = current.mRainEffect;
|
||||
|
||||
mResult.mNight = (gameHour < mSunriseTime || gameHour > mTimeSettings.mNightStart - 1);
|
||||
mResult.mNight = (gameHour < mSunriseTime || gameHour > mTimeSettings.mNightStart + mTimeSettings.mStarsPostSunsetStart - mTimeSettings.mStarsFadingDuration);
|
||||
|
||||
mResult.mFogDepth = current.mLandFogDepth.getValue(gameHour, mTimeSettings);
|
||||
mResult.mFogDepth = current.mLandFogDepth.getValue(gameHour, mTimeSettings, "Fog");
|
||||
mResult.mFogColor = current.mFogColor.getValue(gameHour, mTimeSettings, "Fog");
|
||||
mResult.mAmbientColor = current.mAmbientColor.getValue(gameHour, mTimeSettings, "Ambient");
|
||||
mResult.mSunColor = current.mSunColor.getValue(gameHour, mTimeSettings, "Sun");
|
||||
mResult.mSkyColor = current.mSkyColor.getValue(gameHour, mTimeSettings, "Sky");
|
||||
mResult.mNightFade = mNightFade.getValue(gameHour, mTimeSettings, "Stars");
|
||||
mResult.mDLFogFactor = current.mDL.FogFactor;
|
||||
mResult.mDLFogOffset = current.mDL.FogOffset;
|
||||
mResult.mFogColor = current.mFogColor.getValue(gameHour, mTimeSettings);
|
||||
mResult.mAmbientColor = current.mAmbientColor.getValue(gameHour, mTimeSettings);
|
||||
mResult.mSunColor = current.mSunColor.getValue(gameHour, mTimeSettings);
|
||||
mResult.mSkyColor = current.mSkyColor.getValue(gameHour, mTimeSettings);
|
||||
mResult.mNightFade = mNightFade.getValue(gameHour, mTimeSettings);
|
||||
|
||||
if (gameHour >= mSunsetTime - mSunPreSunsetTime)
|
||||
WeatherSetting setting = mTimeSettings.getSetting("Sun");
|
||||
float preSunsetTime = setting.mPreSunsetTime;
|
||||
|
||||
if (gameHour >= mTimeSettings.mDayEnd - preSunsetTime)
|
||||
{
|
||||
float factor = (gameHour - (mSunsetTime - mSunPreSunsetTime)) / mSunPreSunsetTime;
|
||||
float factor = 1.f;
|
||||
if (preSunsetTime > 0)
|
||||
factor = (gameHour - (mTimeSettings.mDayEnd - preSunsetTime)) / preSunsetTime;
|
||||
factor = std::min(1.f, factor);
|
||||
mResult.mSunDiscColor = lerp(osg::Vec4f(1,1,1,1), current.mSunDiscSunsetColor, factor);
|
||||
// The SunDiscSunsetColor in the INI isn't exactly the resulting color on screen, most likely because
|
||||
@ -1087,15 +1130,17 @@ inline void WeatherManager::calculateResult(const int weatherID, const float gam
|
||||
else
|
||||
mResult.mSunDiscColor = osg::Vec4f(1,1,1,1);
|
||||
|
||||
if (gameHour >= mSunsetTime)
|
||||
if (gameHour >= mTimeSettings.mDayEnd)
|
||||
{
|
||||
float fade = std::min(1.f, (gameHour - mSunsetTime) / 2.f);
|
||||
// sunset
|
||||
float fade = std::min(1.f, (gameHour - mTimeSettings.mDayEnd) / (mTimeSettings.mNightStart - mTimeSettings.mDayEnd));
|
||||
fade = fade*fade;
|
||||
mResult.mSunDiscColor.a() = 1.f - fade;
|
||||
}
|
||||
else if (gameHour >= mSunriseTime && gameHour <= mSunriseTime + 1)
|
||||
else if (gameHour >= mTimeSettings.mNightEnd && gameHour <= mTimeSettings.mNightEnd + mSunriseDuration / 2.f)
|
||||
{
|
||||
mResult.mSunDiscColor.a() = gameHour - mSunriseTime;
|
||||
// sunrise
|
||||
mResult.mSunDiscColor.a() = gameHour - mTimeSettings.mNightEnd;
|
||||
}
|
||||
else
|
||||
mResult.mSunDiscColor.a() = 1;
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include <osg/Vec4f>
|
||||
|
||||
#include <components/fallback/fallback.hpp>
|
||||
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
|
||||
#include "../mwrender/sky.hpp"
|
||||
@ -38,6 +40,13 @@ namespace MWWorld
|
||||
{
|
||||
class TimeStamp;
|
||||
|
||||
struct WeatherSetting
|
||||
{
|
||||
float mPreSunriseTime;
|
||||
float mPostSunriseTime;
|
||||
float mPreSunsetTime;
|
||||
float mPostSunsetTime;
|
||||
};
|
||||
|
||||
struct TimeOfDaySettings
|
||||
{
|
||||
@ -45,7 +54,37 @@ namespace MWWorld
|
||||
float mNightEnd;
|
||||
float mDayStart;
|
||||
float mDayEnd;
|
||||
float mSunriseTime;
|
||||
|
||||
std::map<std::string, WeatherSetting> mSunriseTransitions;
|
||||
|
||||
float mStarsPostSunsetStart;
|
||||
float mStarsPreSunriseFinish;
|
||||
float mStarsFadingDuration;
|
||||
|
||||
WeatherSetting getSetting(const std::string& type) const
|
||||
{
|
||||
std::map<std::string, WeatherSetting>::const_iterator it = mSunriseTransitions.find(type);
|
||||
if (it != mSunriseTransitions.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
return { 1.f, 1.f, 1.f, 1.f };
|
||||
}
|
||||
}
|
||||
|
||||
void addSetting(const Fallback::Map& fallback, const std::string& type)
|
||||
{
|
||||
WeatherSetting setting = {
|
||||
fallback.getFallbackFloat("Weather_" + type + "_Pre-Sunrise_Time"),
|
||||
fallback.getFallbackFloat("Weather_" + type + "_Post-Sunrise_Time"),
|
||||
fallback.getFallbackFloat("Weather_" + type + "_Pre-Sunset_Time"),
|
||||
fallback.getFallbackFloat("Weather_" + type + "_Post-Sunset_Time")
|
||||
};
|
||||
|
||||
mSunriseTransitions[type] = setting;
|
||||
}
|
||||
};
|
||||
|
||||
/// Interpolates between 4 data points (sunrise, day, sunset, night) based on the time of day.
|
||||
@ -59,7 +98,7 @@ namespace MWWorld
|
||||
{
|
||||
}
|
||||
|
||||
T getValue (const float gameHour, const TimeOfDaySettings& timeSettings) const;
|
||||
T getValue (const float gameHour, const TimeOfDaySettings& timeSettings, const std::string& prefix) const;
|
||||
|
||||
private:
|
||||
T mSunriseValue, mDayValue, mSunsetValue, mNightValue;
|
||||
|
@ -31,6 +31,18 @@ void ESM::Player::load (ESMReader &esm)
|
||||
mPaidCrimeId = -1;
|
||||
esm.getHNOT (mPaidCrimeId, "PAYD");
|
||||
|
||||
bool checkPrevItems = true;
|
||||
while (checkPrevItems)
|
||||
{
|
||||
std::string boundItemId = esm.getHNOString("BOUN");
|
||||
std::string prevItemId = esm.getHNOString("PREV");
|
||||
|
||||
if (!boundItemId.empty())
|
||||
mPreviousItems[boundItemId] = prevItemId;
|
||||
else
|
||||
checkPrevItems = false;
|
||||
}
|
||||
|
||||
if (esm.hasMoreSubs())
|
||||
{
|
||||
for (int i=0; i<ESM::Attribute::Length; ++i)
|
||||
@ -62,6 +74,12 @@ void ESM::Player::save (ESMWriter &esm) const
|
||||
esm.writeHNT ("CURD", mCurrentCrimeId);
|
||||
esm.writeHNT ("PAYD", mPaidCrimeId);
|
||||
|
||||
for (PreviousItems::const_iterator it=mPreviousItems.begin(); it != mPreviousItems.end(); ++it)
|
||||
{
|
||||
esm.writeHNString ("BOUN", it->first);
|
||||
esm.writeHNString ("PREV", it->second);
|
||||
}
|
||||
|
||||
for (int i=0; i<ESM::Attribute::Length; ++i)
|
||||
mSaveAttributes[i].save(esm);
|
||||
for (int i=0; i<ESM::Skill::Length; ++i)
|
||||
|
@ -34,6 +34,9 @@ namespace ESM
|
||||
StatState<int> mSaveAttributes[ESM::Attribute::Length];
|
||||
StatState<int> mSaveSkills[ESM::Skill::Length];
|
||||
|
||||
typedef std::map<std::string, std::string> PreviousItems; // previous equipped items, needed for bound spells
|
||||
PreviousItems mPreviousItems;
|
||||
|
||||
void load (ESMReader &esm);
|
||||
void save (ESMWriter &esm) const;
|
||||
};
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "defs.hpp"
|
||||
|
||||
unsigned int ESM::SavedGame::sRecordId = ESM::REC_SAVE;
|
||||
int ESM::SavedGame::sCurrentFormat = 4;
|
||||
int ESM::SavedGame::sCurrentFormat = 5;
|
||||
|
||||
void ESM::SavedGame::load (ESMReader &esm)
|
||||
{
|
||||
|
@ -8,6 +8,8 @@
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>openmw-launcher</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.openmw.openmw</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleLongVersionString</key>
|
||||
|
Loading…
x
Reference in New Issue
Block a user