1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-01 03:39:42 +00:00

Merge branch 'coverity' into 'master'

Coverity fixes

See merge request OpenMW/openmw!4198
This commit is contained in:
psi29a 2024-06-24 07:10:28 +00:00
commit 57adb93075
3 changed files with 14 additions and 11 deletions

View file

@ -1097,6 +1097,9 @@ namespace MWGui
{ {
tag = tag.substr(MyGuiPrefix.length()); tag = tag.substr(MyGuiPrefix.length());
size_t comma_pos = tag.find(','); size_t comma_pos = tag.find(',');
if (comma_pos == std::string_view::npos)
throw std::runtime_error("Invalid setting tag (expected comma): " + std::string(tag));
std::string_view settingSection = tag.substr(0, comma_pos); std::string_view settingSection = tag.substr(0, comma_pos);
std::string_view settingTag = tag.substr(comma_pos + 1, tag.length()); std::string_view settingTag = tag.substr(comma_pos + 1, tag.length());

View file

@ -932,7 +932,7 @@ namespace MWLua
if (stackable) if (stackable)
params.setFlag(ESM::ActiveSpells::Flag_Stackable); params.setFlag(ESM::ActiveSpells::Flag_Stackable);
for (auto enam : enams) for (const ESM::IndexedENAMstruct& enam : enams)
{ {
const ESM::MagicEffect* mgef = esmStore.get<ESM::MagicEffect>().find(enam.mData.mEffectID); const ESM::MagicEffect* mgef = esmStore.get<ESM::MagicEffect>().find(enam.mData.mEffectID);
MWMechanics::ActiveSpells::ActiveEffect effect; MWMechanics::ActiveSpells::ActiveEffect effect;

View file

@ -2181,14 +2181,14 @@ namespace NifOsg
} }
void handleShaderMaterialNodeProperties( void handleShaderMaterialNodeProperties(
Bgsm::MaterialFilePtr material, osg::StateSet* stateset, std::vector<unsigned int>& boundTextures) const Bgsm::MaterialFile* material, osg::StateSet* stateset, std::vector<unsigned int>& boundTextures)
{ {
const unsigned int uvSet = 0; const unsigned int uvSet = 0;
const bool wrapS = material->wrapS(); const bool wrapS = material->wrapS();
const bool wrapT = material->wrapT(); const bool wrapT = material->wrapT();
if (material->mShaderType == Bgsm::ShaderType::Lighting) if (material->mShaderType == Bgsm::ShaderType::Lighting)
{ {
const Bgsm::BGSMFile* bgsm = static_cast<const Bgsm::BGSMFile*>(material.get()); const Bgsm::BGSMFile* bgsm = static_cast<const Bgsm::BGSMFile*>(material);
if (!bgsm->mDiffuseMap.empty()) if (!bgsm->mDiffuseMap.empty())
attachExternalTexture( attachExternalTexture(
@ -2205,7 +2205,7 @@ namespace NifOsg
} }
else if (material->mShaderType == Bgsm::ShaderType::Effect) else if (material->mShaderType == Bgsm::ShaderType::Effect)
{ {
const Bgsm::BGEMFile* bgem = static_cast<const Bgsm::BGEMFile*>(material.get()); const Bgsm::BGEMFile* bgem = static_cast<const Bgsm::BGEMFile*>(material);
if (!bgem->mBaseMap.empty()) if (!bgem->mBaseMap.empty())
attachExternalTexture("diffuseMap", bgem->mBaseMap, wrapS, wrapT, uvSet, stateset, boundTextures); attachExternalTexture("diffuseMap", bgem->mBaseMap, wrapS, wrapT, uvSet, stateset, boundTextures);
@ -2288,7 +2288,7 @@ namespace NifOsg
} }
void handleShaderMaterialDrawableProperties( void handleShaderMaterialDrawableProperties(
Bgsm::MaterialFilePtr shaderMat, osg::ref_ptr<osg::Material> mat, osg::Node& node, bool& hasSortAlpha) const Bgsm::MaterialFile* shaderMat, osg::ref_ptr<osg::Material> mat, osg::Node& node, bool& hasSortAlpha)
{ {
mat->setAlpha(osg::Material::FRONT_AND_BACK, shaderMat->mTransparency); mat->setAlpha(osg::Material::FRONT_AND_BACK, shaderMat->mTransparency);
handleAlphaTesting(shaderMat->mAlphaTest, osg::AlphaFunc::GREATER, shaderMat->mAlphaTestThreshold, node); handleAlphaTesting(shaderMat->mAlphaTest, osg::AlphaFunc::GREATER, shaderMat->mAlphaTestThreshold, node);
@ -2297,13 +2297,13 @@ namespace NifOsg
handleDecal(shaderMat->mDecal, hasSortAlpha, node); handleDecal(shaderMat->mDecal, hasSortAlpha, node);
if (shaderMat->mShaderType == Bgsm::ShaderType::Lighting) if (shaderMat->mShaderType == Bgsm::ShaderType::Lighting)
{ {
auto bgsm = static_cast<const Bgsm::BGSMFile*>(shaderMat.get()); auto bgsm = static_cast<const Bgsm::BGSMFile*>(shaderMat);
mat->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4f(bgsm->mEmittanceColor, 1.f)); mat->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4f(bgsm->mEmittanceColor, 1.f));
mat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4f(bgsm->mSpecularColor, 1.f)); mat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4f(bgsm->mSpecularColor, 1.f));
} }
else if (shaderMat->mShaderType == Bgsm::ShaderType::Effect) else if (shaderMat->mShaderType == Bgsm::ShaderType::Effect)
{ {
auto bgem = static_cast<const Bgsm::BGEMFile*>(shaderMat.get()); auto bgem = static_cast<const Bgsm::BGEMFile*>(shaderMat);
mat->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4f(bgem->mEmittanceColor, 1.f)); mat->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4f(bgem->mEmittanceColor, 1.f));
if (bgem->mSoft) if (bgem->mSoft)
SceneUtil::setupSoftEffect(node, bgem->mSoftDepth, true, bgem->mSoftDepth); SceneUtil::setupSoftEffect(node, bgem->mSoftDepth, true, bgem->mSoftDepth);
@ -2537,7 +2537,7 @@ namespace NifOsg
clearBoundTextures(stateset, boundTextures); clearBoundTextures(stateset, boundTextures);
if (Bgsm::MaterialFilePtr material = getShaderMaterial(texprop->mName, mMaterialManager)) if (Bgsm::MaterialFilePtr material = getShaderMaterial(texprop->mName, mMaterialManager))
{ {
handleShaderMaterialNodeProperties(material, stateset, boundTextures); handleShaderMaterialNodeProperties(material.get(), stateset, boundTextures);
break; break;
} }
if (!texprop->mTextureSet.empty()) if (!texprop->mTextureSet.empty())
@ -2564,7 +2564,7 @@ namespace NifOsg
clearBoundTextures(stateset, boundTextures); clearBoundTextures(stateset, boundTextures);
if (Bgsm::MaterialFilePtr material = getShaderMaterial(texprop->mName, mMaterialManager)) if (Bgsm::MaterialFilePtr material = getShaderMaterial(texprop->mName, mMaterialManager))
{ {
handleShaderMaterialNodeProperties(material, stateset, boundTextures); handleShaderMaterialNodeProperties(material.get(), stateset, boundTextures);
break; break;
} }
if (!texprop->mSourceTexture.empty()) if (!texprop->mSourceTexture.empty())
@ -2783,7 +2783,7 @@ namespace NifOsg
auto shaderprop = static_cast<const Nif::BSLightingShaderProperty*>(property); auto shaderprop = static_cast<const Nif::BSLightingShaderProperty*>(property);
if (Bgsm::MaterialFilePtr shaderMat = getShaderMaterial(shaderprop->mName, mMaterialManager)) if (Bgsm::MaterialFilePtr shaderMat = getShaderMaterial(shaderprop->mName, mMaterialManager))
{ {
handleShaderMaterialDrawableProperties(shaderMat, mat, *node, hasSortAlpha); handleShaderMaterialDrawableProperties(shaderMat.get(), mat, *node, hasSortAlpha);
if (shaderMat->mShaderType == Bgsm::ShaderType::Lighting) if (shaderMat->mShaderType == Bgsm::ShaderType::Lighting)
{ {
auto bgsm = static_cast<const Bgsm::BGSMFile*>(shaderMat.get()); auto bgsm = static_cast<const Bgsm::BGSMFile*>(shaderMat.get());
@ -2809,7 +2809,7 @@ namespace NifOsg
auto shaderprop = static_cast<const Nif::BSEffectShaderProperty*>(property); auto shaderprop = static_cast<const Nif::BSEffectShaderProperty*>(property);
if (Bgsm::MaterialFilePtr shaderMat = getShaderMaterial(shaderprop->mName, mMaterialManager)) if (Bgsm::MaterialFilePtr shaderMat = getShaderMaterial(shaderprop->mName, mMaterialManager))
{ {
handleShaderMaterialDrawableProperties(shaderMat, mat, *node, hasSortAlpha); handleShaderMaterialDrawableProperties(shaderMat.get(), mat, *node, hasSortAlpha);
break; break;
} }
handleDecal(shaderprop->decal(), hasSortAlpha, *node); handleDecal(shaderprop->decal(), hasSortAlpha, *node);