mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[6897] Avoid DB access on uninvite from group.
Signed-off-by: hunuza <hunuza@gmail.com>
This commit is contained in:
parent
bc816b70fc
commit
ac2748a141
8 changed files with 113 additions and 79 deletions
|
|
@ -212,7 +212,7 @@ bool Group::AddInvite(Player *player)
|
||||||
|
|
||||||
RemoveInvite(player);
|
RemoveInvite(player);
|
||||||
|
|
||||||
m_invitees.insert(player->GetGUID());
|
m_invitees.insert(player);
|
||||||
|
|
||||||
player->SetGroupInvite(this);
|
player->SetGroupInvite(this);
|
||||||
|
|
||||||
|
|
@ -231,14 +231,7 @@ bool Group::AddLeaderInvite(Player *player)
|
||||||
|
|
||||||
uint32 Group::RemoveInvite(Player *player)
|
uint32 Group::RemoveInvite(Player *player)
|
||||||
{
|
{
|
||||||
for(InvitesList::iterator itr=m_invitees.begin(); itr!=m_invitees.end(); ++itr)
|
m_invitees.erase(player);
|
||||||
{
|
|
||||||
if((*itr) == player->GetGUID())
|
|
||||||
{
|
|
||||||
m_invitees.erase(itr);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
player->SetGroupInvite(NULL);
|
player->SetGroupInvite(NULL);
|
||||||
return GetMembersCount();
|
return GetMembersCount();
|
||||||
|
|
@ -247,14 +240,31 @@ uint32 Group::RemoveInvite(Player *player)
|
||||||
void Group::RemoveAllInvites()
|
void Group::RemoveAllInvites()
|
||||||
{
|
{
|
||||||
for(InvitesList::iterator itr=m_invitees.begin(); itr!=m_invitees.end(); ++itr)
|
for(InvitesList::iterator itr=m_invitees.begin(); itr!=m_invitees.end(); ++itr)
|
||||||
{
|
(*itr)->SetGroupInvite(NULL);
|
||||||
Player *invitee = objmgr.GetPlayer(*itr);
|
|
||||||
if(invitee)
|
|
||||||
invitee->SetGroupInvite(NULL);
|
|
||||||
}
|
|
||||||
m_invitees.clear();
|
m_invitees.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player* Group::GetInvited(const uint64& guid) const
|
||||||
|
{
|
||||||
|
for(InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr)
|
||||||
|
{
|
||||||
|
if((*itr)->GetGUID() == guid)
|
||||||
|
return (*itr);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player* Group::GetInvited(const std::string& name) const
|
||||||
|
{
|
||||||
|
for(InvitesList::const_iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr)
|
||||||
|
{
|
||||||
|
if((*itr)->GetName() == name)
|
||||||
|
return (*itr);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
bool Group::AddMember(const uint64 &guid, const char* name)
|
bool Group::AddMember(const uint64 &guid, const char* name)
|
||||||
{
|
{
|
||||||
if(!_addMember(guid, name))
|
if(!_addMember(guid, name))
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ class MANGOS_DLL_SPEC Group
|
||||||
typedef UNORDERED_MAP< uint32 /*mapId*/, InstanceGroupBind> BoundInstancesMap;
|
typedef UNORDERED_MAP< uint32 /*mapId*/, InstanceGroupBind> BoundInstancesMap;
|
||||||
protected:
|
protected:
|
||||||
typedef MemberSlotList::iterator member_witerator;
|
typedef MemberSlotList::iterator member_witerator;
|
||||||
typedef std::set<uint64> InvitesList;
|
typedef std::set<Player*> InvitesList;
|
||||||
|
|
||||||
typedef std::vector<Roll*> Rolls;
|
typedef std::vector<Roll*> Rolls;
|
||||||
|
|
||||||
|
|
@ -183,6 +183,17 @@ class MANGOS_DLL_SPEC Group
|
||||||
// member manipulation methods
|
// member manipulation methods
|
||||||
bool IsMember(const uint64& guid) const { return _getMemberCSlot(guid) != m_memberSlots.end(); }
|
bool IsMember(const uint64& guid) const { return _getMemberCSlot(guid) != m_memberSlots.end(); }
|
||||||
bool IsLeader(const uint64& guid) const { return (GetLeaderGUID() == guid); }
|
bool IsLeader(const uint64& guid) const { return (GetLeaderGUID() == guid); }
|
||||||
|
uint64 GetMemberGUID(const std::string& name)
|
||||||
|
{
|
||||||
|
for(member_citerator itr = m_memberSlots.begin(); itr != m_memberSlots.end(); ++itr)
|
||||||
|
{
|
||||||
|
if(itr->name == name)
|
||||||
|
{
|
||||||
|
return itr->guid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
bool IsAssistant(uint64 guid) const
|
bool IsAssistant(uint64 guid) const
|
||||||
{
|
{
|
||||||
member_citerator mslot = _getMemberCSlot(guid);
|
member_citerator mslot = _getMemberCSlot(guid);
|
||||||
|
|
@ -191,6 +202,8 @@ class MANGOS_DLL_SPEC Group
|
||||||
|
|
||||||
return mslot->assistant;
|
return mslot->assistant;
|
||||||
}
|
}
|
||||||
|
Player* GetInvited(const uint64& guid) const;
|
||||||
|
Player* GetInvited(const std::string& name) const;
|
||||||
|
|
||||||
bool SameSubGroup(uint64 guid1,const uint64& guid2) const
|
bool SameSubGroup(uint64 guid1,const uint64& guid2) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
-FIX sending PartyMemberStats
|
-FIX sending PartyMemberStats
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void WorldSession::SendPartyResult(PartyOperation operation, std::string member, PartyResult res)
|
void WorldSession::SendPartyResult(PartyOperation operation, const std::string& member, PartyResult res)
|
||||||
{
|
{
|
||||||
WorldPacket data(SMSG_PARTY_COMMAND_RESULT, (8+member.size()+1));
|
WorldPacket data(SMSG_PARTY_COMMAND_RESULT, (8+member.size()+1));
|
||||||
data << (uint32)operation;
|
data << (uint32)operation;
|
||||||
|
|
@ -246,17 +246,37 @@ void WorldSession::HandleGroupUninviteGuidOpcode(WorldPacket & recv_data)
|
||||||
uint64 guid;
|
uint64 guid;
|
||||||
recv_data >> guid;
|
recv_data >> guid;
|
||||||
|
|
||||||
if(_player->InBattleGround())
|
//can't uninvite yourself
|
||||||
|
if(guid == GetPlayer()->GetGUID())
|
||||||
{
|
{
|
||||||
SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_INVITE_RESTRICTED);
|
sLog.outError("WorldSession::HandleGroupUninviteGuidOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string membername;
|
PartyResult res = GetPlayer()->CanUninviteFromGroup();
|
||||||
if(!objmgr.GetPlayerNameByGUID(guid, membername))
|
if(res != PARTY_RESULT_OK)
|
||||||
return; // not found
|
{
|
||||||
|
SendPartyResult(PARTY_OP_LEAVE, "", res);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
HandleGroupUninvite(guid, membername);
|
Group* grp = GetPlayer()->GetGroup();
|
||||||
|
if(!grp)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(grp->IsMember(guid))
|
||||||
|
{
|
||||||
|
Player::RemoveFromGroup(grp,guid);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Player* plr = grp->GetInvited(guid))
|
||||||
|
{
|
||||||
|
plr->UninviteFromGroup();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SendPartyResult(PARTY_OP_LEAVE, "", PARTY_RESULT_NOT_IN_YOUR_PARTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandleGroupUninviteNameOpcode(WorldPacket & recv_data)
|
void WorldSession::HandleGroupUninviteNameOpcode(WorldPacket & recv_data)
|
||||||
|
|
@ -266,65 +286,41 @@ void WorldSession::HandleGroupUninviteNameOpcode(WorldPacket & recv_data)
|
||||||
std::string membername;
|
std::string membername;
|
||||||
recv_data >> membername;
|
recv_data >> membername;
|
||||||
|
|
||||||
if(_player->InBattleGround())
|
|
||||||
{
|
|
||||||
SendPartyResult(PARTY_OP_INVITE, membername, PARTY_RESULT_INVITE_RESTRICTED);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// player not found
|
// player not found
|
||||||
if(!normalizePlayerName(membername))
|
if(!normalizePlayerName(membername))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint64 guid = objmgr.GetPlayerGUIDByName(membername);
|
// can't uninvite yourself
|
||||||
|
if(GetPlayer()->GetName() == membername)
|
||||||
// player not found
|
|
||||||
if(!guid)
|
|
||||||
return;
|
|
||||||
|
|
||||||
HandleGroupUninvite(guid, membername);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WorldSession::HandleGroupUninvite(uint64 guid, std::string name)
|
|
||||||
{
|
|
||||||
Group *group = GetPlayer()->GetGroup();
|
|
||||||
if(!group)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(_player->InBattleGround())
|
|
||||||
{
|
{
|
||||||
SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_INVITE_RESTRICTED);
|
sLog.outError("WorldSession::HandleGroupUninviteNameOpcode: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player *player = objmgr.GetPlayer(guid);
|
PartyResult res = GetPlayer()->CanUninviteFromGroup();
|
||||||
|
if(res != PARTY_RESULT_OK)
|
||||||
/** error handling **/
|
|
||||||
if(!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
|
|
||||||
{
|
{
|
||||||
SendPartyResult(PARTY_OP_LEAVE, "", PARTY_RESULT_YOU_NOT_LEADER);
|
SendPartyResult(PARTY_OP_LEAVE, "", res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!group->IsMember(guid) && (player && player->GetGroupInvite() != group))
|
Group* grp = GetPlayer()->GetGroup();
|
||||||
|
if(!grp)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(uint64 guid = grp->GetMemberGUID(membername))
|
||||||
{
|
{
|
||||||
SendPartyResult(PARTY_OP_LEAVE, name, PARTY_RESULT_NOT_IN_YOUR_PARTY);
|
Player::RemoveFromGroup(grp,guid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(guid == GetPlayer()->GetGUID())
|
if(Player* plr = grp->GetInvited(membername))
|
||||||
{
|
{
|
||||||
sLog.outError("WorldSession::HandleGroupUninvite: leader %s(%d) tried to uninvite himself from the group.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
|
plr->UninviteFromGroup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/********************/
|
|
||||||
|
|
||||||
// everything's fine, do it
|
SendPartyResult(PARTY_OP_LEAVE, membername, PARTY_RESULT_NOT_IN_YOUR_PARTY);
|
||||||
|
|
||||||
if(player && player->GetGroupInvite()) // uninvite invitee
|
|
||||||
player->UninviteFromGroup();
|
|
||||||
else // uninvite member
|
|
||||||
Player::RemoveFromGroup(group,guid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::HandleGroupSetLeaderOpcode( WorldPacket & recv_data )
|
void WorldSession::HandleGroupSetLeaderOpcode( WorldPacket & recv_data )
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,7 @@ class Guild
|
||||||
{
|
{
|
||||||
return (members.find(LowGuid) != members.end());
|
return (members.find(LowGuid) != members.end());
|
||||||
}
|
}
|
||||||
MemberSlot* GetMemberSlot(std::string const& name, uint64& guid)
|
MemberSlot* GetMemberSlot(const std::string& name, uint64& guid)
|
||||||
{
|
{
|
||||||
for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
|
for(MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2024,23 +2024,23 @@ bool Player::IsInSameGroupWith(Player const* p) const
|
||||||
/// \todo Shouldn't we also check if there is no other invitees before disbanding the group?
|
/// \todo Shouldn't we also check if there is no other invitees before disbanding the group?
|
||||||
void Player::UninviteFromGroup()
|
void Player::UninviteFromGroup()
|
||||||
{
|
{
|
||||||
if(GetGroupInvite()) // uninvited invitee
|
Group* group = GetGroupInvite();
|
||||||
|
if(!group)
|
||||||
|
return;
|
||||||
|
|
||||||
|
group->RemoveInvite(this);
|
||||||
|
|
||||||
|
if(group->GetMembersCount() <= 1) // group has just 1 member => disband
|
||||||
{
|
{
|
||||||
Group* group = GetGroupInvite();
|
if(group->IsCreated())
|
||||||
group->RemoveInvite(this);
|
|
||||||
|
|
||||||
if(group->GetMembersCount() <= 1) // group has just 1 member => disband
|
|
||||||
{
|
{
|
||||||
if(group->IsCreated())
|
group->Disband(true);
|
||||||
{
|
objmgr.RemoveGroup(group);
|
||||||
group->Disband(true);
|
|
||||||
objmgr.RemoveGroup(group);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
group->RemoveAllInvites();
|
|
||||||
|
|
||||||
delete group;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
group->RemoveAllInvites();
|
||||||
|
|
||||||
|
delete group;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -18237,6 +18237,21 @@ Player* Player::GetNextRandomRaidMember(float radius)
|
||||||
return nearMembers[randTarget];
|
return nearMembers[randTarget];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PartyResult Player::CanUninviteFromGroup() const
|
||||||
|
{
|
||||||
|
const Group* grp = GetGroup();
|
||||||
|
if(!grp)
|
||||||
|
return PARTY_RESULT_YOU_NOT_IN_GROUP;
|
||||||
|
|
||||||
|
if(!grp->IsLeader(GetGUID()) && !grp->IsAssistant(GetGUID()))
|
||||||
|
return PARTY_RESULT_YOU_NOT_LEADER;
|
||||||
|
|
||||||
|
if(InBattleGround())
|
||||||
|
return PARTY_RESULT_INVITE_RESTRICTED;
|
||||||
|
|
||||||
|
return PARTY_RESULT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
void Player::UpdateUnderwaterState( Map* m, float x, float y, float z )
|
void Player::UpdateUnderwaterState( Map* m, float x, float y, float z )
|
||||||
{
|
{
|
||||||
float water_z = m->GetWaterLevel(x,y);
|
float water_z = m->GetWaterLevel(x,y);
|
||||||
|
|
|
||||||
|
|
@ -2026,6 +2026,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
uint64 GetAuraUpdateMask() { return m_auraUpdateMask; }
|
uint64 GetAuraUpdateMask() { return m_auraUpdateMask; }
|
||||||
void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); }
|
void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); }
|
||||||
Player* GetNextRandomRaidMember(float radius);
|
Player* GetNextRandomRaidMember(float radius);
|
||||||
|
PartyResult CanUninviteFromGroup() const;
|
||||||
|
|
||||||
GridReference<Player> &GetGridRef() { return m_gridRef; }
|
GridReference<Player> &GetGridRef() { return m_gridRef; }
|
||||||
MapReference &GetMapRef() { return m_mapRef; }
|
MapReference &GetMapRef() { return m_mapRef; }
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ class MANGOS_DLL_SPEC WorldSession
|
||||||
void SendNotification(int32 string_id,...);
|
void SendNotification(int32 string_id,...);
|
||||||
void SendPetNameInvalid(uint32 error, std::string name, DeclinedName *declinedName);
|
void SendPetNameInvalid(uint32 error, std::string name, DeclinedName *declinedName);
|
||||||
void SendLfgResult(uint32 type, uint32 entry, uint8 lfg_type);
|
void SendLfgResult(uint32 type, uint32 entry, uint8 lfg_type);
|
||||||
void SendPartyResult(PartyOperation operation, std::string member, PartyResult res);
|
void SendPartyResult(PartyOperation operation, const std::string& member, PartyResult res);
|
||||||
void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2,3);
|
void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2,3);
|
||||||
|
|
||||||
uint32 GetSecurity() const { return _security; }
|
uint32 GetSecurity() const { return _security; }
|
||||||
|
|
@ -332,7 +332,6 @@ class MANGOS_DLL_SPEC WorldSession
|
||||||
void HandleGroupDeclineOpcode(WorldPacket& recvPacket);
|
void HandleGroupDeclineOpcode(WorldPacket& recvPacket);
|
||||||
void HandleGroupUninviteNameOpcode(WorldPacket& recvPacket);
|
void HandleGroupUninviteNameOpcode(WorldPacket& recvPacket);
|
||||||
void HandleGroupUninviteGuidOpcode(WorldPacket& recvPacket);
|
void HandleGroupUninviteGuidOpcode(WorldPacket& recvPacket);
|
||||||
void HandleGroupUninvite(uint64 guid, std::string name);
|
|
||||||
void HandleGroupSetLeaderOpcode(WorldPacket& recvPacket);
|
void HandleGroupSetLeaderOpcode(WorldPacket& recvPacket);
|
||||||
void HandleGroupLeaveOpcode(WorldPacket& recvPacket);
|
void HandleGroupLeaveOpcode(WorldPacket& recvPacket);
|
||||||
void HandleGroupPassOnLootOpcode( WorldPacket &recv_data );
|
void HandleGroupPassOnLootOpcode( WorldPacket &recv_data );
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "6896"
|
#define REVISION_NR "6897"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue