From 1fb136a41712d5be77f862193e333cc5d1d7aacc Mon Sep 17 00:00:00 2001 From: uramer Date: Fri, 13 May 2022 18:45:03 +0200 Subject: [PATCH 1/3] Correct icon and mesh paths in Lua records --- apps/openmw/mwbase/windowmanager.hpp | 1 + apps/openmw/mwgui/windowmanagerimp.cpp | 5 +++++ apps/openmw/mwgui/windowmanagerimp.hpp | 1 + apps/openmw/mwlua/types/creature.cpp | 6 +++++- apps/openmw/mwlua/types/door.cpp | 6 +++++- apps/openmw/mwlua/types/weapon.cpp | 11 +++++++++-- components/misc/resourcehelpers.cpp | 5 +++++ components/misc/resourcehelpers.hpp | 1 + 8 files changed, 32 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index c1c99436cb..470eaf3d26 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -341,6 +341,7 @@ namespace MWBase virtual std::string correctIconPath(const std::string& path) = 0; virtual std::string correctBookartPath(const std::string& path, int width, int height, bool* exists = nullptr) = 0; virtual std::string correctTexturePath(const std::string& path) = 0; + virtual std::string correctMeshPath(const std::string& path) = 0; virtual bool textureExists(const std::string& path) = 0; virtual void addCell(MWWorld::CellStore* cell) = 0; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 1d964f09ec..872ac1980c 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -2140,6 +2140,11 @@ namespace MWGui return Misc::ResourceHelpers::correctTexturePath(path, mResourceSystem->getVFS()); } + std::string WindowManager::correctMeshPath(const std::string& path) + { + return Misc::ResourceHelpers::correctMeshPath(path, mResourceSystem->getVFS()); + } + bool WindowManager::textureExists(const std::string &path) { std::string corrected = Misc::ResourceHelpers::correctTexturePath(path, mResourceSystem->getVFS()); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 58400ec76b..483c7e5c32 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -381,6 +381,7 @@ namespace MWGui std::string correctIconPath(const std::string& path) override; std::string correctBookartPath(const std::string& path, int width, int height, bool* exists = nullptr) override; std::string correctTexturePath(const std::string& path) override; + std::string correctMeshPath(const std::string& path) override; bool textureExists(const std::string& path) override; void addCell(MWWorld::CellStore* cell) override; diff --git a/apps/openmw/mwlua/types/creature.cpp b/apps/openmw/mwlua/types/creature.cpp index 87be291493..2358c3f41d 100644 --- a/apps/openmw/mwlua/types/creature.cpp +++ b/apps/openmw/mwlua/types/creature.cpp @@ -3,6 +3,7 @@ #include #include +#include #include "../stats.hpp" #include "../luabindings.hpp" @@ -24,7 +25,10 @@ namespace MWLua sol::usertype record = context.mLua->sol().new_usertype("ESM3_Creature"); record[sol::meta_function::to_string] = [](const ESM::Creature& rec) { return "ESM3_Creature[" + rec.mId + "]"; }; record["name"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mName; }); - record["model"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mModel; }); + record["model"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string + { + return MWBase::Environment::get().getWindowManager()->correctMeshPath(rec.mModel); + }); record["mwscript"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mScript; }); record["baseCreature"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mOriginal; }); } diff --git a/apps/openmw/mwlua/types/door.cpp b/apps/openmw/mwlua/types/door.cpp index 3b5e9a29cc..a6d2a7bc0d 100644 --- a/apps/openmw/mwlua/types/door.cpp +++ b/apps/openmw/mwlua/types/door.cpp @@ -3,6 +3,7 @@ #include #include +#include #include "../luabindings.hpp" @@ -48,7 +49,10 @@ namespace MWLua record[sol::meta_function::to_string] = [](const ESM::Door& rec) -> std::string { return "ESM3_Door[" + rec.mId + "]"; }; record["id"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mId; }); record["name"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mName; }); - record["model"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mModel; }); + record["model"] = sol::readonly_property([](const ESM::Door& rec) -> std::string + { + return MWBase::Environment::get().getWindowManager()->correctMeshPath(rec.mModel); + }); record["mwscript"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mScript; }); record["openSound"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mOpenSound; }); record["closeSound"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mCloseSound; }); diff --git a/apps/openmw/mwlua/types/weapon.cpp b/apps/openmw/mwlua/types/weapon.cpp index 594e447f00..beca109216 100644 --- a/apps/openmw/mwlua/types/weapon.cpp +++ b/apps/openmw/mwlua/types/weapon.cpp @@ -3,6 +3,7 @@ #include #include +#include #include "../luabindings.hpp" @@ -41,8 +42,14 @@ namespace MWLua record[sol::meta_function::to_string] = [](const ESM::Weapon& rec) -> std::string { return "ESM3_Weapon[" + rec.mId + "]"; }; record["id"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mId; }); record["name"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mName; }); - record["model"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mModel; }); - record["icon"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mIcon; }); + record["model"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string + { + return MWBase::Environment::get().getWindowManager()->correctMeshPath(rec.mModel); + }); + record["icon"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string + { + return MWBase::Environment::get().getWindowManager()->correctIconPath(rec.mIcon); + }); record["enchant"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mEnchant; }); record["mwscript"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mScript; }); record["isMagical"] = sol::readonly_property( diff --git a/components/misc/resourcehelpers.cpp b/components/misc/resourcehelpers.cpp index 0095568653..73a1d961e7 100644 --- a/components/misc/resourcehelpers.cpp +++ b/components/misc/resourcehelpers.cpp @@ -145,6 +145,11 @@ std::string Misc::ResourceHelpers::correctActorModelPath(const std::string &resP return mdlname; } +std::string Misc::ResourceHelpers::correctMeshPath(const std::string &resPath, const VFS::Manager* vfs) +{ + return "meshes\\" + resPath; +} + std::string Misc::ResourceHelpers::correctSoundPath(const std::string& resPath, const VFS::Manager* vfs) { std::string sound = resPath; diff --git a/components/misc/resourcehelpers.hpp b/components/misc/resourcehelpers.hpp index 4ea5f5e121..0be1076d7d 100644 --- a/components/misc/resourcehelpers.hpp +++ b/components/misc/resourcehelpers.hpp @@ -24,6 +24,7 @@ namespace Misc std::string correctBookartPath(const std::string &resPath, int width, int height, const VFS::Manager* vfs); /// Use "xfoo.nif" instead of "foo.nif" if available std::string correctActorModelPath(const std::string &resPath, const VFS::Manager* vfs); + std::string correctMeshPath(const std::string &resPath, const VFS::Manager* vfs); std::string correctSoundPath(const std::string& resPath, const VFS::Manager* vfs); From fd7965d77fea28146c1546df413b26d7c7bc96c2 Mon Sep 17 00:00:00 2001 From: uramer Date: Fri, 13 May 2022 19:28:53 +0200 Subject: [PATCH 2/3] Use correctMeshPath instead of string constants --- apps/navmeshtool/worldspacedata.cpp | 2 +- apps/openmw/mwclass/activator.cpp | 5 +++-- apps/openmw/mwclass/apparatus.cpp | 2 +- apps/openmw/mwclass/armor.cpp | 2 +- apps/openmw/mwclass/bodypart.cpp | 5 ++++- apps/openmw/mwclass/book.cpp | 2 +- apps/openmw/mwclass/clothing.cpp | 2 +- apps/openmw/mwclass/container.cpp | 2 +- apps/openmw/mwclass/creature.cpp | 5 +++-- apps/openmw/mwclass/door.cpp | 2 +- apps/openmw/mwclass/ingredient.cpp | 2 +- apps/openmw/mwclass/light.cpp | 2 +- apps/openmw/mwclass/lockpick.cpp | 2 +- apps/openmw/mwclass/misc.cpp | 2 +- apps/openmw/mwclass/npc.cpp | 10 +++++----- apps/openmw/mwclass/potion.cpp | 2 +- apps/openmw/mwclass/probe.cpp | 2 +- apps/openmw/mwclass/repair.cpp | 2 +- apps/openmw/mwclass/static.cpp | 5 ++++- apps/openmw/mwclass/weapon.cpp | 2 +- apps/openmw/mwmechanics/activespells.cpp | 5 ++++- apps/openmw/mwmechanics/actors.cpp | 7 +++++-- apps/openmw/mwmechanics/character.cpp | 8 ++++++-- apps/openmw/mwmechanics/spellcasting.cpp | 18 +++++++++++++----- apps/openmw/mwmechanics/spelleffects.cpp | 6 ++++-- apps/openmw/mwmechanics/summoning.cpp | 3 ++- apps/openmw/mwrender/actoranimation.cpp | 3 ++- apps/openmw/mwrender/npcanimation.cpp | 19 +++++++++++-------- apps/openmw/mwrender/objectpaging.cpp | 3 ++- apps/openmw/mwworld/groundcoverstore.cpp | 9 +++++++-- apps/openmw/mwworld/projectilemanager.cpp | 7 +++++-- apps/openmw/mwworld/worldimp.cpp | 11 ++++++++--- 32 files changed, 103 insertions(+), 56 deletions(-) diff --git a/apps/navmeshtool/worldspacedata.cpp b/apps/navmeshtool/worldspacedata.cpp index 56f9147ff3..e93b50842c 100644 --- a/apps/navmeshtool/worldspacedata.cpp +++ b/apps/navmeshtool/worldspacedata.cpp @@ -122,7 +122,7 @@ namespace NavMeshTool { try { - return bulletShapeManager.getShape("meshes/" + model); + return bulletShapeManager.getShape(Misc::ResourceHelpers::correctMeshPath(model, &vfs)); } catch (const std::exception& e) { diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index f2212e7c95..e50b3cca85 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -60,7 +60,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } @@ -145,7 +145,8 @@ namespace MWClass for (const ESM::Creature &iter : store.get()) { - if (!iter.mModel.empty() && Misc::StringUtils::ciEqual(model, "meshes\\" + iter.mModel)) + if (!iter.mModel.empty() && Misc::StringUtils::ciEqual(model, + MWBase::Environment::get().getWindowManager()->correctMeshPath(iter.mModel))) { creatureId = !iter.mOriginal.empty() ? iter.mOriginal : iter.mId; break; diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 6004868ac0..07dac3e2d7 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -38,7 +38,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 9bd7deb38f..d2b5c096cb 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -46,7 +46,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/bodypart.cpp b/apps/openmw/mwclass/bodypart.cpp index ecc59f5459..bd32784a7d 100644 --- a/apps/openmw/mwclass/bodypart.cpp +++ b/apps/openmw/mwclass/bodypart.cpp @@ -5,6 +5,9 @@ #include "../mwworld/cellstore.hpp" +#include "../mwbase/environment.hpp" +#include "../mwbase/windowmanager.hpp" + namespace MWClass { BodyPart::BodyPart() @@ -42,7 +45,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 2247d388e8..c057182187 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -43,7 +43,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index de2b1c870f..0a922b30af 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -41,7 +41,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index d4fa3e2f1c..9f9666534d 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -123,7 +123,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 667942b320..026ef268fe 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -184,7 +184,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } @@ -626,7 +626,8 @@ namespace MWClass for (const ESM::Creature &creature : store.get()) { if (creature.mId != ourId && creature.mOriginal != ourId && !creature.mModel.empty() - && Misc::StringUtils::ciEqual(model, "meshes\\" + creature.mModel)) + && Misc::StringUtils::ciEqual(model, + MWBase::Environment::get().getWindowManager()->correctMeshPath(creature.mModel))) { const std::string& fallbackId = !creature.mOriginal.empty() ? creature.mOriginal : creature.mId; sound = store.get().begin(); diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 37b45e531b..23e492bec4 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -99,7 +99,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 73f9fb4ac9..1996e1742e 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -40,7 +40,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 3ab9d3b630..3b1cb19068 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -71,7 +71,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index ef4af50c6a..ff23535145 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -40,7 +40,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 571bbda0ea..10fada6dbb 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -50,7 +50,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index b6105df4d7..76e60c7880 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -443,19 +443,19 @@ namespace MWClass models.emplace_back(Settings::Manager::getString("xbaseanim", "Models")); if (!npc->mBase->mModel.empty()) - models.push_back("meshes/"+npc->mBase->mModel); + models.push_back(MWBase::Environment::get().getWindowManager()->correctMeshPath(npc->mBase->mModel)); if (!npc->mBase->mHead.empty()) { const ESM::BodyPart* head = MWBase::Environment::get().getWorld()->getStore().get().search(npc->mBase->mHead); if (head) - models.push_back("meshes/"+head->mModel); + models.push_back(MWBase::Environment::get().getWindowManager()->correctMeshPath(head->mModel)); } if (!npc->mBase->mHair.empty()) { const ESM::BodyPart* hair = MWBase::Environment::get().getWorld()->getStore().get().search(npc->mBase->mHair); if (hair) - models.push_back("meshes/"+hair->mModel); + models.push_back(MWBase::Environment::get().getWindowManager()->correctMeshPath(hair->mModel)); } bool female = (npc->mBase->mFlags & ESM::NPC::Female); @@ -493,7 +493,7 @@ namespace MWClass partname = female ? it->mMale : it->mFemale; const ESM::BodyPart* part = MWBase::Environment::get().getWorld()->getStore().get().search(partname); if (part && !part->mModel.empty()) - models.push_back("meshes/"+part->mModel); + models.push_back(MWBase::Environment::get().getWindowManager()->correctMeshPath(part->mModel)); } } } @@ -506,7 +506,7 @@ namespace MWClass { const ESM::BodyPart* part = *it; if (part && !part->mModel.empty()) - models.push_back("meshes/"+part->mModel); + models.push_back(MWBase::Environment::get().getWindowManager()->correctMeshPath(part->mModel)); } } diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 3b55cbc679..20f4c3bcce 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -42,7 +42,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index a528068f23..ea90c1e78c 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -40,7 +40,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index e9a504f22c..6a23c43303 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -37,7 +37,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index 8b793dbc67..27b04481ad 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -11,6 +11,9 @@ #include "../mwrender/renderinginterface.hpp" #include "../mwrender/vismask.hpp" +#include "../mwbase/environment.hpp" +#include "../mwbase/windowmanager.hpp" + namespace MWClass { Static::Static() @@ -43,7 +46,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 505b2a4d1e..478e67036c 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -46,7 +46,7 @@ namespace MWClass const std::string &model = ref->mBase->mModel; if (!model.empty()) { - return "meshes\\" + model; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(model); } return ""; } diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 8dcf6ca90c..663809d109 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -17,6 +17,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" +#include "../mwbase/windowmanager.hpp" #include "../mwrender/animation.hpp" @@ -261,7 +262,9 @@ namespace MWMechanics const ESM::Static* reflectStatic = MWBase::Environment::get().getWorld()->getStore().get().find("VFX_Reflect"); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr); if(animation && !reflectStatic->mModel.empty()) - animation->addEffect("meshes\\" + reflectStatic->mModel, ESM::MagicEffect::Reflect, false, std::string()); + animation->addEffect( + MWBase::Environment::get().getWindowManager()->correctMeshPath(reflectStatic->mModel), + ESM::MagicEffect::Reflect, false, std::string()); caster.getClass().getCreatureStats(caster).getActiveSpells().addSpell(*reflected); } if(removedSpell) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index a384a2edfa..2353f3729d 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -203,7 +203,9 @@ void soulTrap(const MWWorld::Ptr& creature) const ESM::Static* fx = world->getStore().get() .search("VFX_Soul_Trap"); if (fx) - world->spawnEffect("meshes\\" + fx->mModel, "", creature.getRefData().getPosition().asVec3()); + world->spawnEffect( + MWBase::Environment::get().getWindowManager()->correctMeshPath(fx->mModel), + "", creature.getRefData().getPosition().asVec3()); MWBase::Environment::get().getSoundManager()->playSound3D(creature.getRefData().getPosition().asVec3(), "conjuration hit", 1.f, 1.f); return; //remove to get vanilla behaviour @@ -1745,7 +1747,8 @@ namespace MWMechanics const ESM::Static* fx = MWBase::Environment::get().getWorld()->getStore().get() .search("VFX_Summon_End"); if (fx) - MWBase::Environment::get().getWorld()->spawnEffect("meshes\\" + fx->mModel, + MWBase::Environment::get().getWorld()->spawnEffect( + MWBase::Environment::get().getWindowManager()->correctMeshPath(fx->mModel), "", ptr.getRefData().getPosition().asVec3()); // Remove the summoned creature's summoned creatures as well diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 471ec7b5f4..b76ebc91a7 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1433,10 +1433,14 @@ bool CharacterController::updateState(CharacterState idle) for (size_t iter = 0; iter < effects.size(); ++iter) // play hands vfx for each effect { if (mAnimation->getNode("Bip01 L Hand")) - mAnimation->addEffect("meshes\\" + castStatic->mModel, -1, false, "Bip01 L Hand", effect->mParticle); + mAnimation->addEffect( + MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), + -1, false, "Bip01 L Hand", effect->mParticle); if (mAnimation->getNode("Bip01 R Hand")) - mAnimation->addEffect("meshes\\" + castStatic->mModel, -1, false, "Bip01 R Hand", effect->mParticle); + mAnimation->addEffect( + MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), + -1, false, "Bip01 R Hand", effect->mParticle); } const ESM::ENAMstruct &firstEffect = effects.at(0); // first effect used for casting animation diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index b92cbc74fb..dcfd125519 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -476,13 +476,17 @@ namespace MWMechanics castStatic = store.get().find ("VFX_DefaultCast"); // check if the effect was already added - if (std::find(addedEffects.begin(), addedEffects.end(), "meshes\\" + castStatic->mModel) != addedEffects.end()) + if (std::find(addedEffects.begin(), addedEffects.end(), + MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel)) + != addedEffects.end()) continue; MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(mCaster); if (animation) { - animation->addEffect("meshes\\" + castStatic->mModel, effect->mIndex, false, "", effect->mParticle); + animation->addEffect( + MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), + effect->mIndex, false, "", effect->mParticle); } else { @@ -511,7 +515,9 @@ namespace MWMechanics scale *= npcScaleVec.z(); } scale = std::max(scale, 1.f); - MWBase::Environment::get().getWorld()->spawnEffect("meshes\\" + castStatic->mModel, effect->mParticle, pos, scale); + MWBase::Environment::get().getWorld()->spawnEffect( + MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), + effect->mParticle, pos, scale); } if (animation && !mCaster.getClass().isActor()) @@ -521,7 +527,7 @@ namespace MWMechanics "alteration", "conjuration", "destruction", "illusion", "mysticism", "restoration" }; - addedEffects.push_back("meshes\\" + castStatic->mModel); + addedEffects.push_back(MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel)); MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager(); if(!effect->mCastSound.empty()) @@ -559,7 +565,9 @@ namespace MWMechanics { // Don't play particle VFX unless the effect is new or it should be looping. if (playNonLooping || loop) - anim->addEffect("meshes\\" + castStatic->mModel, magicEffect.mIndex, loop, "", magicEffect.mParticle); + anim->addEffect( + MWBase::Environment::get().getWindowManager()->correctMeshPath(castStatic->mModel), + magicEffect.mIndex, loop, "", magicEffect.mParticle); } } } diff --git a/apps/openmw/mwmechanics/spelleffects.cpp b/apps/openmw/mwmechanics/spelleffects.cpp index ae18c6ae0c..e10eaa3ff9 100644 --- a/apps/openmw/mwmechanics/spelleffects.cpp +++ b/apps/openmw/mwmechanics/spelleffects.cpp @@ -272,7 +272,9 @@ namespace const ESM::Static* absorbStatic = esmStore.get().find("VFX_Absorb"); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target); if (animation && !absorbStatic->mModel.empty()) - animation->addEffect( "meshes\\" + absorbStatic->mModel, ESM::MagicEffect::SpellAbsorption, false, std::string()); + animation->addEffect( + MWBase::Environment::get().getWindowManager()->correctMeshPath(absorbStatic->mModel), + ESM::MagicEffect::SpellAbsorption, false, std::string()); const ESM::Spell* spell = esmStore.get().search(spellId); int spellCost = 0; if (spell) @@ -430,7 +432,7 @@ void applyMagicEffect(const MWWorld::Ptr& target, const MWWorld::Ptr& caster, co anim->removeEffect(effect.mEffectId); const ESM::Static* fx = world->getStore().get().search("VFX_Summon_end"); if (fx) - anim->addEffect("meshes\\" + fx->mModel, -1); + anim->addEffect(MWBase::Environment::get().getWindowManager()->correctMeshPath(fx->mModel), -1); } } else if (caster == getPlayer()) diff --git a/apps/openmw/mwmechanics/summoning.cpp b/apps/openmw/mwmechanics/summoning.cpp index c1923d4337..5fc39f416b 100644 --- a/apps/openmw/mwmechanics/summoning.cpp +++ b/apps/openmw/mwmechanics/summoning.cpp @@ -5,6 +5,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/mechanicsmanager.hpp" +#include "../mwbase/windowmanager.hpp" #include "../mwworld/esmstore.hpp" #include "../mwworld/class.hpp" @@ -85,7 +86,7 @@ namespace MWMechanics { const ESM::Static* fx = world->getStore().get().search("VFX_Summon_Start"); if (fx) - anim->addEffect("meshes\\" + fx->mModel, -1, false); + anim->addEffect(MWBase::Environment::get().getWindowManager()->correctMeshPath(fx->mModel), -1, false); } } catch (std::exception& e) diff --git a/apps/openmw/mwrender/actoranimation.cpp b/apps/openmw/mwrender/actoranimation.cpp index b3d76d423c..777a095c9e 100644 --- a/apps/openmw/mwrender/actoranimation.cpp +++ b/apps/openmw/mwrender/actoranimation.cpp @@ -24,6 +24,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" +#include "../mwbase/windowmanager.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/class.hpp" #include "../mwworld/cellstore.hpp" @@ -127,7 +128,7 @@ std::string ActorAnimation::getShieldMesh(const MWWorld::ConstPtr& shield, bool if (bodypart == nullptr || bodypart->mData.mType != ESM::BodyPart::MT_Armor) return std::string(); if (!bodypart->mModel.empty()) - return "meshes\\" + bodypart->mModel; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(bodypart->mModel); } } } diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 8a7da4c800..ba44a94cd9 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -39,6 +39,7 @@ #include "../mwbase/world.hpp" #include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/soundmanager.hpp" +#include "../mwbase/windowmanager.hpp" #include "camera.hpp" #include "rotatecontroller.hpp" @@ -80,7 +81,7 @@ std::string getVampireHead(const std::string& race, bool female) const ESM::BodyPart* bodyPart = sVampireMapping[thisCombination]; if (!bodyPart) return std::string(); - return "meshes\\" + bodyPart->mModel; + return MWBase::Environment::get().getWindowManager()->correctMeshPath(bodyPart->mModel); } } @@ -467,7 +468,7 @@ void NpcAnimation::updateNpcBase() { const ESM::BodyPart* bp = store.get().search(headName); if (bp) - mHeadModel = "meshes\\" + bp->mModel; + mHeadModel = MWBase::Environment::get().getWindowManager()->correctMeshPath(bp->mModel); else Log(Debug::Warning) << "Warning: Failed to load body part '" << headName << "'"; } @@ -476,7 +477,7 @@ void NpcAnimation::updateNpcBase() { const ESM::BodyPart* bp = store.get().search(hairName); if (bp) - mHairModel = "meshes\\" + bp->mModel; + mHairModel = MWBase::Environment::get().getWindowManager()->correctMeshPath(bp->mModel); else Log(Debug::Warning) << "Warning: Failed to load body part '" << hairName << "'"; } @@ -493,7 +494,8 @@ void NpcAnimation::updateNpcBase() std::string smodel = defaultSkeleton; if (!is1stPerson && !isWerewolf && !mNpc->mModel.empty()) - smodel = Misc::ResourceHelpers::correctActorModelPath("meshes\\" + mNpc->mModel, mResourceSystem->getVFS()); + smodel = Misc::ResourceHelpers::correctActorModelPath( + MWBase::Environment::get().getWindowManager()->correctMeshPath(mNpc->mModel), mResourceSystem->getVFS()); setObjectRoot(smodel, true, true, false); @@ -653,8 +655,8 @@ void NpcAnimation::updateParts() if(store != inv.end() && (part=*store).getType() == ESM::Light::sRecordId) { const ESM::Light *light = part.get()->mBase; - addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, - 1, "meshes\\"+light->mModel, false, nullptr, true); + addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1, + MWBase::Environment::get().getWindowManager()->correctMeshPath(light->mModel), false, nullptr, true); if (mObjectParts[ESM::PRT_Shield]) addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), light); } @@ -674,7 +676,7 @@ void NpcAnimation::updateParts() const ESM::BodyPart* bodypart = parts[part]; if(bodypart) addOrReplaceIndividualPart((ESM::PartReferenceType)part, -1, 1, - "meshes\\"+bodypart->mModel); + MWBase::Environment::get().getWindowManager()->correctMeshPath(bodypart->mModel)); } } @@ -904,7 +906,8 @@ void NpcAnimation::addPartGroup(int group, int priority, const std::vectormModel, enchantedGlow, glowColor); + addOrReplaceIndividualPart((ESM::PartReferenceType)part.mPart, group, priority, + MWBase::Environment::get().getWindowManager()->correctMeshPath(bodypart->mModel), enchantedGlow, glowColor); else reserveIndividualPart((ESM::PartReferenceType)part.mPart, group, priority); } diff --git a/apps/openmw/mwrender/objectpaging.cpp b/apps/openmw/mwrender/objectpaging.cpp index 23532f8b07..7513ecdabe 100644 --- a/apps/openmw/mwrender/objectpaging.cpp +++ b/apps/openmw/mwrender/objectpaging.cpp @@ -31,6 +31,7 @@ #include "apps/openmw/mwworld/esmstore.hpp" #include "apps/openmw/mwbase/environment.hpp" #include "apps/openmw/mwbase/world.hpp" +#include "apps/openmw/mwbase/windowmanager.hpp" #include "vismask.hpp" @@ -528,7 +529,7 @@ namespace MWRender int type = store.findStatic(ref.mRefID); std::string model = getModel(type, ref.mRefID, store); if (model.empty()) continue; - model = "meshes/" + model; + model = MWBase::Environment::get().getWindowManager()->correctMeshPath(model); if (activeGrid && type != ESM::REC_STAT) { diff --git a/apps/openmw/mwworld/groundcoverstore.cpp b/apps/openmw/mwworld/groundcoverstore.cpp index 1b27f8eed3..1c75ce19f2 100644 --- a/apps/openmw/mwworld/groundcoverstore.cpp +++ b/apps/openmw/mwworld/groundcoverstore.cpp @@ -4,6 +4,9 @@ #include #include +#include +#include + namespace MWWorld { void GroundcoverStore::init(const Store& statics, const Files::Collections& fileCollections, const std::vector& groundcoverFiles, ToUTF8::Utf8Encoder* encoder) @@ -18,13 +21,15 @@ namespace MWWorld for (const ESM::Static& stat : statics) { std::string id = Misc::StringUtils::lowerCase(stat.mId); - mMeshCache[id] = "meshes\\" + Misc::StringUtils::lowerCase(stat.mModel); + mMeshCache[id] = Misc::StringUtils::lowerCase( + MWBase::Environment::get().getWindowManager()->correctMeshPath(stat.mModel)); } for (const ESM::Static& stat : content.mStatics) { std::string id = Misc::StringUtils::lowerCase(stat.mId); - mMeshCache[id] = "meshes\\" + Misc::StringUtils::lowerCase(stat.mModel); + mMeshCache[id] = Misc::StringUtils::lowerCase( + MWBase::Environment::get().getWindowManager()->correctMeshPath(stat.mModel)); } for (const ESM::Cell& cell : content.mCells) diff --git a/apps/openmw/mwworld/projectilemanager.cpp b/apps/openmw/mwworld/projectilemanager.cpp index e931afa07b..3acef2db3f 100644 --- a/apps/openmw/mwworld/projectilemanager.cpp +++ b/apps/openmw/mwworld/projectilemanager.cpp @@ -32,6 +32,7 @@ #include "../mwbase/soundmanager.hpp" #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" +#include "../mwbase/windowmanager.hpp" #include "../mwmechanics/combat.hpp" #include "../mwmechanics/creaturestats.hpp" @@ -218,7 +219,8 @@ namespace MWWorld SceneUtil::FindByNameVisitor findVisitor(nodeName.str()); attachTo->accept(findVisitor); if (findVisitor.mFoundNode) - mResourceSystem->getSceneManager()->getInstance("meshes\\" + weapon->mModel, findVisitor.mFoundNode); + mResourceSystem->getSceneManager()->getInstance( + MWBase::Environment::get().getWindowManager()->correctMeshPath(weapon->mModel), findVisitor.mFoundNode); } if (createLight) @@ -318,7 +320,8 @@ namespace MWWorld // in case there are multiple effects, the model is a dummy without geometry. Use the second effect for physics shape if (state.mIdMagic.size() > 1) - model = "meshes\\" + MWBase::Environment::get().getWorld()->getStore().get().find(state.mIdMagic[1])->mModel; + model = MWBase::Environment::get().getWindowManager()->correctMeshPath( + MWBase::Environment::get().getWorld()->getStore().get().find(state.mIdMagic[1])->mModel); state.mProjectileId = mPhysics->addProjectile(caster, pos, model, true); state.mToDelete = false; mMagicBolts.push_back(state); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 3c0d796e9b..0c0b3d593d 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -3683,7 +3683,8 @@ namespace MWWorld if (texture.empty()) texture = Fallback::Map::getString("Blood_Texture_0"); - std::string model = "meshes\\" + Fallback::Map::getString("Blood_Model_" + std::to_string(Misc::Rng::rollDice(3))); // [0, 2] + std::string model = MWBase::Environment::get().getWindowManager()->correctMeshPath( + Fallback::Map::getString("Blood_Model_" + std::to_string(Misc::Rng::rollDice(3)))); // [0, 2] mRendering->spawnEffect(model, texture, worldPosition, 1.0f, false); } @@ -3722,11 +3723,15 @@ namespace MWWorld if (effectInfo.mArea <= 0) { if (effectInfo.mRange == ESM::RT_Target) - mRendering->spawnEffect("meshes\\" + areaStatic->mModel, texture, origin, 1.0f); + mRendering->spawnEffect( + MWBase::Environment::get().getWindowManager()->correctMeshPath(areaStatic->mModel), + texture, origin, 1.0f); continue; } else - mRendering->spawnEffect("meshes\\" + areaStatic->mModel, texture, origin, static_cast(effectInfo.mArea * 2)); + mRendering->spawnEffect( + MWBase::Environment::get().getWindowManager()->correctMeshPath(areaStatic->mModel), + texture, origin, static_cast(effectInfo.mArea * 2)); // Play explosion sound (make sure to use NoTrack, since we will delete the projectile now) static const std::string schools[] = { From bf905fce4cbcb2454b538c99adaa114d9397ef6b Mon Sep 17 00:00:00 2001 From: uramer Date: Sun, 12 Jun 2022 13:07:50 +0200 Subject: [PATCH 3/3] Don't use WindowManager outside of UI, correct paths for new record types --- apps/openmw/mwbase/windowmanager.hpp | 1 - apps/openmw/mwgui/formatting.cpp | 17 +++++++++-------- apps/openmw/mwgui/windowmanagerimp.cpp | 8 -------- apps/openmw/mwgui/windowmanagerimp.hpp | 1 - apps/openmw/mwlua/types/activator.cpp | 9 ++++++++- apps/openmw/mwlua/types/apparatus.cpp | 14 ++++++++++++-- apps/openmw/mwlua/types/book.cpp | 14 ++++++++++++-- apps/openmw/mwlua/types/container.cpp | 9 ++++++++- apps/openmw/mwlua/types/creature.cpp | 9 ++++++--- apps/openmw/mwlua/types/door.cpp | 9 ++++++--- apps/openmw/mwlua/types/lockpick.cpp | 14 ++++++++++++-- apps/openmw/mwlua/types/misc.cpp | 14 ++++++++++++-- apps/openmw/mwlua/types/potion.cpp | 13 +++++++++++-- apps/openmw/mwlua/types/probe.cpp | 14 ++++++++++++-- apps/openmw/mwlua/types/repair.cpp | 14 ++++++++++++-- apps/openmw/mwlua/types/weapon.cpp | 15 +++++++++------ 16 files changed, 129 insertions(+), 46 deletions(-) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 470eaf3d26..2d7c2299a6 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -339,7 +339,6 @@ namespace MWBase // In WindowManager for now since there isn't a VFS singleton virtual std::string correctIconPath(const std::string& path) = 0; - virtual std::string correctBookartPath(const std::string& path, int width, int height, bool* exists = nullptr) = 0; virtual std::string correctTexturePath(const std::string& path) = 0; virtual std::string correctMeshPath(const std::string& path) = 0; virtual bool textureExists(const std::string& path) = 0; diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index f416fbe07c..c9a9da6066 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -5,14 +5,15 @@ #include #include -// correctBookartPath -#include "../mwbase/environment.hpp" -#include "../mwbase/windowmanager.hpp" - #include #include +#include +#include #include +#include +#include "../mwbase/environment.hpp" +#include "../mwbase/windowmanager.hpp" #include "../mwscript/interpretercontext.hpp" namespace MWGui::Formatting @@ -285,8 +286,9 @@ namespace MWGui::Formatting int width = MyGUI::utility::parseInt(attr.at("width")); int height = MyGUI::utility::parseInt(attr.at("height")); - bool exists; - std::string correctedSrc = MWBase::Environment::get().getWindowManager()->correctBookartPath(src, width, height, &exists); + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + std::string correctedSrc = Misc::ResourceHelpers::correctBookartPath(src, width, height, vfs); + bool exists = vfs->exists(correctedSrc); if (!exists) { @@ -296,8 +298,7 @@ namespace MWGui::Formatting pag.setIgnoreLeadingEmptyLines(false); - ImageElement elem(paper, pag, mBlockStyle, - correctedSrc, width, height); + ImageElement elem(paper, pag, mBlockStyle, correctedSrc, width, height); elem.paginate(); break; } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 872ac1980c..f768b784eb 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -2127,14 +2127,6 @@ namespace MWGui return Misc::ResourceHelpers::correctIconPath(path, mResourceSystem->getVFS()); } - std::string WindowManager::correctBookartPath(const std::string& path, int width, int height, bool* exists) - { - std::string corrected = Misc::ResourceHelpers::correctBookartPath(path, width, height, mResourceSystem->getVFS()); - if (exists) - *exists = mResourceSystem->getVFS()->exists(corrected); - return corrected; - } - std::string WindowManager::correctTexturePath(const std::string& path) { return Misc::ResourceHelpers::correctTexturePath(path, mResourceSystem->getVFS()); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 483c7e5c32..dc17e31a77 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -379,7 +379,6 @@ namespace MWGui // In WindowManager for now since there isn't a VFS singleton std::string correctIconPath(const std::string& path) override; - std::string correctBookartPath(const std::string& path, int width, int height, bool* exists = nullptr) override; std::string correctTexturePath(const std::string& path) override; std::string correctMeshPath(const std::string& path) override; bool textureExists(const std::string& path) override; diff --git a/apps/openmw/mwlua/types/activator.cpp b/apps/openmw/mwlua/types/activator.cpp index 825a464878..6d5d86722d 100644 --- a/apps/openmw/mwlua/types/activator.cpp +++ b/apps/openmw/mwlua/types/activator.cpp @@ -1,6 +1,8 @@ #include "types.hpp" #include +#include +#include #include @@ -16,6 +18,8 @@ namespace MWLua { void addActivatorBindings(sol::table activator, const Context& context) { + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); activator["record"] = sol::overload( [](const Object& obj) -> const ESM::Activator* { return obj.ptr().get()->mBase; }, @@ -24,7 +28,10 @@ namespace MWLua record[sol::meta_function::to_string] = [](const ESM::Activator& rec) { return "ESM3_Activator[" + rec.mId + "]"; }; record["id"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mId; }); record["name"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mName; }); - record["model"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mModel; }); + record["model"] = sol::readonly_property([vfs](const ESM::Activator& rec) -> std::string + { + return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); + }); record["mwscript"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mScript; }); } } diff --git a/apps/openmw/mwlua/types/apparatus.cpp b/apps/openmw/mwlua/types/apparatus.cpp index 385040b3d6..5957feab60 100644 --- a/apps/openmw/mwlua/types/apparatus.cpp +++ b/apps/openmw/mwlua/types/apparatus.cpp @@ -1,6 +1,8 @@ #include "types.hpp" #include +#include +#include #include @@ -23,6 +25,8 @@ namespace MWLua {"Retort", ESM::Apparatus::Retort}, })); + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); apparatus["record"] = sol::overload( [](const Object& obj) -> const ESM::Apparatus* { return obj.ptr().get()->mBase; }, @@ -31,9 +35,15 @@ namespace MWLua record[sol::meta_function::to_string] = [](const ESM::Apparatus& rec) { return "ESM3_Apparatus[" + rec.mId + "]"; }; record["id"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mId; }); record["name"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mName; }); - record["model"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mModel; }); + record["model"] = sol::readonly_property([vfs](const ESM::Apparatus& rec) -> std::string + { + return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); + }); record["mwscript"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mScript; }); - record["icon"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mIcon; }); + record["icon"] = sol::readonly_property([vfs](const ESM::Apparatus& rec) -> std::string + { + return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); + }); record["type"] = sol::readonly_property([](const ESM::Apparatus& rec) -> int { return rec.mData.mType; }); record["value"] = sol::readonly_property([](const ESM::Apparatus& rec) -> int { return rec.mData.mValue; }); record["weight"] = sol::readonly_property([](const ESM::Apparatus& rec) -> float { return rec.mData.mWeight; }); diff --git a/apps/openmw/mwlua/types/book.cpp b/apps/openmw/mwlua/types/book.cpp index 9d34a2026e..5129f94049 100644 --- a/apps/openmw/mwlua/types/book.cpp +++ b/apps/openmw/mwlua/types/book.cpp @@ -1,6 +1,8 @@ #include "types.hpp" #include +#include +#include #include @@ -24,6 +26,8 @@ namespace MWLua skill[skillName] = skillName; } + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); book["record"] = sol::overload( [](const Object& obj) -> const ESM::Book* { return obj.ptr().get()->mBase; }, @@ -32,9 +36,15 @@ namespace MWLua record[sol::meta_function::to_string] = [](const ESM::Book& rec) { return "ESM3_Book[" + rec.mId + "]"; }; record["id"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mId; }); record["name"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mName; }); - record["model"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mModel; }); + record["model"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string + { + return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); + }); record["mwscript"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mScript; }); - record["icon"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mIcon; }); + record["icon"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string + { + return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); + }); record["text"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mText; }); record["enchant"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mEnchant; }); record["isScroll"] = sol::readonly_property([](const ESM::Book& rec) -> bool { return rec.mData.mIsScroll; }); diff --git a/apps/openmw/mwlua/types/container.cpp b/apps/openmw/mwlua/types/container.cpp index 729363435b..e1ce587e2c 100644 --- a/apps/openmw/mwlua/types/container.cpp +++ b/apps/openmw/mwlua/types/container.cpp @@ -1,6 +1,8 @@ #include "types.hpp" #include +#include +#include #include #include @@ -33,6 +35,8 @@ namespace MWLua return ptr.getClass().getCapacity(ptr); }; + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); container["record"] = sol::overload( [](const Object& obj) -> const ESM::Container* { return obj.ptr().get()->mBase; }, @@ -41,7 +45,10 @@ namespace MWLua record[sol::meta_function::to_string] = [](const ESM::Container& rec) -> std::string { return "ESM3_Container[" + rec.mId + "]"; }; record["id"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mId; }); record["name"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mName; }); - record["model"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mModel; }); + record["model"] = sol::readonly_property([vfs](const ESM::Container& rec) -> std::string + { + return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); + }); record["mwscript"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mScript; }); record["weight"] = sol::readonly_property([](const ESM::Container& rec) -> float { return rec.mWeight; }); } diff --git a/apps/openmw/mwlua/types/creature.cpp b/apps/openmw/mwlua/types/creature.cpp index 2358c3f41d..251edd24e0 100644 --- a/apps/openmw/mwlua/types/creature.cpp +++ b/apps/openmw/mwlua/types/creature.cpp @@ -3,7 +3,8 @@ #include #include -#include +#include +#include #include "../stats.hpp" #include "../luabindings.hpp" @@ -18,6 +19,8 @@ namespace MWLua { void addCreatureBindings(sol::table creature, const Context& context) { + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); creature["record"] = sol::overload( [](const Object& obj) -> const ESM::Creature* { return obj.ptr().get()->mBase; }, @@ -25,9 +28,9 @@ namespace MWLua sol::usertype record = context.mLua->sol().new_usertype("ESM3_Creature"); record[sol::meta_function::to_string] = [](const ESM::Creature& rec) { return "ESM3_Creature[" + rec.mId + "]"; }; record["name"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mName; }); - record["model"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string + record["model"] = sol::readonly_property([vfs](const ESM::Creature& rec) -> std::string { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(rec.mModel); + return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); record["mwscript"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mScript; }); record["baseCreature"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mOriginal; }); diff --git a/apps/openmw/mwlua/types/door.cpp b/apps/openmw/mwlua/types/door.cpp index a6d2a7bc0d..4b215d0881 100644 --- a/apps/openmw/mwlua/types/door.cpp +++ b/apps/openmw/mwlua/types/door.cpp @@ -1,9 +1,10 @@ #include "types.hpp" #include +#include +#include #include -#include #include "../luabindings.hpp" @@ -41,6 +42,8 @@ namespace MWLua return sol::nil; }; + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); door["record"] = sol::overload( [](const Object& obj) -> const ESM::Door* { return obj.ptr().get()->mBase; }, @@ -49,9 +52,9 @@ namespace MWLua record[sol::meta_function::to_string] = [](const ESM::Door& rec) -> std::string { return "ESM3_Door[" + rec.mId + "]"; }; record["id"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mId; }); record["name"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mName; }); - record["model"] = sol::readonly_property([](const ESM::Door& rec) -> std::string + record["model"] = sol::readonly_property([vfs](const ESM::Door& rec) -> std::string { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(rec.mModel); + return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); record["mwscript"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mScript; }); record["openSound"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mOpenSound; }); diff --git a/apps/openmw/mwlua/types/lockpick.cpp b/apps/openmw/mwlua/types/lockpick.cpp index 71c7ec5646..9a46399982 100644 --- a/apps/openmw/mwlua/types/lockpick.cpp +++ b/apps/openmw/mwlua/types/lockpick.cpp @@ -1,6 +1,8 @@ #include "types.hpp" #include +#include +#include #include @@ -16,6 +18,8 @@ namespace MWLua { void addLockpickBindings(sol::table lockpick, const Context& context) { + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); lockpick["record"] = sol::overload( [](const Object& obj) -> const ESM::Lockpick* { return obj.ptr().get()->mBase;}, @@ -24,9 +28,15 @@ namespace MWLua record[sol::meta_function::to_string] = [](const ESM::Lockpick& rec) { return "ESM3_Lockpick[" + rec.mId + "]";}; record["id"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mId;}); record["name"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mName;}); - record["model"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mModel;}); + record["model"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string + { + return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); + }); record["mwscript"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mScript;}); - record["icon"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mIcon;}); + record["icon"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string + { + return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); + }); record["maxCondition"] = sol::readonly_property([](const ESM::Lockpick& rec) -> int { return rec.mData.mUses;}); record["value"] = sol::readonly_property([](const ESM::Lockpick& rec) -> int { return rec.mData.mValue;}); record["weight"] = sol::readonly_property([](const ESM::Lockpick& rec) -> float { return rec.mData.mWeight;}); diff --git a/apps/openmw/mwlua/types/misc.cpp b/apps/openmw/mwlua/types/misc.cpp index 7546561dad..be53d03d93 100644 --- a/apps/openmw/mwlua/types/misc.cpp +++ b/apps/openmw/mwlua/types/misc.cpp @@ -1,6 +1,8 @@ #include "types.hpp" #include +#include +#include #include @@ -16,6 +18,8 @@ namespace MWLua { void addMiscellaneousBindings(sol::table miscellaneous, const Context& context) { + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); miscellaneous["record"] = sol::overload( [](const Object& obj) -> const ESM::Miscellaneous* { return obj.ptr().get()->mBase; }, @@ -24,9 +28,15 @@ namespace MWLua record[sol::meta_function::to_string] = [](const ESM::Miscellaneous& rec) { return "ESM3_Miscellaneous[" + rec.mId + "]"; }; record["id"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mId; }); record["name"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mName; }); - record["model"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mModel; }); + record["model"] = sol::readonly_property([vfs](const ESM::Miscellaneous& rec) -> std::string + { + return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); + }); record["mwscript"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mScript; }); - record["icon"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mIcon; }); + record["icon"] = sol::readonly_property([vfs](const ESM::Miscellaneous& rec) -> std::string + { + return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); + }); record["isKey"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> bool { return rec.mData.mIsKey; }); record["value"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> int { return rec.mData.mValue; }); record["weight"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> float { return rec.mData.mWeight; }); diff --git a/apps/openmw/mwlua/types/potion.cpp b/apps/openmw/mwlua/types/potion.cpp index 0d1b7e202e..c3c5ace281 100644 --- a/apps/openmw/mwlua/types/potion.cpp +++ b/apps/openmw/mwlua/types/potion.cpp @@ -1,6 +1,8 @@ #include "types.hpp" #include +#include +#include #include @@ -21,12 +23,19 @@ namespace MWLua [](const Object& obj) -> const ESM::Potion* { return obj.ptr().get()->mBase; }, [store](const std::string& recordId) -> const ESM::Potion* { return store->find(recordId); }); + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); sol::usertype record = context.mLua->sol().new_usertype("ESM3_Potion"); record[sol::meta_function::to_string] = [](const ESM::Potion& rec) { return "ESM3_Potion[" + rec.mId + "]"; }; record["id"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mId; }); record["name"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mName; }); - record["model"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mModel; }); - record["icon"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mIcon; }); + record["model"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string + { + return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); + }); + record["icon"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string + { + return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); + }); record["mwscript"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mScript; }); record["weight"] = sol::readonly_property([](const ESM::Potion& rec) -> float { return rec.mData.mWeight; }); record["value"] = sol::readonly_property([](const ESM::Potion& rec) -> int { return rec.mData.mValue; }); diff --git a/apps/openmw/mwlua/types/probe.cpp b/apps/openmw/mwlua/types/probe.cpp index 771824fce1..373ac622ef 100644 --- a/apps/openmw/mwlua/types/probe.cpp +++ b/apps/openmw/mwlua/types/probe.cpp @@ -1,6 +1,8 @@ #include "types.hpp" #include +#include +#include #include @@ -16,6 +18,8 @@ namespace MWLua { void addProbeBindings(sol::table probe, const Context& context) { + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); probe["record"] = sol::overload( [](const Object& obj) -> const ESM::Probe* { return obj.ptr().get()->mBase;}, @@ -24,9 +28,15 @@ namespace MWLua record[sol::meta_function::to_string] = [](const ESM::Probe& rec) { return "ESM3_Probe[" + rec.mId + "]";}; record["id"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mId;}); record["name"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mName;}); - record["model"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mModel;}); + record["model"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string + { + return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); + }); record["mwscript"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mScript;}); - record["icon"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mIcon;}); + record["icon"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string + { + return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); + }); record["maxCondition"] = sol::readonly_property([](const ESM::Probe& rec) -> int { return rec.mData.mUses;}); record["value"] = sol::readonly_property([](const ESM::Probe& rec) -> int { return rec.mData.mValue;}); record["weight"] = sol::readonly_property([](const ESM::Probe& rec) -> float { return rec.mData.mWeight;}); diff --git a/apps/openmw/mwlua/types/repair.cpp b/apps/openmw/mwlua/types/repair.cpp index fa1e34ac63..5b73e713c5 100644 --- a/apps/openmw/mwlua/types/repair.cpp +++ b/apps/openmw/mwlua/types/repair.cpp @@ -1,6 +1,8 @@ #include "types.hpp" #include +#include +#include #include @@ -16,6 +18,8 @@ namespace MWLua { void addRepairBindings(sol::table repair, const Context& context) { + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); repair["record"] = sol::overload( [](const Object& obj) -> const ESM::Repair* { return obj.ptr().get()->mBase; }, @@ -24,9 +28,15 @@ namespace MWLua record[sol::meta_function::to_string] = [](const ESM::Repair& rec) { return "ESM3_Repair[" + rec.mId + "]"; }; record["id"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mId; }); record["name"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mName; }); - record["model"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mModel; }); + record["model"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string + { + return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); + }); record["mwscript"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mScript; }); - record["icon"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mIcon; }); + record["icon"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string + { + return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); + }); record["maxCondition"] = sol::readonly_property([](const ESM::Repair& rec) -> int { return rec.mData.mUses; }); record["value"] = sol::readonly_property([](const ESM::Repair& rec) -> int { return rec.mData.mValue; }); record["weight"] = sol::readonly_property([](const ESM::Repair& rec) -> float { return rec.mData.mWeight; }); diff --git a/apps/openmw/mwlua/types/weapon.cpp b/apps/openmw/mwlua/types/weapon.cpp index beca109216..628e47fc68 100644 --- a/apps/openmw/mwlua/types/weapon.cpp +++ b/apps/openmw/mwlua/types/weapon.cpp @@ -1,9 +1,10 @@ #include "types.hpp" #include +#include +#include #include -#include #include "../luabindings.hpp" @@ -12,7 +13,7 @@ namespace sol template <> struct is_automagical : std::false_type {}; } - +#include namespace MWLua { void addWeaponBindings(sol::table weapon, const Context& context) @@ -34,6 +35,8 @@ namespace MWLua {"Bolt", ESM::Weapon::Bolt}, })); + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); weapon["record"] = sol::overload( [](const Object& obj) -> const ESM::Weapon* { return obj.ptr().get()->mBase; }, @@ -42,13 +45,13 @@ namespace MWLua record[sol::meta_function::to_string] = [](const ESM::Weapon& rec) -> std::string { return "ESM3_Weapon[" + rec.mId + "]"; }; record["id"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mId; }); record["name"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mName; }); - record["model"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string + record["model"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string { - return MWBase::Environment::get().getWindowManager()->correctMeshPath(rec.mModel); + return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); }); - record["icon"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string + record["icon"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string { - return MWBase::Environment::get().getWindowManager()->correctIconPath(rec.mIcon); + return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); }); record["enchant"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mEnchant; }); record["mwscript"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mScript; });