feat(Scripts/Commands): Convert cs_achievement to new system (#8736)
This commit is contained in:
committed by
GitHub
parent
784e567585
commit
b82a73d982
@@ -22,14 +22,11 @@ Comment: All achievement related commands
|
|||||||
Category: commandscripts
|
Category: commandscripts
|
||||||
EndScriptData */
|
EndScriptData */
|
||||||
|
|
||||||
|
#include "ScriptMgr.h"
|
||||||
|
#include "AchievementMgr.h"
|
||||||
#include "Chat.h"
|
#include "Chat.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "ScriptMgr.h"
|
|
||||||
|
|
||||||
#if AC_COMPILER == AC_COMPILER_GNU
|
|
||||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace Acore::ChatCommands;
|
using namespace Acore::ChatCommands;
|
||||||
|
|
||||||
@@ -42,30 +39,18 @@ public:
|
|||||||
{
|
{
|
||||||
static ChatCommandTable achievementCommandTable =
|
static ChatCommandTable achievementCommandTable =
|
||||||
{
|
{
|
||||||
{ "add", SEC_GAMEMASTER, false, &HandleAchievementAddCommand, "" },
|
{ "add", HandleAchievementAddCommand, SEC_GAMEMASTER, Console::No },
|
||||||
{ "checkall", SEC_ADMINISTRATOR, false, &HandleAchievementCheckAllCommand, "" }
|
{ "checkall", HandleAchievementCheckAllCommand, SEC_ADMINISTRATOR, Console::No }
|
||||||
};
|
};
|
||||||
static ChatCommandTable commandTable =
|
static ChatCommandTable commandTable =
|
||||||
{
|
{
|
||||||
{ "achievement", SEC_GAMEMASTER, false, nullptr, "", achievementCommandTable }
|
{ "achievement", achievementCommandTable }
|
||||||
};
|
};
|
||||||
return commandTable;
|
return commandTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HandleAchievementAddCommand(ChatHandler* handler, char const* args)
|
static bool HandleAchievementAddCommand(ChatHandler* handler, AchievementEntry const* achievementEntry)
|
||||||
{
|
{
|
||||||
if (!*args)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint32 achievementId = atoi((char*)args);
|
|
||||||
if (!achievementId)
|
|
||||||
{
|
|
||||||
if (char* id = handler->extractKeyFromLink((char*)args, "Hachievement"))
|
|
||||||
achievementId = atoi(id);
|
|
||||||
if (!achievementId)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player* target = handler->getSelectedPlayer();
|
Player* target = handler->getSelectedPlayer();
|
||||||
if (!target)
|
if (!target)
|
||||||
{
|
{
|
||||||
@@ -73,14 +58,12 @@ public:
|
|||||||
handler->SetSentErrorMessage(true);
|
handler->SetSentErrorMessage(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
target->CompletedAchievement(achievementEntry);
|
||||||
if (AchievementEntry const* achievementEntry = sAchievementStore.LookupEntry(achievementId))
|
|
||||||
target->CompletedAchievement(achievementEntry);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool HandleAchievementCheckAllCommand(ChatHandler* handler, char const* /*args*/)
|
static bool HandleAchievementCheckAllCommand(ChatHandler* handler)
|
||||||
{
|
{
|
||||||
Player* target = handler->getSelectedPlayer();
|
Player* target = handler->getSelectedPlayer();
|
||||||
if (!target)
|
if (!target)
|
||||||
|
|||||||
Reference in New Issue
Block a user