Core/Misc: More Fixes

This commit is contained in:
hondacrx
2018-05-06 15:32:00 -04:00
parent d84fe44a81
commit daa425b029
+11 -22
View File
@@ -26,6 +26,7 @@ using Game.Network.Packets;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.Linq;
namespace Game.BattleFields namespace Game.BattleFields
{ {
@@ -1026,8 +1027,8 @@ namespace Game.BattleFields
m_neutralValuePct = 0; m_neutralValuePct = 0;
m_maxSpeed = 0; m_maxSpeed = 0;
m_activePlayers[0] = new List<ObjectGuid>(); m_activePlayers[0] = new HashSet<ObjectGuid>();
m_activePlayers[1] = new List<ObjectGuid>(); m_activePlayers[1] = new HashSet<ObjectGuid>();
} }
public virtual bool HandlePlayerEnter(Player player) public virtual bool HandlePlayerEnter(Player player)
@@ -1043,12 +1044,10 @@ namespace Game.BattleFields
} }
} }
m_activePlayers[player.GetTeamId()].Add(player.GetGUID()); return m_activePlayers[player.GetTeamId()].Add(player.GetGUID());
return true;
} }
//Index of place in for loop public virtual void HandlePlayerLeave(Player player)
public virtual int HandlePlayerLeave(Player player)
{ {
if (!m_capturePointGUID.IsEmpty()) if (!m_capturePointGUID.IsEmpty())
{ {
@@ -1057,13 +1056,7 @@ namespace Game.BattleFields
player.SendUpdateWorldState(capturePoint.GetGoInfo().ControlZone.worldState1, 0); player.SendUpdateWorldState(capturePoint.GetGoInfo().ControlZone.worldState1, 0);
} }
var index = m_activePlayers[player.GetTeamId()].IndexOf(player.GetGUID());
if (index == m_activePlayers[player.GetTeamId()].Count)
return m_activePlayers[player.GetTeamId()].Count; // return end()
m_activePlayers[player.GetTeamId()].Remove(player.GetGUID()); m_activePlayers[player.GetTeamId()].Remove(player.GetGUID());
return ++index;
} }
public virtual void SendChangePhase() public virtual void SendChangePhase()
@@ -1154,18 +1147,14 @@ namespace Game.BattleFields
for (byte team = 0; team < SharedConst.BGTeamsCount; ++team) for (byte team = 0; team < SharedConst.BGTeamsCount; ++team)
{ {
for (int i = 0; i < m_activePlayers[team].Count; ) foreach (var guid in m_activePlayers[team].ToList())
{ {
Player player = Global.ObjAccessor.FindPlayer(m_activePlayers[team][i]); Player player = Global.ObjAccessor.FindPlayer(guid);
if (player) if (player)
{ {
if (!capturePoint.IsWithinDistInMap(player, radius) || !player.IsOutdoorPvPActive()) if (!capturePoint.IsWithinDistInMap(player, radius) || !player.IsOutdoorPvPActive())
i = HandlePlayerLeave(player); HandlePlayerLeave(player);
else
++i;
} }
else
++i;
} }
} }
@@ -1178,8 +1167,8 @@ namespace Game.BattleFields
{ {
if (player.IsOutdoorPvPActive()) if (player.IsOutdoorPvPActive())
{ {
m_activePlayers[player.GetTeamId()].Add(player.GetGUID()); if (m_activePlayers[player.GetTeamId()].Add(player.GetGUID()))
HandlePlayerEnter(player); HandlePlayerEnter(player);
} }
} }
} }
@@ -1317,7 +1306,7 @@ namespace Game.BattleFields
uint GetTeamId() { return m_team; } uint GetTeamId() { return m_team; }
// active Players in the area of the objective, 0 - alliance, 1 - horde // active Players in the area of the objective, 0 - alliance, 1 - horde
List<ObjectGuid>[] m_activePlayers = new List<ObjectGuid>[SharedConst.BGTeamsCount]; HashSet<ObjectGuid>[] m_activePlayers = new HashSet<ObjectGuid>[SharedConst.BGTeamsCount];
// Total shift needed to capture the objective // Total shift needed to capture the objective
float m_maxValue; float m_maxValue;