backoff parallelization

This commit is contained in:
Mark Sturgill 2013-10-19 17:08:31 -07:00
parent 3655814e4a
commit 0e5292d84d
4 changed files with 4 additions and 104 deletions

View file

@ -2494,7 +2494,6 @@ namespace Server.Mobiles
IPooledEnumerable<Mobile> eable = map.GetMobilesInRange(m_Mobile.Location, iRange);
#if !Framework_4_0
foreach (Mobile m in eable)
{
if (m.Deleted || m.Blessed)
@ -2587,105 +2586,6 @@ namespace Server.Mobiles
val = theirVal;
}
}
#endif
#if Framework_4_0
object valLock = new object();
Parallel.ForEach(eable, m => {
if (m.Deleted || m.Blessed)
return;
// Let's not target ourselves...
if (m == m_Mobile || m is BaseFamiliar)
return;
// Dead targets are invalid.
if (!m.Alive || m.IsDeadBondedPet)
return;
// Staff members cannot be targeted.
if (m.AccessLevel > AccessLevel.Player)
return;
// Does it have to be a player?
if (bPlayerOnly && !m.Player)
return;
// Can't acquire a target we can't see.
if (!m_Mobile.CanSee(m))
return;
if (Core.AOS && m is BaseCreature && (m as BaseCreature).Summoned && !(m as BaseCreature).Controlled)
return;
if (m_Mobile.Summoned && m_Mobile.SummonMaster != null)
{
// If this is a summon, it can't target its controller.
if (m == m_Mobile.SummonMaster)
return;
// It also must abide by harmful spell rules.
if (!Server.Spells.SpellHelper.ValidIndirectTarget(m_Mobile.SummonMaster, m))
return;
// Animated creatures cannot attack players directly.
if (m is PlayerMobile && m_Mobile.IsAnimatedDead)
return;
}
// If we only want faction friends, make sure it's one.
if (bFacFriend && !m_Mobile.IsFriend(m))
return;
//Ignore anyone under EtherealVoyage
if (TransformationSpellHelper.UnderTransformation(m, typeof(EtherealVoyageSpell)))
return;
// Ignore players with activated honor
if (m is PlayerMobile && ((PlayerMobile)m).HonorActive && !(m_Mobile.Combatant == m))
return;
if (acqType == FightMode.Aggressor || acqType == FightMode.Evil)
{
bool bValid = IsHostile(m);
if (!bValid)
bValid = (m_Mobile.GetFactionAllegiance(m) == BaseCreature.Allegiance.Enemy || m_Mobile.GetEthicAllegiance(m) == BaseCreature.Allegiance.Enemy);
if (acqType == FightMode.Evil && !bValid)
{
if (m is BaseCreature && ((BaseCreature)m).Controlled && ((BaseCreature)m).ControlMaster != null)
bValid = (((BaseCreature)m).ControlMaster.Karma < 0);
else
bValid = (m.Karma < 0);
}
if (!bValid)
return;
}
else
{
// Same goes for faction enemies.
if (bFacFoe && !m_Mobile.IsEnemy(m))
return;
// If it's an enemy factioned mobile, make sure we can be harmful to it.
if (bFacFoe && !bFacFriend && !m_Mobile.CanBeHarmful(m, false))
return;
}
theirVal = m_Mobile.GetFightModeRanking(m, acqType, bPlayerOnly);
lock (valLock) {
if (theirVal > val && m_Mobile.InLOS(m))
{
newFocusMob = m;
val = theirVal;
}
}
});
#endif
eable.Free();

View file

@ -3308,7 +3308,7 @@ namespace Server
#if Framework_4_0
_processing = true;
if (m_DeltaQueue.Count >= 64) {
if (m_DeltaQueue.Count >= 512) {
Parallel.ForEach(m_DeltaQueue, i => i.ProcessDelta());
} else {
for (int i = 0; i < m_DeltaQueue.Count; i++) m_DeltaQueue[i].ProcessDelta();

View file

@ -10328,7 +10328,7 @@ namespace Server
#if Framework_4_0
_processing = true;
if (m_DeltaQueue.Count >= 64) {
if (m_DeltaQueue.Count >= 512) {
Parallel.ForEach(m_DeltaQueue, m => m.ProcessDelta());
m_DeltaQueue.Clear();
} else {

View file

@ -1052,7 +1052,7 @@ namespace Server.Network {
public static void FlushAll() {
#if Framework_4_0
if (m_Instances.Count >= 128)
if (m_Instances.Count >= 1024)
Parallel.ForEach(m_Instances, ns => ns.Flush());
else
#endif
@ -1175,7 +1175,7 @@ namespace Server.Network {
try {
long curTicks = Core.TickCount;
#if Framework_4_0
if (m_Instances.Count >= 512)
if (m_Instances.Count >= 1024)
Parallel.ForEach(m_Instances, ns => ns.CheckAlive(curTicks));
else
#endif