diff --git a/apps/navmeshtool/main.cpp b/apps/navmeshtool/main.cpp index 0dfaf86783..12f7f83434 100644 --- a/apps/navmeshtool/main.cpp +++ b/apps/navmeshtool/main.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -200,11 +200,10 @@ namespace NavMeshTool Settings::Manager::load(config); - const auto agentCollisionShape = DetourNavigator::toCollisionShapeType( - Settings::Manager::getInt("actor collision shape type", "Game")); - const osg::Vec3f agentHalfExtents - = Settings::Manager::getVector3("default actor pathfind half extents", "Game"); - const DetourNavigator::AgentBounds agentBounds{ agentCollisionShape, agentHalfExtents }; + const DetourNavigator::AgentBounds agentBounds{ + Settings::game().mActorCollisionShapeType, + Settings::game().mDefaultActorPathfindHalfExtents, + }; const std::uint64_t maxDbFileSize = Settings::Manager::getUInt64("max navmeshdb file size", "Navigator"); const auto dbPath = Files::pathToUnicodeString(config.getUserDataPath() / "navmesh.db"); diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index e949e87803..19132f30ee 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/soundmanager.hpp" @@ -61,7 +61,6 @@ namespace MWClass Container::Container() : MWWorld::RegisteredClass(ESM::Container::sRecordId) - , mHarvestEnabled(Settings::Manager::getBool("graphic herbalism", "Game")) { } @@ -80,7 +79,7 @@ namespace MWClass bool Container::canBeHarvested(const MWWorld::ConstPtr& ptr) const { - if (!mHarvestEnabled) + if (!Settings::game().mGraphicHerbalism) return false; const MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr); if (animation == nullptr) diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index a2eb5d65f6..5f8b962e4a 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -31,8 +31,6 @@ namespace MWClass { friend MWWorld::RegisteredClass; - const bool mHarvestEnabled; - Container(); void ensureCustomData(const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 1ff9c6375a..672b198704 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include "../mwmechanics/actorutil.hpp" #include "../mwmechanics/aisetting.hpp" @@ -484,10 +484,8 @@ namespace MWClass if (stats.isDead()) { - bool canLoot = Settings::Manager::getBool("can loot during death animation", "Game"); - // by default user can loot friendly actors during death animation - if (canLoot && !stats.getAiSequence().isInCombat()) + if (Settings::game().mCanLootDuringDeathAnimation && !stats.getAiSequence().isInCombat()) return std::make_unique(ptr); // otherwise wait until death animation diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index d00da800d1..931ed73dfe 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/soundmanager.hpp" @@ -166,8 +166,7 @@ namespace MWClass std::string text; // Don't show duration for infinite light sources. - if (Settings::Manager::getBool("show effect duration", "Game") - && ptr.getClass().getRemainingUsageTime(ptr) != -1) + if (Settings::game().mShowEffectDuration && ptr.getClass().getRemainingUsageTime(ptr) != -1) text += MWGui::ToolTips::getDurationString(ptr.getClass().getRemainingUsageTime(ptr), "\n#{sDuration}"); text += MWGui::ToolTips::getWeightString(ref->mBase->mData.mWeight, "#{sWeight}"); diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index fdb2a7274f..2f28cc2775 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" @@ -90,7 +90,7 @@ namespace MWClass if (creature) { int soul = creature->mData.mSoul; - if (Settings::Manager::getBool("rebalance soul gem values", "Game")) + if (Settings::game().mRebalanceSoulGemValues) { // use the 'soul gem value rebalance' formula from the Morrowind Code Patch float soulValue = 0.0001 * pow(soul, 3) + 2 * soul; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 6c37b72b5b..11064b582e 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include "../mwbase/dialoguemanager.hpp" #include "../mwbase/environment.hpp" @@ -826,12 +826,10 @@ namespace MWClass } if (hasArmor) { - static const bool creatureDamage - = Settings::Manager::getBool("unarmed creature attacks damage armor", "Game"); - + // Unarmed creature attacks don't affect armor condition unless it was + // explicitly requested. if (!object.isEmpty() || attacker.isEmpty() || attacker.getClass().isNpc() - || creatureDamage) // Unarmed creature attacks don't affect armor condition unless it was - // explicitly requested. + || Settings::game().mUnarmedCreatureAttacksDamageArmor) { int armorhealth = armor.getClass().getItemHealth(armor); armorhealth -= std::min(damageDiff, armorhealth); @@ -919,10 +917,8 @@ namespace MWClass if (stats.isDead()) { - bool canLoot = Settings::Manager::getBool("can loot during death animation", "Game"); - // by default user can loot friendly actors during death animation - if (canLoot && !stats.getAiSequence().isInCombat()) + if (Settings::game().mCanLootDuringDeathAnimation && !stats.getAiSequence().isInCombat()) return std::make_unique(ptr); // otherwise wait until death animation @@ -940,9 +936,7 @@ namespace MWClass } else // In combat { - const bool stealingInCombat - = Settings::Manager::getBool("always allow stealing from knocked out actors", "Game"); - if (stealingInCombat && stats.getKnockedDown()) + if (Settings::game().mAlwaysAllowStealingFromKnockedOutActors && stats.getKnockedDown()) return std::make_unique(ptr); // stealing } @@ -1090,9 +1084,7 @@ namespace MWClass if (!customData.mNpcStats.getAiSequence().isInCombat()) return true; - const bool stealingInCombat - = Settings::Manager::getBool("always allow stealing from knocked out actors", "Game"); - if (stealingInCombat && customData.mNpcStats.getKnockedDown()) + if (Settings::game().mAlwaysAllowStealingFromKnockedOutActors && customData.mNpcStats.getKnockedDown()) return true; return false; diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 74e26a3b83..ab47bb4764 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -160,8 +160,7 @@ namespace MWClass std::string text; // weapon type & damage - if (weaponType->mWeaponClass != ESM::WeaponType::Ammo - || Settings::Manager::getBool("show projectile damage", "Game")) + if (weaponType->mWeaponClass != ESM::WeaponType::Ammo || Settings::game().mShowProjectileDamage) { text += "\n#{sType} "; @@ -215,7 +214,7 @@ namespace MWClass + MWGui::ToolTips::toString(ref->mBase->mData.mHealth); } - const bool verbose = Settings::Manager::getBool("show melee info", "Game"); + const bool verbose = Settings::game().mShowMeleeInfo; // add reach for melee weapon if (weaponType->mWeaponClass == ESM::WeaponType::Melee && verbose) { diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 320a082a54..04d84d12c0 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/journal.hpp" @@ -583,7 +583,7 @@ namespace MWDialogue updateOriginalDisposition(); mCurrentDisposition += delta; mActor.getClass().getNpcStats(mActor).setBaseDisposition(mCurrentDisposition); - if (Settings::Manager::getBool("barter disposition change is permanent", "Game")) + if (Settings::game().mBarterDispositionChangeIsPermanent) mPermanentDispositionChange += delta; } } diff --git a/apps/openmw/mwgui/enchantingdialog.cpp b/apps/openmw/mwgui/enchantingdialog.cpp index bb11e9d47c..4628bf7517 100644 --- a/apps/openmw/mwgui/enchantingdialog.cpp +++ b/apps/openmw/mwgui/enchantingdialog.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include @@ -158,8 +158,7 @@ namespace MWGui mEnchanting.setSelfEnchanting(true); mEnchanting.setEnchanter(MWMechanics::getPlayer()); mBuyButton->setCaptionWithReplacing("#{sCreate}"); - bool enabled = Settings::Manager::getBool("show enchant chance", "Game"); - mChanceLayout->setVisible(enabled); + mChanceLayout->setVisible(Settings::game().mShowEnchantChance); mPtr = MWMechanics::getPlayer(); setSoulGem(ptr); mPrice->setVisible(false); diff --git a/apps/openmw/mwgui/spellicons.cpp b/apps/openmw/mwgui/spellicons.cpp index e5eff6e178..4da3e8b56f 100644 --- a/apps/openmw/mwgui/spellicons.cpp +++ b/apps/openmw/mwgui/spellicons.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" @@ -136,7 +136,7 @@ namespace MWGui += MWBase::Environment::get().getWindowManager()->getGameSettingString("spoint", {}); } } - if (effectInfo.mRemainingTime > -1 && Settings::Manager::getBool("show effect duration", "Game")) + if (effectInfo.mRemainingTime > -1 && Settings::game().mShowEffectDuration) sourcesDescription += MWGui::ToolTips::getDurationString(effectInfo.mRemainingTime, " #{sDuration}"); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index fdf945f2dc..c0aa37daf2 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include "../mwbase/environment.hpp" @@ -42,7 +42,6 @@ namespace MWGui , mLastMouseY(0) , mEnabled(true) , mFullHelp(false) - , mShowOwned(0) , mFrameDuration(0.f) { getWidget(mDynamicToolTipBox, "DynamicToolTipBox"); @@ -61,8 +60,6 @@ namespace MWGui { mMainWidget->getChildAt(i)->setVisible(false); } - - mShowOwned = Settings::Manager::getInt("show owned", "Game"); } void ToolTips::setEnabled(bool enabled) @@ -402,7 +399,8 @@ namespace MWGui { mDynamicToolTipBox->setVisible(true); - if ((mShowOwned == 1 || mShowOwned == 3) && isOwned) + const int showOwned = Settings::game().mShowOwned; + if ((showOwned == 1 || showOwned == 3) && isOwned) mDynamicToolTipBox->changeWidgetSkin(MWBase::Environment::get().getWindowManager()->isGuiMode() ? "HUD_Box_NoTransp_Owned" : "HUD_Box_Owned"); diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index 500c3bea44..aa03c8a31b 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -134,8 +134,6 @@ namespace MWGui bool mFullHelp; - int mShowOwned; - float mFrameDuration; }; } diff --git a/apps/openmw/mwgui/tradeitemmodel.cpp b/apps/openmw/mwgui/tradeitemmodel.cpp index 2e97e82baa..f14d7fe72c 100644 --- a/apps/openmw/mwgui/tradeitemmodel.cpp +++ b/apps/openmw/mwgui/tradeitemmodel.cpp @@ -1,7 +1,7 @@ #include "tradeitemmodel.hpp" #include -#include +#include #include "../mwworld/class.hpp" #include "../mwworld/containerstore.hpp" @@ -140,9 +140,8 @@ namespace MWGui throw std::runtime_error("The borrowed item disappeared"); const ItemStack& item = sourceModel->getItem(i); - static const bool prevent = Settings::Manager::getBool("prevent merchant equipping", "Game"); // copy the borrowed items to our model - copyItem(item, itemStack.mCount, !prevent); + copyItem(item, itemStack.mCount, !Settings::game().mPreventMerchantEquipping); // then remove them from the source model sourceModel->removeItem(item, itemStack.mCount); } diff --git a/apps/openmw/mwgui/trainingwindow.cpp b/apps/openmw/mwgui/trainingwindow.cpp index 90c092dd79..39857412a0 100644 --- a/apps/openmw/mwgui/trainingwindow.cpp +++ b/apps/openmw/mwgui/trainingwindow.cpp @@ -17,7 +17,7 @@ #include "../mwmechanics/npcstats.hpp" #include -#include +#include #include "tooltips.hpp" @@ -27,8 +27,6 @@ namespace MWGui TrainingWindow::TrainingWindow() : WindowBase("openmw_trainingwindow.layout") , mTimeAdvancer(0.05f) - , mTrainingSkillBasedOnBaseSkill( - Settings::Manager::getBool("trainers training skills based on base skill", "Game")) { getWidget(mTrainingOptions, "TrainingOptions"); getWidget(mCancelButton, "CancelButton"); @@ -199,7 +197,7 @@ namespace MWGui float TrainingWindow::getSkillForTraining(const MWMechanics::NpcStats& stats, ESM::RefId id) const { - if (mTrainingSkillBasedOnBaseSkill) + if (Settings::game().mTrainersTrainingSkillsBasedOnBaseSkill) return stats.getSkill(id).getBase(); return stats.getSkill(id).getModified(); } diff --git a/apps/openmw/mwgui/trainingwindow.hpp b/apps/openmw/mwgui/trainingwindow.hpp index c169022b25..70df7a1cd7 100644 --- a/apps/openmw/mwgui/trainingwindow.hpp +++ b/apps/openmw/mwgui/trainingwindow.hpp @@ -50,7 +50,6 @@ namespace MWGui WaitDialogProgressBar mProgressBar; TimeAdvancer mTimeAdvancer; - bool mTrainingSkillBasedOnBaseSkill; // corresponds to the setting 'training skills based on base skill' }; } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index fab7191a32..ee16cd2a46 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -196,7 +196,6 @@ namespace MWGui , mForceHidden(GW_None) , mAllowed(GW_ALL) , mRestAllowed(true) - , mShowOwned(0) , mEncoding(encoding) , mVersionDescription(versionDescription) , mWindowVisible(true) @@ -297,8 +296,6 @@ namespace MWGui MyGUI::ClipboardManager::getInstance().eventClipboardRequested += MyGUI::newDelegate(this, &WindowManager::onClipboardRequested); - mShowOwned = Settings::Manager::getInt("show owned", "Game"); - mVideoWrapper = std::make_unique(window, viewer); mVideoWrapper->setGammaContrast( Settings::Manager::getFloat("gamma", "Video"), Settings::Manager::getFloat("contrast", "Video")); @@ -1040,7 +1037,8 @@ namespace MWGui { mToolTips->setFocusObject(focus); - if (mHud && (mShowOwned == 2 || mShowOwned == 3)) + const int showOwned = Settings::game().mShowOwned; + if (mHud && (showOwned == 2 || showOwned == 3)) { bool owned = mToolTips->checkOwned(); mHud->setCrosshairOwned(owned); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 74fad4b64f..8bb3d1f8b0 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -515,8 +515,6 @@ namespace MWGui void updateMap(); - int mShowOwned; - ToUTF8::FromType mEncoding; std::string mVersionDescription; diff --git a/apps/openmw/mwlua/nearbybindings.cpp b/apps/openmw/mwlua/nearbybindings.cpp index 876cffb3d7..6c7ee88803 100644 --- a/apps/openmw/mwlua/nearbybindings.cpp +++ b/apps/openmw/mwlua/nearbybindings.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -166,8 +166,8 @@ namespace MWLua })); static const DetourNavigator::AgentBounds defaultAgentBounds{ - DetourNavigator::toCollisionShapeType(Settings::Manager::getInt("actor collision shape type", "Game")), - Settings::Manager::getVector3("default actor pathfind half extents", "Game"), + Settings::game().mActorCollisionShapeType, + Settings::game().mDefaultActorPathfindHalfExtents, }; static const float defaultStepSize = 2 * std::max(defaultAgentBounds.mHalfExtents.x(), defaultAgentBounds.mHalfExtents.y()); diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index b759cdb8b9..ef5c9992be 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include "actorutil.hpp" #include "creaturestats.hpp" @@ -289,9 +289,7 @@ namespace MWMechanics { if (!reflected) { - static const bool keepOriginalCaster - = Settings::Manager::getBool("classic reflected absorb spells behavior", "Game"); - if (keepOriginalCaster) + if (Settings::game().mClassicReflectedAbsorbSpellsBehavior) reflected = { *spellIt, caster }; else reflected = { *spellIt, ptr }; @@ -369,8 +367,7 @@ namespace MWMechanics ++spellIt; } - static const bool keepCalm = Settings::Manager::getBool("classic calm spells behavior", "Game"); - if (keepCalm) + if (Settings::game().mClassicCalmSpellsBehavior) { ESM::MagicEffect::Effects effect = ptr.getClass().isNpc() ? ESM::MagicEffect::CalmHumanoid : ESM::MagicEffect::CalmCreature; diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 8cdc88549c..0c5055bbf8 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include @@ -425,7 +425,7 @@ namespace MWMechanics void Actors::updateMovementSpeed(const MWWorld::Ptr& actor) const { - if (mSmoothMovement) + if (Settings::game().mSmoothMovement) return; const auto& actorClass = actor.getClass(); @@ -559,7 +559,7 @@ namespace MWMechanics float angle = std::atan2(from, to); actorState.setAngleToPlayer(angle); float deltaAngle = Misc::normalizeAngle(angle - actor.getRefData().getPosition().rot[2]); - if (!mSmoothMovement || std::abs(deltaAngle) > osg::DegreesToRadians(60.f)) + if (!Settings::game().mSmoothMovement || std::abs(deltaAngle) > osg::DegreesToRadians(60.f)) actorState.setTurningToPlayer(true); } } @@ -598,8 +598,9 @@ namespace MWMechanics const osg::Vec3f actor1Pos(actor1.getRefData().getPosition().asVec3()); const osg::Vec3f actor2Pos(actor2.getRefData().getPosition().asVec3()); const float sqrDist = (actor1Pos - actor2Pos).length2(); + const int actorsProcessingRange = Settings::game().mActorsProcessingRange; - if (sqrDist > mActorsProcessingRange * mActorsProcessingRange) + if (sqrDist > actorsProcessingRange * actorsProcessingRange) return; // If this is set to true, actor1 will start combat with actor2 if the awareness check at the end of the method @@ -677,8 +678,7 @@ namespace MWMechanics // If set in the settings file, player followers and escorters will become aggressive toward enemies in combat // with them or the player - static const bool followersAttackOnSight = Settings::Manager::getBool("followers attack on sight", "Game"); - if (!aggressive && isPlayerFollowerOrEscorter && followersAttackOnSight) + if (!aggressive && isPlayerFollowerOrEscorter && Settings::game().mFollowersAttackOnSight) { if (creatureStats2.getAiSequence().isInCombat(actor1)) aggressive = true; @@ -1161,23 +1161,6 @@ namespace MWMechanics } } - Actors::Actors() - : mSmoothMovement(Settings::Manager::getBool("smooth movement", "Game")) - { - updateProcessingRange(); - } - - void Actors::updateProcessingRange() - { - // We have to cap it since using high values (larger than 7168) will make some quests harder or impossible to - // complete (bug #1876) - static constexpr float maxRange = 7168.f; - static constexpr float minRange = maxRange / 2.f; - - mActorsProcessingRange - = std::clamp(Settings::Manager::getFloat("actors processing range", "Game"), minRange, maxRange); - } - void Actors::addActor(const MWWorld::Ptr& ptr, bool updateImmediately) { removeActor(ptr, true); @@ -1208,7 +1191,8 @@ namespace MWMechanics const float dist = (player.getRefData().getPosition().asVec3() - ptr.getRefData().getPosition().asVec3()).length(); - if (dist > mActorsProcessingRange) + const int actorsProcessingRange = Settings::game().mActorsProcessingRange; + if (dist > actorsProcessingRange) { ptr.getRefData().getBaseNode()->setNodeMask(0); return; @@ -1218,8 +1202,8 @@ namespace MWMechanics // Fade away actors on large distance (>90% of actor's processing distance) float visibilityRatio = 1.0; - const float fadeStartDistance = mActorsProcessingRange * 0.9f; - const float fadeEndDistance = mActorsProcessingRange; + const float fadeStartDistance = actorsProcessingRange * 0.9f; + const float fadeEndDistance = actorsProcessingRange; const float fadeRatio = (dist - fadeStartDistance) / (fadeEndDistance - fadeStartDistance); if (fadeRatio > 0) visibilityRatio -= std::max(0.f, fadeRatio); @@ -1263,7 +1247,7 @@ namespace MWMechanics // Otherwise check if any actor in AI processing range sees the target actor std::vector neighbors; osg::Vec3f position(actor.getRefData().getPosition().asVec3()); - getObjectsInRange(position, mActorsProcessingRange, neighbors); + getObjectsInRange(position, Settings::game().mActorsProcessingRange, neighbors); for (const MWWorld::Ptr& neighbor : neighbors) { if (neighbor == actor) @@ -1310,13 +1294,15 @@ namespace MWMechanics if (aiActive) { + const int actorsProcessingRange = Settings::game().mActorsProcessingRange; for (const Actor& actor : mActors) { if (actor.getPtr() == player) continue; - bool inProcessingRange = (playerPos - actor.getPtr().getRefData().getPosition().asVec3()).length2() - <= mActorsProcessingRange * mActorsProcessingRange; + const bool inProcessingRange + = (playerPos - actor.getPtr().getRefData().getPosition().asVec3()).length2() + <= actorsProcessingRange * actorsProcessingRange; if (inProcessingRange) { MWMechanics::CreatureStats& stats = actor.getPtr().getClass().getCreatureStats(actor.getPtr()); @@ -1353,7 +1339,7 @@ namespace MWMechanics const float maxDistForPartialAvoiding = 200.f; const float maxDistForStrictAvoiding = 100.f; const float maxTimeToCheck = 2.0f; - static const bool giveWayWhenIdle = Settings::Manager::getBool("NPCs give way", "Game"); + const bool giveWayWhenIdle = Settings::game().mNPCsGiveWay; const MWWorld::Ptr player = getPlayer(); const MWBase::World* const world = MWBase::Environment::get().getWorld(); @@ -1538,6 +1524,7 @@ namespace MWMechanics player.getClass().getCreatureStats(player).setHitAttemptActorId(-1); } const bool godmode = MWBase::Environment::get().getWorld()->getGodModeState(); + const int actorsProcessingRange = Settings::game().mActorsProcessingRange; // AI and magic effects update for (Actor& actor : mActors) @@ -1549,7 +1536,7 @@ namespace MWMechanics const float distSqr = (playerPos - actor.getPtr().getRefData().getPosition().asVec3()).length2(); // AI processing is only done within given distance to the player. - const bool inProcessingRange = distSqr <= mActorsProcessingRange * mActorsProcessingRange; + const bool inProcessingRange = distSqr <= actorsProcessingRange * actorsProcessingRange; // If dead or no longer in combat, no longer store any actors who attempted to hit us. Also remove for // the player. @@ -1648,8 +1635,7 @@ namespace MWMechanics } } - static const bool avoidCollisions = Settings::Manager::getBool("NPCs avoid collisions", "Game"); - if (avoidCollisions) + if (Settings::game().mNPCsAvoidCollisions) predictAndAvoidCollisions(duration); mTimerUpdateHeadTrack += duration; @@ -1671,7 +1657,7 @@ namespace MWMechanics MWMechanics::AiSequence& seq = stats.getAiSequence(); alwaysActive = !seq.isEmpty() && seq.getActivePackage().alwaysActive(); } - const bool inRange = isPlayer || dist <= mActorsProcessingRange || alwaysActive; + const bool inRange = isPlayer || dist <= actorsProcessingRange || alwaysActive; const int activeFlag = isPlayer ? 2 : 1; // Can be changed back to '2' to keep updating bounding boxes // off screen (more accurate, but slower) const int active = inRange ? activeFlag : 0; @@ -1885,6 +1871,7 @@ namespace MWMechanics const MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); const osg::Vec3f playerPos = player.getRefData().getPosition().asVec3(); + const int actorsProcessingRange = Settings::game().mActorsProcessingRange; for (const Actor& actor : mActors) { @@ -1899,7 +1886,7 @@ namespace MWMechanics if ((!actor.getPtr().getRefData().getBaseNode()) || (playerPos - actor.getPtr().getRefData().getPosition().asVec3()).length2() - > mActorsProcessingRange * mActorsProcessingRange) + > actorsProcessingRange * actorsProcessingRange) continue; adjustMagicEffects(actor.getPtr(), duration); @@ -1947,7 +1934,7 @@ namespace MWMechanics std::vector observers; const osg::Vec3f position(player.getRefData().getPosition().asVec3()); - const float radius = std::min(fSneakUseDist, mActorsProcessingRange); + const float radius = std::min(fSneakUseDist, Settings::game().mActorsProcessingRange); getObjectsInRange(position, radius, observers); std::set sidingActors; @@ -2231,7 +2218,7 @@ namespace MWMechanics std::vector list; std::vector neighbors; const osg::Vec3f position(actor.getRefData().getPosition().asVec3()); - getObjectsInRange(position, mActorsProcessingRange, neighbors); + getObjectsInRange(position, Settings::game().mActorsProcessingRange, neighbors); for (const MWWorld::Ptr& neighbor : neighbors) { if (neighbor == actor) @@ -2252,7 +2239,7 @@ namespace MWMechanics std::vector list; std::vector neighbors; osg::Vec3f position(actor.getRefData().getPosition().asVec3()); - getObjectsInRange(position, mActorsProcessingRange, neighbors); + getObjectsInRange(position, Settings::game().mActorsProcessingRange, neighbors); std::set followers; getActorsFollowing(actor, followers); diff --git a/apps/openmw/mwmechanics/actors.hpp b/apps/openmw/mwmechanics/actors.hpp index f65077b38b..1c5799159e 100644 --- a/apps/openmw/mwmechanics/actors.hpp +++ b/apps/openmw/mwmechanics/actors.hpp @@ -40,8 +40,6 @@ namespace MWMechanics class Actors { public: - Actors(); - std::list::const_iterator begin() const { return mActors.begin(); } std::list::const_iterator end() const { return mActors.end(); } std::size_t size() const { return mActors.size(); } @@ -56,8 +54,6 @@ namespace MWMechanics /// paused we may want to do it manually (after equipping permanent enchantment) void updateMagicEffects(const MWWorld::Ptr& ptr) const; - void updateProcessingRange(); - void addActor(const MWWorld::Ptr& ptr, bool updateImmediately = false); ///< Register an actor for stats management /// @@ -186,8 +182,6 @@ namespace MWMechanics float mTimerUpdateHello = 0; float mSneakTimer = 0; // Times update of sneak icon float mSneakSkillTimer = 0; // Times sneak skill progress from "avoid notice" - float mActorsProcessingRange; - bool mSmoothMovement; MusicType mCurrentMusic = MusicType::Title; void updateVisibility(const MWWorld::Ptr& ptr, CharacterController& ctrl) const; diff --git a/apps/openmw/mwmechanics/aipackage.cpp b/apps/openmw/mwmechanics/aipackage.cpp index c3ed1fe253..463a6f1a3a 100644 --- a/apps/openmw/mwmechanics/aipackage.cpp +++ b/apps/openmw/mwmechanics/aipackage.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -190,7 +190,7 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, const osg::Vec3f& const float pointTolerance = getPointTolerance(actor.getClass().getMaxSpeed(actor), duration, world->getHalfExtents(actor)); - static const bool smoothMovement = Settings::Manager::getBool("smooth movement", "Game"); + const bool smoothMovement = Settings::game().mSmoothMovement; PathFinder::UpdateFlags updateFlags{}; @@ -469,15 +469,12 @@ bool MWMechanics::AiPackage::isReachableRotatingOnTheRun(const MWWorld::Ptr& act DetourNavigator::Flags MWMechanics::AiPackage::getNavigatorFlags(const MWWorld::Ptr& actor) const { - static const bool allowToFollowOverWaterSurface - = Settings::Manager::getBool("allow actors to follow over water surface", "Game"); - const MWWorld::Class& actorClass = actor.getClass(); DetourNavigator::Flags result = DetourNavigator::Flag_none; if ((actorClass.isPureWaterCreature(actor) || (getTypeId() != AiPackageTypeId::Wander - && ((allowToFollowOverWaterSurface && getTypeId() == AiPackageTypeId::Follow) + && ((Settings::game().mAllowActorsToFollowOverWaterSurface && getTypeId() == AiPackageTypeId::Follow) || actorClass.canSwim(actor) || hasWaterWalking(actor)))) && actorClass.getSwimSpeed(actor) > 0) result |= DetourNavigator::Flag_swim; diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 38788c3445..24d7285ad9 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include @@ -1509,9 +1509,7 @@ namespace MWMechanics } } - static const bool useCastingAnimations - = Settings::Manager::getBool("use magic item animations", "Game"); - if (isMagicItem && !useCastingAnimations) + if (isMagicItem && !Settings::game().mUseMagicItemAnimations) { world->breakInvisibility(mPtr); // Enchanted items by default do not use casting animations @@ -1619,7 +1617,7 @@ namespace MWMechanics mAttackType = "shoot"; else if (mPtr == getPlayer()) { - if (Settings::Manager::getBool("best attack", "Game")) + if (Settings::game().mBestAttack) { if (!mWeapon.isEmpty() && mWeapon.getType() == ESM::Weapon::sRecordId) { @@ -1864,8 +1862,7 @@ namespace MWMechanics float scale = mPtr.getCellRef().getScale(); - static const bool normalizeSpeed = Settings::Manager::getBool("normalise race speed", "Game"); - if (!normalizeSpeed && cls.isNpc()) + if (!Settings::game().mNormaliseRaceSpeed && cls.isNpc()) { const ESM::NPC* npc = mPtr.get()->mBase; const ESM::Race* race = world->getStore().get().find(npc->mRace); @@ -1913,11 +1910,9 @@ namespace MWMechanics movementSettings.mSpeedFactor = std::min(vec.length(), 1.f); vec.normalize(); - static const bool smoothMovement = Settings::Manager::getBool("smooth movement", "Game"); + const bool smoothMovement = Settings::game().mSmoothMovement; if (smoothMovement) { - static const float playerTurningCoef = 1.0 - / std::max(0.01f, Settings::Manager::getFloat("smooth movement player turning delay", "Game")); float angle = mPtr.getRefData().getPosition().rot[2]; osg::Vec2f targetSpeed = Misc::rotateVec2f(osg::Vec2f(vec.x(), vec.y()), -angle) * movementSettings.mSpeedFactor; @@ -1930,7 +1925,7 @@ namespace MWMechanics maxDelta = 1; else if (std::abs(speedDelta) < deltaLen / 2) // Turning is smooth for player and less smooth for NPCs (otherwise NPC can miss a path point). - maxDelta = duration * (isPlayer ? playerTurningCoef : 6.f); + maxDelta = duration * (isPlayer ? 1.0 / Settings::game().mSmoothMovementPlayerTurningDelay : 6.f); else if (isPlayer && speedDelta < -deltaLen / 2) // As soon as controls are released, mwinput switches player from running to walking. // So stopping should be instant for player, otherwise it causes a small twitch. @@ -1964,8 +1959,7 @@ namespace MWMechanics float effectiveRotation = rot.z(); bool canMove = cls.getMaxSpeed(mPtr) > 0; - static const bool turnToMovementDirection - = Settings::Manager::getBool("turn to movement direction", "Game"); + const bool turnToMovementDirection = Settings::game().mTurnToMovementDirection; if (!turnToMovementDirection || isFirstPersonPlayer) { movementSettings.mIsStrafing = std::abs(vec.x()) > std::abs(vec.y()) * 2; @@ -2230,13 +2224,11 @@ namespace MWMechanics else mAnimation->setBodyPitchRadians(0); - static const bool swimUpwardCorrection = Settings::Manager::getBool("swim upward correction", "Game"); - if (inwater && isPlayer && !isFirstPersonPlayer && swimUpwardCorrection) + if (inwater && isPlayer && !isFirstPersonPlayer && Settings::game().mSwimUpwardCorrection) { - static const float swimUpwardCoef = Settings::Manager::getFloat("swim upward coef", "Game"); - static const float swimForwardCoef = sqrtf(1.0f - swimUpwardCoef * swimUpwardCoef); + const float swimUpwardCoef = Settings::game().mSwimUpwardCoef; vec.z() = std::abs(vec.y()) * swimUpwardCoef; - vec.y() *= swimForwardCoef; + vec.y() *= std::sqrt(1.0f - swimUpwardCoef * swimUpwardCoef); } // Player can not use smooth turning as NPCs, so we play turning animation a bit to avoid jittering diff --git a/apps/openmw/mwmechanics/combat.cpp b/apps/openmw/mwmechanics/combat.cpp index b83eb1f10c..b20a3ed2fb 100644 --- a/apps/openmw/mwmechanics/combat.cpp +++ b/apps/openmw/mwmechanics/combat.cpp @@ -2,7 +2,7 @@ #include "combat.hpp" #include -#include +#include #include @@ -174,8 +174,7 @@ namespace MWMechanics bool isMagical = flags & ESM::Weapon::Magical; bool isEnchanted = !weapon.getClass().getEnchantment(weapon).empty(); - return !isSilver && !isMagical - && (!isEnchanted || !Settings::Manager::getBool("enchanted weapons are magical", "Game")); + return !isSilver && !isMagical && (!isEnchanted || !Settings::game().mEnchantedWeaponsAreMagical); } void resistNormalWeapon( @@ -251,8 +250,7 @@ namespace MWMechanics if (validVictim) { - if (weapon == projectile - || Settings::Manager::getBool("only appropriate ammunition bypasses resistance", "Game") + if (weapon == projectile || Settings::game().mOnlyAppropriateAmmunitionBypassesResistance || isNormalWeapon(weapon)) resistNormalWeapon(victim, attacker, projectile, damage); applyWerewolfDamageMult(victim, projectile, damage); @@ -469,7 +467,7 @@ namespace MWMechanics // 0 = Do not factor strength into hand-to-hand combat. // 1 = Factor into werewolf hand-to-hand combat. // 2 = Ignore werewolves. - int factorStrength = Settings::Manager::getInt("strength influences hand to hand", "Game"); + const int factorStrength = Settings::game().mStrengthInfluencesHandToHand; if (factorStrength == 1 || (factorStrength == 2 && !isWerewolf)) { damage diff --git a/apps/openmw/mwmechanics/difficultyscaling.cpp b/apps/openmw/mwmechanics/difficultyscaling.cpp index a20bb1eac7..b6e8feefdb 100644 --- a/apps/openmw/mwmechanics/difficultyscaling.cpp +++ b/apps/openmw/mwmechanics/difficultyscaling.cpp @@ -1,6 +1,6 @@ #include "difficultyscaling.hpp" -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -12,13 +12,10 @@ float scaleDamage(float damage, const MWWorld::Ptr& attacker, const MWWorld::Ptr { const MWWorld::Ptr& player = MWMechanics::getPlayer(); - // [-500, 500] - const int difficultySetting = std::clamp(Settings::Manager::getInt("difficulty", "Game"), -500, 500); - static const float fDifficultyMult = MWBase::Environment::get().getESMStore()->get().find("fDifficultyMult")->mValue.getFloat(); - float difficultyTerm = 0.01f * difficultySetting; + const float difficultyTerm = 0.01f * Settings::game().mDifficulty; float x = 0; if (victim == player) diff --git a/apps/openmw/mwmechanics/enchanting.cpp b/apps/openmw/mwmechanics/enchanting.cpp index d44c798666..f7393874fb 100644 --- a/apps/openmw/mwmechanics/enchanting.cpp +++ b/apps/openmw/mwmechanics/enchanting.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include "../mwworld/class.hpp" #include "../mwworld/containerstore.hpp" @@ -368,11 +368,10 @@ namespace MWMechanics ESM::WeaponType::Class weapclass = MWMechanics::getWeaponType(mWeaponType)->mWeaponClass; if (weapclass == ESM::WeaponType::Thrown || weapclass == ESM::WeaponType::Ammo) { - static const float multiplier - = std::clamp(Settings::Manager::getFloat("projectiles enchant multiplier", "Game"), 0.f, 1.f); MWWorld::Ptr player = getPlayer(); count = player.getClass().getContainerStore(player).count(mOldItemPtr.getCellRef().getRefId()); - count = std::clamp(getGemCharge() * multiplier / enchantPoints, 1, count); + count = std::clamp( + getGemCharge() * Settings::game().mProjectilesEnchantMultiplier / enchantPoints, 1, count); } } @@ -381,8 +380,7 @@ namespace MWMechanics float Enchanting::getTypeMultiplier() const { - static const bool useMultiplier = Settings::Manager::getFloat("projectiles enchant multiplier", "Game") > 0; - if (useMultiplier && mWeaponType != -1 && getEnchantPoints() > 0) + if (Settings::game().mProjectilesEnchantMultiplier > 0 && mWeaponType != -1 && getEnchantPoints() > 0) { ESM::WeaponType::Class weapclass = MWMechanics::getWeaponType(mWeaponType)->mWeaponClass; if (weapclass == ESM::WeaponType::Thrown || weapclass == ESM::WeaponType::Ammo) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 889fdd642b..135c8e4660 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -350,8 +350,6 @@ namespace MWMechanics if (state != MWBase::StateManager::State_Running) continue; - mActors.updateProcessingRange(); - // Update mechanics for new processing range immediately update(0.f, false); } diff --git a/apps/openmw/mwmechanics/spelleffects.cpp b/apps/openmw/mwmechanics/spelleffects.cpp index 2c410c842a..89dff6443c 100644 --- a/apps/openmw/mwmechanics/spelleffects.cpp +++ b/apps/openmw/mwmechanics/spelleffects.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -649,9 +649,8 @@ namespace MWMechanics modDynamicStat(target, index, -effect.mMagnitude); else { - static const bool uncappedDamageFatigue - = Settings::Manager::getBool("uncapped damage fatigue", "Game"); - adjustDynamicStat(target, index, -effect.mMagnitude, index == 2 && uncappedDamageFatigue); + adjustDynamicStat( + target, index, -effect.mMagnitude, index == 2 && Settings::game().mUncappedDamageFatigue); if (index == 0) receivedMagicDamage = affectedHealth = true; } @@ -716,10 +715,9 @@ namespace MWMechanics case ESM::MagicEffect::DrainFatigue: if (!godmode) { - static const bool uncappedDamageFatigue - = Settings::Manager::getBool("uncapped damage fatigue", "Game"); int index = effect.mEffectId - ESM::MagicEffect::DrainHealth; - adjustDynamicStat(target, index, -effect.mMagnitude, uncappedDamageFatigue && index == 2); + adjustDynamicStat( + target, index, -effect.mMagnitude, Settings::game().mUncappedDamageFatigue && index == 2); if (index == 0) receivedMagicDamage = affectedHealth = true; } diff --git a/apps/openmw/mwmechanics/steering.cpp b/apps/openmw/mwmechanics/steering.cpp index 7271b3bc41..fe7d12e6df 100644 --- a/apps/openmw/mwmechanics/steering.cpp +++ b/apps/openmw/mwmechanics/steering.cpp @@ -1,7 +1,7 @@ #include "steering.hpp" #include -#include +#include #include "../mwworld/class.hpp" #include "../mwworld/ptr.hpp" @@ -26,8 +26,7 @@ namespace MWMechanics float limit = getAngularVelocity(actor.getClass().getMaxSpeed(actor)) * MWBase::Environment::get().getFrameDuration(); - static const bool smoothMovement = Settings::Manager::getBool("smooth movement", "Game"); - if (smoothMovement) + if (Settings::game().mSmoothMovement) limit *= std::min(absDiff / osg::PI + 0.1, 0.5); if (absDiff > limit) diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index d1f13326cb..4a500792a2 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -104,8 +104,6 @@ namespace MWPhysics , mWaterEnabled(false) , mParentNode(parentNode) , mPhysicsDt(1.f / 60.f) - , mActorCollisionShapeType( - DetourNavigator::toCollisionShapeType(Settings::Manager::getInt("actor collision shape type", "Game"))) { mResourceSystem->addResourceManager(mShapeManager.get()); @@ -668,7 +666,8 @@ namespace MWPhysics const MWMechanics::MagicEffects& effects = ptr.getClass().getCreatureStats(ptr).getMagicEffects(); const bool canWaterWalk = effects.getOrDefault(ESM::MagicEffect::WaterWalking).getMagnitude() > 0; - auto actor = std::make_shared(ptr, shape, mTaskScheduler.get(), canWaterWalk, mActorCollisionShapeType); + auto actor = std::make_shared( + ptr, shape, mTaskScheduler.get(), canWaterWalk, Settings::game().mActorCollisionShapeType); mActors.emplace(ptr.mRef, std::move(actor)); } diff --git a/apps/openmw/mwphysics/physicssystem.hpp b/apps/openmw/mwphysics/physicssystem.hpp index 32899dd711..d73a87509e 100644 --- a/apps/openmw/mwphysics/physicssystem.hpp +++ b/apps/openmw/mwphysics/physicssystem.hpp @@ -16,7 +16,6 @@ #include #include -#include #include #include "../mwworld/ptr.hpp" @@ -342,8 +341,6 @@ namespace MWPhysics float mPhysicsDt; - DetourNavigator::CollisionShapeType mActorCollisionShapeType; - std::size_t mSimulationsCounter = 0; std::array, 2> mSimulations; std::vector> mActorsPositions; diff --git a/apps/openmw/mwrender/actoranimation.cpp b/apps/openmw/mwrender/actoranimation.cpp index fa5b2c9532..eef65816a0 100644 --- a/apps/openmw/mwrender/actoranimation.cpp +++ b/apps/openmw/mwrender/actoranimation.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include @@ -163,8 +163,7 @@ namespace MWRender bool ActorAnimation::updateCarriedLeftVisible(const int weaptype) const { - static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game"); - if (shieldSheathing) + if (Settings::game().mShieldSheathing) { const MWWorld::Class& cls = mPtr.getClass(); MWMechanics::CreatureStats& stats = cls.getCreatureStats(mPtr); @@ -189,8 +188,7 @@ namespace MWRender void ActorAnimation::updateHolsteredShield(bool showCarriedLeft) { - static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game"); - if (!shieldSheathing) + if (!Settings::game().mShieldSheathing) return; if (!mPtr.getClass().hasInventoryStore(mPtr)) @@ -256,8 +254,7 @@ namespace MWRender bool ActorAnimation::useShieldAnimations() const { - static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game"); - if (!shieldSheathing) + if (!Settings::game().mShieldSheathing) return false; const MWWorld::Class& cls = mPtr.getClass(); @@ -325,8 +322,7 @@ namespace MWRender void ActorAnimation::updateHolsteredWeapon(bool showHolsteredWeapons) { - static const bool weaponSheathing = Settings::Manager::getBool("weapon sheathing", "Game"); - if (!weaponSheathing) + if (!Settings::game().mWeaponSheathing) return; if (!mPtr.getClass().hasInventoryStore(mPtr)) @@ -405,8 +401,7 @@ namespace MWRender void ActorAnimation::updateQuiver() { - static const bool weaponSheathing = Settings::Manager::getBool("weapon sheathing", "Game"); - if (!weaponSheathing) + if (!Settings::game().mWeaponSheathing) return; if (!mPtr.getClass().hasInventoryStore(mPtr)) diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 034e6c1bc3..115f49a0b1 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -42,7 +42,7 @@ #include #include -#include +#include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -616,8 +616,7 @@ namespace MWRender addSingleAnimSource(kfname, baseModel); - static const bool useAdditionalSources = Settings::Manager::getBool("use additional anim sources", "Game"); - if (useAdditionalSources) + if (Settings::game().mUseAdditionalAnimSources) loadAllAnimationsInFolder(kfname, baseModel); } @@ -1388,11 +1387,10 @@ namespace MWRender mAccumRoot = nullptr; mAccumCtrl = nullptr; - static const bool useAdditionalSources = Settings::Manager::getBool("use additional anim sources", "Game"); std::string defaultSkeleton; bool inject = false; - if (useAdditionalSources && mPtr.getClass().isActor()) + if (Settings::game().mUseAdditionalAnimSources && mPtr.getClass().isActor()) { if (isCreature) { @@ -1867,8 +1865,7 @@ namespace MWRender visitor.remove(); } - if (Settings::Manager::getBool("day night switches", "Game") - && SceneUtil::hasUserDescription(mObjectRoot, Constants::NightDayLabel)) + if (Settings::game().mDayNightSwitches && SceneUtil::hasUserDescription(mObjectRoot, Constants::NightDayLabel)) { AddSwitchCallbacksVisitor visitor; mObjectRoot->accept(visitor); diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 43769c7ef1..99f21bc9ab 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include @@ -297,8 +297,7 @@ namespace MWRender rebuild(); setRenderBin(); - static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game"); - if (viewChange && shieldSheathing) + if (viewChange && Settings::game().mShieldSheathing) { int weaptype = ESM::Weapon::None; MWMechanics::getActiveWeapon(mPtr, &weaptype); @@ -988,8 +987,7 @@ namespace MWRender bool NpcAnimation::updateCarriedLeftVisible(const int weaptype) const { - static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game"); - if (shieldSheathing) + if (Settings::game().mShieldSheathing) { const MWWorld::Class& cls = mPtr.getClass(); MWMechanics::CreatureStats& stats = cls.getCreatureStats(mPtr); @@ -1125,8 +1123,7 @@ namespace MWRender void NpcAnimation::equipmentChanged() { - static const bool shieldSheathing = Settings::Manager::getBool("shield sheathing", "Game"); - if (shieldSheathing) + if (Settings::game().mShieldSheathing) { int weaptype = ESM::Weapon::None; MWMechanics::getActiveWeapon(mPtr, &weaptype); diff --git a/apps/openmw/mwworld/projectilemanager.cpp b/apps/openmw/mwworld/projectilemanager.cpp index 28f1904508..785b19ea82 100644 --- a/apps/openmw/mwworld/projectilemanager.cpp +++ b/apps/openmw/mwworld/projectilemanager.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include "../mwworld/class.hpp" #include "../mwworld/esmstore.hpp" @@ -431,7 +431,7 @@ namespace MWWorld void ProjectileManager::moveMagicBolts(float duration) { - static const bool normaliseRaceSpeed = Settings::Manager::getBool("normalise race speed", "Game"); + const bool normaliseRaceSpeed = Settings::game().mNormaliseRaceSpeed; for (auto& magicBoltState : mMagicBolts) { if (magicBoltState.mToDelete) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c83c2f0fd2..3f246628cc 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -53,6 +53,8 @@ #include #include +#include + #include "../mwbase/environment.hpp" #include "../mwbase/luamanager.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -256,9 +258,6 @@ namespace MWWorld , mDiscardMovements(true) , mContentFiles(contentFiles) , mUserDataPath(userDataPath) - , mDefaultHalfExtents(Settings::Manager::getVector3("default actor pathfind half extents", "Game")) - , mDefaultActorCollisionShapeType( - DetourNavigator::toCollisionShapeType(Settings::Manager::getInt("actor collision shape type", "Game"))) , mActivationDistanceOverride(activationDistanceOverride) , mStartCell(startCell) , mDistanceToFacedObject(-1.f) @@ -3808,7 +3807,8 @@ namespace MWWorld { const MWPhysics::Actor* physicsActor = mPhysics->getActor(actor); if (physicsActor == nullptr || !actor.isInCell() || actor.getCell()->isExterior()) - return DetourNavigator::AgentBounds{ mDefaultActorCollisionShapeType, mDefaultHalfExtents }; + return DetourNavigator::AgentBounds{ Settings::game().mActorCollisionShapeType, + Settings::game().mDefaultActorPathfindHalfExtents }; else return DetourNavigator::AgentBounds{ physicsActor->getCollisionShapeType(), physicsActor->getHalfExtents() }; diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index af0383668c..e15f5808d3 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -114,9 +113,6 @@ namespace MWWorld std::filesystem::path mUserDataPath; - osg::Vec3f mDefaultHalfExtents; - DetourNavigator::CollisionShapeType mDefaultActorCollisionShapeType; - int mActivationDistanceOverride; std::string mStartCell; diff --git a/components/settings/categories/game.hpp b/components/settings/categories/game.hpp index c96ff1e63c..ded367a54c 100644 --- a/components/settings/categories/game.hpp +++ b/components/settings/categories/game.hpp @@ -25,6 +25,8 @@ namespace Settings SettingValue mShowEnchantChance{ mIndex, "Game", "show enchant chance" }; SettingValue mBestAttack{ mIndex, "Game", "best attack" }; SettingValue mDifficulty{ mIndex, "Game", "difficulty", makeClampSanitizerInt(-500, 500) }; + // We have to cap it since using high values (larger than 7168) will make some quests harder or impossible to + // complete (bug #1876) SettingValue mActorsProcessingRange{ mIndex, "Game", "actors processing range", makeClampSanitizerInt(3584, 7168) }; SettingValue mClassicReflectedAbsorbSpellsBehavior{ mIndex, "Game",