daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest Dec 11th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
  2. index 8660b04..5dfc322 100755
  3. --- a/src/server/game/Entities/Player/Player.cpp
  4. +++ b/src/server/game/Entities/Player/Player.cpp
  5. @@ -2408,6 +2408,10 @@ void Player::RemoveFromWorld()
  6.          UnsummonPetTemporaryIfAny();
  7.          sOutdoorPvPMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
  8.          sBattlefieldMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
  9. +
  10. +        if (Group* g = GetGroup())
  11. +            if (g->IsLeader(GetGUID()))
  12. +                g->HandleLeaderLogOut(this);
  13.      }
  14.  
  15.      ///- Do not add/remove the player from the object storage
  16.  
  17. diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp
  18. index fda04ef..ae08b23 100755
  19. --- a/src/server/game/Groups/Group.cpp
  20. +++ b/src/server/game/Groups/Group.cpp
  21. @@ -2413,3 +2413,40 @@ void Group::ToggleGroupMemberFlag(member_witerator slot, uint8 flag, bool apply)
  22.          slot->flags &= ~flag;
  23.  }
  24.  
  25. +void Group::HandleLeaderLogOut(Player* player)
  26. +{
  27. +    //! Find new potential leader
  28. +    member_citerator itr = m_memberSlots.begin();
  29. +    for (; itr != m_memberSlots.end(); ++itr)
  30. +        if (itr->flags & MEMBER_FLAG_ASSISTANT) //! First look for oldest assistant
  31. +            break;
  32. +
  33. +    //! If no assistant is found, choose the oldest member
  34. +    if (itr == m_memberSlots.end())
  35. +        itr = m_memberSlots.begin();
  36. +    
  37. +    //! This loop only exists just in case FindPlayer returns NULL
  38. +    Player* newLeader = NULL;
  39. +    while (!newLeader && itr != m_memberSlots.end())
  40. +    {
  41. +        newLeader = ObjectAccessor::FindPlayer(itr->guid);
  42. +        ++itr;
  43. +    }
  44. +
  45. +    if (!newLeader)
  46. +        return;
  47. +
  48. +    newLeader->m_Events.AddEvent(new GroupChangeLeaderEvent(newLeader), newLeader->m_Events.CalculateTime(CHANGELEADERDELAY));
  49. +    
  50. +}
  51. +
  52. +bool GroupChangeLeaderEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
  53. +{
  54. +    if (Group* group = _owner->GetGroup())
  55. +    {
  56. +        group->ChangeLeader(_owner->GetGUID());
  57. +        return true;
  58. +    }
  59. +
  60. +    return false;
  61. +}
  62.  
  63. diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h
  64. index de622a1..f6eb125 100755
  65. --- a/src/server/game/Groups/Group.h
  66. +++ b/src/server/game/Groups/Group.h
  67. @@ -45,6 +45,7 @@ struct MapEntry;
  68.  #define MAXRAIDSIZE 40
  69.  #define MAX_RAID_SUBGROUPS MAXRAIDSIZE/MAXGROUPSIZE
  70.  #define TARGETICONCOUNT 8
  71. +#define CHANGELEADERDELAY 2 * MINUTE * IN_MILLISECONDS
  72.  
  73.  enum RollVote
  74.  {
  75. @@ -201,6 +202,7 @@ class Group
  76.          void   SetLootThreshold(ItemQualities threshold);
  77.          void   Disband(bool hideDestroy=false);
  78.          void   SetLfgRoles(uint64 guid, const uint8 roles);
  79. +        void HandleLeaderLogOut(Player* player);
  80.  
  81.          // properties accessories
  82.          bool IsFull() const;
  83. @@ -341,4 +343,14 @@ class Group
  84.          uint32              m_maxEnchantingLevel;
  85.          uint32              m_dbStoreId;                    // Represents the ID used in database (Can be reused by other groups if group was disbanded)
  86.  };
  87. +
  88. +class GroupChangeLeaderEvent : public BasicEvent
  89. +{
  90. +    public:
  91. +        GroupChangeLeaderEvent(Player* owner) : _owner(owner), BasicEvent() {};
  92. +        bool Execute(uint64 /*e_time*/, uint32 /*p_time*/);
  93. +
  94. +    private:
  95. +        Player* _owner;
  96. +};
  97.  #endif
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top