From 05b12ac8799ed18369a8932dad44c0c89a348761 Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Sat, 1 Feb 2025 04:32:20 -0700 Subject: [PATCH] CLEANUP: Use more appropriate object types & functions in addTopic binding --- apps/openmw/mwlua/types/player.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwlua/types/player.cpp b/apps/openmw/mwlua/types/player.cpp index 2235cfc49c..25056caa41 100644 --- a/apps/openmw/mwlua/types/player.cpp +++ b/apps/openmw/mwlua/types/player.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "../birthsignbindings.hpp" #include "../luamanagerimp.hpp" @@ -196,14 +197,14 @@ namespace MWLua throw std::runtime_error("Only player and global scripts can toggle teleportation."); MWBase::Environment::get().getWorld()->enableTeleporting(state); }; - player["addTopic"] = [](const Object& player, std::string topicId) { - if (dynamic_cast(&player) && !dynamic_cast(&player)) - throw std::runtime_error("Only player and global scripts may add topics."); + player["addTopic"] = [](const Object& player, std::string_view topicId) { + verifyPlayer(player); - ESM::RefId topic = ESM::RefId::stringRefId(topicId); + ESM::RefId topic = ESM::RefId::deserializeText(topicId); if (!MWBase::Environment::get().getESMStore()->get().search(topic)) { - throw std::runtime_error("Failed to add topic " + topicId + ": topic record not found"); + throw std::runtime_error( + Misc::StringUtils::format("Failed to add topic ", topicId, ": topic record not found")); } MWBase::Environment::get().getDialogueManager()->addTopic(topic);