fix crash with groups, added enum for battlfield leave reasons

This commit is contained in:
Kandera
2012-08-20 13:36:09 -04:00
parent 6318fd91ff
commit dd05f1dcd2
3 changed files with 14 additions and 21 deletions
+3 -11
View File
@@ -103,17 +103,9 @@ void Battlefield::HandlePlayerLeaveZone(Player *plr, uint32 /*zone */ )
{ {
m_PlayersInWar[plr->GetTeamId()].erase(plr->GetGUID()); m_PlayersInWar[plr->GetTeamId()].erase(plr->GetGUID());
plr->GetSession()->SendBfLeaveMessage(m_BattleId); plr->GetSession()->SendBfLeaveMessage(m_BattleId);
if (Group* group = GetGroupPlayer(plr->GetGUID(), plr->GetTeamId())) // remove from raid group if player is member if (Group* group = plr->GetGroup()) // remove from raid group if player is member
{ group->RemoveMember(plr->GetGUID());
// I think that now is not a hack
if (!group->RemoveMember(plr->GetGUID())) // group was disbanded
{
m_Groups[plr->GetTeamId()].erase(group->GetGUID());
group->SetBattlefieldGroup(NULL);
sGroupMgr->RemoveGroup(group);
delete group;
}
}
OnPlayerLeaveWar(plr); //For scripting OnPlayerLeaveWar(plr); //For scripting
} }
} }
@@ -26,15 +26,6 @@
#include "BattlefieldMgr.h" #include "BattlefieldMgr.h"
#include "Opcodes.h" #include "Opcodes.h"
enum BFLeaveReason
{
BF_LEAVE_REASON_CLOSE = 0x00000001,
//BF_LEAVE_REASON_UNK1 = 0x00000002, (not used)
//BF_LEAVE_REASON_UNK2 = 0x00000004, (not used)
BF_LEAVE_REASON_EXITED = 0x00000008,
BF_LEAVE_REASON_LOW_LEVEL = 0x00000010,
};
//This send to player windows for invite player to join the war //This send to player windows for invite player to join the war
//Param1:(BattleId) the BattleId of Bf //Param1:(BattleId) the BattleId of Bf
//Param2:(ZoneId) the zone where the battle is (4197 for wg) //Param2:(ZoneId) the zone where the battle is (4197 for wg)
@@ -97,7 +88,7 @@ void WorldSession::SendBfLeaveMessage(uint32 BattleId, BFLeaveReason reason)
{ {
WorldPacket data(SMSG_BATTLEFIELD_MGR_EJECTED, 7); WorldPacket data(SMSG_BATTLEFIELD_MGR_EJECTED, 7);
data << uint32(BattleId); data << uint32(BattleId);
data << uint8(reason);//byte Reason (1=close invite,8="exited",10="to low level") data << uint8(reason);//byte Reason
data << uint8(2);//byte BattleStatus data << uint8(2);//byte BattleStatus
data << uint8(0);//bool Relocated data << uint8(0);//bool Relocated
SendPacket(&data); SendPacket(&data);
+10
View File
@@ -125,6 +125,16 @@ enum PartyResult
ERR_PARTY_LFG_TELEPORT_IN_COMBAT = 30 ERR_PARTY_LFG_TELEPORT_IN_COMBAT = 30
}; };
enum BFLeaveReason
{
BF_LEAVE_REASON_CLOSE = 0x00000001,
//BF_LEAVE_REASON_UNK1 = 0x00000002, (not used)
//BF_LEAVE_REASON_UNK2 = 0x00000004, (not used)
BF_LEAVE_REASON_EXITED = 0x00000008,
BF_LEAVE_REASON_LOW_LEVEL = 0x00000010,
};
enum ChatRestrictionType enum ChatRestrictionType
{ {
ERR_CHAT_RESTRICTED = 0, ERR_CHAT_RESTRICTED = 0,