AzerothCore 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
 
uint16 GetTotalAvailableHooks ()
 

Additional Inherited Members

- Protected Member Functions inherited from GroupScript
 GroupScript (const char *name, std::vector< uint16 > enabledHooks=std::vector< uint16 >())
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ LFGGroupScript()

lfg::LFGGroupScript::LFGGroupScript ( )
143 :
144 GroupScript("LFGGroupScript",
145 {
151 })
152 {
153 }
@ GROUPHOOK_ON_CHANGE_LEADER
Definition: GroupScript.h:30
@ GROUPHOOK_ON_ADD_MEMBER
Definition: GroupScript.h:27
@ GROUPHOOK_ON_INVITE_MEMBER
Definition: GroupScript.h:28
@ GROUPHOOK_ON_REMOVE_MEMBER
Definition: GroupScript.h:29
@ GROUPHOOK_ON_DISBAND
Definition: GroupScript.h:31
Definition: GroupScript.h:40

References GROUPHOOK_ON_ADD_MEMBER, GROUPHOOK_ON_CHANGE_LEADER, GROUPHOOK_ON_DISBAND, GROUPHOOK_ON_INVITE_MEMBER, and GROUPHOOK_ON_REMOVE_MEMBER.

Member Function Documentation

◆ OnAddMember()

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

Reimplemented from GroupScript.

156 {
158 return;
159
160 ObjectGuid gguid = group->GetGUID();
161 ObjectGuid leader = group->GetLeaderGUID();
162
163 if (leader == guid)
164 {
165 LOG_DEBUG("lfg", "LFGScripts::OnAddMember [{}]: added [{}] leader [{}]", gguid.ToString(), guid.ToString(), leader.ToString());
166 sLFGMgr->SetLeader(gguid, guid);
167 }
168 else
169 {
170 LfgState gstate = sLFGMgr->GetState(gguid);
171 LfgState state = sLFGMgr->GetState(guid);
172 LOG_DEBUG("lfg", "LFGScripts::OnAddMember [{}]: added [{}] leader [{}] gstate: {}, state: {}",
173 gguid.ToString(), guid.ToString(), leader.ToString(), gstate, state);
174
175 if (state == LFG_STATE_QUEUED)
176 sLFGMgr->LeaveLfg(guid);
177
178 if (gstate == LFG_STATE_QUEUED)
179 sLFGMgr->LeaveLfg(gguid);
180 }
181
182 if (!group->isLFGGroup())
183 {
184 sLFGMgr->LeaveAllLfgQueues(leader, true, gguid); // pussywizard: invited, queued, party formed, neither party nor new member are queued, but leader is in queue solo!
185 sLFGMgr->LeaveAllLfgQueues(guid, false);
186 }
187
188 sLFGMgr->SetGroup(guid, gguid);
189 sLFGMgr->AddPlayerToGroup(gguid, guid);
190
191 // pussywizard: after all necessary actions handle raid browser
192 if (sLFGMgr->GetState(guid) == LFG_STATE_RAIDBROWSER)
193 sLFGMgr->LeaveLfg(guid);
194 }
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
#define sLFGMgr
Definition: LFGMgr.h:641
@ 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:67
@ LFG_STATE_RAIDBROWSER
Definition: LFG.h:75
@ LFG_STATE_QUEUED
Definition: LFG.h:70
Definition: ObjectGuid.h:118
std::string ToString() const
Definition: ObjectGuid.cpp:47
bool isLFGGroup(bool restricted=false) const
Definition: Group.cpp:2261
ObjectGuid GetGUID() const
Definition: Group.cpp:2302
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2292

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.

283 {
285 return;
286
287 ObjectGuid gguid = group->GetGUID();
288
289 LOG_DEBUG("lfg", "LFGScripts::OnChangeLeader [{}]: old [{}] new [{}]",
290 gguid.ToString(), newLeaderGuid.ToString(), oldLeaderGuid.ToString());
291 sLFGMgr->SetLeader(gguid, newLeaderGuid);
292
293 // pussywizard: after all necessary actions handle raid browser
294 if (sLFGMgr->GetState(oldLeaderGuid) == LFG_STATE_RAIDBROWSER)
295 sLFGMgr->LeaveLfg(oldLeaderGuid);
296 }

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.

268 {
270 return;
271
272 ObjectGuid gguid = group->GetGUID();
273 LOG_DEBUG("lfg", "LFGScripts::OnDisband [{}]", gguid.ToString());
274
275 // pussywizard: after all necessary actions handle raid browser
276 if (sLFGMgr->GetState(group->GetLeaderGUID()) == LFG_STATE_RAIDBROWSER)
277 sLFGMgr->LeaveLfg(group->GetLeaderGUID());
278
279 sLFGMgr->RemoveGroupData(gguid);
280 }

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.

299 {
300 // used only with EXTRA_LOGS
301 (void)guid;
302
304 return;
305
306 ObjectGuid gguid = group->GetGUID();
307 ObjectGuid leader = group->GetLeaderGUID();
308 LOG_DEBUG("lfg", "LFGScripts::OnInviteMember [{}]: invite [{}] leader [{}]", gguid.ToString(), guid.ToString(), leader.ToString());
309 // No gguid == new group being formed
310 // No leader == after group creation first invite is new leader
311 // leader and no gguid == first invite after leader is added to new group (this is the real invite)
312 if (leader && !gguid)
313 {
314 sLFGMgr->LeaveLfg(leader);
315 sLFGMgr->LeaveAllLfgQueues(leader, true);
316 }
317 }

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.

197 {
198 // used only with EXTRA_LOGS
199 (void)kicker;
200 (void)reason;
201
203 return;
204
205 ObjectGuid gguid = group->GetGUID();
206 LOG_DEBUG("lfg", "LFGScripts::OnRemoveMember [{}]: remove [{}] Method: {} Kicker: [{}] Reason: {}",
207 gguid.ToString(), guid.ToString(), method, kicker.ToString(), (reason ? reason : ""));
208
209 bool isLFG = group->isLFGGroup();
210 LfgState state = sLFGMgr->GetState(gguid);
211 uint32 dungeonId = sLFGMgr->GetDungeon(gguid, false);
212
213 // If group is being formed after proposal success do nothing more
214 if (state == LFG_STATE_PROPOSAL && method == GROUP_REMOVEMETHOD_DEFAULT)
215 {
216 // LfgData: Remove player from group
217 sLFGMgr->SetGroup(guid, ObjectGuid::Empty);
218 sLFGMgr->RemovePlayerFromGroup(gguid, guid);
219 return;
220 }
221
222 sLFGMgr->LeaveLfg(guid);
223 sLFGMgr->LeaveAllLfgQueues(guid, true, gguid);
224 sLFGMgr->SetGroup(guid, ObjectGuid::Empty);
225 uint8 players = sLFGMgr->RemovePlayerFromGroup(gguid, guid);
226
227 // pussywizard: after all necessary actions handle raid browser
228 // pussywizard: already done above
229 //if (sLFGMgr->GetState(guid) == LFG_STATE_RAIDBROWSER)
230 // sLFGMgr->LeaveLfg(guid);
231
232 // Xinef: only LFG groups can go below
233 if (!isLFG)
234 return;
235
236 if (state != LFG_STATE_FINISHED_DUNGEON && group) // Need more players to finish the dungeon
237 {
238 if (Player* leader = ObjectAccessor::FindConnectedPlayer(sLFGMgr->GetLeader(gguid)))
239 {
240 sLFGMgr->SetDungeon(gguid, dungeonId);
241 leader->GetSession()->SendLfgOfferContinue(sLFGMgr->GetDungeon(gguid, false));
242 }
243 }
244
246 {
247 // xinef: fixed dungeon deserter
249 player->HasAura(LFG_SPELL_DUNGEON_COOLDOWN) && players >= LFG_GROUP_KICK_VOTES_NEEDED &&
250 sWorld->getBoolConfig(CONFIG_LFG_CAST_DESERTER))
251 {
252 player->AddAura(LFG_SPELL_DUNGEON_DESERTER, player);
253 }
254 //else if (state == LFG_STATE_BOOT)
255 // Update internal kick cooldown of kicked
256
257 player->GetSession()->SendLfgUpdateParty(LfgUpdateData(LFG_UPDATETYPE_LEADER_UNK1));
258 if (player->GetMap()->IsDungeon()) // Teleport player out the dungeon
259 {
260 // Xinef: no longer valid sLFGMgr->TeleportPlayer(player, true);
261 if (!player->IsBeingTeleportedFar() && player->GetMapId() == sLFGMgr->GetDungeonMapId(gguid))
262 player->TeleportToEntryPoint();
263 }
264 }
265 }
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
@ CONFIG_LFG_CAST_DESERTER
Definition: IWorld.h:137
@ GROUP_REMOVEMETHOD_KICK_LFG
Definition: SharedDefines.h:3590
@ GROUP_REMOVEMETHOD_DEFAULT
Definition: SharedDefines.h:3587
#define sWorld
Definition: World.h:443
@ LFG_STATE_FINISHED_DUNGEON
Definition: LFG.h:74
@ LFG_STATE_PROPOSAL
Definition: LFG.h:71
@ LFG_UPDATETYPE_LEADER_UNK1
Definition: LFG.h:49
@ 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:257
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
Definition: Player.h:1064

References CONFIG_LFG_CAST_DESERTER, 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, sWorld, and ObjectGuid::ToString().