Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -3,60 +3,62 @@ using Server.Network;
|
|||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public class ProtocolExtensions
|
||||
{
|
||||
private static PacketHandler[] m_Handlers = new PacketHandler[0x100];
|
||||
public class ProtocolExtensions
|
||||
{
|
||||
private static PacketHandler[] m_Handlers = new PacketHandler[0x100];
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
PacketHandlers.Register( 0xF0, 0, false, DecodeBundledPacket );
|
||||
}
|
||||
public static void Initialize()
|
||||
{
|
||||
PacketHandlers.Register(0xF0, 0, false, DecodeBundledPacket);
|
||||
}
|
||||
|
||||
public static void Register( int packetID, bool ingame, OnPacketReceive onReceive )
|
||||
{
|
||||
m_Handlers[packetID] = new PacketHandler( packetID, 0, ingame, onReceive );
|
||||
}
|
||||
public static void Register(int packetID, bool ingame, OnPacketReceive onReceive)
|
||||
{
|
||||
m_Handlers[packetID] = new PacketHandler(packetID, 0, ingame, onReceive);
|
||||
}
|
||||
|
||||
public static PacketHandler GetHandler( int packetID )
|
||||
{
|
||||
if ( packetID >= 0 && packetID < m_Handlers.Length )
|
||||
return m_Handlers[packetID];
|
||||
public static PacketHandler GetHandler(int packetID)
|
||||
{
|
||||
if (packetID >= 0 && packetID < m_Handlers.Length)
|
||||
return m_Handlers[packetID];
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void DecodeBundledPacket( NetState state, PacketReader pvSrc )
|
||||
{
|
||||
int packetID = pvSrc.ReadByte();
|
||||
public static void DecodeBundledPacket(NetState state, PacketReader pvSrc)
|
||||
{
|
||||
int packetID = pvSrc.ReadByte();
|
||||
|
||||
PacketHandler ph = GetHandler( packetID );
|
||||
PacketHandler ph = GetHandler(packetID);
|
||||
|
||||
if ( ph != null )
|
||||
{
|
||||
if ( ph.Ingame && state.Mobile == null )
|
||||
{
|
||||
Console.WriteLine( "Client: {0}: Sent ingame packet (0xF0x{1:X2}) before having been attached to a mobile", state, packetID );
|
||||
state.Dispose();
|
||||
}
|
||||
else if ( ph.Ingame && state.Mobile.Deleted )
|
||||
{
|
||||
state.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
ph.OnReceive( state, pvSrc );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ph != null)
|
||||
{
|
||||
if (ph.Ingame && state.Mobile == null)
|
||||
{
|
||||
Console.WriteLine(
|
||||
"Client: {0}: Sent ingame packet (0xF0x{1:X2}) before having been attached to a mobile", state,
|
||||
packetID);
|
||||
state.Dispose();
|
||||
}
|
||||
else if (ph.Ingame && state.Mobile.Deleted)
|
||||
{
|
||||
state.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
ph.OnReceive(state, pvSrc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class ProtocolExtension : Packet
|
||||
{
|
||||
public ProtocolExtension( int packetID, int capacity ) : base( 0xF0 )
|
||||
{
|
||||
EnsureCapacity( 4 + capacity );
|
||||
public abstract class ProtocolExtension : Packet
|
||||
{
|
||||
public ProtocolExtension(int packetID, int capacity) : base(0xF0)
|
||||
{
|
||||
EnsureCapacity(4 + capacity);
|
||||
|
||||
m_Stream.Write( (byte) packetID );
|
||||
}
|
||||
}
|
||||
m_Stream.Write((byte)packetID);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue