Fixes casting checks

This commit is contained in:
Kamron Batman 2018-08-19 01:38:55 +08:00
parent 7ea00fbf4f
commit 03dd5f1926
431 changed files with 5616 additions and 6250 deletions

View file

@ -441,7 +441,7 @@ namespace Server.Network
byte layer = pvSrc.ReadByte();
Serial serial = pvSrc.ReadInt32();
int amount = pvSrc.ReadInt16();
buyList.Add( new BuyItemResponse( serial, amount ) );
}
@ -2028,11 +2028,11 @@ namespace Server.Network
public static PlayCharCallback ThirdPartyAuthCallback = null, ThirdPartyHackedCallback = null;
private static byte[] m_ThirdPartyAuthKey = new byte[]
{
0x9, 0x11, 0x83, (byte)'+', 0x4, 0x17, 0x83,
0x5, 0x24, 0x85,
0x7, 0x17, 0x87,
private static byte[] m_ThirdPartyAuthKey = new byte[]
{
0x9, 0x11, 0x83, (byte)'+', 0x4, 0x17, 0x83,
0x5, 0x24, 0x85,
0x7, 0x17, 0x87,
0x6, 0x19, 0x88,
};
@ -2080,7 +2080,7 @@ namespace Server.Network
bool match = true;
for ( int i=0; match && i < m_ThirdPartyAuthKey.Length; i++ )
match = match && pvSrc.ReadByte() == m_ThirdPartyAuthKey[i];
if ( match )
authOK = true;
}
@ -2308,7 +2308,7 @@ namespace Server.Network
race = Race.Races[(byte)(genderRace / 2)];
}
if( race == null )
if ( race == null )
race = Race.DefaultRace;
CityInfo[] info = state.CityInfo;
@ -2427,8 +2427,8 @@ namespace Server.Network
byte raceID = (byte)(genderRace < 4 ? 0 : ((genderRace / 2) - 1));
race = Race.Races[raceID];
if( race == null )
if ( race == null )
race = Race.DefaultRace;
CityInfo[] info = state.CityInfo;
@ -2518,7 +2518,7 @@ namespace Server.Network
private static Dictionary<int, AuthIDPersistence> m_AuthIDWindow = new Dictionary<int, AuthIDPersistence>( m_AuthIDWindowSize );
private static int GenerateAuthID( NetState state )
{
{
if ( m_AuthIDWindow.Count == m_AuthIDWindowSize ) {
int oldestID = 0;
DateTime oldest = DateTime.MaxValue;
@ -2532,7 +2532,7 @@ namespace Server.Network
m_AuthIDWindow.Remove( oldestID );
}
int authID;
do {
@ -2543,7 +2543,7 @@ namespace Server.Network
} while ( m_AuthIDWindow.ContainsKey( authID ) );
m_AuthIDWindow[authID] = new AuthIDPersistence( state.Version );
return authID;
}
@ -2569,7 +2569,7 @@ namespace Server.Network
state.Dispose();
return;
}
if ( state.m_AuthID != 0 && authID != state.m_AuthID )
{
Console.WriteLine( "Login: {0}: Invalid client detected, disconnecting", state );

View file

@ -303,7 +303,7 @@ namespace Server.Network
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 );
m_Stream.Write( (byte)0 );//itemid offset
@ -331,7 +331,7 @@ namespace Server.Network
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 );
m_Stream.Write( (byte)0 );//itemid offset
@ -575,7 +575,7 @@ namespace Server.Network
m_Stream.Write( (int) -3 );
if ( name == null )
if ( name == null )
m_Stream.Write( (ushort) 0 );
else
{
@ -837,7 +837,7 @@ namespace Server.Network
string question = menu.Question;
if ( question == null )
if ( question == null )
m_Stream.Write( (byte) 0 );
else
{
@ -858,7 +858,7 @@ namespace Server.Network
string answer = answers[i];
if ( answer == null )
if ( answer == null )
m_Stream.Write( (byte) 0 );
else
{
@ -1193,7 +1193,7 @@ namespace Server.Network
itemID &= 0x3FFF;
m_Stream.Write( (short) itemID );
m_Stream.Write( (short) itemID );
m_Stream.Write( (byte) 0 );
/*} else if ( ) {
@ -1201,7 +1201,7 @@ namespace Server.Network
m_Stream.Write( (int) item.Serial );
m_Stream.Write( (short) itemID );
m_Stream.Write( (short) itemID );
m_Stream.Write( (byte) item.Direction );*/
} else {
@ -1211,7 +1211,7 @@ namespace Server.Network
itemID &= 0x7FFF;
m_Stream.Write( (short) itemID );
m_Stream.Write( (short) itemID );
m_Stream.Write( (byte) 0 );
}
@ -1248,7 +1248,7 @@ namespace Server.Network
itemID &= 0x3FFF;
m_Stream.Write( (ushort) itemID );
m_Stream.Write( (ushort) itemID );
m_Stream.Write( (byte) 0 );
/*} else if ( ) {
@ -1256,7 +1256,7 @@ namespace Server.Network
m_Stream.Write( (int) item.Serial );
m_Stream.Write( (ushort) itemID );
m_Stream.Write( (ushort) itemID );
m_Stream.Write( (byte) item.Direction );*/
} else {
@ -1266,7 +1266,7 @@ namespace Server.Network
itemID &= 0xFFFF;
m_Stream.Write( (ushort) itemID );
m_Stream.Write( (ushort) itemID );
m_Stream.Write( (byte) 0 );
}
@ -1622,7 +1622,7 @@ namespace Server.Network
public ScreenFadeOut()
: base( ScreenEffectType.FadeOut )
{
{
}
}
@ -1642,7 +1642,7 @@ namespace Server.Network
public ScreenFadeInOut()
: base( ScreenEffectType.FadeInOut )
{
{
}
}
@ -1662,7 +1662,7 @@ namespace Server.Network
public ScreenDarkFlash()
: base( ScreenEffectType.DarkFlash )
{
{
}
}
@ -3285,7 +3285,7 @@ namespace Server.Network
m_Stream.Write( (int) m.Serial );
m_Stream.Write( (short) 1 );
m_Stream.Write( (short) 1 );
Poison p = m.Poison;
@ -3497,9 +3497,9 @@ namespace Server.Network
List<Item> eq = beheld.Items;
int count = eq.Count;
if( beheld.HairItemID > 0 )
if ( beheld.HairItemID > 0 )
count++;
if( beheld.FacialHairItemID > 0 )
if ( beheld.FacialHairItemID > 0 )
count++;
this.EnsureCapacity( 23 + (count * 9) );
@ -3549,54 +3549,54 @@ namespace Server.Network
}
}
if( beheld.HairItemID > 0 )
if ( beheld.HairItemID > 0 )
{
if( m_DupedLayers[(int)Layer.Hair] != m_Version )
if ( m_DupedLayers[(int)Layer.Hair] != m_Version )
{
m_DupedLayers[(int)Layer.Hair] = m_Version;
hue = beheld.HairHue;
if( beheld.SolidHueOverride >= 0 )
if ( beheld.SolidHueOverride >= 0 )
hue = beheld.SolidHueOverride;
int itemID = beheld.HairItemID & 0x7FFF;
bool writeHue = (hue != 0);
if( writeHue )
if ( writeHue )
itemID |= 0x8000;
m_Stream.Write( (int)HairInfo.FakeSerial( beheld ) );
m_Stream.Write( (ushort)itemID );
m_Stream.Write( (byte)Layer.Hair );
if( writeHue )
if ( writeHue )
m_Stream.Write( (short)hue );
}
}
if( beheld.FacialHairItemID > 0 )
if ( beheld.FacialHairItemID > 0 )
{
if( m_DupedLayers[(int)Layer.FacialHair] != m_Version )
if ( m_DupedLayers[(int)Layer.FacialHair] != m_Version )
{
m_DupedLayers[(int)Layer.FacialHair] = m_Version;
hue = beheld.FacialHairHue;
if( beheld.SolidHueOverride >= 0 )
if ( beheld.SolidHueOverride >= 0 )
hue = beheld.SolidHueOverride;
int itemID = beheld.FacialHairItemID & 0x7FFF;
bool writeHue = (hue != 0);
if( writeHue )
if ( writeHue )
itemID |= 0x8000;
m_Stream.Write( (int)FacialHairInfo.FakeSerial( beheld ) );
m_Stream.Write( (ushort)itemID );
m_Stream.Write( (byte)Layer.FacialHair );
if( writeHue )
if ( writeHue )
m_Stream.Write( (short)hue );
}
}
@ -3623,9 +3623,9 @@ namespace Server.Network
List<Item> eq = beheld.Items;
int count = eq.Count;
if( beheld.HairItemID > 0 )
if ( beheld.HairItemID > 0 )
count++;
if( beheld.FacialHairItemID > 0 )
if ( beheld.FacialHairItemID > 0 )
count++;
this.EnsureCapacity( 23 + (count * 9) );
@ -3675,54 +3675,54 @@ namespace Server.Network
}
}
if( beheld.HairItemID > 0 )
if ( beheld.HairItemID > 0 )
{
if( m_DupedLayers[(int)Layer.Hair] != m_Version )
if ( m_DupedLayers[(int)Layer.Hair] != m_Version )
{
m_DupedLayers[(int)Layer.Hair] = m_Version;
hue = beheld.HairHue;
if( beheld.SolidHueOverride >= 0 )
if ( beheld.SolidHueOverride >= 0 )
hue = beheld.SolidHueOverride;
int itemID = beheld.HairItemID & 0x7FFF;
bool writeHue = (hue != 0);
if( writeHue )
if ( writeHue )
itemID |= 0x8000;
m_Stream.Write( (int)HairInfo.FakeSerial( beheld ) );
m_Stream.Write( (ushort)itemID );
m_Stream.Write( (byte)Layer.Hair );
if( writeHue )
if ( writeHue )
m_Stream.Write( (short)hue );
}
}
if( beheld.FacialHairItemID > 0 )
if ( beheld.FacialHairItemID > 0 )
{
if( m_DupedLayers[(int)Layer.FacialHair] != m_Version )
if ( m_DupedLayers[(int)Layer.FacialHair] != m_Version )
{
m_DupedLayers[(int)Layer.FacialHair] = m_Version;
hue = beheld.FacialHairHue;
if( beheld.SolidHueOverride >= 0 )
if ( beheld.SolidHueOverride >= 0 )
hue = beheld.SolidHueOverride;
int itemID = beheld.FacialHairItemID & 0x7FFF;
bool writeHue = (hue != 0);
if( writeHue )
if ( writeHue )
itemID |= 0x8000;
m_Stream.Write( (int)FacialHairInfo.FakeSerial( beheld ) );
m_Stream.Write( (ushort)itemID );
m_Stream.Write( (byte)Layer.FacialHair );
if( writeHue )
if ( writeHue )
m_Stream.Write( (short)hue );
}
}