diff --git a/Scripts/Gumps/WarningGump.cs b/Scripts/Gumps/WarningGump.cs index 49e610741..665f7e776 100644 --- a/Scripts/Gumps/WarningGump.cs +++ b/Scripts/Gumps/WarningGump.cs @@ -11,16 +11,16 @@ namespace Server.Gumps private object m_State; private bool m_CancelButton; - public WarningGump( int header, int headerColor, object content, int contentColor, int width, int height, WarningGumpCallback callback, object state, bool cancelButton ) - : this( header, headerColor, content, contentColor, width, height, callback, state ) + public WarningGump( int header, int headerColor, object content, int contentColor, int width, int height, WarningGumpCallback callback, object state ) + : this( header, headerColor, content, contentColor, width, height, callback, state, false ) { - m_CancelButton = cancelButton; } - public WarningGump( int header, int headerColor, object content, int contentColor, int width, int height, WarningGumpCallback callback, object state ) : base( (640 - width) / 2, (480 - height) / 2 ) + public WarningGump( int header, int headerColor, object content, int contentColor, int width, int height, WarningGumpCallback callback, object state, bool cancelButton ) : base( (640 - width) / 2, (480 - height) / 2 ) { m_Callback = callback; m_State = state; + m_CancelButton = cancelButton; Closable = false; diff --git a/Scripts/Items/Misc/BulletinBoards.cs b/Scripts/Items/Misc/BulletinBoards.cs index 9e1061978..aa9985f82 100644 --- a/Scripts/Items/Misc/BulletinBoards.cs +++ b/Scripts/Items/Misc/BulletinBoards.cs @@ -157,8 +157,14 @@ namespace Server.Items if ( CheckRange( from ) ) { Cleanup(); - from.Send( new BBDisplayBoard( this ) ); - from.Send( new ContainerContent( from, this ) ); + + NetState state = from.NetState; + + state.Send( new BBDisplayBoard( this ) ); + if ( state.IsPost6017 ) + state.Send( new ContainerContent6017( from, this ) ); + else + state.Send( new ContainerContent( from, this ) ); } else { diff --git a/Scripts/Items/Skill Items/Magical/Spellbook.cs b/Scripts/Items/Skill Items/Magical/Spellbook.cs index 03d97459f..6e4d77504 100644 --- a/Scripts/Items/Skill Items/Magical/Spellbook.cs +++ b/Scripts/Items/Skill Items/Magical/Spellbook.cs @@ -1,11 +1,11 @@ using System; using System.Collections; using Server; -using Server.Targeting; -using Server.Network; -using Server.Spells; using Server.Commands; using Server.Engines.Craft; +using Server.Network; +using Server.Spells; +using Server.Targeting; namespace Server.Items { @@ -484,7 +484,10 @@ namespace Server.Items else if ( Parent is Item ) { // What will happen if the client doesn't know about our parent? - to.Send( new ContainerContentUpdate( this ) ); + if ( to.NetState.IsPost6017 ) + to.Send( new ContainerContentUpdate6017( this ) ); + else + to.Send( new ContainerContentUpdate( this ) ); } else if ( Parent is Mobile ) { diff --git a/Scripts/Mobiles/Vendors/BaseVendor.cs b/Scripts/Mobiles/Vendors/BaseVendor.cs index c6a4f9b9d..373c848f3 100644 --- a/Scripts/Mobiles/Vendors/BaseVendor.cs +++ b/Scripts/Mobiles/Vendors/BaseVendor.cs @@ -633,7 +633,10 @@ namespace Server.Mobiles SendPacksTo( from ); - from.Send( new VendorBuyContent( list ) ); + if ( from.NetState.IsPost6017 ) + from.Send( new VendorBuyContent6017( list ) ); + else + from.Send( new VendorBuyContent( list ) ); from.Send( new VendorBuyList( this, list ) ); from.Send( new DisplayBuyList( this ) ); from.Send( new MobileStatusExtended( from ) );//make sure their gold amount is sent diff --git a/Server/Item.cs b/Server/Item.cs index c934b8570..c4819fc26 100644 --- a/Server/Item.cs +++ b/Server/Item.cs @@ -2964,7 +2964,6 @@ namespace Server { if ( (flags & ItemDelta.Update) != 0 ) { - Packet p = null; Point3D worldLoc = GetWorldLocation(); Mobile rootParent = contParent.RootParent as Mobile; @@ -2978,10 +2977,10 @@ namespace Server { if ( rootParent.CanSee( this ) && rootParent.InRange( worldLoc, GetUpdateRange( rootParent ) ) ) { - if ( p == null ) - p = Packet.Acquire( new ContainerContentUpdate( this ) ); - - ns.Send( p ); + if ( ns.IsPost6017 ) + ns.Send( new ContainerContentUpdate6017( this ) ); + else + ns.Send( new ContainerContentUpdate( this ) ); if ( ObjectPropertyList.Enabled ) ns.Send( OPLPacket ); @@ -3015,10 +3014,10 @@ namespace Server { if ( tradeRecip.CanSee( this ) && tradeRecip.InRange( worldLoc, GetUpdateRange( tradeRecip ) ) ) { - if ( p == null ) - p = Packet.Acquire( new ContainerContentUpdate( this ) ); - - ns.Send( p ); + if ( ns.IsPost6017 ) + ns.Send( new ContainerContentUpdate6017( this ) ); + else + ns.Send( new ContainerContentUpdate( this ) ); if ( ObjectPropertyList.Enabled ) ns.Send( OPLPacket ); @@ -3053,10 +3052,10 @@ namespace Server { if ( mob.CanSee( this ) ) { - if ( p == null ) - p = Packet.Acquire( new ContainerContentUpdate( this ) ); - - ns.Send( p ); + if ( ns.IsPost6017 ) + ns.Send( new ContainerContentUpdate6017( this ) ); + else + ns.Send( new ContainerContentUpdate( this ) ); if ( ObjectPropertyList.Enabled ) ns.Send( OPLPacket ); @@ -3068,9 +3067,6 @@ namespace Server if ( openers.Count == 0 ) contParent.Openers = null; } - - Packet.Release( p ); - return; } } @@ -3091,16 +3087,19 @@ namespace Server } else { if ( p == null ) { if ( m_Parent is Item ) { - p = new ContainerContentUpdate( this ); + if ( state.IsPost6017 ) + state.Send( new ContainerContentUpdate6017( this ) ); + else + state.Send( new ContainerContentUpdate( this ) ); } else if ( m_Parent is Mobile ) { p = new EquipUpdate( this ); + p.Acquire(); + state.Send( p ); } - - p.Acquire(); + } else { + state.Send( p ); } - state.Send( p ); - if ( ObjectPropertyList.Enabled ) { state.Send( OPLPacket ); } @@ -3108,7 +3107,8 @@ namespace Server } } - Packet.Release( p ); + if ( p != null ) + Packet.Release( p ); eable.Free(); sendOPLUpdate = false; diff --git a/Server/Items/Container.cs b/Server/Items/Container.cs index 483824c78..935c6bfc0 100644 --- a/Server/Items/Container.cs +++ b/Server/Items/Container.cs @@ -1658,7 +1658,11 @@ namespace Server.Items } to.Send( new ContainerDisplay( this ) ); - to.Send( new ContainerContent( to, this ) ); + + if ( to.NetState.IsPost6017 ) + to.Send( new ContainerContent6017( to, this ) ); + else + to.Send( new ContainerContent( to, this ) ); if ( ObjectPropertyList.Enabled ) { diff --git a/Server/Mobile.cs b/Server/Mobile.cs index bbc7afd2a..2ffbac919 100644 --- a/Server/Mobile.cs +++ b/Server/Mobile.cs @@ -4290,9 +4290,12 @@ namespace Server { state.Send( new LiftRej( reject ) ); - if( item.Parent is Item ) - state.Send( new ContainerContentUpdate( item ) ); - else if( item.Parent is Mobile ) + if( item.Parent is Item ) { + if ( state.IsPost6017 ) + state.Send( new ContainerContentUpdate6017( item ) ); + else + state.Send( new ContainerContentUpdate( item ) ); + } else if( item.Parent is Mobile ) state.Send( new EquipUpdate( item ) ); else item.SendInfoTo( state ); diff --git a/Server/Network/MessagePump.cs b/Server/Network/MessagePump.cs index 0c982d71a..47ceeeb0b 100644 --- a/Server/Network/MessagePump.cs +++ b/Server/Network/MessagePump.cs @@ -167,7 +167,7 @@ namespace Server.Network break; } - PacketHandler handler = PacketHandlers.GetHandler( packetID ); + PacketHandler handler = ns.GetHandler( packetID ); if ( handler == null ) { diff --git a/Server/Network/NetState.cs b/Server/Network/NetState.cs index 134781c92..7af475e24 100644 --- a/Server/Network/NetState.cs +++ b/Server/Network/NetState.cs @@ -200,6 +200,11 @@ namespace Server.Network { } set { m_Version = value; + + if ( value >= m_Version6017 ) + m_Post6017 = true; + else + m_Post6017 = false; } } @@ -211,6 +216,16 @@ namespace Server.Network { } } + private static ClientVersion m_Version6017 = new ClientVersion( "6.0.1.7" ); + + private bool m_Post6017; + + public bool IsPost6017 { + get { + return m_Post6017; + } + } + public List Trades { get { return m_Trades; @@ -531,6 +546,14 @@ namespace Server.Network { } } + public PacketHandler GetHandler( int packetID ) + { + if ( IsPost6017 ) + return PacketHandlers.Get6017Handler( packetID ); + else + return PacketHandlers.GetHandler( packetID ); + } + public virtual void Send( Packet p ) { if ( m_Socket == null || m_BlockAllPackets ) { p.OnSend(); diff --git a/Server/Network/PacketHandlers.cs b/Server/Network/PacketHandlers.cs index 116e09bae..b56c50917 100644 --- a/Server/Network/PacketHandlers.cs +++ b/Server/Network/PacketHandlers.cs @@ -60,6 +60,7 @@ namespace Server.Network public class PacketHandlers { private static PacketHandler[] m_Handlers; + private static PacketHandler[] m_6017Handlers; private static PacketHandler[] m_ExtendedHandlersLow; private static Dictionary m_ExtendedHandlersHigh; @@ -75,6 +76,7 @@ namespace Server.Network static PacketHandlers() { m_Handlers = new PacketHandler[0x100]; + m_6017Handlers = new PacketHandler[0x100]; m_ExtendedHandlersLow = new PacketHandler[0x100]; m_ExtendedHandlersHigh = new Dictionary(); @@ -133,7 +135,7 @@ namespace Server.Network Register( 0xB6, 9, true, new OnPacketReceive( ObjectHelpRequest ) ); Register( 0xB8, 0, true, new OnPacketReceive( ProfileReq ) ); Register( 0xBB, 9, false, new OnPacketReceive( AccountID ) ); - Register( 0xBD, 0, true, new OnPacketReceive( ClientVersion ) ); + Register( 0xBD, 0, false, new OnPacketReceive( ClientVersion ) ); Register( 0xBE, 0, true, new OnPacketReceive( AssistVersion ) ); Register( 0xBF, 0, true, new OnPacketReceive( ExtendedCommand ) ); Register( 0xC2, 0, true, new OnPacketReceive( UnicodePromptResponse ) ); @@ -146,6 +148,8 @@ namespace Server.Network Register( 0xD6, 0, true, new OnPacketReceive( BatchQueryProperties ) ); Register( 0xD7, 0, true, new OnPacketReceive( EncodedCommand ) ); + Register6017( 0x08, 15, true, new OnPacketReceive( DropReq6017 ) ); + RegisterExtended( 0x05, false, new OnPacketReceive( ScreenSize ) ); RegisterExtended( 0x06, true, new OnPacketReceive( PartyMessage ) ); RegisterExtended( 0x07, true, new OnPacketReceive( QuestArrow ) ); @@ -171,6 +175,9 @@ namespace Server.Network public static void Register( int packetID, int length, bool ingame, OnPacketReceive onReceive ) { m_Handlers[packetID] = new PacketHandler( packetID, length, ingame, onReceive ); + + if ( m_6017Handlers[packetID] == null ) + m_6017Handlers[packetID] = new PacketHandler( packetID, length, ingame, onReceive ); } public static PacketHandler GetHandler( int packetID ) @@ -178,6 +185,16 @@ namespace Server.Network return m_Handlers[packetID]; } + public static void Register6017( int packetID, int length, bool ingame, OnPacketReceive onReceive ) + { + m_6017Handlers[packetID] = new PacketHandler( packetID, length, ingame, onReceive ); + } + + public static PacketHandler Get6017Handler( int packetID ) + { + return m_6017Handlers[packetID]; + } + public static void RegisterExtended( int packetID, bool ingame, OnPacketReceive onReceive ) { if ( packetID >= 0 && packetID < 0x100 ) @@ -971,6 +988,27 @@ namespace Server.Network from.Drop( loc ); } + public static void DropReq6017( NetState state, PacketReader pvSrc ) + { + pvSrc.ReadInt32(); // serial, ignored + int x = pvSrc.ReadInt16(); + int y = pvSrc.ReadInt16(); + int z = pvSrc.ReadSByte(); + pvSrc.ReadByte(); // Grid Location? + Serial dest = pvSrc.ReadInt32(); + + Point3D loc = new Point3D( x, y, z ); + + Mobile from = state.Mobile; + + if ( dest.IsMobile ) + from.Drop( World.FindMobile( dest ), loc ); + else if ( dest.IsItem ) + from.Drop( World.FindItem( dest ), loc ); + else + from.Drop( loc ); + } + public static void ConfigurationFile( NetState state, PacketReader pvSrc ) { } @@ -1801,6 +1839,30 @@ namespace Server.Network } } + private class LoginTimer : Timer + { + private NetState m_State; + private Mobile m_Mobile; + + public LoginTimer( NetState state, Mobile m ) : base( TimeSpan.FromSeconds( 1.0 ), TimeSpan.FromSeconds( 1.0 ) ) + { + m_State = state; + m_Mobile = m; + } + + protected override void OnTick() + { + if ( m_State == null ) + Stop(); + if ( m_State.Version != null ) + { + m_State.BlockAllPackets = false; + DoLogin( m_State, m_Mobile ); + Stop(); + } + } + } + public static void PlayCharacter( NetState state, PacketReader pvSrc ) { pvSrc.ReadInt32(); // 0xEDEDEDED @@ -1848,6 +1910,8 @@ namespace Server.Network NetState.ProcessDisposedQueue(); + state.Send( new ClientVersionReq() ); + state.BlockAllPackets = true; state.Flags = flags; @@ -1855,8 +1919,7 @@ namespace Server.Network state.Mobile = m; m.NetState = state; - state.BlockAllPackets = false; - DoLogin( state, m ); + new LoginTimer( state, m ).Start(); } } } @@ -1993,6 +2056,8 @@ namespace Server.Network race ); + state.Send( new ClientVersionReq() ); + state.BlockAllPackets = true; EventSink.InvokeCharacterCreated( args ); @@ -2003,9 +2068,7 @@ namespace Server.Network { state.Mobile = m; m.NetState = state; - - state.BlockAllPackets = false; - DoLogin( state, m ); + new LoginTimer( state, m ).Start(); } else { diff --git a/Server/Network/Packets.cs b/Server/Network/Packets.cs index 9aa7d558a..00c251182 100644 --- a/Server/Network/Packets.cs +++ b/Server/Network/Packets.cs @@ -198,6 +198,22 @@ namespace Server.Network } } + public sealed class SecureTradeEquip6017 : Packet + { + public SecureTradeEquip6017( Item item, Mobile m ) : base( 0x25, 21 ) + { + m_Stream.Write( (int) item.Serial ); + m_Stream.Write( (short) item.ItemID ); + m_Stream.Write( (byte) 0 ); + m_Stream.Write( (short) item.Amount ); + m_Stream.Write( (short) item.X ); + m_Stream.Write( (short) item.Y ); + m_Stream.Write( (byte) 0 ); // Grid Location? + m_Stream.Write( (int) m.Serial ); + m_Stream.Write( (short) item.Hue ); + } + } + public sealed class MapPatches : Packet { public MapPatches() : base( 0xBF ) @@ -261,6 +277,35 @@ namespace Server.Network } } + public sealed class VendorBuyContent6017 : Packet + { + public VendorBuyContent6017( ArrayList list ) : base( 0x3c ) + { + this.EnsureCapacity( list.Count*20 + 5 ); + + m_Stream.Write( (short)list.Count ); + + //The client sorts these by their X/Y value. + //OSI sends these in wierd order. X/Y highest to lowest and serial loest to highest + //These are already sorted by serial (done by the vendor class) but we have to send them by x/y + //(the x74 packet is sent in 'correct' order.) + for ( int i = list.Count - 1; i >= 0; --i ) + { + BuyItemState bis = (BuyItemState)list[i]; + + m_Stream.Write( (int)bis.MySerial ); + m_Stream.Write( (ushort)(bis.ItemID & 0x3FFF) ); + m_Stream.Write( (byte)0 );//itemid offset + m_Stream.Write( (ushort)bis.Amount ); + m_Stream.Write( (short)(i+1) );//x + m_Stream.Write( (short)1 );//y + m_Stream.Write( (byte)0 ); // Grid Location? + m_Stream.Write( (int)bis.ContainerSerial ); + m_Stream.Write( (ushort)bis.Hue ); + } + } + } + public sealed class DisplayBuyList : Packet { public DisplayBuyList( Mobile vendor ) : base( 0x24, 7 ) @@ -1527,6 +1572,39 @@ namespace Server.Network } } + public sealed class ContainerContentUpdate6017 : Packet + { + public ContainerContentUpdate6017( Item item ) : base( 0x25, 21 ) + { + Serial parentSerial; + + if ( item.Parent is Item ) + { + parentSerial = ((Item)item.Parent).Serial; + } + else + { + Console.WriteLine( "Warning: ContainerContentUpdate on item with !(parent is Item)" ); + parentSerial = Serial.Zero; + } + + ushort cid = (ushort) item.ItemID; + + if ( cid > 0x3FFF ) + cid = 0x9D7; + + m_Stream.Write( (int) item.Serial ); + m_Stream.Write( (short) cid ); + m_Stream.Write( (byte) 0 ); // signed, itemID offset + m_Stream.Write( (ushort) item.Amount ); + m_Stream.Write( (short) item.X ); + m_Stream.Write( (short) item.Y ); + m_Stream.Write( (byte) 0 ); // Grid Location? + m_Stream.Write( (int) parentSerial ); + m_Stream.Write( (ushort) item.Hue ); + } + } + public sealed class ContainerContent : Packet { public ContainerContent( Mobile beholder, Item beheld ) : base( 0x3C ) @@ -1573,6 +1651,53 @@ namespace Server.Network } } + public sealed class ContainerContent6017 : Packet + { + public ContainerContent6017( Mobile beholder, Item beheld ) : base( 0x3C ) + { + List items = beheld.Items; + int count = items.Count; + + this.EnsureCapacity( 5 + (count * 20) ); + + long pos = m_Stream.Position; + + int written = 0; + + m_Stream.Write( (ushort) 0 ); + + for ( int i = 0; i < count; ++i ) + { + Item child = items[i]; + + if ( !child.Deleted && beholder.CanSee( child ) ) + { + Point3D loc = child.Location; + + ushort cid = (ushort) child.ItemID; + + if ( cid > 0x3FFF ) + cid = 0x9D7; + + m_Stream.Write( (int) child.Serial ); + m_Stream.Write( (ushort) cid ); + m_Stream.Write( (byte) 0 ); // signed, itemID offset + m_Stream.Write( (ushort) child.Amount ); + m_Stream.Write( (short) loc.m_X ); + m_Stream.Write( (short) loc.m_Y ); + m_Stream.Write( (byte) 0 ); // Grid Location? + m_Stream.Write( (int) beheld.Serial ); + m_Stream.Write( (ushort) child.Hue ); + + ++written; + } + } + + m_Stream.Seek( pos, SeekOrigin.Begin ); + m_Stream.Write( (ushort) written ); + } + } + public sealed class SetWarMode : Packet { public static readonly Packet InWarMode = Packet.SetStatic( new SetWarMode( true ) ); diff --git a/Server/SecureTrade.cs b/Server/SecureTrade.cs index e7639ef1c..357a6b14a 100644 --- a/Server/SecureTrade.cs +++ b/Server/SecureTrade.cs @@ -211,17 +211,29 @@ namespace Server from.Send( new MobileStatus( from, to ) ); from.Send( new UpdateSecureTrade( m_From.Container, false, false ) ); - from.Send( new SecureTradeEquip( m_To.Container, to ) ); + if ( from.NetState.IsPost6017 ) + from.Send( new SecureTradeEquip6017( m_To.Container, to ) ); + else + from.Send( new SecureTradeEquip( m_To.Container, to ) ); from.Send( new UpdateSecureTrade( m_From.Container, false, false ) ); - from.Send( new SecureTradeEquip( m_From.Container, from ) ); + if ( from.NetState.IsPost6017 ) + from.Send( new SecureTradeEquip6017( m_From.Container, from ) ); + else + from.Send( new SecureTradeEquip( m_From.Container, from ) ); from.Send( new DisplaySecureTrade( to, m_From.Container, m_To.Container, to.Name ) ); from.Send( new UpdateSecureTrade( m_From.Container, false, false ) ); to.Send( new MobileStatus( to, from ) ); to.Send( new UpdateSecureTrade( m_To.Container, false, false ) ); - to.Send( new SecureTradeEquip( m_From.Container, from ) ); + if ( to.NetState.IsPost6017 ) + to.Send( new SecureTradeEquip6017( m_From.Container, from ) ); + else + to.Send( new SecureTradeEquip( m_From.Container, from ) ); to.Send( new UpdateSecureTrade( m_To.Container, false, false ) ); - to.Send( new SecureTradeEquip( m_To.Container, to ) ); + if ( to.NetState.IsPost6017 ) + to.Send( new SecureTradeEquip6017( m_To.Container, to ) ); + else + to.Send( new SecureTradeEquip( m_To.Container, to ) ); to.Send( new DisplaySecureTrade( from, m_To.Container, m_From.Container, from.Name ) ); to.Send( new UpdateSecureTrade( m_To.Container, false, false ) ); }