more net 4.0 parallelization
This commit is contained in:
parent
0e31731d01
commit
d2e02ecda4
5 changed files with 254 additions and 155 deletions
|
|
@ -1212,6 +1212,8 @@ namespace Server.Mobiles
|
||||||
|
|
||||||
public override void OnHiddenChanged()
|
public override void OnHiddenChanged()
|
||||||
{
|
{
|
||||||
|
base.OnHiddenChanged();
|
||||||
|
|
||||||
RemoveBuff(BuffIcon.Invisibility); //Always remove, default to the hiding icon EXCEPT in the invis spell where it's explicitly set
|
RemoveBuff(BuffIcon.Invisibility); //Always remove, default to the hiding icon EXCEPT in the invis spell where it's explicitly set
|
||||||
|
|
||||||
if (!Hidden)
|
if (!Hidden)
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,10 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
#if Framework_4_0
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
#endif
|
||||||
using Server.Network;
|
using Server.Network;
|
||||||
|
|
||||||
namespace Server
|
namespace Server
|
||||||
|
|
@ -65,18 +69,25 @@ namespace Server
|
||||||
if ( map != null )
|
if ( map != null )
|
||||||
{
|
{
|
||||||
Packet playSound = null;
|
Packet playSound = null;
|
||||||
|
object pLock = new object();
|
||||||
|
|
||||||
IPooledEnumerable eable = map.GetClientsInRange( new Point3D( p ) );
|
IPooledEnumerable eable = map.GetClientsInRange( new Point3D( p ) );
|
||||||
|
#if Framework_4_0
|
||||||
foreach ( NetState state in eable )
|
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||||
{
|
#else
|
||||||
|
foreach ( NetState state in eable ) {
|
||||||
|
#endif
|
||||||
state.Mobile.ProcessDelta();
|
state.Mobile.ProcessDelta();
|
||||||
|
|
||||||
if ( playSound == null )
|
lock (pLock)
|
||||||
playSound = Packet.Acquire( new PlaySound( soundID, p ) );
|
if ( playSound == null )
|
||||||
|
playSound = Packet.Acquire( new PlaySound( soundID, p ) );
|
||||||
|
|
||||||
state.Send( playSound );
|
state.Send( playSound );
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
Packet.Release( playSound );
|
Packet.Release( playSound );
|
||||||
|
|
||||||
|
|
@ -104,35 +115,44 @@ namespace Server
|
||||||
e.ProcessDelta();
|
e.ProcessDelta();
|
||||||
|
|
||||||
Packet preEffect = null, boltEffect = null, playSound = null;
|
Packet preEffect = null, boltEffect = null, playSound = null;
|
||||||
|
object pLock1 = new object();
|
||||||
|
object pLock2 = new object();
|
||||||
|
object pLock3 = new object();
|
||||||
|
|
||||||
IPooledEnumerable eable = map.GetClientsInRange( e.Location );
|
IPooledEnumerable eable = map.GetClientsInRange( e.Location );
|
||||||
|
|
||||||
foreach ( NetState state in eable )
|
#if Framework_4_0
|
||||||
{
|
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||||
if ( state.Mobile.CanSee( e ) )
|
#else
|
||||||
{
|
foreach ( NetState state in eable ) {
|
||||||
if ( SendParticlesTo( state ) )
|
#endif
|
||||||
{
|
if ( state.Mobile.CanSee( e ) ) {
|
||||||
if ( preEffect == null )
|
if ( SendParticlesTo( state ) ) {
|
||||||
preEffect = Packet.Acquire( new TargetParticleEffect( e, 0, 10, 5, 0, 0, 5031, 3, 0 ) );
|
lock (pLock1)
|
||||||
|
if ( preEffect == null )
|
||||||
|
preEffect = Packet.Acquire( new TargetParticleEffect( e, 0, 10, 5, 0, 0, 5031, 3, 0 ) );
|
||||||
|
|
||||||
state.Send( preEffect );
|
state.Send( preEffect );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( boltEffect == null )
|
lock (pLock2)
|
||||||
boltEffect = Packet.Acquire( new BoltEffect( e, hue ) );
|
if ( boltEffect == null )
|
||||||
|
boltEffect = Packet.Acquire( new BoltEffect( e, hue ) );
|
||||||
|
|
||||||
state.Send( boltEffect );
|
state.Send( boltEffect );
|
||||||
|
|
||||||
if ( sound )
|
if ( sound ) {
|
||||||
{
|
lock (pLock3)
|
||||||
if ( playSound == null )
|
if ( playSound == null )
|
||||||
playSound = Packet.Acquire( new PlaySound( 0x29, e ) );
|
playSound = Packet.Acquire( new PlaySound( 0x29, e ) );
|
||||||
|
|
||||||
state.Send( playSound );
|
state.Send( playSound );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
Packet.Release( preEffect );
|
Packet.Release( preEffect );
|
||||||
Packet.Release( boltEffect );
|
Packet.Release( boltEffect );
|
||||||
|
|
@ -178,28 +198,35 @@ namespace Server
|
||||||
if ( map != null )
|
if ( map != null )
|
||||||
{
|
{
|
||||||
Packet particles = null, regular = null;
|
Packet particles = null, regular = null;
|
||||||
|
object pLock1 = new object();
|
||||||
|
object pLock2 = new object();
|
||||||
|
|
||||||
IPooledEnumerable eable = map.GetClientsInRange( e.Location );
|
IPooledEnumerable eable = map.GetClientsInRange( e.Location );
|
||||||
|
|
||||||
foreach ( NetState state in eable )
|
#if Framework_4_0
|
||||||
{
|
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||||
|
#else
|
||||||
|
foreach ( NetState state in eable ) {
|
||||||
|
#endif
|
||||||
state.Mobile.ProcessDelta();
|
state.Mobile.ProcessDelta();
|
||||||
|
|
||||||
if ( SendParticlesTo( state ) )
|
if ( SendParticlesTo( state ) ) {
|
||||||
{
|
lock (pLock1)
|
||||||
if ( particles == null )
|
if ( particles == null )
|
||||||
particles = Packet.Acquire( new LocationParticleEffect( e, itemID, speed, duration, hue, renderMode, effect, unknown ) );
|
particles = Packet.Acquire( new LocationParticleEffect( e, itemID, speed, duration, hue, renderMode, effect, unknown ) );
|
||||||
|
|
||||||
state.Send( particles );
|
state.Send( particles );
|
||||||
}
|
} else if ( itemID != 0 ) {
|
||||||
else if ( itemID != 0 )
|
lock (pLock2)
|
||||||
{
|
if ( regular == null )
|
||||||
if ( regular == null )
|
regular = Packet.Acquire( new LocationEffect( e, itemID, speed, duration, hue, renderMode ) );
|
||||||
regular = Packet.Acquire( new LocationEffect( e, itemID, speed, duration, hue, renderMode ) );
|
|
||||||
|
|
||||||
state.Send( regular );
|
state.Send( regular );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
Packet.Release( particles );
|
Packet.Release( particles );
|
||||||
Packet.Release( regular );
|
Packet.Release( regular );
|
||||||
|
|
@ -252,28 +279,35 @@ namespace Server
|
||||||
if ( map != null )
|
if ( map != null )
|
||||||
{
|
{
|
||||||
Packet particles = null, regular = null;
|
Packet particles = null, regular = null;
|
||||||
|
object pLock1 = new object();
|
||||||
|
object pLock2 = new object();
|
||||||
|
|
||||||
IPooledEnumerable eable = map.GetClientsInRange( target.Location );
|
IPooledEnumerable eable = map.GetClientsInRange( target.Location );
|
||||||
|
|
||||||
foreach ( NetState state in eable )
|
#if Framework_4_0
|
||||||
{
|
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||||
|
#else
|
||||||
|
foreach ( NetState state in eable ) {
|
||||||
|
#endif
|
||||||
state.Mobile.ProcessDelta();
|
state.Mobile.ProcessDelta();
|
||||||
|
|
||||||
if ( SendParticlesTo( state ) )
|
if ( SendParticlesTo( state ) ) {
|
||||||
{
|
lock (pLock1)
|
||||||
if ( particles == null )
|
if ( particles == null )
|
||||||
particles = Packet.Acquire( new TargetParticleEffect( target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown ) );
|
particles = Packet.Acquire( new TargetParticleEffect( target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown ) );
|
||||||
|
|
||||||
state.Send( particles );
|
state.Send( particles );
|
||||||
}
|
} else if ( itemID != 0 ) {
|
||||||
else if ( itemID != 0 )
|
lock (pLock2)
|
||||||
{
|
if ( regular == null )
|
||||||
if ( regular == null )
|
regular = Packet.Acquire( new TargetEffect( target, itemID, speed, duration, hue, renderMode ) );
|
||||||
regular = Packet.Acquire( new TargetEffect( target, itemID, speed, duration, hue, renderMode ) );
|
|
||||||
|
|
||||||
state.Send( regular );
|
state.Send( regular );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
Packet.Release( particles );
|
Packet.Release( particles );
|
||||||
Packet.Release( regular );
|
Packet.Release( regular );
|
||||||
|
|
@ -328,28 +362,35 @@ namespace Server
|
||||||
if ( map != null )
|
if ( map != null )
|
||||||
{
|
{
|
||||||
Packet particles = null, regular = null;
|
Packet particles = null, regular = null;
|
||||||
|
object pLock1 = new object();
|
||||||
|
object pLock2 = new object();
|
||||||
|
|
||||||
IPooledEnumerable eable = map.GetClientsInRange( from.Location );
|
IPooledEnumerable eable = map.GetClientsInRange( from.Location );
|
||||||
|
|
||||||
foreach ( NetState state in eable )
|
#if Framework_4_0
|
||||||
{
|
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||||
|
#else
|
||||||
|
foreach ( NetState state in eable ) {
|
||||||
|
#endif
|
||||||
state.Mobile.ProcessDelta();
|
state.Mobile.ProcessDelta();
|
||||||
|
|
||||||
if ( SendParticlesTo( state ) )
|
if ( SendParticlesTo( state ) ) {
|
||||||
{
|
lock (pLock1)
|
||||||
if ( particles == null )
|
if ( particles == null )
|
||||||
particles = Packet.Acquire( new MovingParticleEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, layer, unknown ) );
|
particles = Packet.Acquire( new MovingParticleEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, layer, unknown ) );
|
||||||
|
|
||||||
state.Send( particles );
|
state.Send( particles );
|
||||||
}
|
} else if ( itemID > 1 ) {
|
||||||
else if ( itemID > 1 )
|
lock (pLock2)
|
||||||
{
|
if ( regular == null )
|
||||||
if ( regular == null )
|
regular = Packet.Acquire( new MovingEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode ) );
|
||||||
regular = Packet.Acquire( new MovingEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode ) );
|
|
||||||
|
|
||||||
state.Send( regular );
|
state.Send( regular );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
Packet.Release( particles );
|
Packet.Release( particles );
|
||||||
Packet.Release( regular );
|
Packet.Release( regular );
|
||||||
|
|
@ -362,18 +403,22 @@ namespace Server
|
||||||
|
|
||||||
public static void SendPacket( Point3D origin, Map map, Packet p )
|
public static void SendPacket( Point3D origin, Map map, Packet p )
|
||||||
{
|
{
|
||||||
if ( map != null )
|
if ( map != null ) {
|
||||||
{
|
|
||||||
IPooledEnumerable eable = map.GetClientsInRange( origin );
|
IPooledEnumerable eable = map.GetClientsInRange( origin );
|
||||||
|
|
||||||
p.Acquire();
|
p.Acquire();
|
||||||
|
|
||||||
foreach ( NetState state in eable )
|
#if Framework_4_0
|
||||||
{
|
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||||
|
#else
|
||||||
|
foreach ( NetState state in eable ) {
|
||||||
|
#endif
|
||||||
state.Mobile.ProcessDelta();
|
state.Mobile.ProcessDelta();
|
||||||
|
|
||||||
state.Send( p );
|
state.Send( p );
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
p.Release();
|
p.Release();
|
||||||
|
|
||||||
|
|
@ -389,12 +434,17 @@ namespace Server
|
||||||
|
|
||||||
p.Acquire();
|
p.Acquire();
|
||||||
|
|
||||||
foreach ( NetState state in eable )
|
#if Framework_4_0
|
||||||
{
|
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||||
|
#else
|
||||||
|
foreach ( NetState state in eable ) {
|
||||||
|
#endif
|
||||||
state.Mobile.ProcessDelta();
|
state.Mobile.ProcessDelta();
|
||||||
|
|
||||||
state.Send( p );
|
state.Send( p );
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
p.Release();
|
p.Release();
|
||||||
|
|
||||||
|
|
|
||||||
233
Server/Mobile.cs
233
Server/Mobile.cs
|
|
@ -4391,26 +4391,32 @@ namespace Server
|
||||||
{
|
{
|
||||||
IPooledEnumerable eable = map.GetClientsInRange( from.Location );
|
IPooledEnumerable eable = map.GetClientsInRange( from.Location );
|
||||||
Packet p = null;
|
Packet p = null;
|
||||||
|
object pLock = new object();
|
||||||
|
#if Framework_4_0
|
||||||
|
Parallel.ForEach( eable.Cast<NetState>(), ns => {
|
||||||
|
#else
|
||||||
|
foreach( NetState ns in eable ) {
|
||||||
|
#endif
|
||||||
|
if( ns.Mobile != from && ns.Mobile.CanSee( from ) && ns.Mobile.InLOS( from ) && ns.Mobile.CanSee( root ) ) {
|
||||||
|
lock (pLock) {
|
||||||
|
if (p == null) {
|
||||||
|
IEntity src;
|
||||||
|
|
||||||
foreach( NetState ns in eable )
|
if (root == null)
|
||||||
{
|
src = new Entity(Serial.Zero, item.Location, map);
|
||||||
if( ns.Mobile != from && ns.Mobile.CanSee( from ) && ns.Mobile.InLOS( from ) && ns.Mobile.CanSee( root ) )
|
else
|
||||||
{
|
src = new Entity(((Item)root).Serial, ((Item)root).Location, map);
|
||||||
if( p == null )
|
|
||||||
{
|
|
||||||
IEntity src;
|
|
||||||
|
|
||||||
if( root == null )
|
p = Packet.Acquire(new DragEffect(src, from, item.ItemID, item.Hue, amount));
|
||||||
src = new Entity( Serial.Zero, item.Location, map );
|
}
|
||||||
else
|
|
||||||
src = new Entity( ((Item)root).Serial, ((Item)root).Location, map );
|
|
||||||
|
|
||||||
p = Packet.Acquire( new DragEffect( src, from, item.ItemID, item.Hue, amount ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ns.Send( p );
|
ns.Send( p );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
Packet.Release( p );
|
Packet.Release( p );
|
||||||
|
|
||||||
|
|
@ -4529,34 +4535,44 @@ namespace Server
|
||||||
{
|
{
|
||||||
IPooledEnumerable eable = map.GetClientsInRange( m_Location );
|
IPooledEnumerable eable = map.GetClientsInRange( m_Location );
|
||||||
Packet p = null;
|
Packet p = null;
|
||||||
|
object pLock = new object();
|
||||||
|
|
||||||
bool sameLoc = false;
|
bool sameLoc = false;
|
||||||
|
|
||||||
foreach( NetState ns in eable )
|
#if Framework_4_0
|
||||||
{
|
Parallel.ForEach( eable.Cast<NetState>(), ns => {
|
||||||
if( ns.Mobile != this && ns.Mobile.CanSee( this ) && ns.Mobile.InLOS( this ) && ns.Mobile.CanSee( root ) )
|
#else
|
||||||
{
|
foreach( NetState ns in eable ) {
|
||||||
if( p == null )
|
#endif
|
||||||
{
|
if( ns.Mobile != this && ns.Mobile.CanSee( this ) && ns.Mobile.InLOS( this ) && ns.Mobile.CanSee( root ) ) {
|
||||||
IEntity trg;
|
lock (pLock) {
|
||||||
|
if (p == null) {
|
||||||
|
IEntity trg;
|
||||||
|
|
||||||
if( root == null )
|
if (root == null)
|
||||||
trg = new Entity( Serial.Zero, item.Location, map );
|
trg = new Entity(Serial.Zero, item.Location, map);
|
||||||
else
|
else
|
||||||
trg = new Entity( ((Item)root).Serial, ((Item)root).Location, map );
|
trg = new Entity(((Item)root).Serial, ((Item)root).Location, map);
|
||||||
|
|
||||||
if ( m_Location == trg.Location )
|
if (m_Location == trg.Location)
|
||||||
sameLoc = true;
|
sameLoc = true;
|
||||||
|
|
||||||
p = Packet.Acquire( new DragEffect( this, trg, item.ItemID, item.Hue, item.Amount ) );
|
p = Packet.Acquire(new DragEffect(this, trg, item.ItemID, item.Hue, item.Amount));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ns.StygianAbyss && sameLoc )
|
if ( ns.StygianAbyss && sameLoc )
|
||||||
|
#if Framework_4_0
|
||||||
|
return;
|
||||||
|
#else
|
||||||
continue; // prevents crash
|
continue; // prevents crash
|
||||||
|
#endif
|
||||||
ns.Send( p );
|
ns.Send( p );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
Packet.Release( p );
|
Packet.Release( p );
|
||||||
|
|
||||||
|
|
@ -6287,13 +6303,16 @@ namespace Server
|
||||||
|
|
||||||
Packet p = null;
|
Packet p = null;
|
||||||
//Packet pNew = null;
|
//Packet pNew = null;
|
||||||
|
object pLock = new object();
|
||||||
|
|
||||||
IPooledEnumerable eable = map.GetClientsInRange( m_Location );
|
IPooledEnumerable eable = map.GetClientsInRange( m_Location );
|
||||||
|
|
||||||
foreach( NetState state in eable )
|
#if Framework_4_0
|
||||||
{
|
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||||
if( state.Mobile.CanSee( this ) )
|
#else
|
||||||
{
|
foreach( NetState state in eable ) {
|
||||||
|
#endif
|
||||||
|
if( state.Mobile.CanSee( this ) ) {
|
||||||
state.Mobile.ProcessDelta();
|
state.Mobile.ProcessDelta();
|
||||||
|
|
||||||
//if ( state.StygianAbyss ) {
|
//if ( state.StygianAbyss ) {
|
||||||
|
|
@ -6302,13 +6321,18 @@ namespace Server
|
||||||
|
|
||||||
//state.Send( pNew );
|
//state.Send( pNew );
|
||||||
//} else {
|
//} else {
|
||||||
|
lock (pLock) {
|
||||||
if( p == null )
|
if( p == null )
|
||||||
p = Packet.Acquire( new MobileAnimation( this, action, frameCount, repeatCount, forward, repeat, delay ) );
|
p = Packet.Acquire( new MobileAnimation( this, action, frameCount, repeatCount, forward, repeat, delay ) );
|
||||||
|
}
|
||||||
|
|
||||||
state.Send( p );
|
state.Send( p );
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
Packet.Release( p );
|
Packet.Release( p );
|
||||||
//Packet.Release( pNew );
|
//Packet.Release( pNew );
|
||||||
|
|
@ -6633,24 +6657,26 @@ namespace Server
|
||||||
if( m_Map != null && ns != null )
|
if( m_Map != null && ns != null )
|
||||||
{
|
{
|
||||||
IPooledEnumerable eable = m_Map.GetObjectsInRange( m_Location, Core.GlobalMaxUpdateRange );
|
IPooledEnumerable eable = m_Map.GetObjectsInRange( m_Location, Core.GlobalMaxUpdateRange );
|
||||||
|
#if Framework_4_0
|
||||||
foreach( object o in eable )
|
Parallel.ForEach( eable.Cast<IEntity>(), o => {
|
||||||
{
|
#else
|
||||||
if( o is Mobile )
|
foreach( object o in eable ) {
|
||||||
{
|
#endif
|
||||||
|
if( o is Mobile ) {
|
||||||
Mobile m = (Mobile)o;
|
Mobile m = (Mobile)o;
|
||||||
|
|
||||||
if( m != this && Utility.InUpdateRange( m_Location, m.m_Location ) )
|
if( m != this && Utility.InUpdateRange( m_Location, m.m_Location ) )
|
||||||
ns.Send( m.RemovePacket );
|
ns.Send( m.RemovePacket );
|
||||||
}
|
} else if( o is Item ) {
|
||||||
else if( o is Item )
|
|
||||||
{
|
|
||||||
Item item = (Item)o;
|
Item item = (Item)o;
|
||||||
|
|
||||||
if( InRange( item.Location, item.GetUpdateRange( this ) ) )
|
if( InRange( item.Location, item.GetUpdateRange( this ) ) )
|
||||||
ns.Send( item.RemovePacket );
|
ns.Send( item.RemovePacket );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
eable.Free();
|
eable.Free();
|
||||||
}
|
}
|
||||||
|
|
@ -6836,18 +6862,17 @@ namespace Server
|
||||||
if( m_Map != null && ns != null )
|
if( m_Map != null && ns != null )
|
||||||
{
|
{
|
||||||
IPooledEnumerable eable = m_Map.GetObjectsInRange( m_Location, Core.GlobalMaxUpdateRange );
|
IPooledEnumerable eable = m_Map.GetObjectsInRange( m_Location, Core.GlobalMaxUpdateRange );
|
||||||
|
#if Framework_4_0
|
||||||
foreach( object o in eable )
|
Parallel.ForEach( eable.Cast<IEntity>(), o => {
|
||||||
{
|
#else
|
||||||
if( o is Item )
|
foreach( object o in eable ) {
|
||||||
{
|
#endif
|
||||||
|
if( o is Item ) {
|
||||||
Item item = (Item)o;
|
Item item = (Item)o;
|
||||||
|
|
||||||
if( CanSee( item ) && InRange( item.Location, item.GetUpdateRange( this ) ) )
|
if( CanSee( item ) && InRange( item.Location, item.GetUpdateRange( this ) ) )
|
||||||
item.SendInfoTo( ns );
|
item.SendInfoTo( ns );
|
||||||
}
|
} else if( o is Mobile ) {
|
||||||
else if( o is Mobile )
|
|
||||||
{
|
|
||||||
Mobile m = (Mobile)o;
|
Mobile m = (Mobile)o;
|
||||||
|
|
||||||
if( CanSee( m ) && Utility.InUpdateRange( m_Location, m.m_Location ) )
|
if( CanSee( m ) && Utility.InUpdateRange( m_Location, m.m_Location ) )
|
||||||
|
|
@ -6877,6 +6902,9 @@ namespace Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
eable.Free();
|
eable.Free();
|
||||||
}
|
}
|
||||||
|
|
@ -8016,21 +8044,15 @@ namespace Server
|
||||||
|
|
||||||
if (m_Map != null)
|
if (m_Map != null)
|
||||||
{
|
{
|
||||||
Packet p = null;
|
|
||||||
|
|
||||||
IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location);
|
IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location);
|
||||||
|
#if Framework_4_0
|
||||||
foreach (NetState state in eable)
|
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||||
{
|
#else
|
||||||
if (!state.Mobile.CanSee(this))
|
foreach (NetState state in eable) {
|
||||||
{
|
#endif
|
||||||
if (p == null)
|
if (!state.Mobile.CanSee(this)) {
|
||||||
p = this.RemovePacket;
|
state.Send(this.RemovePacket);
|
||||||
|
} else {
|
||||||
state.Send(p);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (state.StygianAbyss)
|
if (state.StygianAbyss)
|
||||||
state.Send(new MobileIncoming(state.Mobile, this));
|
state.Send(new MobileIncoming(state.Mobile, this));
|
||||||
else
|
else
|
||||||
|
|
@ -8039,8 +8061,7 @@ namespace Server
|
||||||
if (IsDeadBondedPet)
|
if (IsDeadBondedPet)
|
||||||
state.Send(new BondedStatus(0, m_Serial, 1));
|
state.Send(new BondedStatus(0, m_Serial, 1));
|
||||||
|
|
||||||
if (ObjectPropertyList.Enabled)
|
if (ObjectPropertyList.Enabled) {
|
||||||
{
|
|
||||||
state.Send(OPLPacket);
|
state.Send(OPLPacket);
|
||||||
|
|
||||||
//foreach ( Item item in m_Items )
|
//foreach ( Item item in m_Items )
|
||||||
|
|
@ -8048,6 +8069,9 @@ namespace Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
eable.Free();
|
eable.Free();
|
||||||
}
|
}
|
||||||
|
|
@ -8912,15 +8936,17 @@ namespace Server
|
||||||
}
|
}
|
||||||
|
|
||||||
private Packet m_RemovePacket;
|
private Packet m_RemovePacket;
|
||||||
|
private object rpLock = new object();
|
||||||
|
|
||||||
public Packet RemovePacket
|
public Packet RemovePacket
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if( m_RemovePacket == null )
|
lock (rpLock) {
|
||||||
{
|
if (m_RemovePacket == null) {
|
||||||
m_RemovePacket = new RemoveMobile( this );
|
m_RemovePacket = new RemoveMobile(this);
|
||||||
m_RemovePacket.SetStatic();
|
m_RemovePacket.SetStatic();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_RemovePacket;
|
return m_RemovePacket;
|
||||||
|
|
@ -8928,15 +8954,17 @@ namespace Server
|
||||||
}
|
}
|
||||||
|
|
||||||
private Packet m_OPLPacket;
|
private Packet m_OPLPacket;
|
||||||
|
private object oplLock = new object();
|
||||||
|
|
||||||
public Packet OPLPacket
|
public Packet OPLPacket
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if( m_OPLPacket == null )
|
lock (oplLock) {
|
||||||
{
|
if( m_OPLPacket == null ) {
|
||||||
m_OPLPacket = new OPLInfo( PropertyList );
|
m_OPLPacket = new OPLInfo( PropertyList );
|
||||||
m_OPLPacket.SetStatic();
|
m_OPLPacket.SetStatic();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_OPLPacket;
|
return m_OPLPacket;
|
||||||
|
|
@ -9154,20 +9182,21 @@ namespace Server
|
||||||
if( map != null )
|
if( map != null )
|
||||||
{
|
{
|
||||||
// First, send a remove message to everyone who can no longer see us. (inOldRange && !inNewRange)
|
// First, send a remove message to everyone who can no longer see us. (inOldRange && !inNewRange)
|
||||||
Packet removeThis = null;
|
|
||||||
|
|
||||||
IPooledEnumerable eable = map.GetClientsInRange( oldLocation );
|
IPooledEnumerable eable = map.GetClientsInRange( oldLocation );
|
||||||
|
|
||||||
foreach( NetState ns in eable )
|
#if Framework_4_0
|
||||||
{
|
Parallel.ForEach( eable.Cast<NetState>(), ns => {
|
||||||
if( ns != m_NetState && !Utility.InUpdateRange( newLocation, ns.Mobile.Location ) )
|
#else
|
||||||
{
|
foreach( NetState ns in eable ) {
|
||||||
if( removeThis == null )
|
#endif
|
||||||
removeThis = this.RemovePacket;
|
if( ns != m_NetState && !Utility.InUpdateRange( newLocation, ns.Mobile.Location ) ) {
|
||||||
|
ns.Send( this.RemovePacket );
|
||||||
ns.Send( removeThis );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
eable.Free();
|
eable.Free();
|
||||||
|
|
||||||
|
|
@ -9179,8 +9208,11 @@ namespace Server
|
||||||
eable = map.GetObjectsInRange( newLocation, Core.GlobalMaxUpdateRange );
|
eable = map.GetObjectsInRange( newLocation, Core.GlobalMaxUpdateRange );
|
||||||
|
|
||||||
// We are attached to a client, so it's a bit more complex. We need to send new items and people to ourself, and ourself to other clients
|
// We are attached to a client, so it's a bit more complex. We need to send new items and people to ourself, and ourself to other clients
|
||||||
foreach( object o in eable )
|
#if Framework_4_0
|
||||||
{
|
Parallel.ForEach( eable.Cast<IEntity>(), o => {
|
||||||
|
#else
|
||||||
|
foreach( object o in eable ) {
|
||||||
|
#endif
|
||||||
if( o is Item )
|
if( o is Item )
|
||||||
{
|
{
|
||||||
Item item = (Item)o;
|
Item item = (Item)o;
|
||||||
|
|
@ -9196,8 +9228,11 @@ namespace Server
|
||||||
Mobile m = (Mobile)o;
|
Mobile m = (Mobile)o;
|
||||||
|
|
||||||
if( !Utility.InUpdateRange( newLocation, m.m_Location ) )
|
if( !Utility.InUpdateRange( newLocation, m.m_Location ) )
|
||||||
|
#if Framework_4_0
|
||||||
|
return;
|
||||||
|
#else
|
||||||
continue;
|
continue;
|
||||||
|
#endif
|
||||||
bool inOldRange = Utility.InUpdateRange( oldLocation, m.m_Location );
|
bool inOldRange = Utility.InUpdateRange( oldLocation, m.m_Location );
|
||||||
|
|
||||||
if( m.m_NetState != null && ( ( isTeleport && ( !m.m_NetState.HighSeas || !m_NoMoveHS ) ) || !inOldRange ) && m.CanSee( this ) )
|
if( m.m_NetState != null && ( ( isTeleport && ( !m.m_NetState.HighSeas || !m_NoMoveHS ) ) || !inOldRange ) && m.CanSee( this ) )
|
||||||
|
|
@ -9253,6 +9288,9 @@ namespace Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
eable.Free();
|
eable.Free();
|
||||||
}
|
}
|
||||||
|
|
@ -9261,8 +9299,11 @@ namespace Server
|
||||||
eable = map.GetClientsInRange( newLocation );
|
eable = map.GetClientsInRange( newLocation );
|
||||||
|
|
||||||
// We're not attached to a client, so simply send an Incoming
|
// We're not attached to a client, so simply send an Incoming
|
||||||
foreach( NetState ns in eable )
|
#if Framework_4_0
|
||||||
{
|
Parallel.ForEach( eable.Cast<NetState>(), ns => {
|
||||||
|
#else
|
||||||
|
foreach( NetState ns in eable ) {
|
||||||
|
#endif
|
||||||
if( ( ( isTeleport && ( !ns.HighSeas || !m_NoMoveHS ) ) || !Utility.InUpdateRange( oldLocation, ns.Mobile.Location )) && ns.Mobile.CanSee( this ) )
|
if( ( ( isTeleport && ( !ns.HighSeas || !m_NoMoveHS ) ) || !Utility.InUpdateRange( oldLocation, ns.Mobile.Location )) && ns.Mobile.CanSee( this ) )
|
||||||
{
|
{
|
||||||
if ( ns.StygianAbyss ) {
|
if ( ns.StygianAbyss ) {
|
||||||
|
|
@ -9289,6 +9330,9 @@ namespace Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
eable.Free();
|
eable.Free();
|
||||||
}
|
}
|
||||||
|
|
@ -9600,8 +9644,11 @@ namespace Server
|
||||||
{
|
{
|
||||||
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
|
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
|
||||||
|
|
||||||
foreach( NetState state in eable )
|
#if Framework_4_0
|
||||||
{
|
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||||
|
#else
|
||||||
|
foreach( NetState state in eable ) {
|
||||||
|
#endif
|
||||||
if( state.Mobile.CanSee( this ) )
|
if( state.Mobile.CanSee( this ) )
|
||||||
{
|
{
|
||||||
if ( state.StygianAbyss ) {
|
if ( state.StygianAbyss ) {
|
||||||
|
|
@ -9628,6 +9675,9 @@ namespace Server
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if Framework_4_0
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
eable.Free();
|
eable.Free();
|
||||||
}
|
}
|
||||||
|
|
@ -10289,9 +10339,6 @@ namespace Server
|
||||||
object hbyPacketLock = new object();
|
object hbyPacketLock = new object();
|
||||||
object cacheSync = new object();
|
object cacheSync = new object();
|
||||||
|
|
||||||
Packet removePacket = RemovePacket;
|
|
||||||
Packet oplPacket = OPLPacket;
|
|
||||||
|
|
||||||
IPooledEnumerable eable = m.Map.GetClientsInRange(m.m_Location);
|
IPooledEnumerable eable = m.Map.GetClientsInRange(m.m_Location);
|
||||||
|
|
||||||
#if Framework_4_0
|
#if Framework_4_0
|
||||||
|
|
@ -10304,7 +10351,7 @@ namespace Server
|
||||||
if( beholder != m && beholder.CanSee( m ) )
|
if( beholder != m && beholder.CanSee( m ) )
|
||||||
{
|
{
|
||||||
if( sendRemove )
|
if( sendRemove )
|
||||||
state.Send(removePacket);
|
state.Send(this.RemovePacket);
|
||||||
|
|
||||||
if( sendIncoming )
|
if( sendIncoming )
|
||||||
{
|
{
|
||||||
|
|
@ -10445,7 +10492,7 @@ namespace Server
|
||||||
}
|
}
|
||||||
|
|
||||||
if( sendOPLUpdate )
|
if( sendOPLUpdate )
|
||||||
state.Send(oplPacket);
|
state.Send(this.OPLPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if Framework_4_0
|
#if Framework_4_0
|
||||||
|
|
|
||||||
|
|
@ -2475,7 +2475,7 @@ namespace Server.Network
|
||||||
PacketWriter.ReleaseInstance( m_Strings );
|
PacketWriter.ReleaseInstance( m_Strings );
|
||||||
}
|
}
|
||||||
|
|
||||||
private const int GumpBufferSize = 0x4000;
|
private const int GumpBufferSize = 0x5000;
|
||||||
private static BufferPool m_PackBuffers = new BufferPool("Gump", 4, GumpBufferSize);
|
private static BufferPool m_PackBuffers = new BufferPool("Gump", 4, GumpBufferSize);
|
||||||
|
|
||||||
private void WritePacked( PacketWriter src )
|
private void WritePacked( PacketWriter src )
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ namespace Server.Network {
|
||||||
return gram;
|
return gram;
|
||||||
}
|
}
|
||||||
|
|
||||||
private const int PendingCap = 128 * 1024;
|
private const int PendingCap = 256 * 1024;
|
||||||
|
|
||||||
public Gram Enqueue( byte[] buffer, int length ) {
|
public Gram Enqueue( byte[] buffer, int length ) {
|
||||||
return Enqueue( buffer, 0, length );
|
return Enqueue( buffer, 0, length );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue