mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-31 18:06:41 +00:00
Merge branch 'fix_model_path' into 'master'
Fix #7403: incorrect model path for records created by Lua scripts Closes #7403 See merge request OpenMW/openmw!3151
This commit is contained in:
commit
31efad1dd0
9 changed files with 23 additions and 7 deletions
|
@ -23,7 +23,7 @@ namespace
|
||||||
{
|
{
|
||||||
ESM::Activator activator;
|
ESM::Activator activator;
|
||||||
activator.mName = rec["name"];
|
activator.mName = rec["name"];
|
||||||
activator.mModel = rec["model"];
|
activator.mModel = Misc::ResourceHelpers::meshPathForESM3(rec["model"].get<std::string_view>());
|
||||||
std::string_view scriptId = rec["mwscript"].get<std::string_view>();
|
std::string_view scriptId = rec["mwscript"].get<std::string_view>();
|
||||||
activator.mScript = ESM::RefId::deserializeText(scriptId);
|
activator.mScript = ESM::RefId::deserializeText(scriptId);
|
||||||
return activator;
|
return activator;
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace
|
||||||
{
|
{
|
||||||
ESM::Armor armor;
|
ESM::Armor armor;
|
||||||
armor.mName = rec["name"];
|
armor.mName = rec["name"];
|
||||||
armor.mModel = rec["model"];
|
armor.mModel = Misc::ResourceHelpers::meshPathForESM3(rec["model"].get<std::string_view>());
|
||||||
armor.mIcon = rec["icon"];
|
armor.mIcon = rec["icon"];
|
||||||
std::string_view enchantId = rec["enchant"].get<std::string_view>();
|
std::string_view enchantId = rec["enchant"].get<std::string_view>();
|
||||||
armor.mEnchant = ESM::RefId::deserializeText(enchantId);
|
armor.mEnchant = ESM::RefId::deserializeText(enchantId);
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace
|
||||||
{
|
{
|
||||||
ESM::Book book;
|
ESM::Book book;
|
||||||
book.mName = rec["name"];
|
book.mName = rec["name"];
|
||||||
book.mModel = rec["model"];
|
book.mModel = Misc::ResourceHelpers::meshPathForESM3(rec["model"].get<std::string_view>());
|
||||||
book.mIcon = rec["icon"];
|
book.mIcon = rec["icon"];
|
||||||
book.mText = rec["text"];
|
book.mText = rec["text"];
|
||||||
std::string_view enchantId = rec["enchant"].get<std::string_view>();
|
std::string_view enchantId = rec["enchant"].get<std::string_view>();
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace
|
||||||
{
|
{
|
||||||
ESM::Clothing clothing;
|
ESM::Clothing clothing;
|
||||||
clothing.mName = rec["name"];
|
clothing.mName = rec["name"];
|
||||||
clothing.mModel = rec["model"];
|
clothing.mModel = Misc::ResourceHelpers::meshPathForESM3(rec["model"].get<std::string_view>());
|
||||||
clothing.mIcon = rec["icon"];
|
clothing.mIcon = rec["icon"];
|
||||||
std::string_view scriptId = rec["mwscript"].get<std::string_view>();
|
std::string_view scriptId = rec["mwscript"].get<std::string_view>();
|
||||||
clothing.mScript = ESM::RefId::deserializeText(scriptId);
|
clothing.mScript = ESM::RefId::deserializeText(scriptId);
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace
|
||||||
{
|
{
|
||||||
ESM::Miscellaneous misc;
|
ESM::Miscellaneous misc;
|
||||||
misc.mName = rec["name"];
|
misc.mName = rec["name"];
|
||||||
misc.mModel = rec["model"];
|
misc.mModel = Misc::ResourceHelpers::meshPathForESM3(rec["model"].get<std::string_view>());
|
||||||
misc.mIcon = rec["icon"];
|
misc.mIcon = rec["icon"];
|
||||||
std::string_view scriptId = rec["mwscript"].get<std::string_view>();
|
std::string_view scriptId = rec["mwscript"].get<std::string_view>();
|
||||||
misc.mScript = ESM::RefId::deserializeText(scriptId);
|
misc.mScript = ESM::RefId::deserializeText(scriptId);
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace
|
||||||
{
|
{
|
||||||
ESM::Potion potion;
|
ESM::Potion potion;
|
||||||
potion.mName = rec["name"];
|
potion.mName = rec["name"];
|
||||||
potion.mModel = rec["model"];
|
potion.mModel = Misc::ResourceHelpers::meshPathForESM3(rec["model"].get<std::string_view>());
|
||||||
potion.mIcon = rec["icon"];
|
potion.mIcon = rec["icon"];
|
||||||
std::string_view scriptId = rec["mwscript"].get<std::string_view>();
|
std::string_view scriptId = rec["mwscript"].get<std::string_view>();
|
||||||
potion.mScript = ESM::RefId::deserializeText(scriptId);
|
potion.mScript = ESM::RefId::deserializeText(scriptId);
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace
|
||||||
{
|
{
|
||||||
ESM::Weapon weapon;
|
ESM::Weapon weapon;
|
||||||
weapon.mName = rec["name"];
|
weapon.mName = rec["name"];
|
||||||
weapon.mModel = rec["model"];
|
weapon.mModel = Misc::ResourceHelpers::meshPathForESM3(rec["model"].get<std::string_view>());
|
||||||
weapon.mIcon = rec["icon"];
|
weapon.mIcon = rec["icon"];
|
||||||
std::string_view enchantId = rec["enchant"].get<std::string_view>();
|
std::string_view enchantId = rec["enchant"].get<std::string_view>();
|
||||||
weapon.mEnchant = ESM::RefId::deserializeText(enchantId);
|
weapon.mEnchant = ESM::RefId::deserializeText(enchantId);
|
||||||
|
|
|
@ -150,6 +150,17 @@ std::string Misc::ResourceHelpers::correctMeshPath(const std::string& resPath, c
|
||||||
return "meshes\\" + resPath;
|
return "meshes\\" + resPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string_view Misc::ResourceHelpers::meshPathForESM3(std::string_view resPath)
|
||||||
|
{
|
||||||
|
constexpr std::string_view prefix = "meshes";
|
||||||
|
if (resPath.length() < prefix.size() + 1 || !Misc::StringUtils::ciStartsWith(resPath, prefix)
|
||||||
|
|| (resPath[prefix.size()] != '/' && resPath[prefix.size()] != '\\'))
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Path should start with 'meshes\\'");
|
||||||
|
}
|
||||||
|
return resPath.substr(prefix.size() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
std::string Misc::ResourceHelpers::correctSoundPath(std::string_view resPath, const VFS::Manager* vfs)
|
std::string Misc::ResourceHelpers::correctSoundPath(std::string_view resPath, const VFS::Manager* vfs)
|
||||||
{
|
{
|
||||||
// Workaround: Bethesda at some point converted some of the files to mp3, but the references were kept as .wav.
|
// Workaround: Bethesda at some point converted some of the files to mp3, but the references were kept as .wav.
|
||||||
|
|
|
@ -31,8 +31,13 @@ namespace Misc
|
||||||
/// Use "xfoo.nif" instead of "foo.nif" if "xfoo.kf" is available
|
/// Use "xfoo.nif" instead of "foo.nif" if "xfoo.kf" is available
|
||||||
/// Note that if "xfoo.nif" is actually unavailable, we can't fall back to "foo.nif". :(
|
/// Note that if "xfoo.nif" is actually unavailable, we can't fall back to "foo.nif". :(
|
||||||
std::string correctActorModelPath(const std::string& resPath, const VFS::Manager* vfs);
|
std::string correctActorModelPath(const std::string& resPath, const VFS::Manager* vfs);
|
||||||
|
|
||||||
|
// Adds "meshes\\".
|
||||||
std::string correctMeshPath(const std::string& resPath, const VFS::Manager* vfs);
|
std::string correctMeshPath(const std::string& resPath, const VFS::Manager* vfs);
|
||||||
|
|
||||||
|
// Removes "meshes\\".
|
||||||
|
std::string_view meshPathForESM3(std::string_view resPath);
|
||||||
|
|
||||||
std::string correctSoundPath(std::string_view resPath, const VFS::Manager* vfs);
|
std::string correctSoundPath(std::string_view resPath, const VFS::Manager* vfs);
|
||||||
|
|
||||||
/// marker objects that have a hardcoded function in the game logic, should be hidden from the player
|
/// marker objects that have a hardcoded function in the game logic, should be hidden from the player
|
||||||
|
|
Loading…
Reference in a new issue