示例#1
0
        public override byte[] ProcessDataReceived( byte []data, int length )
        {
            //	Console.WriteLine("Rec {0}", data[ 0 ] );
            //	HexViewer.View( data, 0, length );
            int t;
            switch( data[ 0 ] )
            {
                case 0x00://	Logon challenge
                    /*foreach( Account acc in World.allAccounts )
                        if ( acc.Ip != null &&
                            ch.IP.Address == acc.Ip.Address &&
                            //ch.Port == acc.Port &&
                            (bool)tryLoggin[ ch.IP.Address.ToString() ] )
                        {
                            Console.WriteLine("wait!!!");
                            return new byte[] { 0, 3, 0xEE, 0x1, 0x19 };
                        }*/
                //	Console.WriteLine( "Logon challenge" );
                    int clientVersion = ( ( (int)data[ 11 ] ) * 256  )+ data[ 12 ];
                    byte len = data[ 33 ];
                    userName = new byte[ len ];
                    //Console.Write( "User : "******"";
                    for( t = 0;t < len;t++ )
                    {
                        userName[ t ] = data[ 34 + t ];
                        usern+= "" + (char)data[ 34 + t ];
                    //	Console.Write( "{0}", "" + ((char)userName[ t ] ).ToString() );
                    }
                //	Console.WriteLine( "" );

                    myAccount = World.allAccounts.FindByUserName( usern );
                    if ( World.FreeForAll )
                    {
                        if ( myAccount == null )
                        {
                            World.allAccounts.Add( myAccount = new Account( usern, usern ) );
                        }
                    }
                    if ( myAccount == null )
                        return new byte[] { 0x1, 0x4 };

                    if ( myAccount.SelectedChar != null )
                    {
                    //	Console.WriteLine("Already loggin");
                        return new byte[] { 1, 0x6 };
                         // Already logged in
                    }

                    SHA1 sha = new SHA1CryptoServiceProvider();

                    string pass = "******" + myAccount.Password.ToUpper();
                    char []passc = pass.ToCharArray();
                    byte []passb = new byte[ passc.Length ];
                    int ti = 0;
                    foreach( char c in passc )
                        passb[ ti++ ] = (byte)c;
                    byte []user = Concat( userName, passb );
                    byte []hash = sha.ComputeHash( user, 0 , user.Length );
                    byte []res = new Byte[ hash.Length + salt.Length ];
                    t = 0;
                    rand.NextBytes( salt );
                    foreach( byte s in salt )
                        res[ t++ ] = s;
                    foreach( byte s in hash )
                        res[ t++ ] = s;
                    byte []hash2 = sha.ComputeHash( res, 0, res.Length );
                    byte []x = Reverse( hash2 );

                    rN = Reverse( N );
                    rand.NextBytes( b );
                    rb = Reverse( b );

                    BigInteger bi = new BigInteger( x );
                    BigInteger bi2 = new BigInteger( rN );
                    BigInteger g = new BigInteger( new byte[] { 7 } );
                    v = g.modPow( bi, bi2 );

                    K = new BigInteger( new Byte[] { 3 } );
                    BigInteger temp1 = K * v;
                    BigInteger temp2 = g.modPow( new BigInteger( rb ), new BigInteger( rN ) );
                    BigInteger temp3 = temp1 + temp2;
                    B = temp3 % new BigInteger( rN );

                /*	byte []ezfd= B.getBytes();
                    Console.WriteLine("B");
                    HexViewer.View( ezfd, 0, ezfd.Length );
                    BigInteger C = new BigInteger();

                    Console.WriteLine("C/Rn {0}", temp3/new BigInteger( rN ) );*/
                    //Console.WriteLine("temp1 {0}",temp1.ToHexString());
                    //Console.WriteLine("temp2 {0}",temp2.ToHexString());
                    //Console.WriteLine("temp3 {0}",temp3.ToHexString());
            /*		for(int ll = 0;ll < 6;ll++)
                    {
                        C = B;
                        C += new BigInteger( rN ) * ll;
                        C -= temp1;
                        Console.WriteLine("temp3 {0}",C.ToHexString());
                    }*/

                    byte []pack = new byte[ 118 ];
                    //byte[] pack = new byte[119];
                    pack[ 0 ] = pack[ 1 ] = 0;
                    byte []tB = Reverse( B.getBytes() );
                    for( t = 0;t < tB.Length ;t++ )
                        pack[ 3 + t ] = tB[ t ];
                    pack[ 35 ] = 1;// g_length
                    pack[ 36 ] = 7;// g
                    pack[ 37 ] = 32;// n_len
                    for( t = 0;t < N.Length;t++ )
                        pack[ 38 + t ] = N[ t ];
                    for( t = 0;t < salt.Length ;t++ )
                        pack[ 70 + t ] = salt[ t ];
                    for( t = 0;t < 16;t++ )
                    //for (t = 0; t < 17; t++)
                        pack[ 102 + t ] = 0;

                    return pack;

                case 0x01://	Logon proof
                {
                    //Console.WriteLine("Logon proof" );
                    byte []A = new byte[ 32 ];
                    for( t = 0;t < 32;t++ )
                    {
                        A[ t ] = data[ t + 1 ];
                    }
                    byte []kM1 = new byte[ 20 ];
                    for( t = 0;t < 20;t++ )
                    {
                        kM1[ t ] = data[ t + 1 + 32 ];
                    }

                    //A = new byte[] { 0x23, 0x2f, 0xb1, 0xb8, 0x85, 0x29, 0x64, 0x3d, 0x95, 0xb8, 0xdc, 0xe7, 0x8f, 0x27, 0x50, 0xc7, 0x5b, 0x2d, 0xf3, 0x7a, 0xcb, 0xa8, 0x73, 0xeb, 0x31, 0x07, 0x38, 0x39, 0xed, 0xa0, 0x73, 0x8d };
                    byte []rA = Reverse( A );
                    //	B = new BigInteger( new byte[] { 0x64, 0x5d, 0x1f, 0x78, 0x97, 0x30, 0x73, 0x70, 0x1e, 0x12, 0xbc, 0x98, 0xaa, 0x38, 0xea, 0x99, 0xb4, 0xbc, 0x43, 0x5c, 0x32, 0xe8, 0x44, 0x7c, 0x73, 0xab, 0x07, 0x7a, 0xe4, 0xd7, 0x59, 0x64 } );
                    byte []AB = Concat( A, Reverse( B.getBytes() ) );

                    SHA1 shaM1 = new SHA1CryptoServiceProvider();
                    byte []U = shaM1.ComputeHash( AB );
                    //	U = new byte[] { 0x2f, 0x49, 0x69, 0xac, 0x9f, 0x38, 0x7f, 0xd6, 0x72, 0x23, 0x6f, 0x94, 0x91, 0xa5, 0x16, 0x77, 0x7c, 0xdd, 0xe1, 0xc1 };
                    byte []rU = Reverse( U );

                    temp1 = v.modPow( new BigInteger( rU ), new BigInteger( rN ) );
                    temp2 = temp1 * new BigInteger( rA );
                    temp3 = temp2.modPow( new BigInteger( rb ), new BigInteger( rN ) );

                    byte []S1 = new byte[ 16 ];
                    byte []S2 = new byte[ 16 ];
                    byte []S = new byte[ 32 ];
                    byte []temp = temp3.getBytes();
                /*	Console.WriteLine("temp");
                    HexViewer.View( temp, 0, temp.Length );
                    Console.WriteLine("temp1 {0}", temp1.ToHexString());
                    Console.WriteLine("temp2 {0}", temp2.ToHexString());
                    Console.WriteLine("temp3 {0}", temp3.ToHexString());*/
                    Buffer.BlockCopy( temp, 0, S, 0, temp.Length );
                    byte []rS = Reverse( S );

                    for( t = 0;t < 16;t++)
                    {
                        S1[ t ] = rS[ t * 2 ];
                        S2[ t ] = rS[ ( t * 2 ) + 1 ];
                    }
                    byte []hashS1 = shaM1.ComputeHash( S1 );
                    byte []hashS2 = shaM1.ComputeHash( S2 );
                    myAccount.SS_Hash = new byte[ hashS1.Length + hashS2.Length ];
                    for( t = 0;t < hashS1.Length ;t++ )
                    {
                        myAccount.SS_Hash[ t * 2 ] = hashS1[ t ];
                        myAccount.SS_Hash[ ( t * 2 ) + 1 ] = hashS2[ t ];
                    }

                    //	SS_Hash = new byte[] { 0x02, 0x61, 0xf4, 0xeb, 0x48, 0x91, 0xb6, 0x6a, 0x1a, 0x82, 0x6e, 0xb7, 0x79, 0x28, 0xd8, 0x64, 0xb7, 0xea, 0x14, 0x54, 0x38, 0xdb, 0x7c, 0xfd, 0x0d, 0x3d, 0x2f, 0xc0, 0x22, 0xce, 0xcc, 0x46, 0x83, 0x79, 0xf2, 0xc0, 0x87, 0x78, 0x7f, 0x14 };

                    byte []NHash = shaM1.ComputeHash( N );
                    byte []GHash = shaM1.ComputeHash( new byte[]{ 7 } );
                    byte []userHash = shaM1.ComputeHash( userName );
                    byte []NG_Hash = new byte[ 20 ];
                    for( t = 0;t < 20;t++ )
                    {
                        NG_Hash[ t ] = (byte)( NHash[ t ] ^ GHash[ t ] );
                    }
                    byte []Temp = Concat( NG_Hash, userHash );
                    Temp = Concat( Temp, salt );
                    Temp = Concat( Temp, A );
                    Temp = Concat( Temp, B.getBytes() );
                    Temp = Concat( Temp, K.getBytes() );//SS_Hash );

                    byte []M1 = shaM1.ComputeHash( Temp );

                    Temp = Concat( A, kM1 );
                    Temp = Concat( Temp, myAccount.SS_Hash );

                    byte []M2 = shaM1.ComputeHash( Temp );

                    byte []retur = new byte[ M2.Length + 4/*NG_Hash.Length */+ 2 ];
                    //	byte []retur = new byte[ M2.Length + NG_Hash.Length + 2 ];
                    retur[ 0 ] = 0x1;
                    retur[ 1 ] = 0x0;
                    for(t = 0;t < M2.Length;t++ )
                        retur[ t + 2 ] = M2[ t ];

                    //for(t = 0;t < NG_Hash.Length;t++ )
                    //	retur[ t + 2 + 20 ] = NG_Hash[ t ];

                    //	set the account properties
                    Console.WriteLine("Logon proof for {0},{1}", IP.ToString(), myAccount.Username );
                    myAccount.Ip = this.IP;
                    myAccount.Port = 0;
                    myAccount.K = myAccount.SS_Hash;

                    return retur;
                }
                case 0x02://	Reconnect challenge
                {
                //	Console.WriteLine( "Reconnect challenge" );
                    byte []packRecoChallenge = new byte[ 34 ];
                    packRecoChallenge[ 0 ] = 0x02;
                    packRecoChallenge[ 1 ] = 0x00;
                    for( t = 0;t < 16 ;t++ )
                        packRecoChallenge[ 18 + t ] = 0;
                    return packRecoChallenge;
                }
                case 0x03://	Reconnect proof
                //	Console.WriteLine( "Reconnect proof" );
                    return new byte[] { 0x03, 0x00 };
                case 0x04://	Update server
                //	Console.WriteLine( "Update server" );
                    break;
                case 0x10://	Realm List
                //	Console.WriteLine( "Realm lList request" );
                    string ip = World.ServerIP;
                /*	if ( base.theClientHandler.IP.ToString().StartsWith( "192.168.0" ) )
                    {
                        ip = "192.168.0.2";
                    }
                    else*/
                    if ( IP.ToString() == "127.0.0.1" )
                    {
                        ip = "127.0.0.1";
                    }
                    byte []retData = new byte[ 25 + ip.Length + World.ServerName.Length + World.ServerPort.ToString().Length ];
                /*
                byte []retData = new byte[ ]{   0x10, 45,
                                          0x00, 0x00, 0x00, 0x00,
                                          0x00,
                                          0x01, 0x00, 0x00, 0x00,
                                          0x00, 0x00,
                                          (byte)'D', (byte)'r', (byte)' ', (byte)'N', (byte)'e',
                                          (byte)'x', (byte)'u', (byte)'s',
                                          0x00, (byte)'1', (byte)'9', (byte)'2', (byte)'.',
                                          (byte)'1', (byte)'6', (byte)'8', (byte)'.',
                                          (byte)'0', (byte)'.',
                                          (byte)'2',
                                          0x3a, 0x38, 0x30, 0x38, 0x35,
                                          0x00, 0x00, 0x00, 0x00,
                                          0x00, 0x00,
                                          0x01, 0x00,
                                          0x02, 0x00 };*/
                    int offset = 0;
                    Converter.ToBytes( (byte)0x10, retData, ref offset );
                    Converter.ToBytes( (byte)43, retData, ref offset );
                    Converter.ToBytes( 1/*World.allConnectedChars.Count*/, retData, ref offset );
                    Converter.ToBytes( (byte)0, retData, ref offset );
                    Converter.ToBytes( 1, retData, ref offset );
                    Converter.ToBytes( (short)0, retData, ref offset );
                    Converter.ToBytes( World.ServerName, retData, ref offset );
                    Converter.ToBytes( (byte)0, retData, ref offset );
                    Converter.ToBytes( ip, retData, ref offset );
                    Converter.ToBytes( (byte)':', retData, ref offset );
                    Converter.ToBytes( World.ServerPort.ToString(), retData, ref offset );
                    Converter.ToBytes( (byte)0, retData, ref offset );
                    Converter.ToBytes( 0, retData, ref offset );
                //	Converter.ToBytes( (short)0, retData, ref offset );//	cr erreir
                    //Converter.ToBytes( (short)1, retData, ref offset );
                    //Converter.ToBytes( (short)2, retData, ref offset );

                    Converter.ToBytes( (short)World.allConnectedChars.Count, retData, ref offset );
                    Converter.ToBytes( (byte)0, retData, ref offset );
                    Converter.ToBytes( (short)1, retData, ref offset );
                    int atlen = 1;
                    offset -= 3;
                    Converter.ToBytes( offset, retData, ref atlen );
                    Console.WriteLine("Connected player(s) {0}", World.allConnectedChars.Count );
                /*	if ( World.allConnectedChars.Count < 3 )*/
                        //Thread.Sleep( 500 );
                    return retData;

                default:
                    Console.WriteLine( "Receive unknown command {0}", data[ 0 ] );
                    break;

            }
            byte []ret = { 0, 0, 0, 0 };
            return ret;
        }
示例#2
0
        public byte[] DequeueData( byte []data, int length )
        {
            int len = 0;
            int after = 0;
            int code = 0;
            #if !DEBUG
            try
            {
            #endif
            //	Console.Write( "{0}:{1}:{2} {1} <-- ", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, this.IP.ToString() );
            //	HexViewer.View( data, after, length );
            //	Console.WriteLine("IP {0} port {1} ", IP, this.Port );
                if ( playerAccount == null )
                {
            //		Console.WriteLine("playerAccount == null");
                    firstPacket = true;
                    if ( ( (IPEndPoint)this.clientSocket.RemoteEndPoint ) == null )
                        return null;
                    playerAccount = World.allAccounts.FindAccountByIp( IP, ( (IPEndPoint)this.clientSocket.RemoteEndPoint ).Port );
                //	Console.WriteLine("Account {2} IP {0} port {1} ", IP, this.Port, playerAccount.Username );
                }
                else
                    playerAccount.lastHeartBeat = DateTime.Now;

            //	Console.WriteLine("after == {0}", after);
                while( after != - 1 )
                {
                    if ( !firstPacket )
                    {
                        byte a1 = data[ after ];
                        byte a2 = data[ after + 1 ];
                        byte a3 = data[ after + 2 ];
                        byte a4 = data[ after + 3 ];
                        Decode( data, after, length - after );
                        code = ( (int)data[ after + 2 ] ) + ( ( (int)data[ after + 3 ] ) << 8 );
                        len = ( (int)data[ after + 1 ] ) + ( ( (int)data[ after + 0 ] ) << 8 );
                    //	if ( File.Exists( "debug.txt"  ) )
                            /*		switch( code )
                                    {
                                        case (int)OpCodes.MSG_MOVE_FALL_LAND:
                                        case MSG_MOVE_JUMP: case MSG_MOVE_START_FORWARD : case MSG_MOVE_START_BACKWARD: case MSG_MOVE_SET_FACING:
                                        case MSG_MOVE_STOP: case MSG_MOVE_START_STRAFE_LEFT: case MSG_MOVE_START_STRAFE_RIGHT: case MSG_MOVE_STOP_STRAFE:
                                        case MSG_MOVE_START_TURN_LEFT: case MSG_MOVE_START_TURN_RIGHT:  case MSG_MOVE_STOP_TURN: case MSG_MOVE_START_PITCH_UP :
                                        case MSG_MOVE_START_PITCH_DOWN: case MSG_MOVE_STOP_PITCH : case MSG_MOVE_SET_RUN_MODE: case MSG_MOVE_SET_WALK_MODE:
                                        case MSG_MOVE_SET_PITCH: case MSG_MOVE_START_SWIM:
                                        case MSG_MOVE_STOP_SWIM:
                                        case (int)OpCodes.SMSG_MONSTER_MOVE:
                                            break;
                                        default:
                                            if (	loggedChar != null )
                                            Console.Write( "{0}:{1}:{2} {3}-{1} <-- ", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, this.IP.ToString(), this.loggedChar.Guid );
                                            HexViewer.View( data, after, len + 2 );
                                            break;
                                    }*/
                        if ( after + len > data.Length )
                        {
                            byte []toret = new byte[ data.Length - after ];
                            Buffer.BlockCopy( data, after, toret, 0, toret.Length );
                            if ( toret.Length > 0 )
                                toret[ 0 ] = a1;
                            if ( toret.Length > 1 )
                                toret[ 1 ] = a2;
                            if ( toret.Length > 2 )
                                toret[ 2 ] = a3;
                            if ( toret.Length > 3 )
                                toret[ 3 ] = a4;
                            return toret;
                        }
                    }
                    else
                    {
                        code = ( (int)data[ after + 2 ] ) + ( ( (int)data[ after + 3 ] ) << 8 );
                        len = ( (int)data[ after + 1 ] ) + ( ( (int)data[ after + 0 ] ) << 8 );
                    }

                    firstPacket = false;

                    if ( playerAccount != null && playerAccount.loggoutTimer != null )
                    {
                    //	Console.WriteLine("playerAccount != null && playerAccount.loggoutTimer != null");
                        if ( code == (int)OpCodes.CMSG_LOGOUT_CANCEL )
                        {
                            playerAccount.CancelLogout();
                            return null;
                        }
                        SendNullAction( code );
                        return null;
                    }

                //	Console.WriteLine("code {0}",code);
                    switch( code )
                    {
                        case 0x1DC:
                        {
                            //	Heart beat
                            byte []pack = new byte[]{  0x00, 0x06, 0xDD, 0x01, data[ 6 ], data[ 7 ], data[ 8 ], data[ 9 ] };
                            Send( pack );
                            if ( playerAccount != null )
                                playerAccount.HeartBeat();
                            break;

                        }
                        case 0x0036://	new char request
                        {
                            playerAccount.AddCharacter( data );
                            break;
                        }
                        case 0x1ED:
                            break;
                        case (int)OpCodes.CMSG_CHAR_DELETE:
                            playerAccount.Handler = this;
                            playerAccount.DeleteChar( BitConverter.ToUInt64( data, after + 6 ) );
                            //Player.Handler = null;
                            break;

                        case 0x0037:
                        {
                            needLog = false;
                            int t = 4;
                            byte []pack = playerAccount.PrepareDataList( ref t );
                            t-=2;
                            pack[ 0 ] = (byte)( ( t >> 8 ) & 0xff );
                            pack[ 1 ] = (byte)( t & 0xff );
                            pack[ 2 ] = 0x3b;
                            pack[ 3 ] = 0x00;
                            byte []toSend = new byte[ t + 2 ];
                            for(int i = 0;i < t + 2;i++ )
                                toSend[ i ] = pack[ i ];
                            Send( toSend );
                            break;
                        }
                        case 0x003D://	login
                        {
                            dt.Stop();
                            UInt64 guid = (UInt64)BitConverter.ToInt64( data, after + 6 );
                            playerAccount.Handler = this;
                            loggedChar = playerAccount.Login( guid );
                            if ( loggedChar != null )
                            {
                                //SMSG_FRIEND_LIST
                                Send( new byte[]{ 0x00, 0x06, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00 } );
                                //	UpdateTimer updateTimer = new UpdateTimer( this, loggedChar );
                            }
                            else
                                playerAccount.Handler.Send( new byte[]{ 0x00, 0x03, 0x41, 0x00, 0x00 } );
                            break;
                        }
                        default:
                            if ( loggedChar == null )
                            {
                                this.Dispose();
                                return null;
                            }
                            break;
                    }

                    if ( loggedChar != null )
                    {
                        loggedChar.ManagePacket( code, data, ref after, len );
                    }
            /*
                    switch( code )
                    {
                        case MSG_MOVE_START_FORWARD :

                        case (int)OpCodes.MSG_MOVE_FALL_LAND:
                        case (int)OpCodes.MSG_MOVE_JUMP:
                        case (int)OpCodes.MSG_MOVE_START_BACKWARD: case (int)OpCodes.MSG_MOVE_SET_FACING:
                        case (int)OpCodes.MSG_MOVE_STOP: case (int)OpCodes.MSG_MOVE_START_STRAFE_LEFT:
                        case (int)OpCodes.MSG_MOVE_START_STRAFE_RIGHT: case (int)OpCodes.MSG_MOVE_STOP_STRAFE:
                        case (int)OpCodes.MSG_MOVE_START_TURN_LEFT: case (int)OpCodes.MSG_MOVE_START_TURN_RIGHT:
                        case (int)OpCodes.MSG_MOVE_STOP_TURN: case (int)OpCodes.MSG_MOVE_START_PITCH_UP :
                        case (int)OpCodes.MSG_MOVE_START_PITCH_DOWN: case (int)OpCodes.MSG_MOVE_STOP_PITCH :
                        case (int)OpCodes.MSG_MOVE_SET_RUN_MODE: case (int)OpCodes.MSG_MOVE_SET_WALK_MODE:
                        case (int)OpCodes.MSG_MOVE_SET_PITCH: case (int)OpCodes.MSG_MOVE_START_SWIM:
                        case (int)OpCodes.MSG_MOVE_STOP_SWIM:

                            // 00 30 EE 00
                            //00 00 01 20 00 00 6B 8C 09 00
                            //F8 6F 33 45
                            //42 F5 41 C4
                            //5D 6D 20 43
                            //AC 6A 73 40
                            //BA 00 00 00 00 00 00 00 CD F4 49 BF FF 51 1D BF 00 00 E0 40 .@
                        case (int)OpCodes.MSG_MOVE_HEARTBEAT:
                        {
                            if ( code == (int)OpCodes.MSG_MOVE_START_TURN_LEFT ||
                                code == (int)OpCodes.MSG_MOVE_SET_FACING ||
                                code == (int)OpCodes.MSG_MOVE_START_TURN_RIGHT )
                                loggedChar.deadEndTeleportLoop = false;
                        //	TimeSpan ts = DateTime.Now.Subtract( lastUpdate );
                        //	if ( ts.TotalSeconds > 2 )
                            playerAccount.RefreshMobileList( false );
                            playerAccount.realylogged = true;
                            if (loggedChar.AutoShot != null)
                                loggedChar.AutoShot.Restart();
                            playerAccount.MvtToAllPlayerNear( code, data, after, len + 2 );
                            float x = BitConverter.ToSingle( data, after + 14 );
                            float y = BitConverter.ToSingle( data, after + 18 );
                            float z = BitConverter.ToSingle( data, after + 22 );
                            float orientation = BitConverter.ToSingle( data, after + 26 );
                            loggedChar.MoveHandler( x, y, z, orientation );
                            if ( code != (int)OpCodes.MSG_MOVE_FALL_LAND && loggedChar.path != null )
                            {
                                if ( loggedChar.path.Count > 0 )
                                {
                                    int ne = loggedChar.path.Count - 1;
                                    float xx = loggedChar.path[ ne ].x - x;
                                    float yy = loggedChar.path[ ne ].y - y;
                                    float zz = loggedChar.path[ ne ].z - z;
                                    if ( xx + yy + zz != 0 )
                                    {
                                        loggedChar.SendMessage( "Pos x="+x.ToString()+"; y="+y.ToString()+"; z="+z.ToString() );
                                        Coord l = lastCoordTrajet;
                                        lastCoordTrajet = new Coord( x, y, z, lastCoordTrajet, null );
                                        l.next = lastCoordTrajet;
                                        loggedChar.path.Add( lastCoordTrajet, l );
                                    }
                                }
                                else
                                {
                                    lastCoordTrajet = new Coord( x, y, z, null, null );
                                    loggedChar.path.Add( lastCoordTrajet );
                                }
                            }
                            else
                                if ( code == MSG_MOVE_START_STRAFE_RIGHT || code == MSG_MOVE_START_STRAFE_LEFT )
                            {
                                if ( loggedChar.IsCasting )
                                {
                                    loggedChar.CancelCast();
                                }
                            }

                            break;
                        }
                        case (int)OpCodes.CMSG_USE_ITEM:
                            loggedChar.UseItem( data[ after + 6 ], BitConverter.ToInt32( data, after + 7 ) );
                            break;
                        case (int)OpCodes.CMSG_DUEL_CANCELLED:
                        {
                            loggedChar.CancelDuel( BitConverter.ToUInt64( data, after + 6 ) );
                            break;
                        }
                        case (int)OpCodes.CMSG_DUEL_ACCEPTED:
                        {
                            loggedChar.SendDuelArbitrer( BitConverter.ToUInt64( data, after + 6 ) );
                            break;
                        }
                        case (int)OpCodes.CMSG_ENABLE_PVP:
                        {
                            break;
                        }
                        case (int)OpCodes.CMSG_CANCEL_AUTO_REPEAT_SPELL:
                        {
                            loggedChar.OnCancelAutoCastSpell();
                            break;
                        }

                        case (int)OpCodes.CMSG_CAST_SPELL:
                            if ( loggedChar.taxiOn )
                            {
                                loggedChar.SpellFaillure( SpellFailedReason.YourAreInFligth );
                            }
                            else
                            {
                                if ( BitConverter.ToInt32( data, after + 6 ) == 7266 )
                                    loggedChar.PrepareInv( data, after );
                                ushort type = BitConverter.ToUInt16( data, after + 10 );
                                loggedChar.OnCastSpellCMSG(data,after,type);
                            }
                            break;
                        case (int)OpCodes.CMSG_ATTACKSWING:
                            loggedChar.AttackSwing( BitConverter.ToUInt64( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_CANCEL_CAST:
                            loggedChar.CancelCast();
                            break;
                        case (int)OpCodes.CMSG_SET_SELECTION:
                            loggedChar.SetSelection( BitConverter.ToUInt64( data, after + 6 ) );
                            //						SendNullAction( code );
                            break;
                        case (int)OpCodes.CMSG_STANDSTATECHANGE:
                            loggedChar.ChangeStandState( BitConverter.ToInt32( data, after + 6 ) );
                            break;

                        case 0x1DC:
                        {
                            //	Heart beat
                            byte []pack = new byte[]{  0x00, 0x06, 0xDD, 0x01, data[ 6 ], data[ 7 ], data[ 8 ], data[ 9 ] };
                            Send( pack );
                            if ( playerAccount != null )
                                playerAccount.HeartBeat();
                            break;

                        }
                        case 0x0036://	new char request
                        {
                            playerAccount.AddCharacter( data );
                            break;
                        }

                        case 0x0037:
                        {
                            needLog = false;
                            int t = 4;
                            byte []pack = playerAccount.PrepareDataList( ref t );
                            t-=2;
                            pack[ 0 ] = (byte)( ( t >> 8 ) & 0xff );
                            pack[ 1 ] = (byte)( t & 0xff );
                            pack[ 2 ] = 0x3b;
                            pack[ 3 ] = 0x00;
                            byte []toSend = new byte[ t + 2 ];
                            for(int i = 0;i < t + 2;i++ )
                                toSend[ i ] = pack[ i ];
                            //	byte[]toSend = new byte[]{ 0x00, 0xA6, 0x3B, 0x00 , 0x01 , 0xD4 , 0x2F , 0x15 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x52 , 0x69 , 0x73 , 0x65 , 0x00 , 0x07 , 0x01 , 0x01 , 0x04 , 0x03 , 0x03 , 0x01 , 0x06 , 0x01 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x8F , 0x02 , 0xC3 , 0xC5 , 0x39 , 0x84 , 0xA5 , 0x43 , 0x06 , 0x61 , 0xBF , 0x43 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xA3 , 0x26 , 0x00 , 0x00 , 0x04 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xA4 , 0x26 , 0x00 , 0x00 , 0x07 , 0x9D , 0x27 , 0x00 , 0x00 , 0x08 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x06 , 0x06 , 0x00 , 0x00 , 0x15 , 0x2A , 0x49 , 0x00 , 0x00 , 0x0E , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00  };
                            Send( toSend );
                            break;
                        }
                        case 0x003D://	login
                        {
                            dt.Stop();
                            UInt64 guid = (UInt64)BitConverter.ToInt64( data, after + 6 );
                            playerAccount.Handler = this;
                            loggedChar = playerAccount.Login( guid );
                            if ( loggedChar != null )
                            {
                                //SMSG_FRIEND_LIST
                                Send( new byte[]{ 0x00, 0x06, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00 } );
                            //	UpdateTimer updateTimer = new UpdateTimer( this, loggedChar );
                            }
                            else
                                playerAccount.Handler.Send( new byte[]{ 0x00, 0x03, 0x41, 0x00, 0x00 } );
                            break;
                        }
                        case (int)OpCodes.CMSG_GAMEOBJECT_QUERY:
                            loggedChar.GameObjectQuery( BitConverter.ToInt32( data, after + 6 ), (UInt64)BitConverter.ToUInt64( data, after + 10 ) );
                            break;
                        case (int)OpCodes.CMSG_SET_TARGET:
                            loggedChar.Target = (UInt64)BitConverter.ToInt64( data, after + 6 );
                            //	SendNullAction( code );
                            break;
                        case (int)OpCodes.CMSG_LIST_INVENTORY:
                            loggedChar.ShowMobileInventory( (UInt64)BitConverter.ToInt64( data, after + 6 ) );
                            SendNullAction( code );
                            break;
                        case (int)OpCodes.CMSG_BUY_ITEM:
                            loggedChar.Buy( BitConverter.ToUInt64( data, after + 6 ), BitConverter.ToInt32( data, after + 14 ), Slots.None, data[ after + 19 ] );
                            break;
                        case (int)OpCodes.CMSG_SELL_ITEM:
                            loggedChar.Sell( BitConverter.ToUInt64( data, after + 6 ), BitConverter.ToUInt64( data, after + 14 ) );
                            break;

                        case 0x020B:
                            //SendNullAction( code );
                            break;
                        case (int)OpCodes.CMSG_SET_ACTIVE_MOVER://	Account update
                            //	SendNullAction( code );
                            break;
                        case 0x211://	CMSG_GMTICKET
                            playerAccount.Handler.Send( 0x212, new byte[]{ 0x00, 0x06 , 0x12 , 0x02 , 0x01 , 0x00 , 0x00 , 0x00 } );
                            break;
                        case 0x1CE://	Query time
                            byte []buffTime = { 0,0,0,0, 0x90,0xE0,0x22,0x42};
                            playerAccount.Handler.Send( (int)OpCodes.SMSG_QUERY_TIME_RESPONSE, buffTime );
                            break;
                        case 0x1FF://	Looking for Group
                            SendNullAction( code );
                            break;
                        case (int)OpCodes.CMSG_NAME_QUERY:
                            loggedChar.SendName( BitConverter.ToUInt64( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_MESSAGECHAT:
                            //00 00 00 00 00 00 07 00 00 00 7A 6F 62 00
                        {
                            string cmd = "";
                            for(int t = 0;data[ after + t + 14 ] != 0;t++ )
                                cmd += "" + (char)data[ after + t + 14 ];
                            loggedChar.MessageHandler( cmd, (Character.ChatMsgType)BitConverter.ToInt32( data, after + 6 ), BitConverter.ToInt32( data, after + 10 ) );
                            break;
                        }
                        case 0x284:// MSG_QUERY_NEXT_MAIL_TIME
                            playerAccount.Handler.Send( OpCodes.MSG_QUERY_NEXT_MAIL_TIME, new byte[]{ 0,0,0,0, 0x00, 0x0 , 0x0 , 0x0 } );
                            break;
                        case 0xFB://	CMSG_NEXT_CINEMATIC_CAMERA
                            break;
                        case 0xFC://	CMSG_COMPLETE_CINEMATIC
                            break;
                        case 0xFE://	CMSG_TUTORIAL_FLAG
                            //	loggedChar.Trace();
                            break;
                        case 0xFF://	CMSG_TUTORIAL_CLEAR
                            break;
                        case (int)OpCodes.CMSG_JOIN_CHANNEL://	CMSG_JOIN_CHANNEL
                            loggedChar.JoinChannel( data, after + 6 );
                            debloque = true;
                            break;
                        case 0x1F4://	CMSG_ZONEUPDATE
                            loggedChar.ZoneUpdateRequested( BitConverter.ToInt32( data, after + 6 ) );
                            break;
                        case 0x56://	CMSG_ITEM_QUERY_SINGLE
                            loggedChar.SendItem( BitConverter.ToInt32( data, after + 6 ), BitConverter.ToUInt64( data, after + 10 ) );
                            break;
                        case (int)OpCodes.CMSG_LOOT_MONEY:
                            loggedChar.OnLootMoney();
                            break;
                        case (int)OpCodes.CMSG_CREATURE_QUERY:
                            loggedChar.CreatureQuery( (UInt64)BitConverter.ToInt64( data, after + 10 ), BitConverter.ToInt32( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_LOOT_RELEASE:
                            loggedChar.ReleaseLoot();
                            break;
                        case (int)OpCodes.CMSG_AUTOSTORE_LOOT_ITEM:
                            loggedChar.AutostoreLootItem( data[ after + 6 ] );
                            break;
                        case (int)OpCodes.CMSG_LOOT:
                            loggedChar.LootCreature( BitConverter.ToUInt64( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_SETSHEATHED:
                            loggedChar.Sheathed = BitConverter.ToInt32( data, after + 6 );
                            break;
                        case (int)OpCodes.CMSG_QUESTGIVER_QUERY_QUEST:
                            loggedChar.QuestQueryForCreature( BitConverter.ToUInt64( data, after + 6 ), BitConverter.ToInt32( data, after + 14 ) );
                            break;
                        case (int)OpCodes.CMSG_QUESTGIVER_STATUS_QUERY:
                            loggedChar.QuestStatus( BitConverter.ToUInt64( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_QUESTGIVER_HELLO:
                            loggedChar.QuestGiverHello( BitConverter.ToUInt64( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_NPC_TEXT_QUERY:
                            loggedChar.NpcTextQuery( BitConverter.ToInt32( data, after + 6 ), BitConverter.ToUInt64( data, after + 10 ) );
                            break;
                        case (int)OpCodes.CMSG_GOSSIP_SELECT_OPTION:
                            loggedChar.GossipSelectOption( BitConverter.ToUInt64( data, after + 6 ), BitConverter.ToInt32( data, after + 14 ) );
                            break;
                        case (int)OpCodes.CMSG_QUESTGIVER_ACCEPT_QUEST:
                            loggedChar.AcceptQuest( BitConverter.ToUInt64( data, after + 6 ), BitConverter.ToInt32( data, after + 14 ) );
                            break;
                        case (int)OpCodes.CMSG_QUESTLOG_REMOVE_QUEST:
                            loggedChar.RemoveQuest( data[ after + 6 ] );
                            break;
                        case (int)OpCodes.CMSG_QUESTGIVER_COMPLETE_QUEST:
                            loggedChar.QuestGiverCompleteQuest( BitConverter.ToUInt64( data, after + 6 ), BitConverter.ToInt32( data, after + 14 ) );
                            break;
                        case (int)OpCodes.CMSG_QUEST_QUERY:
                            loggedChar.QuestQuery( BitConverter.ToInt32( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_QUESTGIVER_CHOOSE_REWARD:
                            loggedChar.ChooseReward( BitConverter.ToUInt64( data, after + 6 ), BitConverter.ToInt32( data, after + 14 ), BitConverter.ToInt32( data, after + 18 ) );
                            break;
                        case (int)OpCodes.CMSG_GAMEOBJ_USE:
                            loggedChar.GameObjectUse( BitConverter.ToUInt64( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_ATTACKSTOP:
                            if ( playerAccount == null || loggedChar == null )
                                return null;
                            loggedChar.StopAttacking();
                            break;
                        case 0x20A://	CMSG_REQUEST_ACCOUNT_DATA
                            break;
                        case (int)OpCodes.CMSG_SWAP_INV_ITEM:
                            loggedChar.SwapInv( (Slots)data[ after + 6 ], (Slots)data[ after + 7 ] );
                            break;
                        case (int)OpCodes.CMSG_SWAP_ITEM:
                            loggedChar.SwapItem( data[ after + 6 ], data[ after + 7 ], data[ after + 8 ], data[ after + 9 ] );
                            break;
                        case (int)OpCodes.CMSG_DESTROYITEM:
                            loggedChar.DestroyItem( Item.SlotNum( data[ after + 6 ], data[ after + 7 ] ), true );
                            break;
                        case (int)OpCodes.CMSG_AUTOEQUIP_ITEM:
                            loggedChar.AutoEquip( Item.SlotNum( data[ after + 6 ], data[ after + 7 ] ) );
                            break;
                        case (int)OpCodes.CMSG_AUTOSTORE_BAG_ITEM:
                            loggedChar.Autostore( Item.SlotNum( data[ after + 6 ], data[ after + 7 ] ), data[ after + 8 ] );
                            break;
                        case (int)OpCodes.CMSG_INITIATE_TRADE:
                            loggedChar.InitiateTrade( BitConverter.ToUInt64( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_BEGIN_TRADE:
                            loggedChar.BeginTrade();
                            break;
                        case (int)OpCodes.CMSG_SET_TRADE_ITEM:
                            loggedChar.TradeItem( data[ after + 6 ], Item.SlotNum( data[ after + 7 ], data[ after + 8 ] ) );
                            break;
                        case (int)OpCodes.CMSG_CLEAR_TRADE_ITEM:
                            loggedChar.ClearTradeItem( (int)data[ after + 6 ] );
                            break;
                        case (int)OpCodes.CMSG_SET_TRADE_GOLD:
                            loggedChar.TradeGold( BitConverter.ToInt32( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_LOGOUT_REQUEST:
                        {
                            playerAccount.Handler.Send( OpCodes.SMSG_LOGOUT_RESPONSE, new byte[]{ 0x00, 0x06 , 0x12 , 0x02 , 00, 00, 00, 00, 00 } );
                            playerAccount.LoggoutStartTimer();
                            break;
                        }
                        case (int)OpCodes.CMSG_SET_ACTION_BUTTON:
                            loggedChar.AddToActionBar( data[ after + 6 ], BitConverter.ToUInt16( data, after + 7 ), data[ after + 9 ], data[ after + 10 ] );
                            break;

                        case (int)OpCodes.CMSG_TRAINER_LIST:
                            loggedChar.TrainerList( BitConverter.ToUInt64( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_TRAINER_BUY_SPELL:
                            loggedChar.TrainerBuy( BitConverter.ToUInt64( data, after + 6 ), BitConverter.ToInt32( data, after + 14 ) );
                            break;
                        case (int)OpCodes.CMSG_CHAR_DELETE:
                            playerAccount.Handler = this;
                            playerAccount.DeleteChar( BitConverter.ToUInt64( data, after + 6 ) );
                            //playerAccount.Handler = null;
                            break;
                        case (int)OpCodes.CMSG_UNLEARN_SKILL:
                            loggedChar.SendMessage( "Not available yet !" );
                            break;
                        case (int)OpCodes.CMSG_SET_AMMO:
                            loggedChar.SetAmmo( BitConverter.ToInt32( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_TEXT_EMOTE:
                            loggedChar.OnTextEmote( BitConverter.ToInt32( data, after + 6 ), BitConverter.ToUInt64( data, after + 14 ) );
                            break;
                        case (int)OpCodes.CMSG_RECLAIM_CORPSE:
                            loggedChar.ReclaimCorps();
                            break;
                        case (int)OpCodes.MSG_CORPSE_QUERY:
                            loggedChar.CorpseQuery();
                            break;
                        case (int)OpCodes.CMSG_REPOP_REQUEST:
                            loggedChar.OnRepop();
                            break;
                        case (int)OpCodes.CMSG_CANCEL_TRADE:
                            loggedChar.CancelTrade();
                            break;
                        case (int)OpCodes.CMSG_ACCEPT_TRADE:
                            loggedChar.AcceptTrade();
                            break;
                        case (int)OpCodes.CMSG_UNACCEPT_TRADE:
                            if ( loggedChar == null )
                            {
                                this.Dispose();
                                break;
                            }
                            loggedChar.UnacceptTrade();
                            break;
                        case (int)OpCodes.CMSG_LEAVE_CHANNEL:
                            SendNullAction( (int)OpCodes.SMSG_CHANNEL_NOTIFY );
                            break;
                        case (int)OpCodes.CMSG_MEETING_STONE_INFO:
                            loggedChar.MeetingStoneInfo();
                            break;
                        case (int)OpCodes.CMSG_CANCEL_AURA:
                            loggedChar.CancelAura(  BitConverter.ToInt32( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_PET_ACTION:
                            loggedChar.PetAction( BitConverter.ToUInt16( data, after + 0xe ), data[ after + 17 ], BitConverter.ToUInt64( data, after + 18 ) );
                            break;
                        case (int)OpCodes.CMSG_PET_SET_ACTION:
                            if ( len == 0x14 )
                                loggedChar.SetPetAction( BitConverter.ToUInt64( data, after + 6 ), BitConverter.ToInt32( data, after + 0xe ), BitConverter.ToUInt32( data, after + 0x12 ) );
                            else
                                loggedChar.SetPetAction( BitConverter.ToUInt64( data, after + 6 ), BitConverter.ToUInt32( data, after + 0xe ), BitConverter.ToUInt32( data, after + 0x12 ), BitConverter.ToUInt32( data, after + 0x16 ), BitConverter.ToUInt32( data, after + 0x1A ) );
                            break;
                        case (int)OpCodes.CMSG_PET_ABANDON:
                            loggedChar.DismissPet( BitConverter.ToUInt64( data, after + 6 ) );
                            break;
                        case (int)OpCodes.MSG_MOVE_WORLDPORT_ACK:
                            loggedChar.TeleportAck();
                            break;
                        case (int)OpCodes.CMSG_GROUP_INVITE:
                                string name = "";
                                for(int t = 0;data[ after + t + 6 ] != 0;t++ )
                                    name += "" + (char)data[ after + t + 6 ];
                                loggedChar.GroupInvite( name );
                            break;
                        case (int)OpCodes.CMSG_LEARN_TALENT:
                            loggedChar.LearnTalent( BitConverter.ToInt32( data, after + 6 ), BitConverter.ToInt32( data, after + 10 ) );
                            break;
                        case (int)OpCodes.CMSG_GROUP_ACCEPT:
                            loggedChar.GroupAccept();
                            break;
                        case (int)OpCodes.CMSG_GROUP_DISBAND:
                            loggedChar.QuitGroup();
                            break;
                        case (int)OpCodes.CMSG_GROUP_UNINVITE:
                            string uname = "";
                            for(int t = 0;data[ after + t + 6 ] != 0;t++ )
                                uname += "" + (char)data[ after + t + 6 ];
                            loggedChar.GroupUninvite( uname );
                            break;
                        case (int)OpCodes.CMSG_GROUP_SET_LEADER:
                            string lname = "";
                            for(int t = 0;data[ after + t + 6 ] != 0;t++ )
                                lname += "" + (char)data[ after + t + 6 ];
                            loggedChar.GroupSetLeader( lname );
                            break;
                        case (int)OpCodes.CMSG_GROUP_DECLINE:
                            loggedChar.GroupDecline();
                            break;
                        case (int)OpCodes.CMSG_FORCE_RUN_SPEED_CHANGE_ACK:
                            loggedChar.ForceSpeedAck();
                            break;
                        case (int)OpCodes.CMSG_AREATRIGGER:
                            if (Character.onAreaTrigger != null)
                                loggedChar.AreaTrigger( BitConverter.ToInt32( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_TAXINODE_STATUS_QUERY:
                            Taxi.OnCMSG_TAXINODE_STATUS_QUERY( loggedChar );
                            break;
                        case (int)OpCodes.CMSG_TAXIQUERYAVAILABLENODES:
                            Taxi.OnCMSG_TAXIQUERYAVAILABLENODES( loggedChar );
                            break;
                        case (int)OpCodes.CMSG_ACTIVATETAXI:
                            Taxi.OnCMSG_ACTIVATETAXI(loggedChar,BitConverter.ToUInt32( data, after + 14 ),BitConverter.ToUInt32( data, after + 18 ));
                    //		HexViewer.View( data, after, length );
                            break;
                        case (int)OpCodes.CMSG_CANCEL_CHANNELLING:
                            loggedChar.ChannelEnd();
                            break;
                        case (int)OpCodes.CMSG_BINDER_ACTIVATE:
                        //	UInt64 fromg = BitConverter.ToUInt64( data, after + 12 );
                        //	Mobile from = loggedChar.Player.FindMobileByGuid( fromg );
                        //	Character.onBinderActivate( loggedChar, from, BitConverter.ToInt32( data, after + 6 ) );
                            break;
                        case (int)OpCodes.CMSG_GOSSIP_HELLO:
                        {
                            UInt64 fromh = BitConverter.ToUInt64( data, after + 6 );
                            loggedChar.GossipHello( fromh );
                            break;
                        }
                        case (int)OpCodes.CMSG_BUY_ITEM_IN_SLOT:
                        {
                            UInt64 fromseller = BitConverter.ToUInt64( data, after + 6 );
                            int itemid = BitConverter.ToInt32( data, after + 0xe );
                            byte slot = data[ after + 0x1A ];
                            byte n = data[ after + 0x1B ];
                            loggedChar.Buy( fromseller, itemid, (Slots)slot, n );
                            break;
                        }
                        case (int)OpCodes.CMSG_LOOT_METHOD:
                        {
                            loggedChar.SetLootMethod( BitConverter.ToInt32( data, after + 0x6 ) );
                            break;
                        }
                        case (int)OpCodes.CMSG_FRIEND_LIST:
                        {
                            loggedChar.SendFriendList();
                            break;
                        }
                        case (int)OpCodes.CMSG_WHO:
                        {
                            loggedChar.WhoIsRequest();
                            break;
                        }
                        case (int)OpCodes.CMSG_ADD_FRIEND:
                        {
                            string addf = "";
                            for(int t = 0;data[ after + t + 6 ] != 0;t++ )
                                addf += "" + (char)data[ after + t + 6 ];
                            loggedChar.AddFriend( addf );
                            break;
                        }
                        case (int)OpCodes.CMSG_SPIRIT_HEALER_ACTIVATE:
                        {
                            loggedChar.ReclaimCorps();
                            break;
                        }

                        default:
                            if ( code != 0x2CE )
                                Console.WriteLine( "{2} : Receive unknown command {0} ({1})", (OpCodes)code, code.ToString( "X4" ), loggedChar.Name );
                            if ( code > 0x330 )
                            {
                                Console.WriteLine("");
                                Console.WriteLine("{0} kicked", playerAccount.Username );
                                playerAccount.Loggout( loggedChar.Guid );
                                //playerAccount.StopPacketHandler();
                                this.Dispose();
                            }

                            break;
                    }*/
                    if ( len + 2 < ( length - after ) )
                    {
                        //	Console.WriteLine( "Partiel {0} sur {1}/{2}", after, len, length );
                        after += ( len + 2 );
                    }
                    else
                    {
                        //	Console.WriteLine( "Fin" );
                        after = -1;
                    }
                }
                return null;
            #if !DEBUG
            }
            catch( Exception e )
            {
                if ( alreadyCrashed )
                    return null;
                alreadyCrashed = true;
                string info1 = "";
                if ( playerAccount != null )
                    info1 += "Account " + playerAccount.Username;
                if ( loggedChar != null )
                    info1 += " character " + loggedChar.Name;
                info1 += " cause a crash";
                Console.WriteLine( info1 );
                Console.WriteLine( e.Message );
                Console.WriteLine( e.Source );
                Console.WriteLine( e.StackTrace );
                if ( this.loggedChar == null )
                    Console.Write( "{0}:{1}:{2} NULL {3} <-- ", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, this.IP.ToString() );
                else
                    Console.Write( "{0}:{1}:{2} {3} {4} <-- ", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, this.IP.ToString(), this.loggedChar.Guid );
                Console.WriteLine("Code {2} Len {0} After {1}", len, after, code );
                HexViewer.View( data, after, len + 2 );
                /*World.allConnectedAccounts.SendMessageToConnectedGM( info1 );
                World.allConnectedAccounts.SendMessageToConnectedGM( e.Message );
                World.allConnectedAccounts.SendMessageToConnectedGM( e.Source );
                World.allConnectedAccounts.SendMessageToConnectedGM( e.StackTrace );*/
                playerAccount.Loggout( 0 );
                this.Dispose();
                if ( MainConsole.sw1 != null )
                    MainConsole.sw1.Flush();
                alreadyCrashed = false;
                return null;
            }
            #endif
        }
示例#3
0
        public override byte[] ProcessDataReceived( byte []data, int length )
        {
            /*	Console.WriteLine("ProcessDataReceived receive" );
            HexViewer.View( data, 0, length );
            Console.WriteLine("ProcessDataReceived end" );*/
            //	Console.WriteLine("ProcessDataReceived enter" );
            if ( playerAccount == null )
            {
                Console.WriteLine("playerAccount == null, IP={0}", IP.ToString() );
                if ( ( data[ 0 ] == 0 || data[ 0 ] == 2 ) && data[ 2 ] == 0xed && data[ 3 ] == 0x1 )
                {
                    string username = "";
                    for(int t = 0xe;t < length;t++ )
                    {
                        if ( data[ t ] == 0 )
                            break;
                        username += "" + (char)data[ t ];
                    }
                    playerAccount = World.allAccounts.FindByUserName( username );
                    Console.WriteLine("Player {0} with IP {1}", username, IP );
                    if ( playerAccount == null )
                    {
                        Console.WriteLine("Strange bug, {0} was not found in the account list !", username );
                        return null;
                    }
                    playerAccount.Handler = this;
                    playerAccount.PreLogin();
                    if ( playerAccount.packetHandler == null )
                    {
                        Console.WriteLine("packetHandler cannot be null");
                    }

                    if ( playerAccount.Packets.Count > 0 )
                    {
                        Queue q = new Queue();
                        q.Enqueue( new Packet( data, length ) );
                        while( playerAccount.Packets.Count > 0 )
                            q.Enqueue( playerAccount.Packets.Dequeue() );
                        playerAccount.Packets = q;
                    }
                //	Console.WriteLine("Packets.Enqueue for {0} total {1}", playerAccount.Username, playerAccount.Packets.Count );
                    if ( playerAccount.Packets.Count > 100 )
                    {
                        Console.WriteLine("Player {0} send too many packets !!! Kicked !!!" );
                        playerAccount.Packets.Clear();
                        this.Logout();
                        return null;
                    }
                //	playerAccount.Packets.Enqueue( new Packet( data, length ) );
                //	Console.Write( "{0}:{1}:{2}-{1} <-- ", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, this.IP.ToString() );
                //	HexViewer.View( data, 0, length );
                    key = new byte[]{ 0, 0, 0, 0 };
                    needEncode = true;
                    needLog = true;
                    dt = new DelaySend( this );

                    firstPacket = false;
                //	playerAccount.PacketHandler();
                    return null;
                }
                else
                    playerAccount = World.allAccounts.FindNotLoggedAccountByIp( IP );//, Port );

                if ( playerAccount == null )
                {
                    Console.WriteLine( "IP doesn't match the prior IP client send !!!\nMake sure your IP match the IP in the realmlist.rtf" );
                    this.Dispose();
                    return null;
                }
                if ( !needEncode && playerAccount.packetHandler != null )
                {
            //			Console.WriteLine("!needEncode, playerAccount.packetHandler != null" );
                    playerAccount.packetHandler.Stop();
                    playerAccount.packetHandler = null;
                }
                if ( playerAccount != null && playerAccount.packetHandler == null )
                {
            //		Console.WriteLine("playerAccount.packetHandler == null" );
                    playerAccount.Handler = this;
                    playerAccount.PreLogin();
                }

            }
            //	if ( playerAccount != null )//&& playerAccount.SelectedChar != null )
            //	{
            //	Console.WriteLine("ExMutuel.WaitOne" );
            //	playerAccount.ExMutuel.WaitOne();
            //		Console.WriteLine("Packets.Enqueue for {0} total {1}", playerAccount.Username, playerAccount.Packets.Count );
            if ( playerAccount == null )
                Console.WriteLine("Loosing packet for {0}",IP.ToString() );
            else
            {
                lock( playerAccount.Packets )
                {
                    playerAccount.Packets.Enqueue( new Packet( data, length ) );
                }
            }
            //	playerAccount.ExMutuel.ReleaseMutex();
            //	}

            //	else
            //		return DequeueData( data, length );
            //	Console.WriteLine("End" );
            return null;
        }
示例#4
0
文件: Account.cs 项目: karliky/wowwow
 public LoggoutTimer( Account acc )
     : base(WowTimer.Priorities.Second, 3000, "LoggoutTimer")
 {
     from = acc;
     if ( from.selectedChar == null )//	already loggout
         Stop();
     Start();
 }
示例#5
0
文件: Account.cs 项目: karliky/wowwow
 public AutoDeconnect( Account acc )
     : base(WowTimer.Priorities.Second5, 10000, "AutoDeconnect")
 {
     from = acc;
     Start();
 }
示例#6
0
		public void Login( Account acc )
		{
			account = acc;
			guowner = null;
			gu = null;			
			ZoneId = World.mapZones.NearestZoneId( this );
		}
示例#7
0
 /// <summary>
 ///   Adds a <see cref='Account'/> with the specified value to the 
 ///   <see cref='Accounts'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Account'/> to add.</param>
 /// <returns>The index at which the new element was inserted.</returns>
 /// <seealso cref='Accounts.AddRange'/>
 public int Add(Account val)
 {
     return List.Add(val);
 }
示例#8
0
 /// <summary>
 ///   Inserts a <see cref='Account'/> into the <see cref='Accounts'/> at the specified index.
 /// </summary>
 /// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param>
 /// <param name='val'>The <see cref='Account'/> to insert.</param>
 /// <seealso cref='Accounts.Add'/>
 public void Insert(int index, Account val)
 {
     List.Insert(index, val);
 }
示例#9
0
        /// <summary> 
        /// Load all accounts from xml file 
        /// </summary> 
        /// <param name="filename">file with accounts</param> 
        /// <returns></returns> 
        public void Load( string filename )
        {
            if ( System.IO.File.Exists( filename ) )
            {
                XmlFile file = new XmlFile( filename );

                int ver = 1;//readed version, for compatibility (new account list)

                if ( file.DocumentElement.Attributes["version"]!= null )
                {
                    try { ver = Convert.ToInt32(file.DocumentElement.Attributes["version"]); }
                    catch { ver = 1; }
                    // need corrections, maybe wrong file or bad records? .. etc
                }

                foreach ( XmlNode node in file.DocumentElement.SelectNodes( "account" ) )
                {
                    Account acc = new Account( ver, node, file );
                    if ( acc != null )
                        List.Add( acc );
                }
            }
            if ( Count == 0 )
            {
                Account admin = new Account( "admin", "changeme", AccessLevels.Admin );
                Add( admin );
            }
        }
示例#10
0
 public void Deserialize( GenericReader gr )
 {
     List.Clear();
     if ( !gr.notFound )
     {
         int version = gr.ReadInt();
         int n = gr.ReadInt();
         for(int t = 0;t < n;t++ )
         {
             Add( new Account( gr ) );
         }
     }
     if ( Count == 0 )
     {
         Account admin = new Account( "admin", "changeme", AccessLevels.Admin );
         Add( admin );
     }
     if ( !gr.notFound )
         gr.Close();
 }
示例#11
0
 /// <summary>
 ///    Returns the index of a <see cref='Account'/> in 
 ///       the <see cref='Accounts'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Account'/> to locate.</param>
 /// <returns>
 ///   The index of the <see cref='Account'/> of <paramref name='val'/> in the 
 ///   <see cref='Accounts'/>, if found; otherwise, -1.
 /// </returns>
 /// <seealso cref='Accounts.Contains'/>
 public int IndexOf(Account val)
 {
     return List.IndexOf(val);
 }
示例#12
0
 /// <summary>
 ///   Copies the <see cref='Accounts'/> values to a one-dimensional <see cref='Array'/> instance at the 
 ///    specified index.
 /// </summary>
 /// <param name='array'>The one-dimensional <see cref='Array'/> that is the destination of the values copied from <see cref='Accounts'/>.</param>
 /// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
 /// <exception cref='ArgumentException'>
 ///   <para><paramref name='array'/> is multidimensional.</para>
 ///   <para>-or-</para>
 ///   <para>The number of elements in the <see cref='Accounts'/> is greater than
 ///         the available space between <paramref name='arrayIndex'/> and the end of
 ///         <paramref name='array'/>.</para>
 /// </exception>
 /// <exception cref='ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
 /// <exception cref='ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
 /// <seealso cref='Array'/>
 public void CopyTo(Account[] array, int index)
 {
     List.CopyTo(array, index);
 }
示例#13
0
 /// <summary>
 ///   Gets a value indicating whether the 
 ///    <see cref='Accounts'/> contains the specified <see cref='Account'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Account'/> to locate.</param>
 /// <returns>
 /// <see langword='true'/> if the <see cref='Account'/> is contained in the collection; 
 ///   otherwise, <see langword='false'/>.
 /// </returns>
 /// <seealso cref='Accounts.IndexOf'/>
 public bool Contains(Account val)
 {
     return List.Contains(val);
 }
示例#14
0
 /// <summary>
 ///   Copies the elements of an array to the end of the <see cref='Accounts'/>.
 /// </summary>
 /// <param name='val'>
 ///    An array of type <see cref='Account'/> containing the objects to add to the collection.
 /// </param>
 /// <seealso cref='Accounts.Add'/>
 public void AddRange(Account[] val)
 {
     for (int i = 0; i < val.Length; i++)
     {
         this.Add(val[i]);
     }
 }
示例#15
0
		public void ItemsUpdateForOther( Account acc )
		{
			ItemsUpdateForOther( acc.Handler );
		}
示例#16
0
 /// <summary>
 ///   Removes a specific <see cref='Account'/> from the <see cref='Accounts'/>.
 /// </summary>
 /// <param name='val'>The <see cref='Account'/> to remove from the <see cref='Accounts'/>.</param>
 /// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
 public void Remove(Account val)
 {
     List.Remove(val);
 }
示例#17
0
		public Character( Account acc, byte []data ): this( -8897.50f, -173.480f, 81.5775f, 0f )
		{			
			account = acc;
			Name = "";
			int part = 0;
			for(int t = 6;t < data.Length;t++ )			
			{
				byte b = data[ t ];
				if ( part == 0 )
				{
					if ( b == 0 )
					{
						part++;					
					}
					else
						if ( b != 0 && part == 0 )
						Name += (char)b;
				}
				else
					if ( part == 1 )
				{
					race = (Races)b;
					part++;
				}
				else
					if ( part == 2 )
				{							
					switch( b )
					{
						case (int)Classes.Warrior:
							if ( !World.WarriorClassAvailable )
							{
								this.Send( OpCodes.SMSG_CHAR_CREATE, new byte[]{ 0, 0, 0, 0, 0x31 } );
								Name = null;
								return;
							}
							Classe = Classes.Warrior;
							manaType = 1;
							AllSkills.Add( new DaggerSkill( 1, 300 ) );
							AllSkills.Add( new AxeSkill( 1, 300 ) );
							AllSkills.Add( new SwordSkill( 1, 300 ) );
							AllSkills.Add( new MacesSkill( 1, 300 ) );
							AllSkills.Add( new ShieldSkill( 1, 1 ) );
							AllSkills.Add( new ClothSkill( 1, 1 ) );
							AllSkills.Add( new LeatherSkill( 1, 1 ) );
							AllSkills.Add( new MailSkill( 1, 1 ) );
							
							if ( Race == Races.Orc || Race == Races.Dwarf )
								AllSkills.Add( new TwoHandedAxeSkill( 1, 300 ) );
							else
							if ( Race == Races.Tauren )
								AllSkills.Add( new TwoHandedMaceSkill( 1, 300 ) );
							else								
								AllSkills.Add( new TwoHandedSwordSkill( 1, 300 ) );
							AllSkills.Add( new Arms( 1, 1 ) );
							AllSkills.Add( new Protection( 1, 1 ) );
							Mana = BaseMana = 100;							
							break;
						case (int)Classes.Paladin:
							if ( !World.PaladinClassAvailable )
							{
								this.Send( OpCodes.SMSG_CHAR_CREATE, new byte[]{ 0, 0, 0, 0, 0x31 } );
								Name = null;
								return;
							}
							Classe = Classes.Paladin;
							manaType = 0;
							AllSkills.Add( new TwoHandedMaceSkill( 1, 300 ) );
							AllSkills.Add( new MacesSkill( 1, 300 ) );
							AllSkills.Add( new ClothSkill( 1, 1 ) );
							AllSkills.Add( new ShieldSkill( 1, 1 ) );
							AllSkills.Add( new LeatherSkill( 1, 1 ) );
							AllSkills.Add( new MailSkill( 1, 1 ) );
							break;
						case (int)Classes.Rogue:
							if ( !World.RogueClassAvailable )
							{
								this.Send( OpCodes.SMSG_CHAR_CREATE, new byte[]{ 0, 0, 0, 0, 0x31 } );
								Name = null;
								return;
							}
							Classe = Classes.Rogue;
							manaType = 3;
							AllSkills.Add( new ThrowsSkill( 1, 300 ) );
							AllSkills.Add( new DaggerSkill( 1, 300 ) );
							AllSkills.Add( new ThrowsSkill( 1, 300 ) );
							AllSkills.Add( new ClothSkill( 1, 1 ) );
							AllSkills.Add( new LeatherSkill( 1, 1 ) );
							AllSkills.Add( new Assassination( 1, 1 ) );
							AllSkills.Add( new Subtlety( 1, 1 ) );
							AllSkills.Add( new Combat( 1, 1 ) );
							Mana = BaseMana = 100;
							break;
						case (int)Classes.Hunter:
							if ( !World.HunterClassAvailable )
							{
								this.Send( OpCodes.SMSG_CHAR_CREATE, new byte[]{ 0, 0, 0, 0, 0x31 } );
								Name = null;
								return;
							}
							Classe = Classes.Hunter;
							manaType = 0;
							AllSkills.Add( new AxeSkill( 1, 300 ) );
							AllSkills.Add( new BowsSkill( 1, 300 ) );
							AllSkills.Add( new DaggerSkill( 1, 300 ) );
							AllSkills.Add( new LeatherSkill( 1, 1 ) );
							AllSkills.Add( new ClothSkill( 1, 1 ) );
							AllSkills.Add( new GunSkill( 1, 300 ) );
							break;
						case (int)Classes.Warlock:
							if ( !World.WarlockClassAvailable )
							{
								this.Send( OpCodes.SMSG_CHAR_CREATE, new byte[]{ 0, 0, 0, 0, 0x31 } );
								Name = null;
								return;
							}
							Classe = Classes.Warlock;
							manaType = 0;
							AllSkills.Add( new WandsSkill( 1, 300 ) );
							AllSkills.Add( new DaggerSkill( 1, 300 ) );
							AllSkills.Add( new Destruction( 1, 300 ) );
							AllSkills.Add( new Demonology( 1, 300 ) );
							AllSkills.Add( new Affliction( 1, 300 ) );
							AllSkills.Add( new ClothSkill( 1, 1 ) );
							Mana = BaseMana = 100;
							break;
						case (int)Classes.Mage:
							if ( !World.MageClassAvailable )
							{
								this.Send( OpCodes.SMSG_CHAR_CREATE, new byte[]{ 0, 0, 0, 0, 0x31 } );
								Name = null;
								return;
							}
							Classe = Classes.Mage;
							manaType = 0;
							AllSkills.Add( new WandsSkill( 1, 300 ) );
							//AllSkills.Add( new DaggerSkill( 1, 300 ) );
							AllSkills.Add( new StavesSkill( 1, 300 ) );
							AllSkills.Add( new ClothSkill( 1, 300 ) );

							AllSkills.Add( new ArcaneSkill( 1, 300 ) );
							AllSkills.Add( new FireSkill( 1, 300 ) );
							AllSkills.Add( new FrostSkill( 1, 300 ) );

							Mana = BaseMana = 100;
							break;
						case (int)Classes.Shaman:
							if ( !World.ShamanClassAvailable )
							{
								this.Send( OpCodes.SMSG_CHAR_CREATE, new byte[]{ 0, 0, 0, 0, 0x31 } );
								Name = null;
								return;
							}
							Classe = Classes.Shaman;
							manaType = 0;
							AllSkills.Add( new StavesSkill( 1, 300 ) );
							AllSkills.Add( new MacesSkill( 1, 300 ) );
							AllSkills.Add( new ClothSkill( 1, 1 ) );
							AllSkills.Add( new LeatherSkill( 1, 1 ) );
							break;
						case (int)Classes.Priest:
							if ( !World.PriestClassAvailable )
							{
								this.Send( OpCodes.SMSG_CHAR_CREATE, new byte[]{ 0, 0, 0, 0, 0x31 } );
								Name = null;
								return;
							}
							Classe = Classes.Priest;
							manaType = 0;
							AllSkills.Add( new WandsSkill( 1, 300 ) );
							AllSkills.Add( new MacesSkill( 1, 300 ) );
							AllSkills.Add( new ClothSkill( 1, 1 ) );
							break;
						case (int)Classes.Druid:
							if ( !World.DruidClassAvailable )
							{
								this.Send( OpCodes.SMSG_CHAR_CREATE, new byte[]{ 0, 0, 0, 0, 0x31 } );
								Name = null;
								return;
							}
							Classe = Classes.Druid;
							manaType = 0;
							AllSkills.Add( new StavesSkill( 1, 300 ) );
							AllSkills.Add( new LeatherSkill( 1, 1 ) );
							AllSkills.Add( new ClothSkill( 1, 1 ) );
							break;
						default:
							manaType = 0;
							break;
					}
					part++;
				}
				else
					if ( part == 3 )
				{
					gender = b;
					part++;
				}
				else
					if ( part == 4 )
				{
					skin = b;
					part++;
				}
				else
					if ( part == 5 )
				{
					face = b;
					part++;
				}
				else
					if ( part == 6 )
				{
					hairStyle = b;
					part++;
				}
				else
					if ( part == 7 )
				{
					hairColour = b;
					part++;
				}
				else
					if ( part == 8 )
				{
					facialHair = b;
					part++;
					break;
				}
			}


			foreach( Account acco in World.allAccounts )
				foreach( Character ch in acco.characteres )
					if ( ch.Name.ToLower() == Name.ToLower() )
					{
						byte []pack = new byte[]{  0x00, 0x03, 0x3a, 0x00, 0x39 };
						Send( pack );
						Name = null;
						return;
					}

			MapId = 0;
			ZoneId = 9;

			HitPoints = 50;
			BaseHitPoints = 50;
			Rage = BaseRage = 350;
			Level = 1;

			//	Skill lang = null;

			/*TrainAbility( 6247 );//	Open
			TrainAbility( 6249 );//	Open
			TrainAbility( 6461 );//	Open*/
			TrainAbility( 6477 );//	Open
			TrainAbility( 6478 );//	Open
			TrainAbility( 7266 );//	Open
			//TrainAbility( 11437 );//	Open

			switch( Race)
			{
				case Races.Human:
					Faction = Factions.Player_Human;
					break;
				case Races.Dwarf:
					Faction = Factions.Player_Dwarf;
					break;
				case Races.NightElf:
					Faction = Factions.Player_Elf;
					break;
				case Races.Gnome:
					Faction = Factions.Player_Gnome;
					break;
				case Races.Orc:
					Faction = Factions.Player_Orc;
					break;
				case Races.Undead:
					Faction = Factions.Player_Undead;
					break;
				case Races.Tauren:
					Faction = Factions.Player_Tauren;
					break;
				case Races.Troll:
					Faction = Factions.Player_Troll;
					break;
			}
			foreach( Factions f in World.FriendRaces[ Race ] as ArrayList )
				reputationAdjustments[ (int)World.FactionAssociated[ f ] ] = 0;

			onCharacterChooseRace( this, race );
			Copper = 100;
			AllSkills.Add( new UnarmedSkill( 1, 300 ) );
			AllSkills.Add( new DefenseSkill( 1, 300 ) );

			OnCreateCharacter();
			byte []ok = new byte[]{  0x00, 0x03, 0x3a, 0x00, 0x2d };
			Send( ok );
		}
示例#18
0
 /// <summary>
 ///   Initializes a new instance of <see cref='Accounts'/> containing any array of <see cref='Account'/> objects.
 /// </summary>
 /// <param name='val'>
 ///       A array of <see cref='Account'/> objects with which to intialize the collection
 /// </param>
 public Accounts(Account[] val)
 {
     this.AddRange(val);
 }
示例#19
0
		public void Loggout()
		{
			account = null;
		}
示例#20
0
        public override byte[] ProcessDataReceived( byte []data, int length )
        {
            string crlf = "" + (char)0xd + "" + (char)0xa;
            if ( World.AllowHttpFrom != "0.0.0.0" && World.AllowHttpFrom != IP.ToString() )
            {
                Send403();
                return null;
            }
            if ( !World.onHttpDataReceived( this, data, length ) )
                return null;
            try
            {
                string str = "";
                for(int t = 0;t < length;t++ )
                {
                    str += "" + (char)data[ t ];
                }

                string []strs = str.Split( new char[] { ' ' } );
                if ( strs[ 0 ] == "POST" )
                {
                    if ( strs[ 1 ] == "/account.htm" )
                    {
                        int iuser = str.IndexOf( "username="******"password="******"Username : {0}, Password : {1}", username, password );
                        if ( username.Length > 12 || password.Length > 12 )
                            return null;
                        Account newAccount = new Account( username, password, AccessLevels.PlayerLevel );
                        Account myAccount = World.allAccounts.FindByUserName( username.ToUpper() );
                        if ( myAccount == null )
                        {
                            World.allAccounts.Add( newAccount );
                            TextReader tx = new StreamReader( "./http/accountcreated.htm" );
                            string part2 = tx.ReadToEnd();
                            tx.Close();
                            string part1 = "HTTP/1.1 200 OK" + crlf +
                                "Date: " + DateTime.Now.ToString( "r" ) + crlf +
                                "Server: Dr Nexus 0.1a" + crlf +
                                "X-Powered-By: Dr Nexus" + crlf +
                                "Cache-Control: private" + crlf +
                                //	"Keep-Alive: timeout=15, max=98" +  crlf +
                                "Connection: close" + crlf + //Keep-Alive" + crlf +
                                //	"Transfer-Encoding: chunked" + crlf +
                                "Content-Length: " + ( part2.Length ).ToString() + crlf +
                                "Content-Type: text/html" + crlf + crlf;

                            string pageHtml = part1 + part2;
                            Send( pageHtml );
                            //Send( part2 );
                            return null;
                        }
                        else
                        {
                            World.allAccounts.Add( newAccount );
                            TextReader tx = new StreamReader( "./http/accounterror.htm" );
                            string part2 = tx.ReadToEnd();
                            tx.Close();
                            string part1 = "HTTP/1.1 200 OK" + crlf +
                                "Date: " + DateTime.Now.ToString( "r" ) + crlf +
                                "Server: Dr Nexus 0.1a" + crlf +
                                "X-Powered-By: Dr Nexus" + crlf +
                                "Cache-Control: private" + crlf +
                                //	"Keep-Alive: timeout=15, max=98" +  crlf +
                                "Connection: close" + crlf + //Keep-Alive" + crlf +
                                //	"Transfer-Encoding: chunked" + crlf +
                                "Content-Length: " + ( part2.Length ).ToString() + crlf +
                                "Content-Type: text/html" + crlf + crlf;

                            string pageHtml = part1 + part2;
                            Send( pageHtml );
                            //Send( part2 );
                            return null;
                        }
                    }
                }
                if ( strs[ 0 ] == "GET" )
                {
                    if ( strs[ 1 ] == "/status.htm" )
                    {
                        TextReader tx = new StreamReader( "./http/status.htm" );
                        string part2 = tx.ReadToEnd();
                        tx.Close();

                        string part3 = "";
                        string fonct = "";
                        for(int t = 0;t < part2.Length;t++ )
                        {
                            if ( part2[ t ] == '<' && state == 0 )
                                state = 1;
                            else
                                if ( part2[ t ] == '?' && state == 1 )
                                state = 2;
                            else
                                if ( part2[ t ] == '?' && state == 2 )
                                state = 3;
                            else
                                if ( part2[ t ] == '>' && state == 3 )
                            {
                                state = 0;
                                fonct = "using System;using System.Collections;using Server.Items;using HelperTools; namespace Server { " + fonct + " }";
                                CSharpCodeProvider codeProvider = new CSharpCodeProvider();
                                ICodeCompiler compiler = codeProvider.CreateCompiler();
                                CompilerParameters parameters = new CompilerParameters();

                                parameters.GenerateExecutable = false;
                                parameters.GenerateInMemory = true;

                                parameters.MainClass = "";
                                foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
                                {
                                    parameters.ReferencedAssemblies.Add(asm.Location);
                                }

                                parameters.IncludeDebugInformation = false;
                                //parameters.OutputAssembly = "./res.dll";

                                CompilerResults results = compiler.CompileAssemblyFromSource( parameters, fonct );

                                if (results.Errors.Count > 0)
                                {
                                    string errors = "Compilation failed:\n";
                                    foreach (CompilerError err in results.Errors)
                                    {
                                        errors += err.ToString() + "\n";
                                    }
                                    part3 += "<p>" + errors + "</p>";
                                }
                                else
                                {
                                    Assembly asm = results.CompiledAssembly;
                                    ConstructorInfo ct = Utility.FindConstructor( "HttpHandler", asm );
                                    BaseHttpHandler h = (BaseHttpHandler)ct.Invoke( null );
                                    part3 += h.Get();
                                }
                            }
                            else
                                if ( state == 2 )
                            {
                                fonct += part2[ t ];
                            }
                            else
                            {
                                if ( state == 1 )
                                    part3 += "<";
                                state = 0;
                                part3 += part2[ t ];
                            }
                        }

                        string part1 = "HTTP/1.1 200 OK" + crlf +
                            "Date: " + DateTime.Now.ToString( "r" ) + crlf +
                            "Server: Dr Nexus 0.1a" + crlf +
                            "X-Powered-By: Dr Nexus" + crlf +
                            "Cache-Control: private" + crlf +
                            "Connection: close" + crlf +
                            "Content-Length: " + ( part3.Length ).ToString() + crlf +
                            "Content-Type: text/html" + crlf + crlf;
                        Send( part1 + part3 );
                        //Send( part3 );
                        return null;
                    }
                    else
                        if ( strs[ 1 ] == "/account.htm" )
                    {
                        TextReader tx = new StreamReader( "./http/account.htm" );
                        string part2 = tx.ReadToEnd();
                        tx.Close();
                        string part1 = "HTTP/1.1 200 OK" + crlf +
                            "Date: " + DateTime.Now.ToString( "r" ) + crlf +
                            "Server: Dr Nexus 0.1a" + crlf +
                            "X-Powered-By: Dr Nexus" + crlf +
                            "Cache-Control: private" + crlf +
                            //	"Keep-Alive: timeout=15, max=98" +  crlf +
                            "Connection: close" + crlf + //Keep-Alive" + crlf +
                            //	"Transfer-Encoding: chunked" + crlf +
                            "Content-Length: " + ( part2.Length ).ToString() + crlf +
                            "Content-Type: text/html" + crlf + crlf;

                        //	string pageHtml = part1 + part2;
                        Send( part1 + part2 );
                        //Send( part2 );
                        return null;
                    }
                    Send404();
                }
            }
            catch( Exception )
            {
            }
            Send403();
            return null;
        }