Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
cs_lfg.cpp
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#include "Chat.h"
7#include "Group.h"
8#include "Language.h"
9#include "LFGMgr.h"
10#include "Player.h"
11#include "ScriptMgr.h"
12
13void GetPlayerInfo(ChatHandler* handler, Player* player)
14{
15 if (!player)
16 return;
17
18 uint64 guid = player->GetGUID();
19 lfg::LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(guid);
20
21 std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid));
22 handler->PSendSysMessage(LANG_LFG_PLAYER_INFO, player->GetName().c_str(),
23 state.c_str(), uint8(dungeons.size()), lfg::ConcatenateDungeons(dungeons).c_str(),
24 lfg::GetRolesString(sLFGMgr->GetRoles(guid)).c_str(), sLFGMgr->GetComment(guid).c_str());
25 handler->SendSysMessage(sLFGMgr->DumpPlayerInfo(guid).c_str());
26}
27
29{
30public:
31 lfg_commandscript() : CommandScript("lfg_commandscript") { }
32
33 std::vector<ChatCommand> GetCommands() const OVERRIDE
34 {
35 static std::vector<ChatCommand> lfgCommandTable =
36 {
42 };
43
44 static std::vector<ChatCommand> commandTable =
45 {
46 { "lfg", rbac::RBAC_PERM_COMMAND_LFG, false, NULL, "", lfgCommandTable },
47 };
48 return commandTable;
49 }
50
51 static bool HandleLfgPlayerInfoCommand(ChatHandler* handler, char const* args)
52 {
53 Player* target = NULL;
54 std::string playerName;
55 if (!handler->extractPlayerTarget((char*)args, &target, NULL, &playerName))
56 return false;
57
58 GetPlayerInfo(handler, target);
59 return true;
60 }
61
62 static bool HandleLfgGroupInfoCommand(ChatHandler* handler, char const* args)
63 {
64 Player* target = NULL;
65 std::string playerName;
66 if (!handler->extractPlayerTarget((char*)args, &target, NULL, &playerName))
67 return false;
68
69 Group* grp = target->GetGroup();
70 if (!grp)
71 {
72 handler->PSendSysMessage(LANG_LFG_NOT_IN_GROUP, playerName.c_str());
73 return true;
74 }
75
76 uint64 guid = grp->GetGUID();
77 std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid));
79 state.c_str(), sLFGMgr->GetDungeon(guid));
80 handler->SendSysMessage(sLFGMgr->DumpGroupInfo(guid).c_str());
81
82 for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
83 GetPlayerInfo(handler, itr->GetSource());
84
85 return true;
86 }
87
88 static bool HandleLfgOptionsCommand(ChatHandler* handler, char const* args)
89 {
90 int32 options = -1;
91 if (char* str = strtok((char*)args, " "))
92 {
93 int32 tmp = atoi(str);
94 if (tmp > -1)
95 options = tmp;
96 }
97
98 if (options != -1)
99 {
100 sLFGMgr->SetOptions(options);
102 }
103 handler->PSendSysMessage(LANG_LFG_OPTIONS, sLFGMgr->GetOptions());
104 return true;
105 }
106
107 static bool HandleLfgQueueInfoCommand(ChatHandler* handler, char const* args)
108 {
109 bool full = args && *args;
110 handler->SendSysMessage(sLFGMgr->DumpQueueInfo(full).c_str());
111 return true;
112 }
113
114 static bool HandleLfgCleanCommand(ChatHandler* handler, char const* /*args*/)
115 {
117 sLFGMgr->Clean();
118 return true;
119 }
120};
121
123{
124 new lfg_commandscript();
125}
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
#define OVERRIDE
Definition Define.h:60
std::uint64_t uint64
Definition Define.h:76
#define sLFGMgr
Definition LFGMgr.h:518
@ LANG_LFG_OPTIONS
Definition Language.h:1134
@ LANG_LFG_NOT_IN_GROUP
Definition Language.h:1132
@ LANG_LFG_GROUP_INFO
Definition Language.h:1131
@ LANG_LFG_PLAYER_INFO
Definition Language.h:1130
@ LANG_LFG_OPTIONS_CHANGED
Definition Language.h:1135
@ LANG_LFG_CLEAN
Definition Language.h:1133
void PSendSysMessage(const char *format,...) ATTR_PRINTF(2
Definition Chat.cpp:221
bool extractPlayerTarget(char *args, Player **player, uint64 *player_guid=NULL, std::string *player_name=NULL)
Definition Chat.cpp:1184
virtual void SendSysMessage(const char *str)
Definition Chat.cpp:153
CommandScript(const char *name)
Definition Group.h:147
bool isLFGGroup() const
Definition Group.cpp:2543
uint64 GetGUID() const
Definition Group.cpp:2573
GroupReference * GetFirstMember()
Definition Group.h:225
GroupReference * next()
uint64 GetGUID() const
Definition Object.h:119
Group * GetGroup()
Definition Player.h:2972
std::string const & GetName() const
Definition Object.h:664
static bool HandleLfgQueueInfoCommand(ChatHandler *handler, char const *args)
Definition cs_lfg.cpp:107
std::vector< ChatCommand > GetCommands() const OVERRIDE
Definition cs_lfg.cpp:33
static bool HandleLfgGroupInfoCommand(ChatHandler *handler, char const *args)
Definition cs_lfg.cpp:62
static bool HandleLfgOptionsCommand(ChatHandler *handler, char const *args)
Definition cs_lfg.cpp:88
static bool HandleLfgPlayerInfoCommand(ChatHandler *handler, char const *args)
Definition cs_lfg.cpp:51
static bool HandleLfgCleanCommand(ChatHandler *handler, char const *)
Definition cs_lfg.cpp:114
void GetPlayerInfo(ChatHandler *handler, Player *player)
Definition cs_lfg.cpp:13
void AddSC_lfg_commandscript()
Definition cs_lfg.cpp:122
std::set< uint32 > LfgDungeonSet
Definition LFG.h:107
std::string GetStateString(LfgState state)
Definition LFG.cpp:70
std::string GetRolesString(uint8 roles)
Definition LFG.cpp:36
std::string ConcatenateDungeons(LfgDungeonSet const &dungeons)
Definition LFG.cpp:13
@ RBAC_PERM_COMMAND_LFG
Definition RBAC.h:318
@ RBAC_PERM_COMMAND_LFG_OPTIONS
Definition RBAC.h:323
@ RBAC_PERM_COMMAND_LFG_GROUP
Definition RBAC.h:320
@ RBAC_PERM_COMMAND_LFG_PLAYER
Definition RBAC.h:319
@ RBAC_PERM_COMMAND_LFG_QUEUE
Definition RBAC.h:321
@ RBAC_PERM_COMMAND_LFG_CLEAN
Definition RBAC.h:322