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

#include <LFGScripts.h>

Public Member Functions

 LFGPlayerScript ()
 
void OnLogout (Player *player) override
 
void OnLogin (Player *player, bool loginFirst) override
 
void OnMapChanged (Player *player) override
 
- Public Member Functions inherited from PlayerScript
virtual void OnPVPKill (Player *, Player *)
 
virtual void OnCreatureKill (Player *, Creature *)
 
virtual void OnPlayerKilledByCreature (Creature *, Player *)
 
virtual void OnLevelChanged (Player *, uint8)
 
virtual void OnFreeTalentPointsChanged (Player *, uint32)
 
virtual void OnTalentsReset (Player *, bool)
 
virtual void OnMoneyChanged (Player *, int64 &)
 
virtual void OnMoneyLimit (Player *, int64)
 
virtual void OnGiveXP (Player *, uint32 &, Unit *)
 
virtual void OnReputationChange (Player *, uint32, int32 &, bool)
 
virtual void OnDuelRequest (Player *, Player *)
 
virtual void OnDuelStart (Player *, Player *)
 
virtual void OnDuelEnd (Player *, Player *, DuelCompleteType)
 
virtual void OnChat (Player *, uint32, uint32, std::string &)
 
virtual void OnChat (Player *, uint32, uint32, std::string &, Player *)
 
virtual void OnChat (Player *, uint32, uint32, std::string &, Group *)
 
virtual void OnChat (Player *, uint32, uint32, std::string &, Guild *)
 
virtual void OnChat (Player *, uint32, uint32, std::string &, Channel *)
 
virtual void OnClearEmote (Player *)
 
virtual void OnTextEmote (Player *, uint32, uint32, ObjectGuid)
 
virtual void OnSpellCast (Player *, Spell *, bool)
 
virtual void OnCreate (Player *)
 
virtual void OnDelete (ObjectGuid, uint32)
 
virtual void OnFailedDelete (ObjectGuid, uint32)
 
virtual void OnSave (Player *)
 
virtual void OnBindToInstance (Player *, Difficulty, uint32, bool, uint8)
 
virtual void OnUpdateZone (Player *, uint32, uint32)
 
virtual void OnQuestStatusChange (Player *, uint32, QuestStatus)
 
- Public Member Functions inherited from UnitScript
virtual void OnHeal (Unit *, Unit *, uint32 &)
 
virtual void OnDamage (Unit *, Unit *, uint32 &)
 
virtual void ModifyPeriodicDamageAurasTick (Unit *, Unit *, uint32 &)
 
virtual void ModifyMeleeDamage (Unit *, Unit *, uint32 &)
 
virtual void ModifySpellDamageTaken (Unit *, Unit *, int32 &)
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Additional Inherited Members

- Protected Member Functions inherited from PlayerScript
 PlayerScript (const char *name)
 
- Protected Member Functions inherited from UnitScript
 UnitScript (const char *name, bool addToScripts=true)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

lfg::LFGPlayerScript::LFGPlayerScript ( )
35 : PlayerScript("LFGPlayerScript") { }
PlayerScript(const char *name)
Definition: ScriptMgr.cpp:1664

Member Function Documentation

void lfg::LFGPlayerScript::OnLogin ( Player *  player,
bool  loginFirst 
)
overridevirtual
Todo:
  • Restore LfgPlayerData and send proper status to player if it was in a group

Reimplemented from PlayerScript.

52 {
54  return;
55 
56  // Temporal: Trying to determine when group data and LFG data gets desynched
57  ObjectGuid guid = player->GetGUID();
58  ObjectGuid gguid = sLFGMgr->GetGroup(guid);
59 
60  if (Group const* group = player->GetGroup())
61  {
62  ObjectGuid gguid2 = group->GetGUID();
63  if (gguid != gguid2)
64  {
65  TC_LOG_ERROR("lfg", "%s on group %s but LFG has group %s saved... Fixing.",
66  player->GetSession()->GetPlayerInfo().c_str(), gguid2.ToString().c_str(), gguid.ToString().c_str());
67  sLFGMgr->SetupGroupMember(guid, group->GetGUID());
68  }
69  }
70 
71  sLFGMgr->SetTeam(player->GetGUID(), player->GetTeam());
73 }
#define sLFGMgr
Definition: LFGMgr.h:481
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Group.h:191

+ Here is the call graph for this function:

void lfg::LFGPlayerScript::OnLogout ( Player *  player)
overridevirtual

Reimplemented from PlayerScript.

38 {
40  return;
41 
42  if (!player->GetGroup())
43  {
44  player->GetSession()->SendLfgLfrList(false);
45  sLFGMgr->LeaveLfg(player->GetGUID());
46  }
47  else if (player->GetSession()->PlayerDisconnected())
48  sLFGMgr->LeaveLfg(player->GetGUID(), true);
49 }
#define sLFGMgr
Definition: LFGMgr.h:481
void lfg::LFGPlayerScript::OnMapChanged ( Player *  player)
overridevirtual

Reimplemented from PlayerScript.

76 {
77  Map const* map = player->GetMap();
78 
79  if (sLFGMgr->inLfgDungeonMap(player->GetGUID(), map->GetId(), map->GetDifficultyID()))
80  {
81  Group* group = player->GetGroup();
82  // This function is also called when players log in
83  // if for some reason the LFG system recognises the player as being in a LFG dungeon,
84  // but the player was loaded without a valid group, we'll teleport to homebind to prevent
85  // crashes or other undefined behaviour
86  if (!group)
87  {
88  sLFGMgr->LeaveLfg(player->GetGUID());
89  player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW);
90  player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, 0.0f);
91  TC_LOG_ERROR("lfg", "LFGPlayerScript::OnMapChanged, Player %s (%s) is in LFG dungeon map but does not have a valid group! "
92  "Teleporting to homebind.", player->GetName().c_str(), player->GetGUID().ToString().c_str());
93  return;
94  }
95 
96  for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
97  if (Player* member = itr->GetSource())
98  player->GetSession()->SendNameQueryOpcode(member->GetGUID());
99 
100  if (sLFGMgr->selectedRandomLfgDungeon(player->GetGUID()))
101  player->CastSpell(player, LFG_SPELL_LUCK_OF_THE_DRAW, true);
102  }
103  else
104  {
105  Group* group = player->GetGroup();
106  if (group && group->GetMembersCount() == 1)
107  {
108  sLFGMgr->LeaveLfg(group->GetGUID());
109  group->Disband();
110  TC_LOG_DEBUG("lfg", "LFGPlayerScript::OnMapChanged, Player %s(%s) is last in the lfggroup so we disband the group.",
111  player->GetName().c_str(), player->GetGUID().ToString().c_str());
112  }
113  player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW);
114  }
115 }
Definition: LFGMgr.h:49
ObjectGuid GetGUID() const
Definition: Group.cpp:2534
Difficulty GetDifficultyID() const
Definition: Map.h:390
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetId(void) const
Definition: Map.h:325
#define sLFGMgr
Definition: LFGMgr.h:481
GroupReference * GetFirstMember()
Definition: Group.h:295
Definition: Map.h:259
void Disband(bool hideDestroy=false)
Definition: Group.cpp:757
uint32 GetMembersCount() const
Definition: Group.h:297
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Group.h:191
Definition: GroupReference.h:27

+ Here is the call graph for this function:


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