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
|
|
@ -18,176 +18,177 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public sealed class ObjectPropertyList : Packet
|
||||
{
|
||||
private int m_Hash;
|
||||
private int m_Strings;
|
||||
public sealed class ObjectPropertyList : Packet
|
||||
{
|
||||
private static byte[] m_Buffer = new byte[1024];
|
||||
private static Encoding m_Encoding = Encoding.Unicode;
|
||||
|
||||
public IEntity Entity { get; }
|
||||
// Each of these are localized to "~1_NOTHING~" which allows the string argument to be used
|
||||
private static int[] m_StringNumbers =
|
||||
{
|
||||
1042971,
|
||||
1070722
|
||||
};
|
||||
|
||||
public int Hash => 0x40000000 + m_Hash;
|
||||
private int m_Hash;
|
||||
private int m_Strings;
|
||||
|
||||
public int Header { get; set; }
|
||||
public ObjectPropertyList(IEntity e) : base(0xD6)
|
||||
{
|
||||
EnsureCapacity(128);
|
||||
|
||||
public string HeaderArgs { get; set; }
|
||||
Entity = e;
|
||||
|
||||
public static bool Enabled { get; set; }
|
||||
m_Stream.Write((short)1);
|
||||
m_Stream.Write(e.Serial);
|
||||
m_Stream.Write((byte)0);
|
||||
m_Stream.Write((byte)0);
|
||||
m_Stream.Write(e.Serial);
|
||||
}
|
||||
|
||||
public ObjectPropertyList( IEntity e ) : base( 0xD6 )
|
||||
{
|
||||
EnsureCapacity( 128 );
|
||||
public IEntity Entity{ get; }
|
||||
|
||||
Entity = e;
|
||||
public int Hash => 0x40000000 + m_Hash;
|
||||
|
||||
m_Stream.Write( (short) 1 );
|
||||
m_Stream.Write( (int) e.Serial );
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write( (byte) 0 );
|
||||
m_Stream.Write( (int) e.Serial );
|
||||
}
|
||||
public int Header{ get; set; }
|
||||
|
||||
public void Add( int number )
|
||||
{
|
||||
if ( number == 0 )
|
||||
return;
|
||||
public string HeaderArgs{ get; set; }
|
||||
|
||||
AddHash( number );
|
||||
public static bool Enabled{ get; set; }
|
||||
|
||||
if ( Header == 0 )
|
||||
{
|
||||
Header = number;
|
||||
HeaderArgs = "";
|
||||
}
|
||||
public void Add(int number)
|
||||
{
|
||||
if (number == 0)
|
||||
return;
|
||||
|
||||
m_Stream.Write( number );
|
||||
m_Stream.Write( (short) 0 );
|
||||
}
|
||||
AddHash(number);
|
||||
|
||||
public void Terminate()
|
||||
{
|
||||
m_Stream.Write( (int) 0 );
|
||||
if (Header == 0)
|
||||
{
|
||||
Header = number;
|
||||
HeaderArgs = "";
|
||||
}
|
||||
|
||||
m_Stream.Seek( 11, System.IO.SeekOrigin.Begin );
|
||||
m_Stream.Write( (int) m_Hash );
|
||||
}
|
||||
m_Stream.Write(number);
|
||||
m_Stream.Write((short)0);
|
||||
}
|
||||
|
||||
private static byte[] m_Buffer = new byte[1024];
|
||||
private static Encoding m_Encoding = Encoding.Unicode;
|
||||
public void Terminate()
|
||||
{
|
||||
m_Stream.Write(0);
|
||||
|
||||
public void AddHash( int val )
|
||||
{
|
||||
m_Hash ^= (val & 0x3FFFFFF);
|
||||
m_Hash ^= (val >> 26) & 0x3F;
|
||||
}
|
||||
m_Stream.Seek(11, SeekOrigin.Begin);
|
||||
m_Stream.Write(m_Hash);
|
||||
}
|
||||
|
||||
public void Add( int number, string arguments )
|
||||
{
|
||||
if ( number == 0 )
|
||||
return;
|
||||
public void AddHash(int val)
|
||||
{
|
||||
m_Hash ^= val & 0x3FFFFFF;
|
||||
m_Hash ^= (val >> 26) & 0x3F;
|
||||
}
|
||||
|
||||
if ( arguments == null )
|
||||
arguments = "";
|
||||
public void Add(int number, string arguments)
|
||||
{
|
||||
if (number == 0)
|
||||
return;
|
||||
|
||||
if ( Header == 0 )
|
||||
{
|
||||
Header = number;
|
||||
HeaderArgs = arguments;
|
||||
}
|
||||
if (arguments == null)
|
||||
arguments = "";
|
||||
|
||||
AddHash( number );
|
||||
AddHash( arguments.GetHashCode() );
|
||||
if (Header == 0)
|
||||
{
|
||||
Header = number;
|
||||
HeaderArgs = arguments;
|
||||
}
|
||||
|
||||
m_Stream.Write( number );
|
||||
AddHash(number);
|
||||
AddHash(arguments.GetHashCode());
|
||||
|
||||
int byteCount = m_Encoding.GetByteCount( arguments );
|
||||
m_Stream.Write(number);
|
||||
|
||||
if ( byteCount > m_Buffer.Length )
|
||||
m_Buffer = new byte[byteCount];
|
||||
int byteCount = m_Encoding.GetByteCount(arguments);
|
||||
|
||||
byteCount = m_Encoding.GetBytes( arguments, 0, arguments.Length, m_Buffer, 0 );
|
||||
if (byteCount > m_Buffer.Length)
|
||||
m_Buffer = new byte[byteCount];
|
||||
|
||||
m_Stream.Write( (short) byteCount );
|
||||
m_Stream.Write( m_Buffer, 0, byteCount );
|
||||
}
|
||||
byteCount = m_Encoding.GetBytes(arguments, 0, arguments.Length, m_Buffer, 0);
|
||||
|
||||
public void Add( int number, string format, object arg0 )
|
||||
{
|
||||
Add( number, string.Format( format, arg0 ) );
|
||||
}
|
||||
m_Stream.Write((short)byteCount);
|
||||
m_Stream.Write(m_Buffer, 0, byteCount);
|
||||
}
|
||||
|
||||
public void Add( int number, string format, object arg0, object arg1 )
|
||||
{
|
||||
Add( number, string.Format( format, arg0, arg1 ) );
|
||||
}
|
||||
public void Add(int number, string format, object arg0)
|
||||
{
|
||||
Add(number, string.Format(format, arg0));
|
||||
}
|
||||
|
||||
public void Add( int number, string format, object arg0, object arg1, object arg2 )
|
||||
{
|
||||
Add( number, string.Format( format, arg0, arg1, arg2 ) );
|
||||
}
|
||||
public void Add(int number, string format, object arg0, object arg1)
|
||||
{
|
||||
Add(number, string.Format(format, arg0, arg1));
|
||||
}
|
||||
|
||||
public void Add( int number, string format, params object[] args )
|
||||
{
|
||||
Add( number, string.Format( format, args ) );
|
||||
}
|
||||
public void Add(int number, string format, object arg0, object arg1, object arg2)
|
||||
{
|
||||
Add(number, string.Format(format, arg0, arg1, arg2));
|
||||
}
|
||||
|
||||
// Each of these are localized to "~1_NOTHING~" which allows the string argument to be used
|
||||
private static int[] m_StringNumbers = {
|
||||
1042971,
|
||||
1070722
|
||||
};
|
||||
public void Add(int number, string format, params object[] args)
|
||||
{
|
||||
Add(number, string.Format(format, args));
|
||||
}
|
||||
|
||||
private int GetStringNumber()
|
||||
{
|
||||
return m_StringNumbers[m_Strings++ % m_StringNumbers.Length];
|
||||
}
|
||||
private int GetStringNumber()
|
||||
{
|
||||
return m_StringNumbers[m_Strings++ % m_StringNumbers.Length];
|
||||
}
|
||||
|
||||
public void Add( string text )
|
||||
{
|
||||
Add( GetStringNumber(), text );
|
||||
}
|
||||
public void Add(string text)
|
||||
{
|
||||
Add(GetStringNumber(), text);
|
||||
}
|
||||
|
||||
public void Add( string format, string arg0 )
|
||||
{
|
||||
Add( GetStringNumber(), string.Format( format, arg0 ) );
|
||||
}
|
||||
public void Add(string format, string arg0)
|
||||
{
|
||||
Add(GetStringNumber(), string.Format(format, arg0));
|
||||
}
|
||||
|
||||
public void Add( string format, string arg0, string arg1 )
|
||||
{
|
||||
Add( GetStringNumber(), string.Format( format, arg0, arg1 ) );
|
||||
}
|
||||
public void Add(string format, string arg0, string arg1)
|
||||
{
|
||||
Add(GetStringNumber(), string.Format(format, arg0, arg1));
|
||||
}
|
||||
|
||||
public void Add( string format, string arg0, string arg1, string arg2 )
|
||||
{
|
||||
Add( GetStringNumber(), string.Format( format, arg0, arg1, arg2 ) );
|
||||
}
|
||||
public void Add(string format, string arg0, string arg1, string arg2)
|
||||
{
|
||||
Add(GetStringNumber(), string.Format(format, arg0, arg1, arg2));
|
||||
}
|
||||
|
||||
public void Add( string format, params object[] args )
|
||||
{
|
||||
Add( GetStringNumber(), string.Format( format, args ) );
|
||||
}
|
||||
}
|
||||
public void Add(string format, params object[] args)
|
||||
{
|
||||
Add(GetStringNumber(), string.Format(format, args));
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class OPLInfo : Packet
|
||||
{
|
||||
/*public OPLInfo( ObjectPropertyList list ) : base( 0xBF )
|
||||
{
|
||||
EnsureCapacity( 13 );
|
||||
public sealed class OPLInfo : Packet
|
||||
{
|
||||
/*public OPLInfo( ObjectPropertyList list ) : base( 0xBF )
|
||||
{
|
||||
EnsureCapacity( 13 );
|
||||
|
||||
m_Stream.Write( (short) 0x10 );
|
||||
m_Stream.Write( (int) list.Entity.Serial );
|
||||
m_Stream.Write( (int) list.Hash );
|
||||
}*/
|
||||
m_Stream.Write( (short) 0x10 );
|
||||
m_Stream.Write( (int) list.Entity.Serial );
|
||||
m_Stream.Write( (int) list.Hash );
|
||||
}*/
|
||||
|
||||
public OPLInfo( ObjectPropertyList list ) : base( 0xDC, 9 )
|
||||
{
|
||||
m_Stream.Write( (int) list.Entity.Serial );
|
||||
m_Stream.Write( (int) list.Hash );
|
||||
}
|
||||
}
|
||||
public OPLInfo(ObjectPropertyList list) : base(0xDC, 9)
|
||||
{
|
||||
m_Stream.Write(list.Entity.Serial);
|
||||
m_Stream.Write(list.Hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue