AzeorthCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
lfg::LFGGroupScript Class Reference

#include "LFGScripts.h"

Inheritance diagram for lfg::LFGGroupScript:
GroupScript ScriptObject

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 GroupScript
bool IsDatabaseBound () const override
 
virtual void OnAddMember (Group *, ObjectGuid)
 
virtual void OnInviteMember (Group *, ObjectGuid)
 
virtual void OnRemoveMember (Group *, ObjectGuid, RemoveMethod, ObjectGuid, const char *)
 
virtual void OnChangeLeader (Group *, ObjectGuid, ObjectGuid)
 
virtual void OnDisband (Group *)
 
virtual bool CanGroupJoinBattlegroundQueue (Group const *, Player *, Battleground const *, uint32, bool, uint32)
 
virtual void OnCreate (Group *, Player *)
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
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 ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ LFGGroupScript()

lfg::LFGGroupScript::LFGGroupScript ( )
132 : GroupScript("LFGGroupScript")
133 {
134 }
Definition: ScriptMgr.h:1529

Member Function Documentation

◆ OnAddMember()

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

Reimplemented from GroupScript.

137 {
139 return;
140
141 ObjectGuid gguid = group->GetGUID();
142 ObjectGuid leader = group->GetLeaderGUID();
143
144 if (leader == guid)
145 {
146 LOG_DEBUG("lfg", "LFGScripts::OnAddMember [{}]: added [{}] leader [{}]", gguid.ToString(), guid.ToString(), leader.ToString());
147 sLFGMgr->SetLeader(gguid, guid);
148 }
149 else
150 {
151 LfgState gstate = sLFGMgr->GetState(gguid);
152 LfgState state = sLFGMgr->GetState(guid);
153 LOG_DEBUG("lfg", "LFGScripts::OnAddMember [{}]: added [{}] leader [{}] gstate: {}, state: {}",
154 gguid.ToString(), guid.ToString(), leader.ToString(), gstate, state);
155
156 if (state == LFG_STATE_QUEUED)
157 sLFGMgr->LeaveLfg(guid);
158
159 if (gstate == LFG_STATE_QUEUED)
160 sLFGMgr->LeaveLfg(gguid);
161 }
162
163 if (!group->isLFGGroup())
164 {
165 sLFGMgr->LeaveAllLfgQueues(leader, true, gguid); // pussywizard: invited, queued, party formed, neither party nor new member are queued, but leader is in queue solo!
166 sLFGMgr->LeaveAllLfgQueues(guid, false);
167 }
168
169 sLFGMgr->SetGroup(guid, gguid);
170 sLFGMgr->AddPlayerToGroup(gguid, guid);
171
172 // pussywizard: after all necessary actions handle raid browser
173 if (sLFGMgr->GetState(guid) == LFG_STATE_RAIDBROWSER)
174 sLFGMgr->LeaveLfg(guid);
175 }
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
#define sLFGMgr
Definition: LFGMgr.h:638
@ LFG_OPTION_ENABLE_SEASONAL_BOSSES
Definition: LFGMgr.h:43
@ LFG_OPTION_ENABLE_DUNGEON_FINDER
Definition: LFGMgr.h:41
@ LFG_OPTION_ENABLE_RAID_BROWSER
Definition: LFGMgr.h:42
LfgState
Definition: LFG.h:70
@ LFG_STATE_RAIDBROWSER
Definition: LFG.h:78
@ LFG_STATE_QUEUED
Definition: LFG.h:73
Definition: ObjectGuid.h:120
std::string ToString() const
Definition: ObjectGuid.cpp:47
bool isLFGGroup(bool restricted=false) const
Definition: Group.cpp:2205
ObjectGuid GetGUID() const
Definition: Group.cpp:2241
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2231

References Group::GetGUID(), Group::GetLeaderGUID(), Group::isLFGGroup(), lfg::LFG_OPTION_ENABLE_DUNGEON_FINDER, lfg::LFG_OPTION_ENABLE_RAID_BROWSER, lfg::LFG_OPTION_ENABLE_SEASONAL_BOSSES, lfg::LFG_STATE_QUEUED, lfg::LFG_STATE_RAIDBROWSER, LOG_DEBUG, sLFGMgr, and ObjectGuid::ToString().

◆ OnChangeLeader()

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

Reimplemented from GroupScript.

263 {
265 return;
266
267 ObjectGuid gguid = group->GetGUID();
268
269 LOG_DEBUG("lfg", "LFGScripts::OnChangeLeader [{}]: old [{}] new [{}]",
270 gguid.ToString(), newLeaderGuid.ToString(), oldLeaderGuid.ToString());
271 sLFGMgr->SetLeader(gguid, newLeaderGuid);
272
273 // pussywizard: after all necessary actions handle raid browser
274 if (sLFGMgr->GetState(oldLeaderGuid) == LFG_STATE_RAIDBROWSER)
275 sLFGMgr->LeaveLfg(oldLeaderGuid);
276 }

References Group::GetGUID(), lfg::LFG_OPTION_ENABLE_DUNGEON_FINDER, lfg::LFG_OPTION_ENABLE_RAID_BROWSER, lfg::LFG_OPTION_ENABLE_SEASONAL_BOSSES, lfg::LFG_STATE_RAIDBROWSER, LOG_DEBUG, sLFGMgr, and ObjectGuid::ToString().

◆ OnDisband()

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

Reimplemented from GroupScript.

248 {
250 return;
251
252 ObjectGuid gguid = group->GetGUID();
253 LOG_DEBUG("lfg", "LFGScripts::OnDisband [{}]", gguid.ToString());
254
255 // pussywizard: after all necessary actions handle raid browser
256 if (sLFGMgr->GetState(group->GetLeaderGUID()) == LFG_STATE_RAIDBROWSER)
257 sLFGMgr->LeaveLfg(group->GetLeaderGUID());
258
259 sLFGMgr->RemoveGroupData(gguid);
260 }

References Group::GetGUID(), Group::GetLeaderGUID(), lfg::LFG_OPTION_ENABLE_DUNGEON_FINDER, lfg::LFG_OPTION_ENABLE_RAID_BROWSER, lfg::LFG_OPTION_ENABLE_SEASONAL_BOSSES, lfg::LFG_STATE_RAIDBROWSER, LOG_DEBUG, sLFGMgr, and ObjectGuid::ToString().

◆ OnInviteMember()

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

Reimplemented from GroupScript.

279 {
280 // used only with EXTRA_LOGS
281 (void)guid;
282
284 return;
285
286 ObjectGuid gguid = group->GetGUID();
287 ObjectGuid leader = group->GetLeaderGUID();
288 LOG_DEBUG("lfg", "LFGScripts::OnInviteMember [{}]: invite [{}] leader [{}]", gguid.ToString(), guid.ToString(), leader.ToString());
289 // No gguid == new group being formed
290 // No leader == after group creation first invite is new leader
291 // leader and no gguid == first invite after leader is added to new group (this is the real invite)
292 if (leader && !gguid)
293 {
294 sLFGMgr->LeaveLfg(leader);
295 sLFGMgr->LeaveAllLfgQueues(leader, true);
296 }
297 }

References Group::GetGUID(), Group::GetLeaderGUID(), lfg::LFG_OPTION_ENABLE_DUNGEON_FINDER, lfg::LFG_OPTION_ENABLE_RAID_BROWSER, lfg::LFG_OPTION_ENABLE_SEASONAL_BOSSES, LOG_DEBUG, sLFGMgr, and ObjectGuid::ToString().

◆ OnRemoveMember()

void lfg::LFGGroupScript::OnRemoveMember ( Group group,
ObjectGuid  guid,
RemoveMethod  method,
ObjectGuid  kicker,
char const *  reason 
)
overridevirtual

Reimplemented from GroupScript.

178 {
179 // used only with EXTRA_LOGS
180 (void)kicker;
181 (void)reason;
182
184 return;
185
186 ObjectGuid gguid = group->GetGUID();
187 LOG_DEBUG("lfg", "LFGScripts::OnRemoveMember [{}]: remove [{}] Method: {} Kicker: [{}] Reason: {}",
188 gguid.ToString(), guid.ToString(), method, kicker.ToString(), (reason ? reason : ""));
189
190 bool isLFG = group->isLFGGroup();
191 LfgState state = sLFGMgr->GetState(gguid);
192 uint32 dungeonId = sLFGMgr->GetDungeon(gguid, false);
193
194 // If group is being formed after proposal success do nothing more
195 if (state == LFG_STATE_PROPOSAL && method == GROUP_REMOVEMETHOD_DEFAULT)
196 {
197 // LfgData: Remove player from group
198 sLFGMgr->SetGroup(guid, ObjectGuid::Empty);
199 sLFGMgr->RemovePlayerFromGroup(gguid, guid);
200 return;
201 }
202
203 sLFGMgr->LeaveLfg(guid);
204 sLFGMgr->LeaveAllLfgQueues(guid, true, gguid);
205 sLFGMgr->SetGroup(guid, ObjectGuid::Empty);
206 uint8 players = sLFGMgr->RemovePlayerFromGroup(gguid, guid);
207
208 // pussywizard: after all necessary actions handle raid browser
209 // pussywizard: already done above
210 //if (sLFGMgr->GetState(guid) == LFG_STATE_RAIDBROWSER)
211 // sLFGMgr->LeaveLfg(guid);
212
213 // Xinef: only LFG groups can go below
214 if (!isLFG)
215 return;
216
217 if (state != LFG_STATE_FINISHED_DUNGEON && group) // Need more players to finish the dungeon
218 {
219 if (Player* leader = ObjectAccessor::FindConnectedPlayer(sLFGMgr->GetLeader(gguid)))
220 {
221 sLFGMgr->SetDungeon(gguid, dungeonId);
222 leader->GetSession()->SendLfgOfferContinue(sLFGMgr->GetDungeon(gguid, false));
223 }
224 }
225
227 {
228 // xinef: fixed dungeon deserter
230 player->HasAura(LFG_SPELL_DUNGEON_COOLDOWN) && players >= LFG_GROUP_KICK_VOTES_NEEDED)
231 {
232 player->AddAura(LFG_SPELL_DUNGEON_DESERTER, player);
233 }
234 //else if (state == LFG_STATE_BOOT)
235 // Update internal kick cooldown of kicked
236
237 player->GetSession()->SendLfgUpdateParty(LfgUpdateData(LFG_UPDATETYPE_LEADER_UNK1));
238 if (player->GetMap()->IsDungeon()) // Teleport player out the dungeon
239 {
240 // Xinef: no longer valid sLFGMgr->TeleportPlayer(player, true);
241 if (!player->IsBeingTeleportedFar() && player->GetMapId() == sLFGMgr->GetDungeonMapId(gguid))
242 player->TeleportToEntryPoint();
243 }
244 }
245 }
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
@ GROUP_REMOVEMETHOD_KICK_LFG
Definition: SharedDefines.h:3562
@ GROUP_REMOVEMETHOD_DEFAULT
Definition: SharedDefines.h:3559
@ LFG_STATE_FINISHED_DUNGEON
Definition: LFG.h:77
@ LFG_STATE_PROPOSAL
Definition: LFG.h:74
@ LFG_UPDATETYPE_LEADER_UNK1
Definition: LFG.h:52
@ LFG_SPELL_DUNGEON_COOLDOWN
Definition: LFGMgr.h:52
@ LFG_GROUP_KICK_VOTES_NEEDED
Definition: LFGMgr.h:55
@ LFG_SPELL_DUNGEON_DESERTER
Definition: LFGMgr.h:53
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:262
static ObjectGuid const Empty
Definition: ObjectGuid.h:122
Definition: Player.h:1046

References ObjectGuid::Empty, ObjectAccessor::FindConnectedPlayer(), Group::GetGUID(), GROUP_REMOVEMETHOD_DEFAULT, GROUP_REMOVEMETHOD_KICK_LFG, Group::isLFGGroup(), lfg::LFG_GROUP_KICK_VOTES_NEEDED, lfg::LFG_OPTION_ENABLE_DUNGEON_FINDER, lfg::LFG_OPTION_ENABLE_RAID_BROWSER, lfg::LFG_OPTION_ENABLE_SEASONAL_BOSSES, lfg::LFG_SPELL_DUNGEON_COOLDOWN, lfg::LFG_SPELL_DUNGEON_DESERTER, lfg::LFG_STATE_FINISHED_DUNGEON, lfg::LFG_STATE_PROPOSAL, lfg::LFG_UPDATETYPE_LEADER_UNK1, LOG_DEBUG, sLFGMgr, and ObjectGuid::ToString().