mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-23 05:36:23 +00:00
refactor(Scripts/Commands): Update cs_quest to the new model (#9267)
This commit is contained in:
@@ -116,3 +116,28 @@ ChatCommandResult Acore::Impl::ChatCommands::ArgInfo<SpellInfo const*>::TryConsu
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
struct QuestVisitor
|
||||
{
|
||||
using value_type = Quest const*;
|
||||
value_type operator()(Hyperlink<quest> quest_template) const { return quest_template->Quest; };
|
||||
value_type operator()(uint32 questId) const { return sObjectMgr->GetQuestTemplate(questId); };
|
||||
};
|
||||
|
||||
ChatCommandResult Acore::Impl::ChatCommands::ArgInfo<Quest const*>::TryConsume(Quest const*& data, ChatHandler const* handler, std::string_view args)
|
||||
{
|
||||
Variant<Hyperlink<quest>, uint32> val;
|
||||
ChatCommandResult result = ArgInfo<decltype(val)>::TryConsume(val, handler, args);
|
||||
|
||||
if (!result || (data = val.visit(QuestVisitor())))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (uint32* id = std::get_if<uint32>(&val))
|
||||
{
|
||||
return FormatAcoreString(handler, LANG_CMDPARSER_QUEST_NO_EXIST, *id);
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -319,6 +319,12 @@ namespace Acore::Impl::ChatCommands
|
||||
static ChatCommandResult TryConsume(SpellInfo const*&, ChatHandler const*, std::string_view);
|
||||
};
|
||||
|
||||
// Quest const* from quest id or link
|
||||
template <>
|
||||
struct AC_GAME_API ArgInfo<Quest const*>
|
||||
{
|
||||
static ChatCommandResult TryConsume(Quest const*&, ChatHandler const*, std::string_view);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user