Scripts/Commands: Convert argument parsing of remaining go command to new system (#25284)
(cherry picked from commit 1aadf6c6d173e593eef0e9976e51a7189a54a8ce)
This commit is contained in:
committed by
Shauren
parent
a773039211
commit
888d217c16
@@ -246,27 +246,24 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleGoQuestCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleGoQuestCommand(ChatHandler* handler, Variant<Hyperlink<quest>, uint32> questData)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
char* id = handler->extractKeyFromLink((char*)args, "Hquest");
|
||||
if (!id)
|
||||
return false;
|
||||
|
||||
uint32 questID = atoul(id);
|
||||
if (!questID)
|
||||
return false;
|
||||
|
||||
if (!sObjectMgr->GetQuestTemplate(questID))
|
||||
uint32 questID;
|
||||
if (questData.holds_alternative<uint32>())
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, questID);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
questID = questData.get<uint32>();
|
||||
|
||||
if (!sObjectMgr->GetQuestTemplate(questID))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, questID);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
questID = questData.get<Hyperlink<quest>>()->Quest->GetQuestId();
|
||||
|
||||
float x, y, z;
|
||||
uint32 mapId;
|
||||
@@ -333,30 +330,11 @@ public:
|
||||
}
|
||||
|
||||
//teleport at coordinates
|
||||
static bool HandleGoZoneXYCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleGoZoneXYCommand(ChatHandler* handler, float x, float y, Optional<Variant<Hyperlink<area>, uint32>> areaIdArg)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
char* zoneX = strtok((char*)args, " ");
|
||||
char* zoneY = strtok(nullptr, " ");
|
||||
char* tail = strtok(nullptr, "");
|
||||
|
||||
char* id = handler->extractKeyFromLink(tail, "Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r
|
||||
|
||||
if (!zoneX || !zoneY)
|
||||
return false;
|
||||
|
||||
float x = (float)atof(zoneX);
|
||||
float y = (float)atof(zoneY);
|
||||
|
||||
// prevent accept wrong numeric args
|
||||
if ((x == 0.0f && *zoneX != '0') || (y == 0.0f && *zoneY != '0'))
|
||||
return false;
|
||||
|
||||
uint32 areaId = id ? atoul(id) : player->GetZoneId();
|
||||
uint32 areaId = areaIdArg ? *areaIdArg : player->GetZoneId();
|
||||
|
||||
AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user