From cd7017e0e45e47d0c3d48356e4c35a10569293b2 Mon Sep 17 00:00:00 2001 From: Mads Buvik Sandvei Date: Mon, 12 Aug 2024 21:38:52 +0200 Subject: [PATCH] use string_view --- apps/openmw/mwlua/animationbindings.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwlua/animationbindings.cpp b/apps/openmw/mwlua/animationbindings.cpp index c2cdccad57..d959e6b478 100644 --- a/apps/openmw/mwlua/animationbindings.cpp +++ b/apps/openmw/mwlua/animationbindings.cpp @@ -257,11 +257,11 @@ namespace MWLua }; api["addVfx"] = [context]( - const sol::object& object, const std::string& model, sol::optional options) { + const sol::object& object, std::string_view model, sol::optional options) { if (options) { context.mLuaManager->addAction( - [object = ObjectVariant(object), model = model, + [object = ObjectVariant(object), model = std::string(model), effectId = options->get_or("vfxId", ""), loop = options->get_or("loop", false), boneName = options->get_or("boneName", ""), particleTexture = options->get_or("particleTextureOverride", "")] { @@ -274,7 +274,7 @@ namespace MWLua else { context.mLuaManager->addAction( - [object = ObjectVariant(object), model = model] { + [object = ObjectVariant(object), model = std::string(model)] { MWRender::Animation* anim = getMutableAnimationOrThrow(object); anim->addEffect(model, ""); }, @@ -310,22 +310,21 @@ namespace MWLua auto world = MWBase::Environment::get().getWorld(); api["spawn"] - = [world, context](const std::string model, const osg::Vec3f& worldPos, sol::optional options) { + = [world, context](std::string_view model, const osg::Vec3f& worldPos, sol::optional options) { if (options) { bool magicVfx = options->get_or("mwMagicVfx", true); std::string texture = options->get_or("particleTextureOverride", ""); float scale = options->get_or("scale", 1.f); context.mLuaManager->addAction( - [world, model = model, texture = std::move(texture), worldPos, scale, magicVfx]() { - world->spawnEffect(model, texture, worldPos, scale, magicVfx); - }, + [world, model = std::string(model), texture = std::move(texture), worldPos, scale, + magicVfx]() { world->spawnEffect(model, texture, worldPos, scale, magicVfx); }, "openmw.vfx.spawn"); } else { context.mLuaManager->addAction( - [world, model = model, worldPos]() { world->spawnEffect(model, "", worldPos); }, + [world, model = std::string(model), worldPos]() { world->spawnEffect(model, "", worldPos); }, "openmw.vfx.spawn"); } };