Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
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
13
void
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
28
class
lfg_commandscript
:
public
CommandScript
29
{
30
public
:
31
lfg_commandscript
() :
CommandScript
(
"lfg_commandscript"
) { }
32
33
std::vector<ChatCommand>
GetCommands
() const
OVERRIDE
34
{
35
static
std::vector<ChatCommand> lfgCommandTable =
36
{
37
{
"player"
,
rbac::RBAC_PERM_COMMAND_LFG_PLAYER
,
false
, &
HandleLfgPlayerInfoCommand
,
""
, },
38
{
"group"
,
rbac::RBAC_PERM_COMMAND_LFG_GROUP
,
false
, &
HandleLfgGroupInfoCommand
,
""
, },
39
{
"queue"
,
rbac::RBAC_PERM_COMMAND_LFG_QUEUE
,
false
, &
HandleLfgQueueInfoCommand
,
""
, },
40
{
"clean"
,
rbac::RBAC_PERM_COMMAND_LFG_CLEAN
,
false
, &
HandleLfgCleanCommand
,
""
, },
41
{
"options"
,
rbac::RBAC_PERM_COMMAND_LFG_OPTIONS
,
false
, &
HandleLfgOptionsCommand
,
""
, },
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));
78
handler->
PSendSysMessage
(
LANG_LFG_GROUP_INFO
, grp->
isLFGGroup
(),
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);
101
handler->
PSendSysMessage
(
LANG_LFG_OPTIONS_CHANGED
);
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
{
116
handler->
PSendSysMessage
(
LANG_LFG_CLEAN
);
117
sLFGMgr
->Clean();
118
return
true
;
119
}
120
};
121
122
void
AddSC_lfg_commandscript
()
123
{
124
new
lfg_commandscript
();
125
}
Chat.h
int32
std::int32_t int32
Definition
Define.h:73
uint8
std::uint8_t uint8
Definition
Define.h:79
OVERRIDE
#define OVERRIDE
Definition
Define.h:60
uint64
std::uint64_t uint64
Definition
Define.h:76
Group.h
LFGMgr.h
sLFGMgr
#define sLFGMgr
Definition
LFGMgr.h:518
Language.h
LANG_LFG_OPTIONS
@ LANG_LFG_OPTIONS
Definition
Language.h:1134
LANG_LFG_NOT_IN_GROUP
@ LANG_LFG_NOT_IN_GROUP
Definition
Language.h:1132
LANG_LFG_GROUP_INFO
@ LANG_LFG_GROUP_INFO
Definition
Language.h:1131
LANG_LFG_PLAYER_INFO
@ LANG_LFG_PLAYER_INFO
Definition
Language.h:1130
LANG_LFG_OPTIONS_CHANGED
@ LANG_LFG_OPTIONS_CHANGED
Definition
Language.h:1135
LANG_LFG_CLEAN
@ LANG_LFG_CLEAN
Definition
Language.h:1133
Player.h
ScriptMgr.h
ChatHandler
Definition
Chat.h:41
ChatHandler::PSendSysMessage
void PSendSysMessage(const char *format,...) ATTR_PRINTF(2
Definition
Chat.cpp:221
ChatHandler::extractPlayerTarget
bool extractPlayerTarget(char *args, Player **player, uint64 *player_guid=NULL, std::string *player_name=NULL)
Definition
Chat.cpp:1184
ChatHandler::SendSysMessage
virtual void SendSysMessage(const char *str)
Definition
Chat.cpp:153
CommandScript::CommandScript
CommandScript(const char *name)
Definition
ScriptMgr.cpp:1466
Group
Definition
Group.h:147
Group::isLFGGroup
bool isLFGGroup() const
Definition
Group.cpp:2543
Group::GetGUID
uint64 GetGUID() const
Definition
Group.cpp:2573
Group::GetFirstMember
GroupReference * GetFirstMember()
Definition
Group.h:225
GroupReference
Definition
GroupReference.h:15
GroupReference::next
GroupReference * next()
Definition
GroupReference.h:24
Object::GetGUID
uint64 GetGUID() const
Definition
Object.h:119
Player
Definition
Player.h:1289
Player::GetGroup
Group * GetGroup()
Definition
Player.h:2972
WorldObject::GetName
std::string const & GetName() const
Definition
Object.h:664
lfg_commandscript
Definition
cs_lfg.cpp:29
lfg_commandscript::HandleLfgQueueInfoCommand
static bool HandleLfgQueueInfoCommand(ChatHandler *handler, char const *args)
Definition
cs_lfg.cpp:107
lfg_commandscript::GetCommands
std::vector< ChatCommand > GetCommands() const OVERRIDE
Definition
cs_lfg.cpp:33
lfg_commandscript::HandleLfgGroupInfoCommand
static bool HandleLfgGroupInfoCommand(ChatHandler *handler, char const *args)
Definition
cs_lfg.cpp:62
lfg_commandscript::lfg_commandscript
lfg_commandscript()
Definition
cs_lfg.cpp:31
lfg_commandscript::HandleLfgOptionsCommand
static bool HandleLfgOptionsCommand(ChatHandler *handler, char const *args)
Definition
cs_lfg.cpp:88
lfg_commandscript::HandleLfgPlayerInfoCommand
static bool HandleLfgPlayerInfoCommand(ChatHandler *handler, char const *args)
Definition
cs_lfg.cpp:51
lfg_commandscript::HandleLfgCleanCommand
static bool HandleLfgCleanCommand(ChatHandler *handler, char const *)
Definition
cs_lfg.cpp:114
GetPlayerInfo
void GetPlayerInfo(ChatHandler *handler, Player *player)
Definition
cs_lfg.cpp:13
AddSC_lfg_commandscript
void AddSC_lfg_commandscript()
Definition
cs_lfg.cpp:122
lfg::LfgDungeonSet
std::set< uint32 > LfgDungeonSet
Definition
LFG.h:107
lfg::GetStateString
std::string GetStateString(LfgState state)
Definition
LFG.cpp:70
lfg::GetRolesString
std::string GetRolesString(uint8 roles)
Definition
LFG.cpp:36
lfg::ConcatenateDungeons
std::string ConcatenateDungeons(LfgDungeonSet const &dungeons)
Definition
LFG.cpp:13
rbac::RBAC_PERM_COMMAND_LFG
@ RBAC_PERM_COMMAND_LFG
Definition
RBAC.h:318
rbac::RBAC_PERM_COMMAND_LFG_OPTIONS
@ RBAC_PERM_COMMAND_LFG_OPTIONS
Definition
RBAC.h:323
rbac::RBAC_PERM_COMMAND_LFG_GROUP
@ RBAC_PERM_COMMAND_LFG_GROUP
Definition
RBAC.h:320
rbac::RBAC_PERM_COMMAND_LFG_PLAYER
@ RBAC_PERM_COMMAND_LFG_PLAYER
Definition
RBAC.h:319
rbac::RBAC_PERM_COMMAND_LFG_QUEUE
@ RBAC_PERM_COMMAND_LFG_QUEUE
Definition
RBAC.h:321
rbac::RBAC_PERM_COMMAND_LFG_CLEAN
@ RBAC_PERM_COMMAND_LFG_CLEAN
Definition
RBAC.h:322
src
server
scripts
Commands
cs_lfg.cpp
Generated on
for Project SkyFire Core by
1.17.0