mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-22 11:39:41 +00:00
Address Coverity Scan complaints left
This commit is contained in:
parent
8b47381162
commit
292879d0fb
8 changed files with 22 additions and 14 deletions
|
@ -375,12 +375,18 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons
|
||||||
return mChoice;
|
return mChoice;
|
||||||
|
|
||||||
case SelectWrapper::Function_AiSetting:
|
case SelectWrapper::Function_AiSetting:
|
||||||
|
{
|
||||||
|
int argument = select.getArgument();
|
||||||
|
if (argument < 0 || argument > 3)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("AiSetting index is out of range");
|
||||||
|
}
|
||||||
|
|
||||||
return mActor.getClass()
|
return mActor.getClass()
|
||||||
.getCreatureStats(mActor)
|
.getCreatureStats(mActor)
|
||||||
.getAiSetting((MWMechanics::AiSetting)select.getArgument())
|
.getAiSetting(static_cast<MWMechanics::AiSetting>(argument))
|
||||||
.getModified(false);
|
.getModified(false);
|
||||||
|
}
|
||||||
case SelectWrapper::Function_PcAttribute:
|
case SelectWrapper::Function_PcAttribute:
|
||||||
{
|
{
|
||||||
ESM::RefId attribute = ESM::Attribute::indexToRefId(select.getArgument());
|
ESM::RefId attribute = ESM::Attribute::indexToRefId(select.getArgument());
|
||||||
|
|
|
@ -344,18 +344,19 @@ namespace MWLua
|
||||||
[world, context](const sol::object& staticOrID, const osg::Vec3f& worldPos) {
|
[world, context](const sol::object& staticOrID, const osg::Vec3f& worldPos) {
|
||||||
auto model = getStaticModelOrThrow(staticOrID);
|
auto model = getStaticModelOrThrow(staticOrID);
|
||||||
context.mLuaManager->addAction(
|
context.mLuaManager->addAction(
|
||||||
[world, model, worldPos]() { world->spawnEffect(model, "", worldPos); }, "openmw.vfx.spawn");
|
[world, model = std::move(model), worldPos]() { world->spawnEffect(model, "", worldPos); },
|
||||||
|
"openmw.vfx.spawn");
|
||||||
},
|
},
|
||||||
[world, context](const sol::object& staticOrID, const osg::Vec3f& worldPos, const sol::table& options) {
|
[world, context](const sol::object& staticOrID, const osg::Vec3f& worldPos, const sol::table& options) {
|
||||||
auto model = getStaticModelOrThrow(staticOrID);
|
auto model = getStaticModelOrThrow(staticOrID);
|
||||||
|
|
||||||
bool magicVfx = options.get_or("mwMagicVfx", true);
|
bool magicVfx = options.get_or("mwMagicVfx", true);
|
||||||
std::string textureOverride = options.get_or<std::string>("particleTextureOverride", "");
|
std::string texture = options.get_or<std::string>("particleTextureOverride", "");
|
||||||
float scale = options.get_or("scale", 1.f);
|
float scale = options.get_or("scale", 1.f);
|
||||||
|
|
||||||
context.mLuaManager->addAction(
|
context.mLuaManager->addAction(
|
||||||
[world, model, textureOverride, worldPos, scale, magicVfx]() {
|
[world, model = std::move(model), texture = std::move(texture), worldPos, scale, magicVfx]() {
|
||||||
world->spawnEffect(model, textureOverride, worldPos, scale, magicVfx);
|
world->spawnEffect(model, texture, worldPos, scale, magicVfx);
|
||||||
},
|
},
|
||||||
"openmw.vfx.spawn");
|
"openmw.vfx.spawn");
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace MWLua
|
||||||
ObjectVariant mObject;
|
ObjectVariant mObject;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ItemData(ObjectVariant object)
|
ItemData(const ObjectVariant& object)
|
||||||
: mObject(object)
|
: mObject(object)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ namespace MWLua
|
||||||
item["itemData"] = [](const sol::object& object) -> sol::optional<ItemData> {
|
item["itemData"] = [](const sol::object& object) -> sol::optional<ItemData> {
|
||||||
ObjectVariant o(object);
|
ObjectVariant o(object);
|
||||||
if (o.ptr().getClass().isItem(o.ptr()) || o.ptr().mRef->getType() == ESM::REC_LIGH)
|
if (o.ptr().getClass().isItem(o.ptr()) || o.ptr().mRef->getType() == ESM::REC_LIGH)
|
||||||
return ItemData(std::move(o));
|
return ItemData(o);
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -643,7 +643,7 @@ namespace MWLua
|
||||||
scripts->setSavedDataDeserializer(mLocalSerializer.get());
|
scripts->setSavedDataDeserializer(mLocalSerializer.get());
|
||||||
ESM::LuaScripts data;
|
ESM::LuaScripts data;
|
||||||
scripts->save(data);
|
scripts->save(data);
|
||||||
localData[id] = data;
|
localData[id] = std::move(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
mMenuScripts.removeAllScripts();
|
mMenuScripts.removeAllScripts();
|
||||||
|
|
|
@ -85,7 +85,7 @@ namespace MWLua
|
||||||
}
|
}
|
||||||
|
|
||||||
context.mLuaManager->addAction(
|
context.mLuaManager->addAction(
|
||||||
[=] {
|
[shader, name, values = std::move(values)] {
|
||||||
MWBase::Environment::get().getWorld()->getPostProcessor()->setUniform(shader.mShader, name, values);
|
MWBase::Environment::get().getWorld()->getPostProcessor()->setUniform(shader.mShader, name, values);
|
||||||
},
|
},
|
||||||
"SetUniformShaderAction");
|
"SetUniformShaderAction");
|
||||||
|
|
|
@ -274,7 +274,8 @@ namespace MWLua
|
||||||
{
|
{
|
||||||
ei = LuaUtil::cast<std::string>(item);
|
ei = LuaUtil::cast<std::string>(item);
|
||||||
}
|
}
|
||||||
context.mLuaManager->addAction([obj = Object(ptr), ei = ei] { setSelectedEnchantedItem(obj.ptr(), ei); },
|
context.mLuaManager->addAction(
|
||||||
|
[obj = Object(ptr), ei = std::move(ei)] { setSelectedEnchantedItem(obj.ptr(), ei); },
|
||||||
"setSelectedEnchantedItemAction");
|
"setSelectedEnchantedItemAction");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ namespace MWLua
|
||||||
// The journal mwscript function has a try function here, we will make the lua function throw an
|
// The journal mwscript function has a try function here, we will make the lua function throw an
|
||||||
// error. However, the addAction will cause it to error outside of this function.
|
// error. However, the addAction will cause it to error outside of this function.
|
||||||
context.mLuaManager->addAction(
|
context.mLuaManager->addAction(
|
||||||
[actor, q, stage] {
|
[actor = std::move(actor), q, stage] {
|
||||||
MWWorld::Ptr actorPtr;
|
MWWorld::Ptr actorPtr;
|
||||||
if (actor)
|
if (actor)
|
||||||
actorPtr = actor->ptr();
|
actorPtr = actor->ptr();
|
||||||
|
|
|
@ -241,7 +241,7 @@ namespace MWLua
|
||||||
for (unsigned i = 0; i < newStack.size(); ++i)
|
for (unsigned i = 0; i < newStack.size(); ++i)
|
||||||
newStack[i] = nameToMode.at(LuaUtil::cast<std::string_view>(modes[i + 1]));
|
newStack[i] = nameToMode.at(LuaUtil::cast<std::string_view>(modes[i + 1]));
|
||||||
luaManager->addAction(
|
luaManager->addAction(
|
||||||
[windowManager, newStack, arg]() {
|
[windowManager, newStack = std::move(newStack), arg]() {
|
||||||
MWWorld::Ptr ptr;
|
MWWorld::Ptr ptr;
|
||||||
if (arg.has_value())
|
if (arg.has_value())
|
||||||
ptr = arg->ptr();
|
ptr = arg->ptr();
|
||||||
|
@ -319,7 +319,7 @@ namespace MWLua
|
||||||
};
|
};
|
||||||
|
|
||||||
auto uiLayer = context.mLua->sol().new_usertype<LuaUi::Layer>("UiLayer");
|
auto uiLayer = context.mLua->sol().new_usertype<LuaUi::Layer>("UiLayer");
|
||||||
uiLayer["name"] = sol::readonly_property([](LuaUi::Layer& self) { return self.name(); });
|
uiLayer["name"] = sol::readonly_property([](LuaUi::Layer& self) -> std::string_view { return self.name(); });
|
||||||
uiLayer["size"] = sol::readonly_property([](LuaUi::Layer& self) { return self.size(); });
|
uiLayer["size"] = sol::readonly_property([](LuaUi::Layer& self) { return self.size(); });
|
||||||
uiLayer[sol::meta_function::to_string]
|
uiLayer[sol::meta_function::to_string]
|
||||||
= [](LuaUi::Layer& self) { return Misc::StringUtils::format("UiLayer(%s)", self.name()); };
|
= [](LuaUi::Layer& self) { return Misc::StringUtils::format("UiLayer(%s)", self.name()); };
|
||||||
|
|
Loading…
Reference in a new issue