7.0.33.1 support
thread-safety
This commit is contained in:
parent
699fa3bdd8
commit
ae8ded4a16
7 changed files with 261 additions and 129 deletions
|
|
@ -167,7 +167,9 @@ namespace Server.Network {
|
|||
set {
|
||||
m_Version = value;
|
||||
|
||||
if ( value >= m_Version70300 ) {
|
||||
if ( value >= m_Version70331 ) {
|
||||
_ProtocolChanges = ProtocolChanges.Version70331;
|
||||
} else if ( value >= m_Version70300 ) {
|
||||
_ProtocolChanges = ProtocolChanges.Version70300;
|
||||
} else if ( value >= m_Version70160 ) {
|
||||
_ProtocolChanges = ProtocolChanges.Version70160;
|
||||
|
|
@ -207,35 +209,38 @@ namespace Server.Network {
|
|||
private static ClientVersion m_Version70130 = new ClientVersion( "7.0.13.0" );
|
||||
private static ClientVersion m_Version70160 = new ClientVersion( "7.0.16.0" );
|
||||
private static ClientVersion m_Version70300 = new ClientVersion( "7.0.30.0" );
|
||||
private static ClientVersion m_Version70331 = new ClientVersion( "7.0.33.1" );
|
||||
|
||||
private ProtocolChanges _ProtocolChanges;
|
||||
|
||||
private enum ProtocolChanges {
|
||||
NewSpellbook = 0x00000001,
|
||||
DamagePacket = 0x00000002,
|
||||
Unpack = 0x00000004,
|
||||
BuffIcon = 0x00000008,
|
||||
NewHaven = 0x00000010,
|
||||
ContainerGridLines = 0x00000020,
|
||||
NewSpellbook = 0x00000001,
|
||||
DamagePacket = 0x00000002,
|
||||
Unpack = 0x00000004,
|
||||
BuffIcon = 0x00000008,
|
||||
NewHaven = 0x00000010,
|
||||
ContainerGridLines = 0x00000020,
|
||||
ExtendedSupportedFeatures = 0x00000040,
|
||||
StygianAbyss = 0x00000080,
|
||||
HighSeas = 0x00000100,
|
||||
NewCharacterList = 0x00000200,
|
||||
StygianAbyss = 0x00000080,
|
||||
HighSeas = 0x00000100,
|
||||
NewCharacterList = 0x00000200,
|
||||
NewCharacterCreation = 0x00000400,
|
||||
ExtendedStatus = 0x00000800,
|
||||
NewMobileIncoming = 0x00001000,
|
||||
|
||||
Version400a = NewSpellbook,
|
||||
Version407a = Version400a | DamagePacket,
|
||||
Version500a = Version407a | Unpack,
|
||||
Version502b = Version500a | BuffIcon,
|
||||
Version6000 = Version502b | NewHaven,
|
||||
Version6017 = Version6000 | ContainerGridLines,
|
||||
Version60142 = Version6017 | ExtendedSupportedFeatures,
|
||||
Version7000 = Version60142 | StygianAbyss,
|
||||
Version7090 = Version7000 | HighSeas,
|
||||
Version70130 = Version7090 | NewCharacterList,
|
||||
Version70160 = Version70130 | NewCharacterCreation,
|
||||
Version70300 = Version70160 | ExtendedStatus
|
||||
Version400a = NewSpellbook,
|
||||
Version407a = Version400a | DamagePacket,
|
||||
Version500a = Version407a | Unpack,
|
||||
Version502b = Version500a | BuffIcon,
|
||||
Version6000 = Version502b | NewHaven,
|
||||
Version6017 = Version6000 | ContainerGridLines,
|
||||
Version60142 = Version6017 | ExtendedSupportedFeatures,
|
||||
Version7000 = Version60142 | StygianAbyss,
|
||||
Version7090 = Version7000 | HighSeas,
|
||||
Version70130 = Version7090 | NewCharacterList,
|
||||
Version70160 = Version70130 | NewCharacterCreation,
|
||||
Version70300 = Version70160 | ExtendedStatus,
|
||||
Version70331 = Version70300 | NewMobileIncoming
|
||||
}
|
||||
|
||||
public bool NewSpellbook { get { return ((_ProtocolChanges & ProtocolChanges.NewSpellbook) != 0); } }
|
||||
|
|
@ -250,6 +255,7 @@ namespace Server.Network {
|
|||
public bool NewCharacterList { get { return ((_ProtocolChanges & ProtocolChanges.NewCharacterList) != 0); } }
|
||||
public bool NewCharacterCreation { get { return ((_ProtocolChanges & ProtocolChanges.NewCharacterCreation) != 0); } }
|
||||
public bool ExtendedStatus { get { return ((_ProtocolChanges & ProtocolChanges.ExtendedStatus) != 0); } }
|
||||
public bool NewMobileIncoming { get { return ((_ProtocolChanges & ProtocolChanges.NewMobileIncoming) != 0); } }
|
||||
|
||||
public bool IsUOTDClient {
|
||||
get {
|
||||
|
|
|
|||
|
|
@ -1299,12 +1299,12 @@ namespace Server.Network
|
|||
|
||||
if ( state.StygianAbyss ) {
|
||||
state.Send( new MobileUpdate( m ) );
|
||||
state.Send( new MobileIncoming( m, m ) );
|
||||
} else {
|
||||
state.Send( new MobileUpdateOld( m ) );
|
||||
state.Send( new MobileIncomingOld( m, m ) );
|
||||
}
|
||||
|
||||
state.Send(MobileIncoming.Create(state, m, m));
|
||||
|
||||
m.SendEverything();
|
||||
|
||||
state.Sequence = 0;
|
||||
|
|
@ -2110,7 +2110,28 @@ namespace Server.Network
|
|||
|
||||
state.Sequence = 0;
|
||||
|
||||
if ( state.StygianAbyss ) {
|
||||
if (state.NewMobileIncoming) {
|
||||
state.Send(new MobileUpdate(m));
|
||||
state.Send(new MobileUpdate(m));
|
||||
|
||||
m.CheckLightLevels(true);
|
||||
|
||||
state.Send(new MobileUpdate(m));
|
||||
|
||||
state.Send(new MobileIncoming(m, m));
|
||||
//state.Send( new MobileAttributes( m ) );
|
||||
state.Send(new MobileStatus(m, m));
|
||||
state.Send(Server.Network.SetWarMode.Instantiate(m.Warmode));
|
||||
|
||||
m.SendEverything();
|
||||
|
||||
state.Send(SupportedFeatures.Instantiate(state));
|
||||
state.Send(new MobileUpdate(m));
|
||||
//state.Send( new MobileAttributes( m ) );
|
||||
state.Send(new MobileStatus(m, m));
|
||||
state.Send(Server.Network.SetWarMode.Instantiate(m.Warmode));
|
||||
state.Send(new MobileIncoming(m, m));
|
||||
} else if ( state.StygianAbyss ) {
|
||||
state.Send( new MobileUpdate( m ) );
|
||||
state.Send( new MobileUpdate( m ) );
|
||||
|
||||
|
|
@ -2118,7 +2139,7 @@ namespace Server.Network
|
|||
|
||||
state.Send( new MobileUpdate( m ) );
|
||||
|
||||
state.Send( new MobileIncoming( m, m ) );
|
||||
state.Send( new MobileIncomingSA( m, m ) );
|
||||
//state.Send( new MobileAttributes( m ) );
|
||||
state.Send( new MobileStatus( m, m ) );
|
||||
state.Send( Server.Network.SetWarMode.Instantiate( m.Warmode ) );
|
||||
|
|
@ -2130,7 +2151,7 @@ namespace Server.Network
|
|||
//state.Send( new MobileAttributes( m ) );
|
||||
state.Send( new MobileStatus( m, m ) );
|
||||
state.Send( Server.Network.SetWarMode.Instantiate( m.Warmode ) );
|
||||
state.Send( new MobileIncoming( m, m ) );
|
||||
state.Send( new MobileIncomingSA( m, m ) );
|
||||
} else {
|
||||
state.Send( new MobileUpdateOld( m ) );
|
||||
state.Send( new MobileUpdateOld( m ) );
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
#if Framework_4_0
|
||||
using System.Threading;
|
||||
#endif
|
||||
using Server.Accounting;
|
||||
using Server.Targeting;
|
||||
using Server.Items;
|
||||
|
|
@ -3344,15 +3347,153 @@ namespace Server.Network
|
|||
|
||||
public sealed class MobileIncoming : Packet
|
||||
{
|
||||
public static Packet Create(NetState ns, Mobile beholder, Mobile beheld)
|
||||
{
|
||||
if (ns.NewMobileIncoming)
|
||||
return new MobileIncoming(beholder, beheld);
|
||||
else if (ns.StygianAbyss)
|
||||
return new MobileIncomingSA(beholder, beheld);
|
||||
else
|
||||
return new MobileIncomingOld(beholder, beheld);
|
||||
}
|
||||
|
||||
#if Framework_4_0
|
||||
private static ThreadLocal<int[]> m_DupedLayersTL = new ThreadLocal<int[]>(() => {return new int[256];});
|
||||
private static ThreadLocal<int> m_VersionTL = new ThreadLocal<int>();
|
||||
#else
|
||||
private static int[] m_DupedLayers = new int[256];
|
||||
private static int m_Version;
|
||||
#endif
|
||||
|
||||
public Mobile m_Beheld;
|
||||
|
||||
public MobileIncoming( Mobile beholder, Mobile beheld ) : base( 0x78 )
|
||||
public MobileIncoming(Mobile beholder, Mobile beheld) : base(0x78)
|
||||
{
|
||||
m_Beheld = beheld;
|
||||
|
||||
#if Framework_4_0
|
||||
int m_Version = ++(m_VersionTL.Value);
|
||||
int[] m_DupedLayers = m_DupedLayersTL.Value;
|
||||
#else
|
||||
++m_Version;
|
||||
#endif
|
||||
|
||||
List<Item> eq = beheld.Items;
|
||||
int count = eq.Count;
|
||||
|
||||
if (beheld.HairItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHairItemID > 0)
|
||||
count++;
|
||||
|
||||
this.EnsureCapacity(23 + (count * 9));
|
||||
|
||||
int hue = beheld.Hue;
|
||||
|
||||
if (beheld.SolidHueOverride >= 0)
|
||||
hue = beheld.SolidHueOverride;
|
||||
|
||||
m_Stream.Write((int)beheld.Serial);
|
||||
m_Stream.Write((short)beheld.Body);
|
||||
m_Stream.Write((short)beheld.X);
|
||||
m_Stream.Write((short)beheld.Y);
|
||||
m_Stream.Write((sbyte)beheld.Z);
|
||||
m_Stream.Write((byte)beheld.Direction);
|
||||
m_Stream.Write((short)hue);
|
||||
m_Stream.Write((byte)beheld.GetPacketFlags());
|
||||
m_Stream.Write((byte)Notoriety.Compute(beholder, beheld));
|
||||
|
||||
for (int i = 0; i < eq.Count; ++i)
|
||||
{
|
||||
Item item = eq[i];
|
||||
|
||||
byte layer = (byte)item.Layer;
|
||||
|
||||
if (!item.Deleted && beholder.CanSee(item) && m_DupedLayers[layer] != m_Version)
|
||||
{
|
||||
m_DupedLayers[layer] = m_Version;
|
||||
|
||||
hue = item.Hue;
|
||||
|
||||
if (beheld.SolidHueOverride >= 0)
|
||||
hue = beheld.SolidHueOverride;
|
||||
|
||||
int itemID = item.ItemID & 0xFFFF;
|
||||
|
||||
m_Stream.Write((int)item.Serial);
|
||||
m_Stream.Write((ushort)itemID);
|
||||
m_Stream.Write((byte)layer);
|
||||
|
||||
m_Stream.Write((short)hue);
|
||||
}
|
||||
}
|
||||
|
||||
if (beheld.HairItemID > 0)
|
||||
{
|
||||
if (m_DupedLayers[(int)Layer.Hair] != m_Version)
|
||||
{
|
||||
m_DupedLayers[(int)Layer.Hair] = m_Version;
|
||||
hue = beheld.HairHue;
|
||||
|
||||
if (beheld.SolidHueOverride >= 0)
|
||||
hue = beheld.SolidHueOverride;
|
||||
|
||||
int itemID = beheld.HairItemID & 0xFFFF;
|
||||
|
||||
m_Stream.Write((int)HairInfo.FakeSerial(beheld));
|
||||
m_Stream.Write((ushort)itemID);
|
||||
m_Stream.Write((byte)Layer.Hair);
|
||||
|
||||
m_Stream.Write((short)hue);
|
||||
}
|
||||
}
|
||||
|
||||
if (beheld.FacialHairItemID > 0)
|
||||
{
|
||||
if (m_DupedLayers[(int)Layer.FacialHair] != m_Version)
|
||||
{
|
||||
m_DupedLayers[(int)Layer.FacialHair] = m_Version;
|
||||
hue = beheld.FacialHairHue;
|
||||
|
||||
if (beheld.SolidHueOverride >= 0)
|
||||
hue = beheld.SolidHueOverride;
|
||||
|
||||
int itemID = beheld.FacialHairItemID & 0xFFFF;
|
||||
|
||||
m_Stream.Write((int)FacialHairInfo.FakeSerial(beheld));
|
||||
m_Stream.Write((ushort)itemID);
|
||||
m_Stream.Write((byte)Layer.FacialHair);
|
||||
|
||||
m_Stream.Write((short)hue);
|
||||
}
|
||||
}
|
||||
|
||||
m_Stream.Write((int)0); // terminate
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MobileIncomingSA : Packet
|
||||
{
|
||||
#if Framework_4_0
|
||||
private static ThreadLocal<int[]> m_DupedLayersTL = new ThreadLocal<int[]>(() => {return new int[256];});
|
||||
private static ThreadLocal<int> m_VersionTL = new ThreadLocal<int>();
|
||||
#else
|
||||
private static int[] m_DupedLayers = new int[256];
|
||||
private static int m_Version;
|
||||
#endif
|
||||
|
||||
public Mobile m_Beheld;
|
||||
|
||||
public MobileIncomingSA(Mobile beholder, Mobile beheld) : base(0x78)
|
||||
{
|
||||
m_Beheld = beheld;
|
||||
|
||||
#if Framework_4_0
|
||||
int m_Version = ++(m_VersionTL.Value);
|
||||
int[] m_DupedLayers = m_DupedLayersTL.Value;
|
||||
#else
|
||||
++m_Version;
|
||||
#endif
|
||||
|
||||
List<Item> eq = beheld.Items;
|
||||
int count = eq.Count;
|
||||
|
|
@ -3468,15 +3609,26 @@ namespace Server.Network
|
|||
// Pre-7.0.0.0 Mobile Incoming
|
||||
public sealed class MobileIncomingOld : Packet
|
||||
{
|
||||
#if Framework_4_0
|
||||
private static ThreadLocal<int[]> m_DupedLayersTL = new ThreadLocal<int[]>(() => {return new int[256];});
|
||||
private static ThreadLocal<int> m_VersionTL = new ThreadLocal<int>();
|
||||
#else
|
||||
private static int[] m_DupedLayers = new int[256];
|
||||
private static int m_Version;
|
||||
#endif
|
||||
|
||||
public Mobile m_Beheld;
|
||||
|
||||
public MobileIncomingOld( Mobile beholder, Mobile beheld ) : base( 0x78 )
|
||||
{
|
||||
m_Beheld = beheld;
|
||||
|
||||
#if Framework_4_0
|
||||
int m_Version = ++(m_VersionTL.Value);
|
||||
int[] m_DupedLayers = m_DupedLayersTL.Value;
|
||||
#else
|
||||
++m_Version;
|
||||
#endif
|
||||
|
||||
List<Item> eq = beheld.Items;
|
||||
int count = eq.Count;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue