1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-04-17 11:43:25 +00:00

Merge branch 'lua_record_paths' into 'master'

Correct VFS paths in Lua records

See merge request OpenMW/openmw!1853
This commit is contained in:
psi29a 2022-06-12 18:45:24 +00:00
commit eac1d8599a
50 changed files with 253 additions and 95 deletions

View File

@ -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)
{

View File

@ -339,8 +339,8 @@ 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;
virtual void addCell(MWWorld::CellStore* cell) = 0;

View File

@ -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<ESM::Creature>())
{
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;

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -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<ESM::Creature>())
{
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<ESM::SoundGenerator>().begin();

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -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<ESM::BodyPart>().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<ESM::BodyPart>().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<ESM::BodyPart>().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));
}
}

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -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 "";
}

View File

@ -5,14 +5,15 @@
#include <MyGUI_EditBox.h>
#include <MyGUI_ImageBox.h>
// correctBookartPath
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include <components/debug/debuglog.hpp>
#include <components/interpreter/defines.hpp>
#include <components/resource/resourcesystem.hpp>
#include <components/vfs/manager.hpp>
#include <components/misc/stringops.hpp>
#include <components/misc/resourcehelpers.hpp>
#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;
}

View File

@ -2127,19 +2127,16 @@ 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());
}
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());

View File

@ -379,8 +379,8 @@ 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;
void addCell(MWWorld::CellStore* cell) override;

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadacti.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -16,6 +18,8 @@ namespace MWLua
{
void addActivatorBindings(sol::table activator, const Context& context)
{
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Activator>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Activator>();
activator["record"] = sol::overload(
[](const Object& obj) -> const ESM::Activator* { return obj.ptr().get<ESM::Activator>()->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; });
}
}

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadappa.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -23,6 +25,8 @@ namespace MWLua
{"Retort", ESM::Apparatus::Retort},
}));
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Apparatus>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Apparatus>();
apparatus["record"] = sol::overload(
[](const Object& obj) -> const ESM::Apparatus* { return obj.ptr().get<ESM::Apparatus>()->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; });

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadbook.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -24,6 +26,8 @@ namespace MWLua
skill[skillName] = skillName;
}
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Book>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Book>();
book["record"] = sol::overload(
[](const Object& obj) -> const ESM::Book* { return obj.ptr().get<ESM::Book>()->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; });

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadcont.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
#include <apps/openmw/mwworld/class.hpp>
@ -33,6 +35,8 @@ namespace MWLua
return ptr.getClass().getCapacity(ptr);
};
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Container>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Container>();
container["record"] = sol::overload(
[](const Object& obj) -> const ESM::Container* { return obj.ptr().get<ESM::Container>()->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; });
}

View File

@ -3,6 +3,8 @@
#include <components/esm3/loadcrea.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include "../stats.hpp"
#include "../luabindings.hpp"
@ -17,6 +19,8 @@ namespace MWLua
{
void addCreatureBindings(sol::table creature, const Context& context)
{
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Creature>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>();
creature["record"] = sol::overload(
[](const Object& obj) -> const ESM::Creature* { return obj.ptr().get<ESM::Creature>()->mBase; },
@ -24,7 +28,10 @@ namespace MWLua
sol::usertype<ESM::Creature> record = context.mLua->sol().new_usertype<ESM::Creature>("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([vfs](const ESM::Creature& rec) -> std::string
{
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; });
}

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loaddoor.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -40,6 +42,8 @@ namespace MWLua
return sol::nil;
};
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Door>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Door>();
door["record"] = sol::overload(
[](const Object& obj) -> const ESM::Door* { return obj.ptr().get<ESM::Door>()->mBase; },
@ -48,7 +52,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([vfs](const ESM::Door& rec) -> std::string
{
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; });
record["closeSound"] = sol::readonly_property([](const ESM::Door& rec) -> std::string { return rec.mCloseSound; });

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadlock.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -16,6 +18,8 @@ namespace MWLua
{
void addLockpickBindings(sol::table lockpick, const Context& context)
{
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Lockpick>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Lockpick>();
lockpick["record"] = sol::overload(
[](const Object& obj) -> const ESM::Lockpick* { return obj.ptr().get<ESM::Lockpick>()->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;});

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadmisc.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -16,6 +18,8 @@ namespace MWLua
{
void addMiscellaneousBindings(sol::table miscellaneous, const Context& context)
{
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Miscellaneous>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Miscellaneous>();
miscellaneous["record"] = sol::overload(
[](const Object& obj) -> const ESM::Miscellaneous* { return obj.ptr().get<ESM::Miscellaneous>()->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; });

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadalch.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -21,12 +23,19 @@ namespace MWLua
[](const Object& obj) -> const ESM::Potion* { return obj.ptr().get<ESM::Potion>()->mBase; },
[store](const std::string& recordId) -> const ESM::Potion* { return store->find(recordId); });
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
sol::usertype<ESM::Potion> record = context.mLua->sol().new_usertype<ESM::Potion>("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; });

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadprob.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -16,6 +18,8 @@ namespace MWLua
{
void addProbeBindings(sol::table probe, const Context& context)
{
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Probe>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Probe>();
probe["record"] = sol::overload(
[](const Object& obj) -> const ESM::Probe* { return obj.ptr().get<ESM::Probe>()->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;});

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadrepa.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -16,6 +18,8 @@ namespace MWLua
{
void addRepairBindings(sol::table repair, const Context& context)
{
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Repair>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Repair>();
repair["record"] = sol::overload(
[](const Object& obj) -> const ESM::Repair* { return obj.ptr().get<ESM::Repair>()->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; });

View File

@ -1,6 +1,8 @@
#include "types.hpp"
#include <components/esm3/loadweap.hpp>
#include <components/misc/resourcehelpers.hpp>
#include <components/resource/resourcesystem.hpp>
#include <apps/openmw/mwworld/esmstore.hpp>
@ -11,7 +13,7 @@ namespace sol
template <>
struct is_automagical<ESM::Weapon> : std::false_type {};
}
#include <components/resource/resourcesystem.hpp>
namespace MWLua
{
void addWeaponBindings(sol::table weapon, const Context& context)
@ -33,6 +35,8 @@ namespace MWLua
{"Bolt", ESM::Weapon::Bolt},
}));
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
const MWWorld::Store<ESM::Weapon>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Weapon>();
weapon["record"] = sol::overload(
[](const Object& obj) -> const ESM::Weapon* { return obj.ptr().get<ESM::Weapon>()->mBase; },
@ -41,8 +45,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([vfs](const ESM::Weapon& rec) -> std::string
{
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
});
record["icon"] = sol::readonly_property([vfs](const ESM::Weapon& rec) -> std::string
{
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; });
record["isMagical"] = sol::readonly_property(

View File

@ -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<ESM::Static>().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)

View File

@ -203,7 +203,9 @@ void soulTrap(const MWWorld::Ptr& creature)
const ESM::Static* fx = world->getStore().get<ESM::Static>()
.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<ESM::Static>()
.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

View File

@ -1398,10 +1398,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

View File

@ -476,13 +476,17 @@ namespace MWMechanics
castStatic = store.get<ESM::Static>().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);
}
}
}

View File

@ -272,7 +272,9 @@ namespace
const ESM::Static* absorbStatic = esmStore.get<ESM::Static>().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<ESM::Spell>().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<ESM::Static>().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())

View File

@ -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<ESM::Static>().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)

View File

@ -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);
}
}
}

View File

@ -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<ESM::BodyPart>().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<ESM::BodyPart>().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<ESM::Light>()->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::vector<ESM::
}
if(bodypart)
addOrReplaceIndividualPart((ESM::PartReferenceType)part.mPart, group, priority, "meshes\\"+bodypart->mModel, 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);
}

View File

@ -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)
{

View File

@ -4,6 +4,9 @@
#include <components/misc/stringops.hpp>
#include <components/esm3/readerscache.hpp>
#include <apps/openmw/mwbase/environment.hpp>
#include <apps/openmw/mwbase/windowmanager.hpp>
namespace MWWorld
{
void GroundcoverStore::init(const Store<ESM::Static>& statics, const Files::Collections& fileCollections, const std::vector<std::string>& 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)

View File

@ -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<ESM::Weapon>().find(state.mIdMagic[1])->mModel;
model = MWBase::Environment::get().getWindowManager()->correctMeshPath(
MWBase::Environment::get().getWorld()->getStore().get<ESM::Weapon>().find(state.mIdMagic[1])->mModel);
state.mProjectileId = mPhysics->addProjectile(caster, pos, model, true);
state.mToDelete = false;
mMagicBolts.push_back(state);

View File

@ -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<float>(effectInfo.mArea * 2));
mRendering->spawnEffect(
MWBase::Environment::get().getWindowManager()->correctMeshPath(areaStatic->mModel),
texture, origin, static_cast<float>(effectInfo.mArea * 2));
// Play explosion sound (make sure to use NoTrack, since we will delete the projectile now)
static const std::string schools[] = {

View File

@ -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;

View File

@ -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);