1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-12 17:43:05 +00:00

CLEANUP: Actually check the record in question is a topic when using addTopic

This commit is contained in:
Dave Corley 2025-02-01 12:01:16 -07:00 committed by Dave Corley
parent 05b12ac879
commit 8ec4fcbf30

View file

@ -201,11 +201,15 @@ namespace MWLua
verifyPlayer(player);
ESM::RefId topic = ESM::RefId::deserializeText(topicId);
if (!MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().search(topic))
{
const ESM::Dialogue* dialogueRecord
= MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().search(topic);
if (!dialogueRecord)
throw std::runtime_error(
Misc::StringUtils::format("Failed to add topic ", topicId, ": topic record not found"));
}
else if (dialogueRecord->mType != ESM::Dialogue::Topic)
throw std::runtime_error(
Misc::StringUtils::format("Failed to add topic ", topicId, ": record is not a topic"));
MWBase::Environment::get().getDialogueManager()->addTopic(topic);
};