1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00

Merge branch 'more_move' into 'master'

Address Coverity Scan complaints left

See merge request OpenMW/openmw!3837
This commit is contained in:
psi29a 2024-02-05 13:22:14 +00:00
commit 76842c3ba1
8 changed files with 22 additions and 14 deletions

View File

@ -375,12 +375,18 @@ int MWDialogue::Filter::getSelectStructInteger(const SelectWrapper& select) cons
return mChoice;
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()
.getCreatureStats(mActor)
.getAiSetting((MWMechanics::AiSetting)select.getArgument())
.getAiSetting(static_cast<MWMechanics::AiSetting>(argument))
.getModified(false);
}
case SelectWrapper::Function_PcAttribute:
{
ESM::RefId attribute = ESM::Attribute::indexToRefId(select.getArgument());

View File

@ -344,18 +344,19 @@ namespace MWLua
[world, context](const sol::object& staticOrID, const osg::Vec3f& worldPos) {
auto model = getStaticModelOrThrow(staticOrID);
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) {
auto model = getStaticModelOrThrow(staticOrID);
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);
context.mLuaManager->addAction(
[world, model, textureOverride, worldPos, scale, magicVfx]() {
world->spawnEffect(model, textureOverride, worldPos, scale, magicVfx);
[world, model = std::move(model), texture = std::move(texture), worldPos, scale, magicVfx]() {
world->spawnEffect(model, texture, worldPos, scale, magicVfx);
},
"openmw.vfx.spawn");
});

View File

@ -42,7 +42,7 @@ namespace MWLua
ObjectVariant mObject;
public:
ItemData(ObjectVariant object)
ItemData(const ObjectVariant& object)
: mObject(object)
{
}
@ -116,7 +116,7 @@ namespace MWLua
item["itemData"] = [](const sol::object& object) -> sol::optional<ItemData> {
ObjectVariant o(object);
if (o.ptr().getClass().isItem(o.ptr()) || o.ptr().mRef->getType() == ESM::REC_LIGH)
return ItemData(std::move(o));
return ItemData(o);
return {};
};

View File

@ -649,7 +649,7 @@ namespace MWLua
scripts->setSavedDataDeserializer(mLocalSerializer.get());
ESM::LuaScripts data;
scripts->save(data);
localData[id] = data;
localData[id] = std::move(data);
}
mMenuScripts.removeAllScripts();

View File

@ -85,7 +85,7 @@ namespace MWLua
}
context.mLuaManager->addAction(
[=] {
[shader, name, values = std::move(values)] {
MWBase::Environment::get().getWorld()->getPostProcessor()->setUniform(shader.mShader, name, values);
},
"SetUniformShaderAction");

View File

@ -274,7 +274,8 @@ namespace MWLua
{
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");
};

View File

@ -117,7 +117,7 @@ namespace MWLua
// 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.
context.mLuaManager->addAction(
[actor, q, stage] {
[actor = std::move(actor), q, stage] {
MWWorld::Ptr actorPtr;
if (actor)
actorPtr = actor->ptr();

View File

@ -241,7 +241,7 @@ namespace MWLua
for (unsigned i = 0; i < newStack.size(); ++i)
newStack[i] = nameToMode.at(LuaUtil::cast<std::string_view>(modes[i + 1]));
luaManager->addAction(
[windowManager, newStack, arg]() {
[windowManager, newStack = std::move(newStack), arg]() {
MWWorld::Ptr ptr;
if (arg.has_value())
ptr = arg->ptr();
@ -319,7 +319,7 @@ namespace MWLua
};
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[sol::meta_function::to_string]
= [](LuaUi::Layer& self) { return Misc::StringUtils::format("UiLayer(%s)", self.name()); };