1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-08 22:34:33 +00:00

CLEANUP: Use more appropriate object types & functions in addTopic binding

This commit is contained in:
Dave Corley 2025-02-01 04:32:20 -07:00 committed by Dave Corley
parent 4150f5fad6
commit 05b12ac879

View file

@ -3,6 +3,7 @@
#include <apps/openmw/mwbase/dialoguemanager.hpp> #include <apps/openmw/mwbase/dialoguemanager.hpp>
#include <components/esm3/loadbsgn.hpp> #include <components/esm3/loadbsgn.hpp>
#include <components/esm3/loadfact.hpp> #include <components/esm3/loadfact.hpp>
#include <components/misc/strings/format.hpp>
#include "../birthsignbindings.hpp" #include "../birthsignbindings.hpp"
#include "../luamanagerimp.hpp" #include "../luamanagerimp.hpp"
@ -196,14 +197,14 @@ namespace MWLua
throw std::runtime_error("Only player and global scripts can toggle teleportation."); throw std::runtime_error("Only player and global scripts can toggle teleportation.");
MWBase::Environment::get().getWorld()->enableTeleporting(state); MWBase::Environment::get().getWorld()->enableTeleporting(state);
}; };
player["addTopic"] = [](const Object& player, std::string topicId) { player["addTopic"] = [](const Object& player, std::string_view topicId) {
if (dynamic_cast<const LObject*>(&player) && !dynamic_cast<const SelfObject*>(&player)) verifyPlayer(player);
throw std::runtime_error("Only player and global scripts may add topics.");
ESM::RefId topic = ESM::RefId::stringRefId(topicId); ESM::RefId topic = ESM::RefId::deserializeText(topicId);
if (!MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().search(topic)) if (!MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().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); MWBase::Environment::get().getDialogueManager()->addTopic(topic);