scale back overaggressive parallelization
This commit is contained in:
parent
20635cc8ee
commit
c631528968
4 changed files with 55 additions and 334 deletions
|
|
@ -69,25 +69,17 @@ namespace Server
|
|||
if ( map != null )
|
||||
{
|
||||
Packet playSound = null;
|
||||
object pLock = new object();
|
||||
|
||||
IPooledEnumerable eable = map.GetClientsInRange( new Point3D( p ) );
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
|
||||
foreach ( NetState state in eable ) {
|
||||
#endif
|
||||
state.Mobile.ProcessDelta();
|
||||
|
||||
lock (pLock)
|
||||
if ( playSound == null )
|
||||
playSound = Packet.Acquire( new PlaySound( soundID, p ) );
|
||||
if ( playSound == null )
|
||||
playSound = Packet.Acquire( new PlaySound( soundID, p ) );
|
||||
|
||||
state.Send( playSound );
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( playSound );
|
||||
|
||||
|
|
@ -115,44 +107,31 @@ namespace Server
|
|||
e.ProcessDelta();
|
||||
|
||||
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 );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach ( NetState state in eable ) {
|
||||
#endif
|
||||
if ( state.Mobile.CanSee( e ) ) {
|
||||
if ( SendParticlesTo( state ) ) {
|
||||
lock (pLock1)
|
||||
if ( preEffect == null )
|
||||
preEffect = Packet.Acquire( new TargetParticleEffect( e, 0, 10, 5, 0, 0, 5031, 3, 0 ) );
|
||||
if ( preEffect == null )
|
||||
preEffect = Packet.Acquire( new TargetParticleEffect( e, 0, 10, 5, 0, 0, 5031, 3, 0 ) );
|
||||
|
||||
state.Send( preEffect );
|
||||
}
|
||||
|
||||
lock (pLock2)
|
||||
if ( boltEffect == null )
|
||||
boltEffect = Packet.Acquire( new BoltEffect( e, hue ) );
|
||||
if ( boltEffect == null )
|
||||
boltEffect = Packet.Acquire( new BoltEffect( e, hue ) );
|
||||
|
||||
state.Send( boltEffect );
|
||||
|
||||
if ( sound ) {
|
||||
lock (pLock3)
|
||||
if ( playSound == null )
|
||||
playSound = Packet.Acquire( new PlaySound( 0x29, e ) );
|
||||
if ( playSound == null )
|
||||
playSound = Packet.Acquire( new PlaySound( 0x29, e ) );
|
||||
|
||||
state.Send( playSound );
|
||||
}
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( preEffect );
|
||||
Packet.Release( boltEffect );
|
||||
|
|
@ -198,35 +177,24 @@ namespace Server
|
|||
if ( map != null )
|
||||
{
|
||||
Packet particles = null, regular = null;
|
||||
object pLock1 = new object();
|
||||
object pLock2 = new object();
|
||||
|
||||
IPooledEnumerable eable = map.GetClientsInRange( e.Location );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach ( NetState state in eable ) {
|
||||
#endif
|
||||
state.Mobile.ProcessDelta();
|
||||
|
||||
if ( SendParticlesTo( state ) ) {
|
||||
lock (pLock1)
|
||||
if ( particles == null )
|
||||
particles = Packet.Acquire( new LocationParticleEffect( e, itemID, speed, duration, hue, renderMode, effect, unknown ) );
|
||||
if ( particles == null )
|
||||
particles = Packet.Acquire( new LocationParticleEffect( e, itemID, speed, duration, hue, renderMode, effect, unknown ) );
|
||||
|
||||
state.Send( particles );
|
||||
} else if ( itemID != 0 ) {
|
||||
lock (pLock2)
|
||||
if ( regular == null )
|
||||
regular = Packet.Acquire( new LocationEffect( e, itemID, speed, duration, hue, renderMode ) );
|
||||
if ( regular == null )
|
||||
regular = Packet.Acquire( new LocationEffect( e, itemID, speed, duration, hue, renderMode ) );
|
||||
|
||||
state.Send( regular );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( particles );
|
||||
Packet.Release( regular );
|
||||
|
|
@ -279,35 +247,24 @@ namespace Server
|
|||
if ( map != null )
|
||||
{
|
||||
Packet particles = null, regular = null;
|
||||
object pLock1 = new object();
|
||||
object pLock2 = new object();
|
||||
|
||||
IPooledEnumerable eable = map.GetClientsInRange( target.Location );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach ( NetState state in eable ) {
|
||||
#endif
|
||||
state.Mobile.ProcessDelta();
|
||||
|
||||
if ( SendParticlesTo( state ) ) {
|
||||
lock (pLock1)
|
||||
if ( particles == null )
|
||||
particles = Packet.Acquire( new TargetParticleEffect( target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown ) );
|
||||
if ( particles == null )
|
||||
particles = Packet.Acquire( new TargetParticleEffect( target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown ) );
|
||||
|
||||
state.Send( particles );
|
||||
} else if ( itemID != 0 ) {
|
||||
lock (pLock2)
|
||||
if ( regular == null )
|
||||
regular = Packet.Acquire( new TargetEffect( target, itemID, speed, duration, hue, renderMode ) );
|
||||
if ( regular == null )
|
||||
regular = Packet.Acquire( new TargetEffect( target, itemID, speed, duration, hue, renderMode ) );
|
||||
|
||||
state.Send( regular );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( particles );
|
||||
Packet.Release( regular );
|
||||
|
|
@ -362,35 +319,24 @@ namespace Server
|
|||
if ( map != null )
|
||||
{
|
||||
Packet particles = null, regular = null;
|
||||
object pLock1 = new object();
|
||||
object pLock2 = new object();
|
||||
|
||||
IPooledEnumerable eable = map.GetClientsInRange( from.Location );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach ( NetState state in eable ) {
|
||||
#endif
|
||||
state.Mobile.ProcessDelta();
|
||||
|
||||
if ( SendParticlesTo( state ) ) {
|
||||
lock (pLock1)
|
||||
if ( particles == null )
|
||||
particles = Packet.Acquire( new MovingParticleEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, layer, unknown ) );
|
||||
if ( particles == null )
|
||||
particles = Packet.Acquire( new MovingParticleEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, layer, unknown ) );
|
||||
|
||||
state.Send( particles );
|
||||
} else if ( itemID > 1 ) {
|
||||
lock (pLock2)
|
||||
if ( regular == null )
|
||||
regular = Packet.Acquire( new MovingEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode ) );
|
||||
if ( regular == null )
|
||||
regular = Packet.Acquire( new MovingEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode ) );
|
||||
|
||||
state.Send( regular );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( particles );
|
||||
Packet.Release( regular );
|
||||
|
|
@ -408,17 +354,10 @@ namespace Server
|
|||
|
||||
p.Acquire();
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach ( NetState state in eable ) {
|
||||
#endif
|
||||
state.Mobile.ProcessDelta();
|
||||
state.Send( p );
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
p.Release();
|
||||
|
||||
|
|
@ -434,17 +373,10 @@ namespace Server
|
|||
|
||||
p.Acquire();
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach ( NetState state in eable ) {
|
||||
#endif
|
||||
state.Mobile.ProcessDelta();
|
||||
state.Send( p );
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
p.Release();
|
||||
|
||||
|
|
|
|||
|
|
@ -1355,20 +1355,13 @@ namespace Server
|
|||
{
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange( oldLocation, GetMaxUpdateRange() );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach ( NetState state in eable ) {
|
||||
#endif
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if ( m.InRange( oldLocation, GetUpdateRange( m ) ) ) {
|
||||
state.Send( this.RemovePacket );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
|
@ -1398,19 +1391,12 @@ namespace Server
|
|||
{
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location, GetMaxUpdateRange() );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach (NetState state in eable) {
|
||||
#endif
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if ( m.CanSee( this ) && m.InRange( m_Location, GetUpdateRange( m ) ) )
|
||||
SendInfoTo( state );
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
|
@ -1428,20 +1414,13 @@ namespace Server
|
|||
{
|
||||
eable = m_Map.GetClientsInRange( oldLocation, GetMaxUpdateRange() );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach (NetState state in eable) {
|
||||
#endif
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if ( !m.InRange( location, GetUpdateRange( m ) ) ) {
|
||||
state.Send( this.RemovePacket );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
|
@ -1455,19 +1434,12 @@ namespace Server
|
|||
|
||||
eable = m_Map.GetClientsInRange( m_Location, GetMaxUpdateRange() );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach (NetState state in eable) {
|
||||
#endif
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if ( m.CanSee( this ) && m.InRange( m_Location, GetUpdateRange( m ) ) )
|
||||
SendInfoTo( state );
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
|
||||
|
|
@ -1832,20 +1804,13 @@ namespace Server
|
|||
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange( worldLoc, GetMaxUpdateRange() );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach (NetState state in eable) {
|
||||
#endif
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if ( !m.CanSee( this ) && m.InRange( worldLoc, GetUpdateRange( m ) ) ) {
|
||||
state.Send( this.RemovePacket );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
|
@ -3221,15 +3186,10 @@ namespace Server
|
|||
{
|
||||
Packet p = null;
|
||||
Point3D worldLoc = GetWorldLocation();
|
||||
object equipUpdateLock = new object();
|
||||
|
||||
IPooledEnumerable eable = map.GetClientsInRange( worldLoc, GetMaxUpdateRange() );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach ( NetState state in eable ) {
|
||||
#endif
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if ( m.CanSee( this ) && m.InRange( worldLoc, GetUpdateRange( m ) ) ) {
|
||||
|
|
@ -3243,10 +3203,8 @@ namespace Server
|
|||
else
|
||||
state.Send( new ContainerContentUpdate( this ) );
|
||||
} else if ( m_Parent is Mobile ) {
|
||||
lock (equipUpdateLock) {
|
||||
p = new EquipUpdate(this);
|
||||
p.Acquire();
|
||||
}
|
||||
p = new EquipUpdate(this);
|
||||
p.Acquire();
|
||||
|
||||
state.Send( p );
|
||||
}
|
||||
|
|
@ -3260,9 +3218,6 @@ namespace Server
|
|||
}
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
if ( p != null )
|
||||
Packet.Release( p );
|
||||
|
|
@ -3276,15 +3231,10 @@ namespace Server
|
|||
{
|
||||
Packet p = null;
|
||||
Point3D worldLoc = GetWorldLocation();
|
||||
object equipPacketLock = new object();
|
||||
|
||||
IPooledEnumerable eable = map.GetClientsInRange( worldLoc, GetMaxUpdateRange() );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach ( NetState state in eable ) {
|
||||
#endif
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if ( m.CanSee( this ) && m.InRange( worldLoc, GetUpdateRange( m ) ) )
|
||||
|
|
@ -3292,9 +3242,8 @@ namespace Server
|
|||
//if ( sendOPLUpdate )
|
||||
// state.Send( RemovePacket );
|
||||
|
||||
lock (equipPacketLock)
|
||||
if ( p == null )
|
||||
p = Packet.Acquire( new EquipUpdate( this ) );
|
||||
if ( p == null )
|
||||
p = Packet.Acquire( new EquipUpdate( this ) );
|
||||
|
||||
state.Send( p );
|
||||
|
||||
|
|
@ -3302,9 +3251,6 @@ namespace Server
|
|||
state.Send( OPLPacket );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( p );
|
||||
|
||||
|
|
@ -3318,19 +3264,12 @@ namespace Server
|
|||
Point3D worldLoc = GetWorldLocation();
|
||||
IPooledEnumerable eable = map.GetClientsInRange( worldLoc, GetMaxUpdateRange() );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach ( NetState state in eable ) {
|
||||
#endif
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if ( m.CanSee( this ) && m.InRange( worldLoc, GetUpdateRange( m ) ) )
|
||||
state.Send( OPLPacket );
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
|
@ -3633,20 +3572,13 @@ namespace Server
|
|||
{
|
||||
eable = m_Map.GetClientsInRange( oldLocation, GetMaxUpdateRange() );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach (NetState state in eable) {
|
||||
#endif
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if ( !m.InRange( value, GetUpdateRange( m ) ) ) {
|
||||
state.Send( this.RemovePacket );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
|
@ -3659,19 +3591,12 @@ namespace Server
|
|||
|
||||
eable = m_Map.GetClientsInRange( m_Location, GetMaxUpdateRange() );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach (NetState state in eable) {
|
||||
#endif
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if ( m.CanSee( this ) && m.InRange( m_Location, GetUpdateRange( m ) ) && ( !state.HighSeas || !m_NoMoveHS || ( m_DeltaFlags & ItemDelta.Update ) != 0 || !m.InRange( oldLoc, GetUpdateRange( m ) ) ) )
|
||||
SendInfoTo( state );
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
|
||||
|
|
@ -4228,20 +4153,13 @@ namespace Server
|
|||
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange( worldLoc, GetMaxUpdateRange() );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach (NetState state in eable) {
|
||||
#endif
|
||||
Mobile m = state.Mobile;
|
||||
|
||||
if ( m.InRange( worldLoc, GetUpdateRange( m ) ) ) {
|
||||
state.Send( this.RemovePacket );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,12 +131,12 @@ namespace Server
|
|||
private static ThreadLocal<long> _HighOrder = new ThreadLocal<long>();
|
||||
private static ThreadLocal<uint> _LastTickCount = new ThreadLocal<uint>();
|
||||
|
||||
private static readonly long _Frequency = Stopwatch.Frequency;
|
||||
private static readonly double _Frequency = 1000.0 / Stopwatch.Frequency;
|
||||
|
||||
public static long TickCount {
|
||||
get {
|
||||
if (Stopwatch.IsHighResolution) // TODO: Unreliable with certain system configurations.
|
||||
return (long)((double)Stopwatch.GetTimestamp() / _Frequency * 1000);
|
||||
return (long)((double)Stopwatch.GetTimestamp() * _Frequency);
|
||||
|
||||
uint t = (uint)Environment.TickCount;
|
||||
|
||||
|
|
@ -154,14 +154,14 @@ namespace Server
|
|||
|
||||
private static object _TickSync = new object();
|
||||
|
||||
private static readonly long _Frequency = Stopwatch.Frequency;
|
||||
private static readonly double _Frequency = 1000.0 / Stopwatch.Frequency;
|
||||
|
||||
public static long TickCount
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Stopwatch.IsHighResolution) // TODO: Unreliable with certain system configurations.
|
||||
return (long)((double)Stopwatch.GetTimestamp() / _Frequency * 1000);
|
||||
return (long)((double)Stopwatch.GetTimestamp() * _Frequency);
|
||||
|
||||
lock (_TickSync)
|
||||
{
|
||||
|
|
|
|||
181
Server/Mobile.cs
181
Server/Mobile.cs
|
|
@ -4028,19 +4028,13 @@ namespace Server
|
|||
if( m_Map != null )
|
||||
{
|
||||
Packet animPacket = null;
|
||||
object pLock = new object();
|
||||
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach( NetState state in eable ) {
|
||||
#endif
|
||||
if( state != m_NetState ) {
|
||||
lock (pLock)
|
||||
if (animPacket == null)
|
||||
animPacket = Packet.Acquire( new DeathAnimation( this, c ) );;
|
||||
if (animPacket == null)
|
||||
animPacket = Packet.Acquire( new DeathAnimation( this, c ) );;
|
||||
|
||||
state.Send( animPacket );
|
||||
|
||||
|
|
@ -4049,9 +4043,6 @@ namespace Server
|
|||
}
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( animPacket );
|
||||
|
||||
|
|
@ -4404,32 +4395,23 @@ namespace Server
|
|||
{
|
||||
IPooledEnumerable eable = map.GetClientsInRange( from.Location );
|
||||
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;
|
||||
if (p == null) {
|
||||
IEntity src;
|
||||
|
||||
if (root == null)
|
||||
src = new Entity(Serial.Zero, item.Location, map);
|
||||
else
|
||||
src = new Entity(((Item)root).Serial, ((Item)root).Location, map);
|
||||
if (root == null)
|
||||
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));
|
||||
}
|
||||
p = Packet.Acquire(new DragEffect(src, from, item.ItemID, item.Hue, amount));
|
||||
}
|
||||
|
||||
ns.Send( p );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( p );
|
||||
|
||||
|
|
@ -4548,44 +4530,30 @@ namespace Server
|
|||
{
|
||||
IPooledEnumerable eable = map.GetClientsInRange( m_Location );
|
||||
Packet p = null;
|
||||
object pLock = new object();
|
||||
|
||||
bool sameLoc = false;
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), ns => {
|
||||
#else
|
||||
foreach( NetState ns in eable ) {
|
||||
#endif
|
||||
if( ns.Mobile != this && ns.Mobile.CanSee( this ) && ns.Mobile.InLOS( this ) && ns.Mobile.CanSee( root ) ) {
|
||||
lock (pLock) {
|
||||
if (p == null) {
|
||||
IEntity trg;
|
||||
if (p == null) {
|
||||
IEntity trg;
|
||||
|
||||
if (root == null)
|
||||
trg = new Entity(Serial.Zero, item.Location, map);
|
||||
else
|
||||
trg = new Entity(((Item)root).Serial, ((Item)root).Location, map);
|
||||
if (root == null)
|
||||
trg = new Entity(Serial.Zero, item.Location, map);
|
||||
else
|
||||
trg = new Entity(((Item)root).Serial, ((Item)root).Location, map);
|
||||
|
||||
if (m_Location == trg.Location)
|
||||
sameLoc = true;
|
||||
if (m_Location == trg.Location)
|
||||
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 Framework_4_0
|
||||
return;
|
||||
#else
|
||||
continue; // prevents crash
|
||||
#endif
|
||||
ns.Send( p );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( p );
|
||||
|
||||
|
|
@ -5370,33 +5338,22 @@ namespace Server
|
|||
|
||||
Packet pNew = null;
|
||||
Packet pOld = null;
|
||||
object pLock1 = new object();
|
||||
object pLock2 = new object();
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), ns => {
|
||||
#else
|
||||
foreach( NetState ns in eable ) {
|
||||
#endif
|
||||
if( ns.Mobile.CanSee( this ) ) {
|
||||
if( ns.DamagePacket ) {
|
||||
lock (pLock1)
|
||||
if( pNew == null )
|
||||
pNew = Packet.Acquire( new DamagePacket( this, amount ) );
|
||||
if( pNew == null )
|
||||
pNew = Packet.Acquire( new DamagePacket( this, amount ) );
|
||||
|
||||
ns.Send( pNew );
|
||||
} else {
|
||||
lock (pLock2)
|
||||
if( pOld == null )
|
||||
pOld = Packet.Acquire( new DamagePacketOld( this, amount ) );
|
||||
if( pOld == null )
|
||||
pOld = Packet.Acquire( new DamagePacketOld( this, amount ) );
|
||||
|
||||
ns.Send( pOld );
|
||||
}
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( pNew );
|
||||
Packet.Release( pOld );
|
||||
|
|
@ -6312,15 +6269,10 @@ namespace Server
|
|||
|
||||
Packet p = null;
|
||||
//Packet pNew = null;
|
||||
object pLock = new object();
|
||||
|
||||
IPooledEnumerable eable = map.GetClientsInRange( m_Location );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach( NetState state in eable ) {
|
||||
#endif
|
||||
if( state.Mobile.CanSee( this ) ) {
|
||||
state.Mobile.ProcessDelta();
|
||||
|
||||
|
|
@ -6330,18 +6282,13 @@ namespace Server
|
|||
|
||||
//state.Send( pNew );
|
||||
//} else {
|
||||
lock (pLock) {
|
||||
if( p == null )
|
||||
p = Packet.Acquire( new MobileAnimation( this, action, frameCount, repeatCount, forward, repeat, delay ) );
|
||||
}
|
||||
if( p == null )
|
||||
p = Packet.Acquire( new MobileAnimation( this, action, frameCount, repeatCount, forward, repeat, delay ) );
|
||||
|
||||
state.Send( p );
|
||||
//}
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( p );
|
||||
//Packet.Release( pNew );
|
||||
|
|
@ -6373,18 +6320,11 @@ namespace Server
|
|||
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach( NetState state in eable ) {
|
||||
#endif
|
||||
if( state.Mobile.CanSee( this ) ) {
|
||||
state.Send( p );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( p );
|
||||
|
||||
|
|
@ -6644,17 +6584,10 @@ namespace Server
|
|||
{
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach( NetState state in eable ) {
|
||||
#endif
|
||||
if( state != m_NetState && (everyone || !state.Mobile.CanSee( this )) )
|
||||
state.Send( this.RemovePacket );
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
|
@ -8055,11 +7988,8 @@ namespace Server
|
|||
if (m_Map != null)
|
||||
{
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location);
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
|
||||
foreach (NetState state in eable) {
|
||||
#endif
|
||||
if (!state.Mobile.CanSee(this)) {
|
||||
state.Send(this.RemovePacket);
|
||||
} else {
|
||||
|
|
@ -8079,9 +8009,6 @@ namespace Server
|
|||
}
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
|
@ -9195,18 +9122,11 @@ namespace Server
|
|||
|
||||
IPooledEnumerable eable = map.GetClientsInRange( oldLocation );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), ns => {
|
||||
#else
|
||||
foreach( NetState ns in eable ) {
|
||||
#endif
|
||||
if( ns != m_NetState && !Utility.InUpdateRange( newLocation, ns.Mobile.Location ) ) {
|
||||
ns.Send( this.RemovePacket );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
|
||||
|
|
@ -9309,11 +9229,7 @@ namespace Server
|
|||
eable = map.GetClientsInRange( newLocation );
|
||||
|
||||
// We're not attached to a client, so simply send an Incoming
|
||||
#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 ( ns.StygianAbyss ) {
|
||||
|
|
@ -9340,9 +9256,6 @@ namespace Server
|
|||
}
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
|
@ -9654,11 +9567,7 @@ namespace Server
|
|||
{
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach( NetState state in eable ) {
|
||||
#endif
|
||||
if( state.Mobile.CanSee( this ) )
|
||||
{
|
||||
if ( state.StygianAbyss ) {
|
||||
|
|
@ -9685,9 +9594,6 @@ namespace Server
|
|||
}
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
|
@ -10689,18 +10595,11 @@ namespace Server
|
|||
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach( NetState state in eable ) {
|
||||
#endif
|
||||
if( state.Mobile.CanSee( this ) && (noLineOfSight || state.Mobile.InLOS( this )) ) {
|
||||
state.Send( p );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( p );
|
||||
|
||||
|
|
@ -10726,18 +10625,11 @@ namespace Server
|
|||
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach( NetState state in eable ) {
|
||||
#endif
|
||||
if( state.Mobile.CanSee( this ) && (noLineOfSight || state.Mobile.InLOS( this )) ) {
|
||||
state.Send( p );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( p );
|
||||
|
||||
|
|
@ -10758,18 +10650,11 @@ namespace Server
|
|||
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach( NetState state in eable ) {
|
||||
#endif
|
||||
if( state.Mobile.CanSee( this ) && (noLineOfSight || state.Mobile.InLOS( this )) ) {
|
||||
state.Send( p );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( p );
|
||||
|
||||
|
|
@ -10840,18 +10725,11 @@ namespace Server
|
|||
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach( NetState state in eable ) {
|
||||
#endif
|
||||
if( state != m_NetState && state.Mobile.CanSee( this ) ) {
|
||||
state.Send( p );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( p );
|
||||
|
||||
|
|
@ -10874,18 +10752,11 @@ namespace Server
|
|||
|
||||
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
|
||||
|
||||
#if Framework_4_0
|
||||
Parallel.ForEach( eable.Cast<NetState>(), state => {
|
||||
#else
|
||||
foreach( NetState state in eable ) {
|
||||
#endif
|
||||
if( state != m_NetState && state.Mobile.CanSee( this ) ) {
|
||||
state.Send( p );
|
||||
}
|
||||
}
|
||||
#if Framework_4_0
|
||||
);
|
||||
#endif
|
||||
|
||||
Packet.Release( p );
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue