mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 10:30:27 +00:00
featScripts/Commands): convert cs_lfg to new system (#8919)
This commit is contained in:
committed by
GitHub
parent
7057ecdb8b
commit
f342535b69
@@ -15,12 +15,13 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "Chat.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Group.h"
|
||||
#include "Language.h"
|
||||
#include "LFGMgr.h"
|
||||
#include "Player.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
void GetPlayerInfo(ChatHandler* handler, Player* player)
|
||||
{
|
||||
@@ -36,10 +37,6 @@ void GetPlayerInfo(ChatHandler* handler, Player* player)
|
||||
lfg::GetRolesString(sLFGMgr->GetRoles(guid)).c_str(), sLFGMgr->GetComment(guid).c_str());
|
||||
}
|
||||
|
||||
#if AC_COMPILER == AC_COMPILER_GNU
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
using namespace Acore::ChatCommands;
|
||||
|
||||
class lfg_commandscript : public CommandScript
|
||||
@@ -51,81 +48,80 @@ public:
|
||||
{
|
||||
static ChatCommandTable lfgCommandTable =
|
||||
{
|
||||
{ "player", SEC_MODERATOR, false, &HandleLfgPlayerInfoCommand, "" },
|
||||
{ "group", SEC_MODERATOR, false, &HandleLfgGroupInfoCommand, "" },
|
||||
{ "queue", SEC_MODERATOR, false, &HandleLfgQueueInfoCommand, "" },
|
||||
{ "clean", SEC_ADMINISTRATOR, false, &HandleLfgCleanCommand, "" },
|
||||
{ "options", SEC_GAMEMASTER, false, &HandleLfgOptionsCommand, "" },
|
||||
{ "player", HandleLfgPlayerInfoCommand, SEC_MODERATOR, Console::No },
|
||||
{ "group", HandleLfgGroupInfoCommand, SEC_MODERATOR, Console::No },
|
||||
{ "queue", HandleLfgQueueInfoCommand, SEC_MODERATOR, Console::Yes },
|
||||
{ "clean", HandleLfgCleanCommand, SEC_ADMINISTRATOR, Console::Yes },
|
||||
{ "options", HandleLfgOptionsCommand, SEC_GAMEMASTER, Console::Yes },
|
||||
};
|
||||
|
||||
static ChatCommandTable commandTable =
|
||||
{
|
||||
{ "lfg", SEC_GAMEMASTER, false, nullptr, "", lfgCommandTable },
|
||||
{ "lfg", lfgCommandTable },
|
||||
};
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool HandleLfgPlayerInfoCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleLfgPlayerInfoCommand(ChatHandler* handler, Optional<PlayerIdentifier> player)
|
||||
{
|
||||
Player* target = nullptr;
|
||||
std::string playerName;
|
||||
if (!handler->extractPlayerTarget((char*)args, &target, nullptr, &playerName))
|
||||
if (!player)
|
||||
player = PlayerIdentifier::FromTargetOrSelf(handler);
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
GetPlayerInfo(handler, target);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleLfgGroupInfoCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
Player* target = nullptr;
|
||||
std::string playerName;
|
||||
if (!handler->extractPlayerTarget((char*)args, &target, nullptr, &playerName))
|
||||
return false;
|
||||
|
||||
Group* grp = target->GetGroup();
|
||||
if (!grp)
|
||||
if (Player* target = player->GetConnectedPlayer())
|
||||
{
|
||||
handler->PSendSysMessage(LANG_LFG_NOT_IN_GROUP, playerName.c_str());
|
||||
GetPlayerInfo(handler, target);
|
||||
return true;
|
||||
}
|
||||
|
||||
ObjectGuid guid = grp->GetGUID();
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool HandleLfgGroupInfoCommand(ChatHandler* handler, Optional<PlayerIdentifier> player)
|
||||
{
|
||||
if (!player)
|
||||
player = PlayerIdentifier::FromTargetOrSelf(handler);
|
||||
if (!player)
|
||||
return false;
|
||||
|
||||
Group* groupTarget = nullptr;
|
||||
if (Player* target = player->GetConnectedPlayer())
|
||||
groupTarget = target->GetGroup();
|
||||
if (!groupTarget)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_LFG_NOT_IN_GROUP, player->GetName().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
ObjectGuid guid = groupTarget->GetGUID();
|
||||
std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid));
|
||||
handler->PSendSysMessage(LANG_LFG_GROUP_INFO, grp->isLFGGroup(),
|
||||
handler->PSendSysMessage(LANG_LFG_GROUP_INFO, groupTarget->isLFGGroup(),
|
||||
state.c_str(), sLFGMgr->GetDungeon(guid));
|
||||
|
||||
for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
|
||||
for (GroupReference* itr = groupTarget->GetFirstMember(); itr != nullptr; itr = itr->next())
|
||||
GetPlayerInfo(handler, itr->GetSource());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleLfgOptionsCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleLfgOptionsCommand(ChatHandler* handler, Optional<uint32> optionsArg)
|
||||
{
|
||||
int32 options = -1;
|
||||
if (char* str = strtok((char*)args, " "))
|
||||
if (optionsArg)
|
||||
{
|
||||
int32 tmp = atoi(str);
|
||||
if (tmp > -1)
|
||||
options = tmp;
|
||||
}
|
||||
|
||||
if (options != -1)
|
||||
{
|
||||
sLFGMgr->SetOptions(options);
|
||||
sLFGMgr->SetOptions(*optionsArg);
|
||||
handler->PSendSysMessage(LANG_LFG_OPTIONS_CHANGED);
|
||||
}
|
||||
handler->PSendSysMessage(LANG_LFG_OPTIONS, sLFGMgr->GetOptions());
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleLfgQueueInfoCommand(ChatHandler* /*handler*/, char const* /*args*/)
|
||||
static bool HandleLfgQueueInfoCommand(ChatHandler* /*handler*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleLfgCleanCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleLfgCleanCommand(ChatHandler* handler)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_LFG_CLEAN);
|
||||
sLFGMgr->Clean();
|
||||
|
||||
Reference in New Issue
Block a user