From 22482b7eece985f55866b9ede84353cfd0506816 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 20 Feb 2017 19:04:02 +0100 Subject: [PATCH 1/7] Don't use xmesh.nif over mesh.nif for classes that don't make use of the separated keyframes --- apps/openmw/mwclass/activator.cpp | 6 +++++- apps/openmw/mwclass/activator.hpp | 3 +++ apps/openmw/mwclass/actor.cpp | 6 +++++- apps/openmw/mwclass/actor.hpp | 2 ++ apps/openmw/mwclass/container.cpp | 6 +++++- apps/openmw/mwclass/container.hpp | 2 ++ apps/openmw/mwclass/door.cpp | 5 ++++- apps/openmw/mwclass/door.hpp | 2 ++ apps/openmw/mwclass/light.cpp | 5 ++++- apps/openmw/mwclass/light.hpp | 2 ++ apps/openmw/mwworld/class.cpp | 5 +++++ apps/openmw/mwworld/class.hpp | 3 +++ apps/openmw/mwworld/scene.cpp | 10 +++++++++- 13 files changed, 51 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index b3747f916..3e0ec366f 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -38,7 +38,6 @@ namespace MWClass { if(!model.empty()) physics.addObject(ptr, model); - MWBase::Environment::get().getMechanicsManager()->add(ptr); } std::string Activator::getModel(const MWWorld::ConstPtr &ptr) const @@ -52,6 +51,11 @@ namespace MWClass return ""; } + bool Activator::useAnim() const + { + return true; + } + std::string Activator::getName (const MWWorld::ConstPtr& ptr) const { const MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/activator.hpp b/apps/openmw/mwclass/activator.hpp index e90620cea..4fe4dda7e 100644 --- a/apps/openmw/mwclass/activator.hpp +++ b/apps/openmw/mwclass/activator.hpp @@ -39,6 +39,9 @@ namespace MWClass static void registerSelf(); virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; + + virtual bool useAnim() const; + ///< Whether or not to use animated variant of model (default false) }; } diff --git a/apps/openmw/mwclass/actor.cpp b/apps/openmw/mwclass/actor.cpp index d46729c1d..ecf089b35 100644 --- a/apps/openmw/mwclass/actor.cpp +++ b/apps/openmw/mwclass/actor.cpp @@ -34,7 +34,11 @@ namespace MWClass if (getCreatureStats(ptr).isDead()) MWBase::Environment::get().getWorld()->enableActorCollision(ptr, false); } - MWBase::Environment::get().getMechanicsManager()->add(ptr); + } + + bool Actor::useAnim() const + { + return true; } void Actor::block(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/actor.hpp b/apps/openmw/mwclass/actor.hpp index 84b8f4ad8..c3720050c 100644 --- a/apps/openmw/mwclass/actor.hpp +++ b/apps/openmw/mwclass/actor.hpp @@ -26,6 +26,8 @@ namespace MWClass virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const; + virtual bool useAnim() const; + virtual void block(const MWWorld::Ptr &ptr) const; virtual osg::Vec3f getRotationVector(const MWWorld::Ptr& ptr) const; diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 47e24f0d6..b0d3ca791 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -100,7 +100,6 @@ namespace MWClass { if(!model.empty()) physics.addObject(ptr, model); - MWBase::Environment::get().getMechanicsManager()->add(ptr); } std::string Container::getModel(const MWWorld::ConstPtr &ptr) const @@ -114,6 +113,11 @@ namespace MWClass return ""; } + bool Container::useAnim() const + { + return true; + } + boost::shared_ptr Container::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index 3add65a7e..04223f264 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -70,6 +70,8 @@ namespace MWClass virtual void restock (const MWWorld::Ptr &ptr) const; virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; + + virtual bool useAnim() const; }; } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 830ba258b..21e191931 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -74,8 +74,11 @@ namespace MWClass MWBase::Environment::get().getWorld()->activateDoor(ptr, customData.mDoorState); } } + } - MWBase::Environment::get().getMechanicsManager()->add(ptr); + bool Door::useAnim() const + { + return true; } std::string Door::getModel(const MWWorld::ConstPtr &ptr) const diff --git a/apps/openmw/mwclass/door.hpp b/apps/openmw/mwclass/door.hpp index 906b18511..3760f59c4 100644 --- a/apps/openmw/mwclass/door.hpp +++ b/apps/openmw/mwclass/door.hpp @@ -20,6 +20,8 @@ namespace MWClass virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const; + virtual bool useAnim() const; + virtual std::string getName (const MWWorld::ConstPtr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 689419f44..e74b9da88 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -51,8 +51,11 @@ namespace MWClass MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->mBase->mSound, 1.0, 1.0, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop); + } - MWBase::Environment::get().getMechanicsManager()->add(ptr); + bool Light::useAnim() const + { + return true; } std::string Light::getModel(const MWWorld::ConstPtr &ptr) const diff --git a/apps/openmw/mwclass/light.hpp b/apps/openmw/mwclass/light.hpp index 68fd2d2c7..284a7d817 100644 --- a/apps/openmw/mwclass/light.hpp +++ b/apps/openmw/mwclass/light.hpp @@ -16,6 +16,8 @@ namespace MWClass virtual void insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const; + virtual bool useAnim() const; + virtual std::string getName (const MWWorld::ConstPtr& ptr) const; ///< \return name (the one that is to be presented to the user; not the internal one); /// can return an empty string. diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 7832c1066..72696e209 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -304,6 +304,11 @@ namespace MWWorld return ""; } + bool Class::useAnim() const + { + return false; + } + void Class::getModelsToPreload(const Ptr &ptr, std::vector &models) const { std::string model = getModel(ptr); diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 0b6c5e038..3b1ddb647 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -271,6 +271,9 @@ namespace MWWorld virtual std::string getModel(const MWWorld::ConstPtr &ptr) const; + virtual bool useAnim() const; + ///< Whether or not to use animated variant of model (default false) + virtual void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector& models) const; ///< Get a list of models to preload that this object may use (directly or indirectly). default implementation: list getModel(). diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 0e8a1fecb..8c3fc771d 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -53,15 +53,23 @@ namespace void addObject(const MWWorld::Ptr& ptr, MWPhysics::PhysicsSystem& physics, MWRender::RenderingManager& rendering) { - std::string model = Misc::ResourceHelpers::correctActorModelPath(ptr.getClass().getModel(ptr), rendering.getResourceSystem()->getVFS()); + bool useAnim = ptr.getClass().useAnim(); + std::string model = ptr.getClass().getModel(ptr); + if (useAnim) + model = Misc::ResourceHelpers::correctActorModelPath(model, rendering.getResourceSystem()->getVFS()); + std::string id = ptr.getCellRef().getRefId(); if (id == "prisonmarker" || id == "divinemarker" || id == "templemarker" || id == "northmarker") model = ""; // marker objects that have a hardcoded function in the game logic, should be hidden from the player + ptr.getClass().insertObjectRendering(ptr, model, rendering); setNodeRotation(ptr, rendering, false); ptr.getClass().insertObject (ptr, model, physics); + if (useAnim) + MWBase::Environment::get().getMechanicsManager()->add(ptr); + if (ptr.getClass().isActor()) rendering.addWaterRippleEmitter(ptr); } From 7e02bb7348569ef30f0ea5514dfe1cff3932c760 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 20 Feb 2017 19:58:00 +0100 Subject: [PATCH 2/7] Preload summoned creature models before the spell is cast --- apps/openmw/mwmechanics/spellcasting.cpp | 36 ++++++++++++++++++++++++ apps/openmw/mwmechanics/spellcasting.hpp | 2 ++ apps/openmw/mwmechanics/summoning.cpp | 32 ++------------------- apps/openmw/mwworld/scene.cpp | 10 +++++-- apps/openmw/mwworld/scene.hpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 20 ++++++++++--- 6 files changed, 64 insertions(+), 38 deletions(-) diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 230d01e78..ffb31d70d 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -1175,4 +1175,40 @@ namespace MWMechanics return true; } + std::string getSummonedCreature(int effectId) + { + static std::map summonMap; + if (summonMap.empty()) + { + summonMap[ESM::MagicEffect::SummonAncestralGhost] = "sMagicAncestralGhostID"; + summonMap[ESM::MagicEffect::SummonBonelord] = "sMagicBonelordID"; + summonMap[ESM::MagicEffect::SummonBonewalker] = "sMagicLeastBonewalkerID"; + summonMap[ESM::MagicEffect::SummonCenturionSphere] = "sMagicCenturionSphereID"; + summonMap[ESM::MagicEffect::SummonClannfear] = "sMagicClannfearID"; + summonMap[ESM::MagicEffect::SummonDaedroth] = "sMagicDaedrothID"; + summonMap[ESM::MagicEffect::SummonDremora] = "sMagicDremoraID"; + summonMap[ESM::MagicEffect::SummonFabricant] = "sMagicFabricantID"; + summonMap[ESM::MagicEffect::SummonFlameAtronach] = "sMagicFlameAtronachID"; + summonMap[ESM::MagicEffect::SummonFrostAtronach] = "sMagicFrostAtronachID"; + summonMap[ESM::MagicEffect::SummonGoldenSaint] = "sMagicGoldenSaintID"; + summonMap[ESM::MagicEffect::SummonGreaterBonewalker] = "sMagicGreaterBonewalkerID"; + summonMap[ESM::MagicEffect::SummonHunger] = "sMagicHungerID"; + summonMap[ESM::MagicEffect::SummonScamp] = "sMagicScampID"; + summonMap[ESM::MagicEffect::SummonSkeletalMinion] = "sMagicSkeletalMinionID"; + summonMap[ESM::MagicEffect::SummonStormAtronach] = "sMagicStormAtronachID"; + summonMap[ESM::MagicEffect::SummonWingedTwilight] = "sMagicWingedTwilightID"; + summonMap[ESM::MagicEffect::SummonWolf] = "sMagicCreature01ID"; + summonMap[ESM::MagicEffect::SummonBear] = "sMagicCreature02ID"; + summonMap[ESM::MagicEffect::SummonBonewolf] = "sMagicCreature03ID"; + summonMap[ESM::MagicEffect::SummonCreature04] = "sMagicCreature04ID"; + summonMap[ESM::MagicEffect::SummonCreature05] = "sMagicCreature05ID"; + } + + std::map::const_iterator it = summonMap.find(effectId); + if (it == summonMap.end()) + return std::string(); + else + return MWBase::Environment::get().getWorld()->getStore().get().find(it->second)->getString(); + } + } diff --git a/apps/openmw/mwmechanics/spellcasting.hpp b/apps/openmw/mwmechanics/spellcasting.hpp index 91bb6821a..8e48681b6 100644 --- a/apps/openmw/mwmechanics/spellcasting.hpp +++ b/apps/openmw/mwmechanics/spellcasting.hpp @@ -67,6 +67,8 @@ namespace MWMechanics /// @return Was the effect a tickable effect with a magnitude? bool effectTick(CreatureStats& creatureStats, const MWWorld::Ptr& actor, const MWMechanics::EffectKey& effectKey, float magnitude); + std::string getSummonedCreature(int effectId); + class CastSpell { private: diff --git a/apps/openmw/mwmechanics/summoning.cpp b/apps/openmw/mwmechanics/summoning.cpp index 3ff8cf667..e4a825efc 100644 --- a/apps/openmw/mwmechanics/summoning.cpp +++ b/apps/openmw/mwmechanics/summoning.cpp @@ -40,32 +40,7 @@ namespace MWMechanics void UpdateSummonedCreatures::process() { - static std::map summonMap; - if (summonMap.empty()) - { - summonMap[ESM::MagicEffect::SummonAncestralGhost] = "sMagicAncestralGhostID"; - summonMap[ESM::MagicEffect::SummonBonelord] = "sMagicBonelordID"; - summonMap[ESM::MagicEffect::SummonBonewalker] = "sMagicLeastBonewalkerID"; - summonMap[ESM::MagicEffect::SummonCenturionSphere] = "sMagicCenturionSphereID"; - summonMap[ESM::MagicEffect::SummonClannfear] = "sMagicClannfearID"; - summonMap[ESM::MagicEffect::SummonDaedroth] = "sMagicDaedrothID"; - summonMap[ESM::MagicEffect::SummonDremora] = "sMagicDremoraID"; - summonMap[ESM::MagicEffect::SummonFabricant] = "sMagicFabricantID"; - summonMap[ESM::MagicEffect::SummonFlameAtronach] = "sMagicFlameAtronachID"; - summonMap[ESM::MagicEffect::SummonFrostAtronach] = "sMagicFrostAtronachID"; - summonMap[ESM::MagicEffect::SummonGoldenSaint] = "sMagicGoldenSaintID"; - summonMap[ESM::MagicEffect::SummonGreaterBonewalker] = "sMagicGreaterBonewalkerID"; - summonMap[ESM::MagicEffect::SummonHunger] = "sMagicHungerID"; - summonMap[ESM::MagicEffect::SummonScamp] = "sMagicScampID"; - summonMap[ESM::MagicEffect::SummonSkeletalMinion] = "sMagicSkeletalMinionID"; - summonMap[ESM::MagicEffect::SummonStormAtronach] = "sMagicStormAtronachID"; - summonMap[ESM::MagicEffect::SummonWingedTwilight] = "sMagicWingedTwilightID"; - summonMap[ESM::MagicEffect::SummonWolf] = "sMagicCreature01ID"; - summonMap[ESM::MagicEffect::SummonBear] = "sMagicCreature02ID"; - summonMap[ESM::MagicEffect::SummonBonewolf] = "sMagicCreature03ID"; - summonMap[ESM::MagicEffect::SummonCreature04] = "sMagicCreature04ID"; - summonMap[ESM::MagicEffect::SummonCreature05] = "sMagicCreature05ID"; - } + MWMechanics::CreatureStats& creatureStats = mActor.getClass().getCreatureStats(mActor); @@ -89,10 +64,7 @@ namespace MWMechanics bool found = creatureMap.find(std::make_pair(it->first, it->second)) != creatureMap.end(); if (!found) { - const std::string& creatureGmst = summonMap[it->first]; - std::string creatureID = - MWBase::Environment::get().getWorld()->getStore().get().find(creatureGmst)->getString(); - + std::string creatureID = getSummonedCreature(it->first); if (!creatureID.empty()) { int creatureActorId = -1; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 8c3fc771d..ea8b7c539 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -684,10 +684,14 @@ namespace MWWorld Resource::SceneManager* mSceneManager; }; - void Scene::preload(const std::string &mesh) + void Scene::preload(const std::string &mesh, bool useAnim) { - if (!mRendering.getResourceSystem()->getSceneManager()->checkLoaded(mesh, mRendering.getReferenceTime())) - mRendering.getWorkQueue()->addWorkItem(new PreloadMeshItem(mesh, mRendering.getResourceSystem()->getSceneManager())); + std::string mesh_ = mesh; + if (useAnim) + mesh_ = Misc::ResourceHelpers::correctActorModelPath(mesh_, mRendering.getResourceSystem()->getVFS()); + + if (!mRendering.getResourceSystem()->getSceneManager()->checkLoaded(mesh_, mRendering.getReferenceTime())) + mRendering.getWorkQueue()->addWorkItem(new PreloadMeshItem(mesh_, mRendering.getResourceSystem()->getSceneManager())); } void Scene::preloadCells(float dt) diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index cbceb14f5..5f17f8d59 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -133,7 +133,7 @@ namespace MWWorld Ptr searchPtrViaActorId (int actorId); - void preload(const std::string& mesh); + void preload(const std::string& mesh, bool useAnim=false); }; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 83b2b4d54..91e10dca1 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -3398,10 +3398,16 @@ namespace MWWorld { if (obj.empty()) return; - MWWorld::ManualRef ref(store, obj); - std::string model = ref.getPtr().getClass().getModel(ref.getPtr()); - if (!model.empty()) - scene->preload(model); + try + { + MWWorld::ManualRef ref(store, obj); + std::string model = ref.getPtr().getClass().getModel(ref.getPtr()); + if (!model.empty()) + scene->preload(model, ref.getPtr().getClass().useAnim()); + } + catch(std::exception& e) + { + } } void World::preloadEffects(const ESM::EffectList *effectList) @@ -3410,6 +3416,12 @@ namespace MWWorld { const ESM::MagicEffect *effect = mStore.get().find(it->mEffectID); + if (MWMechanics::isSummoningEffect(it->mEffectID)) + { + preload(mWorldScene, mStore, "VFX_Summon_Start"); + preload(mWorldScene, mStore, MWMechanics::getSummonedCreature(it->mEffectID)); + } + preload(mWorldScene, mStore, effect->mCasting); preload(mWorldScene, mStore, effect->mHit); From 05ad0dca343c7cf6bf2f305542d3ad6e99d63e92 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 20 Feb 2017 20:26:45 +0100 Subject: [PATCH 3/7] Use ActionTeleport in COE/COC commands --- apps/openmw/mwscript/cellextensions.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index 43e8318b2..2cb76ef88 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -15,6 +15,7 @@ #include "../mwbase/world.hpp" #include "../mwworld/player.hpp" #include "../mwworld/cellstore.hpp" +#include "../mwworld/actionteleport.hpp" #include "../mwmechanics/actorutil.hpp" @@ -46,10 +47,9 @@ namespace MWScript ESM::Position pos; MWBase::World *world = MWBase::Environment::get().getWorld(); - world->getPlayer().setTeleported(true); if (world->findExteriorPosition(cell, pos)) { - world->changeToExteriorCell(pos, true); + MWWorld::ActionTeleport("", pos, false).execute(world->getPlayerPtr()); world->fixPosition(world->getPlayerPtr()); } else @@ -57,7 +57,7 @@ namespace MWScript // Change to interior even if findInteriorPosition() // yields false. In this case position will be zero-point. world->findInteriorPosition(cell, pos); - world->changeToInteriorCell(cell, pos, true); + MWWorld::ActionTeleport(cell, pos, false).execute(world->getPlayerPtr()); } } }; @@ -76,13 +76,13 @@ namespace MWScript ESM::Position pos; MWBase::World *world = MWBase::Environment::get().getWorld(); - world->getPlayer().setTeleported(true); + world->indexToPosition (x, y, pos.pos[0], pos.pos[1], true); pos.pos[2] = 0; pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; - world->changeToExteriorCell (pos, true); + MWWorld::ActionTeleport("", pos, false).execute(world->getPlayerPtr()); world->fixPosition(world->getPlayerPtr()); } }; From 9728a6967ea8e5dcd9e4edfb8fe3faddc2b66fb4 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 20 Feb 2017 20:27:05 +0100 Subject: [PATCH 4/7] Reset fall height when teleporting (Fixes #2629) --- apps/openmw/mwworld/actionteleport.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwworld/actionteleport.cpp b/apps/openmw/mwworld/actionteleport.cpp index 5162cac66..93705f005 100644 --- a/apps/openmw/mwworld/actionteleport.cpp +++ b/apps/openmw/mwworld/actionteleport.cpp @@ -4,6 +4,8 @@ #include "../mwbase/world.hpp" #include "../mwbase/mechanicsmanager.hpp" +#include "../mwmechanics/creaturestats.hpp" + #include "../mwworld/class.hpp" #include "player.hpp" @@ -34,6 +36,7 @@ namespace MWWorld void ActionTeleport::teleport(const Ptr &actor) { MWBase::World* world = MWBase::Environment::get().getWorld(); + actor.getClass().getCreatureStats(actor).land(); if(actor == world->getPlayerPtr()) { world->getPlayer().setTeleported(true); From 3f27c8cc97ff21d3363a5b283902286e129e4cce Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 20 Feb 2017 21:09:15 +0100 Subject: [PATCH 5/7] Always print context for script warnings to remove the need for verbose option (Fixes #2813) --- apps/openmw/engine.cpp | 11 ++--------- apps/openmw/engine.hpp | 4 ---- apps/openmw/main.cpp | 4 ---- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 4 +++- apps/openmw/mwdialogue/dialoguemanagerimp.hpp | 2 +- apps/openmw/mwscript/scriptmanagerimp.cpp | 16 +++++----------- apps/openmw/mwscript/scriptmanagerimp.hpp | 3 +-- components/compiler/streamerrorhandler.cpp | 8 ++++++++ components/compiler/streamerrorhandler.hpp | 4 ++++ 9 files changed, 24 insertions(+), 32 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 8723483f7..d54eed3a6 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -194,7 +194,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) : mWindow(NULL) , mEncoding(ToUTF8::WINDOWS_1252) , mEncoder(NULL) - , mVerboseScripts (false) , mSkipMenu (false) , mUseSound (true) , mCompileAll (false) @@ -284,11 +283,6 @@ void OMW::Engine::addContentFile(const std::string& file) mContentFiles.push_back(file); } -void OMW::Engine::setScriptsVerbosity(bool scriptsVerbosity) -{ - mVerboseScripts = scriptsVerbosity; -} - void OMW::Engine::setSkipMenu (bool skipMenu, bool newGame) { mSkipMenu = skipMenu; @@ -534,8 +528,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full); mScriptContext->setExtensions (&mExtensions); - mEnvironment.setScriptManager (new MWScript::ScriptManager (mEnvironment.getWorld()->getStore(), - mVerboseScripts, *mScriptContext, mWarningsMode, + mEnvironment.setScriptManager (new MWScript::ScriptManager (mEnvironment.getWorld()->getStore(), *mScriptContext, mWarningsMode, mScriptBlacklistUse ? mScriptBlacklist : std::vector())); // Create game mechanics system @@ -544,7 +537,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) // Create dialog system mEnvironment.setJournal (new MWDialogue::Journal); - mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mVerboseScripts, mTranslationDataStorage)); + mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mTranslationDataStorage)); // scripts if (mCompileAll) diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 11b6ec0a6..d06ca594d 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -84,7 +84,6 @@ namespace OMW osg::ref_ptr mScreenCaptureHandler; std::string mCellName; std::vector mContentFiles; - bool mVerboseScripts; bool mSkipMenu; bool mUseSound; bool mCompileAll; @@ -158,9 +157,6 @@ namespace OMW */ void addContentFile(const std::string& file); - /// Enable or disable verbose script output - void setScriptsVerbosity(bool scriptsVerbosity); - /// Disable or enable all sounds void setSoundUsage(bool soundUsage); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 43901d579..adc12bdfc 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -98,9 +98,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("no-sound", bpo::value()->implicit_value(true) ->default_value(false), "disable all sounds") - ("script-verbose", bpo::value()->implicit_value(true) - ->default_value(false), "verbose script output") - ("script-all", bpo::value()->implicit_value(true) ->default_value(false), "compile all scripts (excluding dialogue scripts) at startup") @@ -238,7 +235,6 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat // scripts engine.setCompileAll(variables["script-all"].as()); engine.setCompileAllDialogue(variables["script-all-dialogue"].as()); - engine.setScriptsVerbosity(variables["script-verbose"].as()); engine.setScriptConsoleMode (variables["script-console"].as()); engine.setStartupScript (variables["script-run"].as().toStdString()); engine.setWarningsMode (variables["script-warn"].as()); diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 830c2bcac..29bbc80f8 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -48,7 +48,7 @@ namespace MWDialogue { - DialogueManager::DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose, Translation::Storage& translationDataStorage) : + DialogueManager::DialogueManager (const Compiler::Extensions& extensions, Translation::Storage& translationDataStorage) : mTranslationDataStorage(translationDataStorage) , mCompilerContext (MWScript::CompilerContext::Type_Dialogue) , mErrorStream(std::cout.rdbuf()) @@ -198,6 +198,8 @@ namespace MWDialogue { mErrorHandler.reset(); + mErrorHandler.setContext("[dialogue script]"); + std::istringstream input (cmd + "\n"); Compiler::Scanner scanner (mErrorHandler, input, mCompilerContext.getExtensions()); diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index 086b5ef2f..bbe42975c 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -58,7 +58,7 @@ namespace MWDialogue public: - DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose, Translation::Storage& translationDataStorage); + DialogueManager (const Compiler::Extensions& extensions, Translation::Storage& translationDataStorage); virtual void clear(); diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index b73c9a642..97ea19a63 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -21,10 +21,10 @@ namespace MWScript { - ScriptManager::ScriptManager (const MWWorld::ESMStore& store, bool verbose, + ScriptManager::ScriptManager (const MWWorld::ESMStore& store, Compiler::Context& compilerContext, int warningsMode, const std::vector& scriptBlacklist) - : mErrorHandler (std::cerr), mStore (store), mVerbose (verbose), + : mErrorHandler (std::cerr), mStore (store), mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext), mOpcodesInstalled (false), mGlobalScripts (store) { @@ -44,8 +44,7 @@ namespace MWScript if (const ESM::Script *script = mStore.get().find (name)) { - if (mVerbose) - std::cout << "compiling script: " << name << std::endl; + mErrorHandler.setContext(name); bool Success = true; try @@ -74,8 +73,6 @@ namespace MWScript { std::cerr << "compiling failed: " << name << std::endl; - if (mVerbose) - std::cerr << script->mScriptText << std::endl << std::endl; } if (Success) @@ -172,13 +169,10 @@ namespace MWScript if (const ESM::Script *script = mStore.get().search (name2)) { - if (mVerbose) - std::cout - << "scanning script for local variable declarations: " << name2 - << std::endl; - Compiler::Locals locals; + mErrorHandler.setContext(name2 + "[local variables]"); + std::istringstream stream (script->mScriptText); Compiler::QuickFileParser parser (mErrorHandler, mCompilerContext, locals); Compiler::Scanner scanner (mErrorHandler, stream, mCompilerContext.getExtensions()); diff --git a/apps/openmw/mwscript/scriptmanagerimp.hpp b/apps/openmw/mwscript/scriptmanagerimp.hpp index e4a123b86..c22a5da81 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.hpp +++ b/apps/openmw/mwscript/scriptmanagerimp.hpp @@ -36,7 +36,6 @@ namespace MWScript { Compiler::StreamErrorHandler mErrorHandler; const MWWorld::ESMStore& mStore; - bool mVerbose; Compiler::Context& mCompilerContext; Compiler::FileParser mParser; Interpreter::Interpreter mInterpreter; @@ -52,7 +51,7 @@ namespace MWScript public: - ScriptManager (const MWWorld::ESMStore& store, bool verbose, + ScriptManager (const MWWorld::ESMStore& store, Compiler::Context& compilerContext, int warningsMode, const std::vector& scriptBlacklist); diff --git a/components/compiler/streamerrorhandler.cpp b/components/compiler/streamerrorhandler.cpp index 9ca8aa74b..04bee8adb 100644 --- a/components/compiler/streamerrorhandler.cpp +++ b/components/compiler/streamerrorhandler.cpp @@ -14,6 +14,9 @@ namespace Compiler else mStream << "warning "; + if (!mContext.empty()) + mStream << mContext << " "; + mStream << "line " << loc.mLine+1 << ", column " << loc.mColumn+1 << " (" << loc.mLiteral << ")" << std::endl @@ -34,5 +37,10 @@ namespace Compiler << " " << message << std::endl; } + void StreamErrorHandler::setContext(const std::string &context) + { + mContext = context; + } + StreamErrorHandler::StreamErrorHandler (std::ostream& ErrorStream) : mStream (ErrorStream) {} } diff --git a/components/compiler/streamerrorhandler.hpp b/components/compiler/streamerrorhandler.hpp index 85de1833a..d287833ee 100644 --- a/components/compiler/streamerrorhandler.hpp +++ b/components/compiler/streamerrorhandler.hpp @@ -13,6 +13,8 @@ namespace Compiler { std::ostream& mStream; + std::string mContext; + // not implemented StreamErrorHandler (const StreamErrorHandler&); @@ -26,6 +28,8 @@ namespace Compiler public: + void setContext(const std::string& context); + // constructors StreamErrorHandler (std::ostream& ErrorStream); From 4aa40d16bcd32349cf629d718438447a3e026a41 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 20 Feb 2017 21:38:14 +0100 Subject: [PATCH 6/7] Increase the importance of light radius when sorting lights (Bug #2759) --- components/sceneutil/lightmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/sceneutil/lightmanager.cpp b/components/sceneutil/lightmanager.cpp index ee640d6cc..bd8ef8af4 100644 --- a/components/sceneutil/lightmanager.cpp +++ b/components/sceneutil/lightmanager.cpp @@ -374,7 +374,7 @@ namespace SceneUtil bool sortLights (const LightManager::LightSourceViewBound* left, const LightManager::LightSourceViewBound* right) { - return left->mViewBound.center().length2() - left->mViewBound.radius2()/4.f < right->mViewBound.center().length2() - right->mViewBound.radius2()/4.f; + return left->mViewBound.center().length2() - left->mViewBound.radius2()*81 < right->mViewBound.center().length2() - right->mViewBound.radius2()*81; } void LightListCallback::operator()(osg::Node *node, osg::NodeVisitor *nv) From b9740fd2a12807b49a01a8bd4190792b60f911a9 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 21 Feb 2017 04:47:11 +0100 Subject: [PATCH 7/7] Fix btHeightFieldTerrainShape triangle layout to match rendering --- apps/openmw/mwphysics/physicssystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index de8774cfd..ebf51a66e 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -531,7 +531,7 @@ namespace MWPhysics mShape = new btHeightfieldTerrainShape( sqrtVerts, sqrtVerts, heights, 1, minh, maxh, 2, - PHY_FLOAT, true + PHY_FLOAT, false ); mShape->setUseDiamondSubdivision(true); mShape->setLocalScaling(btVector3(triSize, triSize, 1));