1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 17:59:56 +00:00

Remove unused vfs argument from correctMeshPath

This commit is contained in:
elsid 2023-12-26 13:00:30 +01:00
parent 5d53eb7566
commit 81a483fc7f
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
40 changed files with 93 additions and 180 deletions

View file

@ -131,7 +131,7 @@ namespace NavMeshTool
osg::ref_ptr<const Resource::BulletShape> shape = [&] { osg::ref_ptr<const Resource::BulletShape> shape = [&] {
try try
{ {
return bulletShapeManager.getShape(Misc::ResourceHelpers::correctMeshPath(model, &vfs)); return bulletShapeManager.getShape(Misc::ResourceHelpers::correctMeshPath(model));
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {

View file

@ -145,12 +145,11 @@ namespace MWClass
= getModel(ptr); // Assume it's not empty, since we wouldn't have gotten the soundgen otherwise = getModel(ptr); // Assume it's not empty, since we wouldn't have gotten the soundgen otherwise
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
const ESM::RefId* creatureId = nullptr; const ESM::RefId* creatureId = nullptr;
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
for (const ESM::Creature& iter : store.get<ESM::Creature>()) for (const ESM::Creature& iter : store.get<ESM::Creature>())
{ {
if (!iter.mModel.empty() if (!iter.mModel.empty()
&& Misc::StringUtils::ciEqual(model, Misc::ResourceHelpers::correctMeshPath(iter.mModel, vfs))) && Misc::StringUtils::ciEqual(model, Misc::ResourceHelpers::correctMeshPath(iter.mModel)))
{ {
creatureId = !iter.mOriginal.empty() ? &iter.mOriginal : &iter.mId; creatureId = !iter.mOriginal.empty() ? &iter.mOriginal : &iter.mId;
break; break;

View file

@ -1,8 +1,6 @@
#ifndef OPENMW_MWCLASS_CLASSMODEL_H #ifndef OPENMW_MWCLASS_CLASSMODEL_H
#define OPENMW_MWCLASS_CLASSMODEL_H #define OPENMW_MWCLASS_CLASSMODEL_H
#include "../mwbase/environment.hpp"
#include "../mwworld/livecellref.hpp" #include "../mwworld/livecellref.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
@ -19,8 +17,7 @@ namespace MWClass
const MWWorld::LiveCellRef<Class>* ref = ptr.get<Class>(); const MWWorld::LiveCellRef<Class>* ref = ptr.get<Class>();
if (!ref->mBase->mModel.empty()) if (!ref->mBase->mModel.empty())
return Misc::ResourceHelpers::correctMeshPath( return Misc::ResourceHelpers::correctMeshPath(ref->mBase->mModel);
ref->mBase->mModel, MWBase::Environment::get().getResourceSystem()->getVFS());
return {}; return {};
} }

View file

@ -644,12 +644,10 @@ namespace MWClass
const std::string model = getModel(ptr); const std::string model = getModel(ptr);
if (!model.empty()) if (!model.empty())
{ {
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
for (const ESM::Creature& creature : store.get<ESM::Creature>()) for (const ESM::Creature& creature : store.get<ESM::Creature>())
{ {
if (creature.mId != ourId && creature.mOriginal != ourId && !creature.mModel.empty() if (creature.mId != ourId && creature.mOriginal != ourId && !creature.mModel.empty()
&& Misc::StringUtils::ciEqual( && Misc::StringUtils::ciEqual(model, Misc::ResourceHelpers::correctMeshPath(creature.mModel)))
model, Misc::ResourceHelpers::correctMeshPath(creature.mModel, vfs)))
{ {
const ESM::RefId& fallbackId = !creature.mOriginal.empty() ? creature.mOriginal : creature.mId; const ESM::RefId& fallbackId = !creature.mOriginal.empty() ? creature.mOriginal : creature.mId;
sound = store.get<ESM::SoundGenerator>().begin(); sound = store.get<ESM::SoundGenerator>().begin();

View file

@ -6,6 +6,8 @@
#include <components/esm4/loadtree.hpp> #include <components/esm4/loadtree.hpp>
#include <components/misc/strings/algorithm.hpp> #include <components/misc/strings/algorithm.hpp>
#include "../mwbase/environment.hpp"
#include "../mwgui/tooltips.hpp" #include "../mwgui/tooltips.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"

View file

@ -175,8 +175,7 @@ namespace MWClass
model = data.mTraits->mModel; model = data.mTraits->mModel;
else else
model = data.mIsFemale ? data.mRace->mModelFemale : data.mRace->mModelMale; model = data.mIsFemale ? data.mRace->mModelFemale : data.mRace->mModelMale;
const VFS::Manager* vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); return Misc::ResourceHelpers::correctMeshPath(model);
return Misc::ResourceHelpers::correctMeshPath(model, vfs);
} }
std::string_view ESM4Npc::getName(const MWWorld::ConstPtr& ptr) const std::string_view ESM4Npc::getName(const MWWorld::ConstPtr& ptr) const

View file

@ -431,24 +431,22 @@ namespace MWClass
models.push_back(Settings::models().mXbaseanimfemale); models.push_back(Settings::models().mXbaseanimfemale);
models.push_back(Settings::models().mXbaseanim); models.push_back(Settings::models().mXbaseanim);
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
if (!npc->mBase->mModel.empty()) if (!npc->mBase->mModel.empty())
models.push_back(Misc::ResourceHelpers::correctMeshPath(npc->mBase->mModel, vfs)); models.push_back(Misc::ResourceHelpers::correctMeshPath(npc->mBase->mModel));
if (!npc->mBase->mHead.empty()) if (!npc->mBase->mHead.empty())
{ {
const ESM::BodyPart* head const ESM::BodyPart* head
= MWBase::Environment::get().getESMStore()->get<ESM::BodyPart>().search(npc->mBase->mHead); = MWBase::Environment::get().getESMStore()->get<ESM::BodyPart>().search(npc->mBase->mHead);
if (head) if (head)
models.push_back(Misc::ResourceHelpers::correctMeshPath(head->mModel, vfs)); models.push_back(Misc::ResourceHelpers::correctMeshPath(head->mModel));
} }
if (!npc->mBase->mHair.empty()) if (!npc->mBase->mHair.empty())
{ {
const ESM::BodyPart* hair const ESM::BodyPart* hair
= MWBase::Environment::get().getESMStore()->get<ESM::BodyPart>().search(npc->mBase->mHair); = MWBase::Environment::get().getESMStore()->get<ESM::BodyPart>().search(npc->mBase->mHair);
if (hair) if (hair)
models.push_back(Misc::ResourceHelpers::correctMeshPath(hair->mModel, vfs)); models.push_back(Misc::ResourceHelpers::correctMeshPath(hair->mModel));
} }
bool female = (npc->mBase->mFlags & ESM::NPC::Female); bool female = (npc->mBase->mFlags & ESM::NPC::Female);
@ -487,7 +485,7 @@ namespace MWClass
const ESM::BodyPart* part const ESM::BodyPart* part
= MWBase::Environment::get().getESMStore()->get<ESM::BodyPart>().search(partname); = MWBase::Environment::get().getESMStore()->get<ESM::BodyPart>().search(partname);
if (part && !part->mModel.empty()) if (part && !part->mModel.empty())
models.push_back(Misc::ResourceHelpers::correctMeshPath(part->mModel, vfs)); models.push_back(Misc::ResourceHelpers::correctMeshPath(part->mModel));
} }
} }
} }
@ -501,7 +499,7 @@ namespace MWClass
{ {
const ESM::BodyPart* part = *it; const ESM::BodyPart* part = *it;
if (part && !part->mModel.empty()) if (part && !part->mModel.empty())
models.push_back(Misc::ResourceHelpers::correctMeshPath(part->mModel, vfs)); models.push_back(Misc::ResourceHelpers::correctMeshPath(part->mModel));
} }
} }
} }

View file

@ -43,8 +43,6 @@ namespace MWLua
{ {
void addActivatorBindings(sol::table activator, const Context& context) void addActivatorBindings(sol::table activator, const Context& context)
{ {
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
activator["createRecordDraft"] = tableToActivator; activator["createRecordDraft"] = tableToActivator;
addRecordFunctionBinding<ESM::Activator>(activator, context); addRecordFunctionBinding<ESM::Activator>(activator, context);
@ -54,8 +52,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Activator& rec) -> std::string { record["model"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); return Misc::ResourceHelpers::correctMeshPath(rec.mModel);
}); });
record["mwscript"] = sol::readonly_property( record["mwscript"] = sol::readonly_property(
[](const ESM::Activator& rec) -> std::string { return rec.mScript.serializeText(); }); [](const ESM::Activator& rec) -> std::string { return rec.mScript.serializeText(); });

View file

@ -38,8 +38,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Apparatus& rec) -> std::string { record["model"] = sol::readonly_property([](const ESM::Apparatus& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); return Misc::ResourceHelpers::correctMeshPath(rec.mModel);
}); });
record["mwscript"] = sol::readonly_property( record["mwscript"] = sol::readonly_property(
[](const ESM::Apparatus& rec) -> std::string { return rec.mScript.serializeText(); }); [](const ESM::Apparatus& rec) -> std::string { return rec.mScript.serializeText(); });

View file

@ -95,9 +95,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Armor& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Armor& rec) -> std::string { record["model"] = sol::readonly_property(
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); [](const ESM::Armor& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
});
record["icon"] = sol::readonly_property([vfs](const ESM::Armor& rec) -> std::string { record["icon"] = sol::readonly_property([vfs](const ESM::Armor& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
}); });

View file

@ -104,9 +104,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string { record["model"] = sol::readonly_property(
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); [](const ESM::Book& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
});
record["mwscript"] record["mwscript"]
= sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mScript.serializeText(); }); = sol::readonly_property([](const ESM::Book& rec) -> std::string { return rec.mScript.serializeText(); });
record["icon"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string { record["icon"] = sol::readonly_property([vfs](const ESM::Book& rec) -> std::string {

View file

@ -90,9 +90,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Clothing& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Clothing& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Clothing& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Clothing& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Clothing& rec) -> std::string { record["model"] = sol::readonly_property(
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); [](const ESM::Clothing& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
});
record["icon"] = sol::readonly_property([vfs](const ESM::Clothing& rec) -> std::string { record["icon"] = sol::readonly_property([vfs](const ESM::Clothing& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
}); });

View file

@ -5,10 +5,7 @@
#include <components/misc/resourcehelpers.hpp> #include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp> #include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwbase/environment.hpp>
#include <apps/openmw/mwbase/world.hpp>
#include <apps/openmw/mwworld/class.hpp> #include <apps/openmw/mwworld/class.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
namespace sol namespace sol
{ {
@ -42,8 +39,6 @@ namespace MWLua
}; };
container["capacity"] = container["getCapacity"]; // for compatibility; should be removed later container["capacity"] = container["getCapacity"]; // for compatibility; should be removed later
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
addRecordFunctionBinding<ESM::Container>(container, context); addRecordFunctionBinding<ESM::Container>(container, context);
sol::usertype<ESM::Container> record = context.mLua->sol().new_usertype<ESM::Container>("ESM3_Container"); sol::usertype<ESM::Container> record = context.mLua->sol().new_usertype<ESM::Container>("ESM3_Container");
@ -53,8 +48,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Container& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Container& rec) -> std::string { record["model"] = sol::readonly_property([](const ESM::Container& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); return Misc::ResourceHelpers::correctMeshPath(rec.mModel);
}); });
record["mwscript"] = sol::readonly_property( record["mwscript"] = sol::readonly_property(
[](const ESM::Container& rec) -> std::string { return rec.mScript.serializeText(); }); [](const ESM::Container& rec) -> std::string { return rec.mScript.serializeText(); });

View file

@ -29,8 +29,6 @@ namespace MWLua
{ "Humanoid", ESM::Creature::Humanoid }, { "Humanoid", ESM::Creature::Humanoid },
})); }));
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
addRecordFunctionBinding<ESM::Creature>(creature, context); addRecordFunctionBinding<ESM::Creature>(creature, context);
sol::usertype<ESM::Creature> record = context.mLua->sol().new_usertype<ESM::Creature>("ESM3_Creature"); sol::usertype<ESM::Creature> record = context.mLua->sol().new_usertype<ESM::Creature>("ESM3_Creature");
@ -39,9 +37,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Creature& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Creature& rec) -> std::string { record["model"] = sol::readonly_property(
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); [](const ESM::Creature& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
});
record["mwscript"] = sol::readonly_property( record["mwscript"] = sol::readonly_property(
[](const ESM::Creature& rec) -> std::string { return rec.mScript.serializeText(); }); [](const ESM::Creature& rec) -> std::string { return rec.mScript.serializeText(); });
record["baseCreature"] = sol::readonly_property( record["baseCreature"] = sol::readonly_property(

View file

@ -55,8 +55,6 @@ namespace MWLua
return sol::make_object(lua, LCell{ &cell }); return sol::make_object(lua, LCell{ &cell });
}; };
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
addRecordFunctionBinding<ESM::Door>(door, context); addRecordFunctionBinding<ESM::Door>(door, context);
sol::usertype<ESM::Door> record = context.mLua->sol().new_usertype<ESM::Door>("ESM3_Door"); sol::usertype<ESM::Door> record = context.mLua->sol().new_usertype<ESM::Door>("ESM3_Door");
@ -65,9 +63,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Door& rec) -> std::string { record["model"] = sol::readonly_property(
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); [](const ESM::Door& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
});
record["mwscript"] record["mwscript"]
= sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mScript.serializeText(); }); = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mScript.serializeText(); });
record["openSound"] = sol::readonly_property( record["openSound"] = sol::readonly_property(
@ -95,8 +92,6 @@ namespace MWLua
return sol::make_object(lua, LCell{ &cell }); return sol::make_object(lua, LCell{ &cell });
}; };
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
addRecordFunctionBinding<ESM4::Door>(door, context, "ESM4Door"); addRecordFunctionBinding<ESM4::Door>(door, context, "ESM4Door");
sol::usertype<ESM4::Door> record = context.mLua->sol().new_usertype<ESM4::Door>("ESM4_Door"); sol::usertype<ESM4::Door> record = context.mLua->sol().new_usertype<ESM4::Door>("ESM4_Door");
@ -106,9 +101,8 @@ namespace MWLua
record["id"] = sol::readonly_property( record["id"] = sol::readonly_property(
[](const ESM4::Door& rec) -> std::string { return ESM::RefId(rec.mId).serializeText(); }); [](const ESM4::Door& rec) -> std::string { return ESM::RefId(rec.mId).serializeText(); });
record["name"] = sol::readonly_property([](const ESM4::Door& rec) -> std::string { return rec.mFullName; }); record["name"] = sol::readonly_property([](const ESM4::Door& rec) -> std::string { return rec.mFullName; });
record["model"] = sol::readonly_property([vfs](const ESM4::Door& rec) -> std::string { record["model"] = sol::readonly_property(
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); [](const ESM4::Door& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
});
record["isAutomatic"] = sol::readonly_property( record["isAutomatic"] = sol::readonly_property(
[](const ESM4::Door& rec) -> bool { return rec.mDoorFlags & ESM4::Door::Flag_AutomaticDoor; }); [](const ESM4::Door& rec) -> bool { return rec.mDoorFlags & ESM4::Door::Flag_AutomaticDoor; });
} }

View file

@ -33,8 +33,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Ingredient& rec) -> std::string { record["model"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); return Misc::ResourceHelpers::correctMeshPath(rec.mModel);
}); });
record["mwscript"] = sol::readonly_property( record["mwscript"] = sol::readonly_property(
[](const ESM::Ingredient& rec) -> std::string { return rec.mScript.serializeText(); }); [](const ESM::Ingredient& rec) -> std::string { return rec.mScript.serializeText(); });

View file

@ -31,9 +31,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Light& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Light& rec) -> std::string { record["model"] = sol::readonly_property(
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); [](const ESM::Light& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
});
record["icon"] = sol::readonly_property([vfs](const ESM::Light& rec) -> std::string { record["icon"] = sol::readonly_property([vfs](const ESM::Light& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
}); });

View file

@ -31,9 +31,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string { record["model"] = sol::readonly_property(
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); [](const ESM::Lockpick& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
});
record["mwscript"] = sol::readonly_property( record["mwscript"] = sol::readonly_property(
[](const ESM::Lockpick& rec) -> std::string { return rec.mScript.serializeText(); }); [](const ESM::Lockpick& rec) -> std::string { return rec.mScript.serializeText(); });
record["icon"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string { record["icon"] = sol::readonly_property([vfs](const ESM::Lockpick& rec) -> std::string {

View file

@ -83,8 +83,8 @@ namespace MWLua
record["id"] = sol::readonly_property( record["id"] = sol::readonly_property(
[](const ESM::Miscellaneous& rec) -> std::string { return rec.mId.serializeText(); }); [](const ESM::Miscellaneous& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Miscellaneous& rec) -> std::string { record["model"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); return Misc::ResourceHelpers::correctMeshPath(rec.mModel);
}); });
record["mwscript"] = sol::readonly_property( record["mwscript"] = sol::readonly_property(
[](const ESM::Miscellaneous& rec) -> std::string { return rec.mScript.serializeText(); }); [](const ESM::Miscellaneous& rec) -> std::string { return rec.mScript.serializeText(); });

View file

@ -73,9 +73,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string { record["model"] = sol::readonly_property(
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); [](const ESM::Potion& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
});
record["icon"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string { record["icon"] = sol::readonly_property([vfs](const ESM::Potion& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
}); });

View file

@ -31,9 +31,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string { record["model"] = sol::readonly_property(
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); [](const ESM::Probe& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
});
record["mwscript"] record["mwscript"]
= sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mScript.serializeText(); }); = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mScript.serializeText(); });
record["icon"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string { record["icon"] = sol::readonly_property([vfs](const ESM::Probe& rec) -> std::string {

View file

@ -6,8 +6,6 @@
#include <components/resource/resourcesystem.hpp> #include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwbase/environment.hpp> #include <apps/openmw/mwbase/environment.hpp>
#include <apps/openmw/mwbase/world.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
namespace sol namespace sol
{ {
@ -31,9 +29,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string { record["model"] = sol::readonly_property(
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); [](const ESM::Repair& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
});
record["mwscript"] record["mwscript"]
= sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mScript.serializeText(); }); = sol::readonly_property([](const ESM::Repair& rec) -> std::string { return rec.mScript.serializeText(); });
record["icon"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string { record["icon"] = sol::readonly_property([vfs](const ESM::Repair& rec) -> std::string {

View file

@ -21,8 +21,6 @@ namespace MWLua
{ {
void addStaticBindings(sol::table stat, const Context& context) void addStaticBindings(sol::table stat, const Context& context)
{ {
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
addRecordFunctionBinding<ESM::Static>(stat, context); addRecordFunctionBinding<ESM::Static>(stat, context);
sol::usertype<ESM::Static> record = context.mLua->sol().new_usertype<ESM::Static>("ESM3_Static"); sol::usertype<ESM::Static> record = context.mLua->sol().new_usertype<ESM::Static>("ESM3_Static");
@ -30,8 +28,7 @@ namespace MWLua
= [](const ESM::Static& rec) -> std::string { return "ESM3_Static[" + rec.mId.toDebugString() + "]"; }; = [](const ESM::Static& rec) -> std::string { return "ESM3_Static[" + rec.mId.toDebugString() + "]"; };
record["id"] record["id"]
= sol::readonly_property([](const ESM::Static& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Static& rec) -> std::string { return rec.mId.serializeText(); });
record["model"] = sol::readonly_property([vfs](const ESM::Static& rec) -> std::string { record["model"] = sol::readonly_property(
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); [](const ESM::Static& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
});
} }
} }

View file

@ -6,8 +6,6 @@
#include <components/misc/resourcehelpers.hpp> #include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp> #include <components/resource/resourcesystem.hpp>
#include "apps/openmw/mwworld/esmstore.hpp"
namespace sol namespace sol
{ {
template <> template <>
@ -21,9 +19,6 @@ namespace MWLua
void addESM4TerminalBindings(sol::table term, const Context& context) void addESM4TerminalBindings(sol::table term, const Context& context)
{ {
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
addRecordFunctionBinding<ESM4::Terminal>(term, context, "ESM4Terminal"); addRecordFunctionBinding<ESM4::Terminal>(term, context, "ESM4Terminal");
sol::usertype<ESM4::Terminal> record = context.mLua->sol().new_usertype<ESM4::Terminal>("ESM4_Terminal"); sol::usertype<ESM4::Terminal> record = context.mLua->sol().new_usertype<ESM4::Terminal>("ESM4_Terminal");
@ -38,8 +33,8 @@ namespace MWLua
record["resultText"] record["resultText"]
= sol::readonly_property([](const ESM4::Terminal& rec) -> std::string { return rec.mResultText; }); = sol::readonly_property([](const ESM4::Terminal& rec) -> std::string { return rec.mResultText; });
record["name"] = sol::readonly_property([](const ESM4::Terminal& rec) -> std::string { return rec.mFullName; }); record["name"] = sol::readonly_property([](const ESM4::Terminal& rec) -> std::string { return rec.mFullName; });
record["model"] = sol::readonly_property([vfs](const ESM4::Terminal& rec) -> std::string { record["model"] = sol::readonly_property([](const ESM4::Terminal& rec) -> std::string {
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); return Misc::ResourceHelpers::correctMeshPath(rec.mModel);
}); });
} }
} }

View file

@ -129,9 +129,8 @@ namespace MWLua
record["id"] record["id"]
= sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mId.serializeText(); }); = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mId.serializeText(); });
record["name"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mName; }); record["name"] = sol::readonly_property([](const ESM::Weapon& rec) -> std::string { return rec.mName; });
record["model"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string { record["model"] = sol::readonly_property(
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs); [](const ESM::Weapon& rec) -> std::string { return Misc::ResourceHelpers::correctMeshPath(rec.mModel); });
});
record["icon"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string { record["icon"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string {
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs); return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
}); });

View file

@ -321,11 +321,8 @@ namespace MWMechanics
ESM::RefId::stringRefId("VFX_Reflect")); ESM::RefId::stringRefId("VFX_Reflect"));
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(ptr);
if (animation && !reflectStatic->mModel.empty()) if (animation && !reflectStatic->mModel.empty())
{ animation->addEffect(Misc::ResourceHelpers::correctMeshPath(reflectStatic->mModel),
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
animation->addEffect(Misc::ResourceHelpers::correctMeshPath(reflectStatic->mModel, vfs),
ESM::MagicEffect::Reflect, false); ESM::MagicEffect::Reflect, false);
}
caster.getClass().getCreatureStats(caster).getActiveSpells().addSpell(*reflected); caster.getClass().getCreatureStats(caster).getActiveSpells().addSpell(*reflected);
} }
if (removedSpell) if (removedSpell)

View file

@ -211,11 +211,8 @@ namespace
const ESM::Static* const fx const ESM::Static* const fx
= world->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Soul_Trap")); = world->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Soul_Trap"));
if (fx != nullptr) if (fx != nullptr)
{ world->spawnEffect(Misc::ResourceHelpers::correctMeshPath(fx->mModel), "",
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
world->spawnEffect(Misc::ResourceHelpers::correctMeshPath(fx->mModel, vfs), "",
creature.getRefData().getPosition().asVec3()); creature.getRefData().getPosition().asVec3());
}
MWBase::Environment::get().getSoundManager()->playSound3D( MWBase::Environment::get().getSoundManager()->playSound3D(
creature.getRefData().getPosition().asVec3(), ESM::RefId::stringRefId("conjuration hit"), 1.f, 1.f); creature.getRefData().getPosition().asVec3(), ESM::RefId::stringRefId("conjuration hit"), 1.f, 1.f);
@ -1825,12 +1822,8 @@ namespace MWMechanics
const ESM::Static* fx = MWBase::Environment::get().getESMStore()->get<ESM::Static>().search( const ESM::Static* fx = MWBase::Environment::get().getESMStore()->get<ESM::Static>().search(
ESM::RefId::stringRefId("VFX_Summon_End")); ESM::RefId::stringRefId("VFX_Summon_End"));
if (fx) if (fx)
{
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
MWBase::Environment::get().getWorld()->spawnEffect( MWBase::Environment::get().getWorld()->spawnEffect(
Misc::ResourceHelpers::correctMeshPath(fx->mModel, vfs), "", Misc::ResourceHelpers::correctMeshPath(fx->mModel), "", ptr.getRefData().getPosition().asVec3());
ptr.getRefData().getPosition().asVec3());
}
// Remove the summoned creature's summoned creatures as well // Remove the summoned creature's summoned creatures as well
MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr); MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);

View file

@ -1615,18 +1615,13 @@ namespace MWMechanics
const ESM::Static* castStatic const ESM::Static* castStatic
= world->getStore().get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Hands")); = world->getStore().get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Hands"));
const VFS::Manager* const vfs
= MWBase::Environment::get().getResourceSystem()->getVFS();
if (mAnimation->getNode("Bip01 L Hand")) if (mAnimation->getNode("Bip01 L Hand"))
mAnimation->addEffect( mAnimation->addEffect(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel),
Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs), -1, false, -1, false, "Bip01 L Hand", effect->mParticle);
"Bip01 L Hand", effect->mParticle);
if (mAnimation->getNode("Bip01 R Hand")) if (mAnimation->getNode("Bip01 R Hand"))
mAnimation->addEffect( mAnimation->addEffect(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel),
Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs), -1, false, -1, false, "Bip01 R Hand", effect->mParticle);
"Bip01 R Hand", effect->mParticle);
} }
// first effect used for casting animation // first effect used for casting animation
const ESM::ENAMstruct& firstEffect = effects->front(); const ESM::ENAMstruct& firstEffect = effects->front();

View file

@ -41,7 +41,6 @@ namespace MWMechanics
const ESM::EffectList& effects, const MWWorld::Ptr& ignore, ESM::RangeType rangeType) const const ESM::EffectList& effects, const MWWorld::Ptr& ignore, ESM::RangeType rangeType) const
{ {
const auto world = MWBase::Environment::get().getWorld(); const auto world = MWBase::Environment::get().getWorld();
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
std::map<MWWorld::Ptr, std::vector<ESM::ENAMstruct>> toApply; std::map<MWWorld::Ptr, std::vector<ESM::ENAMstruct>> toApply;
int index = -1; int index = -1;
for (const ESM::ENAMstruct& effectInfo : effects.mList) for (const ESM::ENAMstruct& effectInfo : effects.mList)
@ -75,12 +74,12 @@ namespace MWMechanics
{ {
if (effectInfo.mRange == ESM::RT_Target) if (effectInfo.mRange == ESM::RT_Target)
world->spawnEffect( world->spawnEffect(
Misc::ResourceHelpers::correctMeshPath(areaStatic->mModel, vfs), texture, mHitPosition, 1.0f); Misc::ResourceHelpers::correctMeshPath(areaStatic->mModel), texture, mHitPosition, 1.0f);
continue; continue;
} }
else else
world->spawnEffect(Misc::ResourceHelpers::correctMeshPath(areaStatic->mModel, vfs), texture, world->spawnEffect(Misc::ResourceHelpers::correctMeshPath(areaStatic->mModel), texture, mHitPosition,
mHitPosition, static_cast<float>(effectInfo.mArea * 2)); static_cast<float>(effectInfo.mArea * 2));
// Play explosion sound (make sure to use NoTrack, since we will delete the projectile now) // Play explosion sound (make sure to use NoTrack, since we will delete the projectile now)
{ {
@ -532,7 +531,6 @@ namespace MWMechanics
{ {
const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore(); const MWWorld::ESMStore& store = *MWBase::Environment::get().getESMStore();
std::vector<std::string> addedEffects; std::vector<std::string> addedEffects;
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
for (const ESM::ENAMstruct& effectData : effects) for (const ESM::ENAMstruct& effectData : effects)
{ {
@ -547,15 +545,15 @@ namespace MWMechanics
// check if the effect was already added // check if the effect was already added
if (std::find(addedEffects.begin(), addedEffects.end(), if (std::find(addedEffects.begin(), addedEffects.end(),
Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs)) Misc::ResourceHelpers::correctMeshPath(castStatic->mModel))
!= addedEffects.end()) != addedEffects.end())
continue; continue;
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(mCaster); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(mCaster);
if (animation) if (animation)
{ {
animation->addEffect(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs), effect->mIndex, animation->addEffect(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel), effect->mIndex, false,
false, {}, effect->mParticle); {}, effect->mParticle);
} }
else else
{ {
@ -585,13 +583,13 @@ namespace MWMechanics
} }
scale = std::max(scale, 1.f); scale = std::max(scale, 1.f);
MWBase::Environment::get().getWorld()->spawnEffect( MWBase::Environment::get().getWorld()->spawnEffect(
Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs), effect->mParticle, pos, scale); Misc::ResourceHelpers::correctMeshPath(castStatic->mModel), effect->mParticle, pos, scale);
} }
if (animation && !mCaster.getClass().isActor()) if (animation && !mCaster.getClass().isActor())
animation->addSpellCastGlow(effect); animation->addSpellCastGlow(effect);
addedEffects.push_back(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs)); addedEffects.push_back(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel));
MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager(); MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager();
if (!effect->mCastSound.empty()) if (!effect->mCastSound.empty())
@ -628,11 +626,8 @@ namespace MWMechanics
{ {
// Don't play particle VFX unless the effect is new or it should be looping. // Don't play particle VFX unless the effect is new or it should be looping.
if (playNonLooping || loop) if (playNonLooping || loop)
{ anim->addEffect(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel), magicEffect.mIndex, loop,
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); {}, magicEffect.mParticle);
anim->addEffect(Misc::ResourceHelpers::correctMeshPath(castStatic->mModel, vfs), magicEffect.mIndex,
loop, {}, magicEffect.mParticle);
}
} }
} }
} }

View file

@ -285,11 +285,8 @@ namespace
const ESM::Static* absorbStatic = esmStore.get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Absorb")); const ESM::Static* absorbStatic = esmStore.get<ESM::Static>().find(ESM::RefId::stringRefId("VFX_Absorb"));
MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target); MWRender::Animation* animation = MWBase::Environment::get().getWorld()->getAnimation(target);
if (animation && !absorbStatic->mModel.empty()) if (animation && !absorbStatic->mModel.empty())
{ animation->addEffect(
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); Misc::ResourceHelpers::correctMeshPath(absorbStatic->mModel), ESM::MagicEffect::SpellAbsorption, false);
animation->addEffect(Misc::ResourceHelpers::correctMeshPath(absorbStatic->mModel, vfs),
ESM::MagicEffect::SpellAbsorption, false);
}
const ESM::Spell* spell = esmStore.get<ESM::Spell>().search(spellId); const ESM::Spell* spell = esmStore.get<ESM::Spell>().search(spellId);
int spellCost = 0; int spellCost = 0;
if (spell) if (spell)
@ -461,10 +458,7 @@ namespace MWMechanics
const ESM::Static* fx const ESM::Static* fx
= world->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Summon_end")); = world->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Summon_end"));
if (fx) if (fx)
{ anim->addEffect(Misc::ResourceHelpers::correctMeshPath(fx->mModel), -1);
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
anim->addEffect(Misc::ResourceHelpers::correctMeshPath(fx->mModel, vfs), -1);
}
} }
} }
else if (caster == getPlayer()) else if (caster == getPlayer())

View file

@ -105,10 +105,7 @@ namespace MWMechanics
const ESM::Static* fx const ESM::Static* fx
= world->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Summon_Start")); = world->getStore().get<ESM::Static>().search(ESM::RefId::stringRefId("VFX_Summon_Start"));
if (fx) if (fx)
{ anim->addEffect(Misc::ResourceHelpers::correctMeshPath(fx->mModel), -1, false);
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
anim->addEffect(Misc::ResourceHelpers::correctMeshPath(fx->mModel, vfs), -1, false);
}
} }
} }
catch (std::exception& e) catch (std::exception& e)

View file

@ -130,8 +130,7 @@ namespace MWRender
if (bodypart == nullptr || bodypart->mData.mType != ESM::BodyPart::MT_Armor) if (bodypart == nullptr || bodypart->mData.mType != ESM::BodyPart::MT_Armor)
return std::string(); return std::string();
if (!bodypart->mModel.empty()) if (!bodypart->mModel.empty())
return Misc::ResourceHelpers::correctMeshPath( return Misc::ResourceHelpers::correctMeshPath(bodypart->mModel);
bodypart->mModel, MWBase::Environment::get().getResourceSystem()->getVFS());
} }
} }
} }

View file

@ -12,8 +12,8 @@
#include <components/resource/resourcesystem.hpp> #include <components/resource/resourcesystem.hpp>
#include <components/resource/scenemanager.hpp> #include <components/resource/scenemanager.hpp>
#include "../mwbase/environment.hpp"
#include "../mwclass/esm4npc.hpp" #include "../mwclass/esm4npc.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
namespace MWRender namespace MWRender
@ -51,7 +51,7 @@ namespace MWRender
if (model.empty()) if (model.empty())
return; return;
mResourceSystem->getSceneManager()->getInstance( mResourceSystem->getSceneManager()->getInstance(
Misc::ResourceHelpers::correctMeshPath(model, mResourceSystem->getVFS()), mObjectRoot.get()); Misc::ResourceHelpers::correctMeshPath(model), mObjectRoot.get());
} }
template <class Record> template <class Record>

View file

@ -48,7 +48,7 @@
namespace namespace
{ {
std::string getVampireHead(const ESM::RefId& race, bool female, const VFS::Manager& vfs) std::string getVampireHead(const ESM::RefId& race, bool female)
{ {
static std::map<std::pair<ESM::RefId, int>, const ESM::BodyPart*> sVampireMapping; static std::map<std::pair<ESM::RefId, int>, const ESM::BodyPart*> sVampireMapping;
@ -78,7 +78,7 @@ namespace
const ESM::BodyPart* bodyPart = sVampireMapping[thisCombination]; const ESM::BodyPart* bodyPart = sVampireMapping[thisCombination];
if (!bodyPart) if (!bodyPart)
return std::string(); return std::string();
return Misc::ResourceHelpers::correctMeshPath(bodyPart->mModel, &vfs); return Misc::ResourceHelpers::correctMeshPath(bodyPart->mModel);
} }
} }
@ -467,7 +467,7 @@ namespace MWRender
{ {
const ESM::BodyPart* bp = store.get<ESM::BodyPart>().search(headName); const ESM::BodyPart* bp = store.get<ESM::BodyPart>().search(headName);
if (bp) if (bp)
mHeadModel = Misc::ResourceHelpers::correctMeshPath(bp->mModel, mResourceSystem->getVFS()); mHeadModel = Misc::ResourceHelpers::correctMeshPath(bp->mModel);
else else
Log(Debug::Warning) << "Warning: Failed to load body part '" << headName << "'"; Log(Debug::Warning) << "Warning: Failed to load body part '" << headName << "'";
} }
@ -476,12 +476,12 @@ namespace MWRender
{ {
const ESM::BodyPart* bp = store.get<ESM::BodyPart>().search(hairName); const ESM::BodyPart* bp = store.get<ESM::BodyPart>().search(hairName);
if (bp) if (bp)
mHairModel = Misc::ResourceHelpers::correctMeshPath(bp->mModel, mResourceSystem->getVFS()); mHairModel = Misc::ResourceHelpers::correctMeshPath(bp->mModel);
else else
Log(Debug::Warning) << "Warning: Failed to load body part '" << hairName << "'"; Log(Debug::Warning) << "Warning: Failed to load body part '" << hairName << "'";
} }
const std::string vampireHead = getVampireHead(mNpc->mRace, isFemale, *mResourceSystem->getVFS()); const std::string vampireHead = getVampireHead(mNpc->mRace, isFemale);
if (!isWerewolf && isVampire && !vampireHead.empty()) if (!isWerewolf && isVampire && !vampireHead.empty())
mHeadModel = vampireHead; mHeadModel = vampireHead;
@ -494,8 +494,7 @@ namespace MWRender
std::string smodel = defaultSkeleton; std::string smodel = defaultSkeleton;
if (!is1stPerson && !isWerewolf && !mNpc->mModel.empty()) if (!is1stPerson && !isWerewolf && !mNpc->mModel.empty())
smodel = Misc::ResourceHelpers::correctActorModelPath( smodel = Misc::ResourceHelpers::correctActorModelPath(
Misc::ResourceHelpers::correctMeshPath(mNpc->mModel, mResourceSystem->getVFS()), Misc::ResourceHelpers::correctMeshPath(mNpc->mModel), mResourceSystem->getVFS());
mResourceSystem->getVFS());
setObjectRoot(smodel, true, true, false); setObjectRoot(smodel, true, true, false);
@ -646,9 +645,8 @@ namespace MWRender
if (store != inv.end() && (part = *store).getType() == ESM::Light::sRecordId) if (store != inv.end() && (part = *store).getType() == ESM::Light::sRecordId)
{ {
const ESM::Light* light = part.get<ESM::Light>()->mBase; const ESM::Light* light = part.get<ESM::Light>()->mBase;
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1, addOrReplaceIndividualPart(ESM::PRT_Shield, MWWorld::InventoryStore::Slot_CarriedLeft, 1,
Misc::ResourceHelpers::correctMeshPath(light->mModel, vfs), false, nullptr, true); Misc::ResourceHelpers::correctMeshPath(light->mModel), false, nullptr, true);
if (mObjectParts[ESM::PRT_Shield]) if (mObjectParts[ESM::PRT_Shield])
addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), SceneUtil::LightCommon(*light)); addExtraLight(mObjectParts[ESM::PRT_Shield]->getNode()->asGroup(), SceneUtil::LightCommon(*light));
} }
@ -666,13 +664,9 @@ namespace MWRender
{ {
if (mPartPriorities[part] < 1) if (mPartPriorities[part] < 1)
{ {
const ESM::BodyPart* bodypart = parts[part]; if (const ESM::BodyPart* bodypart = parts[part])
if (bodypart)
{
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
addOrReplaceIndividualPart(static_cast<ESM::PartReferenceType>(part), -1, 1, addOrReplaceIndividualPart(static_cast<ESM::PartReferenceType>(part), -1, 1,
Misc::ResourceHelpers::correctMeshPath(bodypart->mModel, vfs)); Misc::ResourceHelpers::correctMeshPath(bodypart->mModel));
}
} }
} }
@ -901,11 +895,8 @@ namespace MWRender
} }
if (bodypart) if (bodypart)
{
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
addOrReplaceIndividualPart(static_cast<ESM::PartReferenceType>(part.mPart), group, priority, addOrReplaceIndividualPart(static_cast<ESM::PartReferenceType>(part.mPart), group, priority,
Misc::ResourceHelpers::correctMeshPath(bodypart->mModel, vfs), enchantedGlow, glowColor); Misc::ResourceHelpers::correctMeshPath(bodypart->mModel), enchantedGlow, glowColor);
}
else else
reserveIndividualPart((ESM::PartReferenceType)part.mPart, group, priority); reserveIndividualPart((ESM::PartReferenceType)part.mPart, group, priority);
} }

View file

@ -623,7 +623,7 @@ namespace MWRender
std::string model = getModel(type, ref.mRefID, store); std::string model = getModel(type, ref.mRefID, store);
if (model.empty()) if (model.empty())
continue; continue;
model = Misc::ResourceHelpers::correctMeshPath(model, mSceneManager->getVFS()); model = Misc::ResourceHelpers::correctMeshPath(model);
if (activeGrid && type != ESM::REC_STAT) if (activeGrid && type != ESM::REC_STAT)
{ {

View file

@ -26,8 +26,6 @@ namespace MWWorld
const ::EsmLoader::EsmData content const ::EsmLoader::EsmData content
= ::EsmLoader::loadEsmData(query, groundcoverFiles, fileCollections, readers, encoder, listener); = ::EsmLoader::loadEsmData(query, groundcoverFiles, fileCollections, readers, encoder, listener);
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
static constexpr std::string_view prefix = "grass\\"; static constexpr std::string_view prefix = "grass\\";
for (const ESM::Static& stat : statics) for (const ESM::Static& stat : statics)
{ {
@ -35,7 +33,7 @@ namespace MWWorld
std::replace(model.begin(), model.end(), '/', '\\'); std::replace(model.begin(), model.end(), '/', '\\');
if (!model.starts_with(prefix)) if (!model.starts_with(prefix))
continue; continue;
mMeshCache[stat.mId] = Misc::ResourceHelpers::correctMeshPath(model, vfs); mMeshCache[stat.mId] = Misc::ResourceHelpers::correctMeshPath(model);
} }
for (const ESM::Static& stat : content.mStatics) for (const ESM::Static& stat : content.mStatics)
@ -44,7 +42,7 @@ namespace MWWorld
std::replace(model.begin(), model.end(), '/', '\\'); std::replace(model.begin(), model.end(), '/', '\\');
if (!model.starts_with(prefix)) if (!model.starts_with(prefix))
continue; continue;
mMeshCache[stat.mId] = Misc::ResourceHelpers::correctMeshPath(model, vfs); mMeshCache[stat.mId] = Misc::ResourceHelpers::correctMeshPath(model);
} }
for (const ESM::Cell& cell : content.mCells) for (const ESM::Cell& cell : content.mCells)

View file

@ -210,8 +210,6 @@ namespace MWWorld
if (state.mIdMagic.size() > 1) if (state.mIdMagic.size() > 1)
{ {
const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
for (size_t iter = 1; iter != state.mIdMagic.size(); ++iter) for (size_t iter = 1; iter != state.mIdMagic.size(); ++iter)
{ {
std::ostringstream nodeName; std::ostringstream nodeName;
@ -223,7 +221,7 @@ namespace MWWorld
attachTo->accept(findVisitor); attachTo->accept(findVisitor);
if (findVisitor.mFoundNode) if (findVisitor.mFoundNode)
mResourceSystem->getSceneManager()->getInstance( mResourceSystem->getSceneManager()->getInstance(
Misc::ResourceHelpers::correctMeshPath(weapon->mModel, vfs), findVisitor.mFoundNode); Misc::ResourceHelpers::correctMeshPath(weapon->mModel), findVisitor.mFoundNode);
} }
} }
@ -331,8 +329,7 @@ namespace MWWorld
if (state.mIdMagic.size() > 1) if (state.mIdMagic.size() > 1)
{ {
model = Misc::ResourceHelpers::correctMeshPath( model = Misc::ResourceHelpers::correctMeshPath(
MWBase::Environment::get().getESMStore()->get<ESM::Weapon>().find(state.mIdMagic[1])->mModel, MWBase::Environment::get().getESMStore()->get<ESM::Weapon>().find(state.mIdMagic[1])->mModel);
MWBase::Environment::get().getResourceSystem()->getVFS());
} }
state.mProjectileId = mPhysics->addProjectile(caster, pos, model, true); state.mProjectileId = mPhysics->addProjectile(caster, pos, model, true);
state.mToDelete = false; state.mToDelete = false;

View file

@ -3632,9 +3632,8 @@ namespace MWWorld
if (texture.empty()) if (texture.empty())
texture = Fallback::Map::getString("Blood_Texture_0"); texture = Fallback::Map::getString("Blood_Texture_0");
std::string model = Misc::ResourceHelpers::correctMeshPath( std::string model = Misc::ResourceHelpers::correctMeshPath(std::string{
std::string{ Fallback::Map::getString("Blood_Model_" + std::to_string(Misc::Rng::rollDice(3))) }, // [0, 2] Fallback::Map::getString("Blood_Model_" + std::to_string(Misc::Rng::rollDice(3))) } /*[0, 2]*/);
mResourceSystem->getVFS());
mRendering->spawnEffect(model, texture, worldPosition, 1.0f, false); mRendering->spawnEffect(model, texture, worldPosition, 1.0f, false);
} }

View file

@ -159,7 +159,7 @@ std::string Misc::ResourceHelpers::correctActorModelPath(const std::string& resP
return mdlname; return mdlname;
} }
std::string Misc::ResourceHelpers::correctMeshPath(std::string_view resPath, const VFS::Manager* vfs) std::string Misc::ResourceHelpers::correctMeshPath(std::string_view resPath)
{ {
std::string res = "meshes\\"; std::string res = "meshes\\";
res.append(resPath); res.append(resPath);

View file

@ -33,7 +33,7 @@ namespace Misc
std::string correctActorModelPath(const std::string& resPath, const VFS::Manager* vfs); std::string correctActorModelPath(const std::string& resPath, const VFS::Manager* vfs);
// Adds "meshes\\". // Adds "meshes\\".
std::string correctMeshPath(std::string_view resPath, const VFS::Manager* vfs); std::string correctMeshPath(std::string_view resPath);
// Adds "sound\\". // Adds "sound\\".
std::string correctSoundPath(const std::string& resPath); std::string correctSoundPath(const std::string& resPath);