TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lfg::LFGGroupScript Class Reference

#include <LFGScripts.h>

Public Member Functions

 LFGGroupScript ()
 
void OnAddMember (Group *group, ObjectGuid guid) override
 
void OnRemoveMember (Group *group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, char const *reason) override
 
void OnDisband (Group *group) override
 
void OnChangeLeader (Group *group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid) override
 
void OnInviteMember (Group *group, ObjectGuid guid) override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Additional Inherited Members

- Protected Member Functions inherited from GroupScript
 GroupScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

lfg::LFGGroupScript::LFGGroupScript ( )
117 : GroupScript("LFGGroupScript") { }
GroupScript(const char *name)
Definition: ScriptMgr.cpp:1682

Member Function Documentation

void lfg::LFGGroupScript::OnAddMember ( Group group,
ObjectGuid  guid 
)
overridevirtual

Reimplemented from GroupScript.

120 {
122  return;
123 
124  ObjectGuid gguid = group->GetGUID();
125  ObjectGuid leader = group->GetLeaderGUID();
126 
127  if (leader == guid)
128  {
129  TC_LOG_DEBUG("lfg", "LFGScripts::OnAddMember [%s]: added [%s] leader [%s]", gguid.ToString().c_str(), guid.ToString().c_str(), leader.ToString().c_str());
130  sLFGMgr->SetLeader(gguid, guid);
131  }
132  else
133  {
134  LfgState gstate = sLFGMgr->GetState(gguid);
135  LfgState state = sLFGMgr->GetState(guid);
136  TC_LOG_DEBUG("lfg", "LFGScripts::OnAddMember [%s]: added [%s] leader [%s] gstate: %u, state: %u", gguid.ToString().c_str(), guid.ToString().c_str(), leader.ToString().c_str(), gstate, state);
137 
138  if (state == LFG_STATE_QUEUED)
139  sLFGMgr->LeaveLfg(guid);
140 
141  if (gstate == LFG_STATE_QUEUED)
142  sLFGMgr->LeaveLfg(gguid);
143  }
144 
145  sLFGMgr->SetGroup(guid, gguid);
146  sLFGMgr->AddPlayerToGroup(gguid, guid);
147 }
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2529
ObjectGuid GetGUID() const
Definition: Group.cpp:2534
LfgState
Definition: LFG.h:65
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: LFG.h:69
#define sLFGMgr
Definition: LFGMgr.h:481
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void lfg::LFGGroupScript::OnChangeLeader ( Group group,
ObjectGuid  newLeaderGuid,
ObjectGuid  oldLeaderGuid 
)
overridevirtual

Reimplemented from GroupScript.

215 {
217  return;
218 
219  ObjectGuid gguid = group->GetGUID();
220 
221  TC_LOG_DEBUG("lfg", "LFGScripts::OnChangeLeader [%s]: old [%s] new [%s]",
222  gguid.ToString().c_str(), newLeaderGuid.ToString().c_str(), oldLeaderGuid.ToString().c_str());
223 
224  sLFGMgr->SetLeader(gguid, newLeaderGuid);
225 }
ObjectGuid GetGUID() const
Definition: Group.cpp:2534
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sLFGMgr
Definition: LFGMgr.h:481
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void lfg::LFGGroupScript::OnDisband ( Group group)
overridevirtual

Reimplemented from GroupScript.

204 {
206  return;
207 
208  ObjectGuid gguid = group->GetGUID();
209  TC_LOG_DEBUG("lfg", "LFGScripts::OnDisband [%s]", gguid.ToString().c_str());
210 
211  sLFGMgr->RemoveGroupData(gguid);
212 }
ObjectGuid GetGUID() const
Definition: Group.cpp:2534
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sLFGMgr
Definition: LFGMgr.h:481
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void lfg::LFGGroupScript::OnInviteMember ( Group group,
ObjectGuid  guid 
)
overridevirtual

Reimplemented from GroupScript.

228 {
230  return;
231 
232  ObjectGuid gguid = group->GetGUID();
233  ObjectGuid leader = group->GetLeaderGUID();
234  TC_LOG_DEBUG("lfg", "LFGScripts::OnInviteMember [%s]: invite [%s] leader [%s]",
235  gguid.ToString().c_str(), guid.ToString().c_str(), leader.ToString().c_str());
236 
237  // No gguid == new group being formed
238  // No leader == after group creation first invite is new leader
239  // leader and no gguid == first invite after leader is added to new group (this is the real invite)
240  if (!leader.IsEmpty() && gguid.IsEmpty())
241  sLFGMgr->LeaveLfg(leader);
242 }
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2529
ObjectGuid GetGUID() const
Definition: Group.cpp:2534
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sLFGMgr
Definition: LFGMgr.h:481
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

void lfg::LFGGroupScript::OnRemoveMember ( Group group,
ObjectGuid  guid,
RemoveMethod  method,
ObjectGuid  kicker,
char const reason 
)
overridevirtual
Todo:
  • Update internal kick cooldown of kicker

Reimplemented from GroupScript.

150 {
152  return;
153 
154  ObjectGuid gguid = group->GetGUID();
155  TC_LOG_DEBUG("lfg", "LFGScripts::OnRemoveMember [%s]: remove [%s] Method: %d Kicker: [%s] Reason: %s",
156  gguid.ToString().c_str(), guid.ToString().c_str(), method, kicker.ToString().c_str(), (reason ? reason : ""));
157 
158  bool isLFG = group->isLFGGroup();
159 
160  if (isLFG && method == GROUP_REMOVEMETHOD_KICK) // Player have been kicked
161  {
163  std::string str_reason = "";
164  if (reason)
165  str_reason = std::string(reason);
166  sLFGMgr->InitBoot(gguid, kicker, guid, str_reason);
167  return;
168  }
169 
170  LfgState state = sLFGMgr->GetState(gguid);
171 
172  // If group is being formed after proposal success do nothing more
173  if (state == LFG_STATE_PROPOSAL && method == GROUP_REMOVEMETHOD_DEFAULT)
174  {
175  // LfgData: Remove player from group
176  sLFGMgr->SetGroup(guid, ObjectGuid::Empty);
177  sLFGMgr->RemovePlayerFromGroup(gguid, guid);
178  return;
179  }
180 
181  sLFGMgr->LeaveLfg(guid);
182  sLFGMgr->SetGroup(guid, ObjectGuid::Empty);
183  uint8 players = sLFGMgr->RemovePlayerFromGroup(gguid, guid);
184 
185  if (Player* player = ObjectAccessor::FindPlayer(guid))
186  {
187  if (method == GROUP_REMOVEMETHOD_LEAVE && state == LFG_STATE_DUNGEON &&
188  players >= LFG_GROUP_KICK_VOTES_NEEDED)
189  player->CastSpell(player, LFG_SPELL_DUNGEON_DESERTER, true);
190  //else if (state == LFG_STATE_BOOT)
191  // Update internal kick cooldown of kicked
192 
193  player->GetSession()->SendLfgUpdateStatus(LfgUpdateData(LFG_UPDATETYPE_LEADER_UNK1), true);
194  if (isLFG && player->GetMap()->IsDungeon()) // Teleport player out the dungeon
195  sLFGMgr->TeleportPlayer(player, true);
196  }
197 
198  if (isLFG && state != LFG_STATE_FINISHED_DUNGEON) // Need more players to finish the dungeon
199  if (Player* leader = ObjectAccessor::FindConnectedPlayer(sLFGMgr->GetLeader(gguid)))
200  leader->GetSession()->SendLfgOfferContinue(sLFGMgr->GetDungeon(gguid, false));
201 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: LFGMgr.h:50
ObjectGuid GetGUID() const
Definition: Group.cpp:2534
LfgState
Definition: LFG.h:65
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: LFG.h:72
Definition: LFGMgr.h:48
Definition: LFG.h:70
Definition: SharedDefines.h:4688
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
#define sLFGMgr
Definition: LFGMgr.h:481
Definition: SharedDefines.h:4689
bool isLFGGroup() const
Definition: Group.cpp:2504
Definition: SharedDefines.h:4687
uint8_t uint8
Definition: Define.h:152
Definition: ObjectGuid.h:189
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:


The documentation for this class was generated from the following files: