/// <summary>
 ///
 /// </summary>
 /// <param name="worldExtendData"></param>
 public CharRenameSQL(WorldExtendData worldExtendData, NetState netState, long iCharacterGuid, string strCharacterName)
 {
     m_WorldExtendData  = worldExtendData;
     m_NetState         = netState;
     m_iCharacterGuid   = iCharacterGuid;
     m_strCharacterName = strCharacterName;
 }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        public static void World_HandleAuthSession(NetState netState, PacketReader packetReader)
        {
            WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_AuthSession(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == true)
            {
                Debug.WriteLine("World_PacketHandlers.World_AuthSession(...) - extendData.IsLoggedIn == true error!");
                return;
            }

            extendData.AuthSession = AuthSession.ReadWorldAuthSession(packetReader);

            Serial serial = PendingLogins.ExclusiveSerial.GetExclusiveSerial();

            PendingLogins.AddAuthenticate(serial, netState);   // 等待登陆

            // 通知 Realm Server 有新的客户端需要验证
            ProcessServer.RealmNetState.Send(new Realm_RequestSession(serial, extendData.AuthSession.AccountName));
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void World_HandleRealmSplitStateRequest(NetState netState, PacketReader packetReader)
        {
            LOGs.WriteLine(LogMessageType.MSG_HACK, "World_HandleRealmSplitStateRequest...... {0} ", packetReader.Size);

            WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleRealmSplitStateRequest(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleRealmSplitStateRequest(...) - extendData.IsLoggedIn == false error!");
                return;
            }

            if (packetReader.Size < 10 /*ProcessNet.WORLD_HEAD_SIZE + 0*/)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleRealmSplitStateRequest(...) - extendData.Size < 10 error!");
                return;
            }

            uint iUnknown = packetReader.ReadUInt32();

            netState.Send(new Word_RealmSplitStateRequest(iUnknown));
            //netState.Send( new Word_CharEnumResponse( new WowCharacterInfo[0] ) );
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="worldExtendData"></param>
 public CharRenameSQL( WorldExtendData worldExtendData, NetState netState, long iCharacterGuid, string strCharacterName )
 {
     m_WorldExtendData = worldExtendData;
     m_NetState = netState;
     m_iCharacterGuid = iCharacterGuid;
     m_strCharacterName = strCharacterName;
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="newNetState"></param>
        internal static void WorldInitializeNetState(object sender, NetStateInitEventArgs netStateInit)
        {
            LOGs.WriteLine(LogMessageType.MSG_HACK, "World_InitializeNetState...... 0");

            if (netStateInit.NetStateInit != null)
            {
                // 初始化客户端
                WorldExtendData extendData = new WorldExtendData();

                // 客户端保存的扩展数据
                netStateInit.NetStateInit.RegisterComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID, extendData);

                // 加解密数据的接口
                netStateInit.NetStateInit.PacketEncoder = extendData;

                // 开始发送服务端随机的种子给客户端
                netStateInit.NetStateInit.EventConnect += new EventHandler <NetStateConnectEventArgs>(WorldInitConnect);

                // 截获输出的信息包
                netStateInit.NetStateInit.EventSendPacket += new EventHandler <NetStateSendPacketEventArgs>(WorldSendPacket);
            }
            else
            {
                Debug.WriteLine("ProcessNet.World_InitializeNetState(...) - newNetState != null && newNetState.ExtendData == null error!");
            }
        }
        /// <summary>
        /// 开始发送服务端随机的种子给客户端
        /// </summary>
        private static void WorldInitConnect(object sender, NetStateConnectEventArgs eventArgs)
        {
            LOGs.WriteLine(LogMessageType.MSG_HACK, "World_InitConnect...... 0");

            NetState netState = eventArgs.NetStateConnect;

            if (netState == null)
            {
                Debug.WriteLine("ProcessNet.World_InitConnect(...) - netState == null error!");
            }
            else
            {
                // 发送服务端随机的种子信息
                if (netState.Running)
                {
                    WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);
                    if (extendData == null)
                    {
                        Debug.WriteLine("ProcessNet.World_InitConnect(...) - extendData == null error!");
                        return;
                    }

                    netState.Send(new Word_AuthChallenge(extendData.ServerSeed));
                }
            }
        }
        internal static void World_HandleCharRename(NetState netState, PacketReader packetReader)
        {
            WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCharDelete(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCharDelete(...) - extendData.IsLoggedIn == false error!");
                return;
            }

            ulong  iGuid   = packetReader.ReadULong64();
            string strName = packetReader.ReadUTF8String();

            if (ProcessServer.WowZoneCluster.World.GlobalPlayerInfo.GetPlayerInfo(strName) != null)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            CharRenameSQL charEnumSQL = new CharRenameSQL(extendData, netState, (long)iGuid, strName);
            WaitExecuteInfo <CharRenameSQL> waitExecuteInfo = new WaitExecuteInfo <CharRenameSQL>(charEnumSQL, WorldPacketHandlers.SQL_HandleCharRename);

            ProcessServer.WowZoneCluster.World.WaitExecute.JoinWaitExecuteQueue(waitExecuteInfo);
        }
        internal static void World_HandleCharDelete(NetState netState, PacketReader packetReader)
        {
            LOGs.WriteLine(LogMessageType.MSG_ERROR, "World_HandleCharDelete!");

            WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCharDelete(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCharDelete(...) - extendData.IsLoggedIn == false error!");
                return;
            }

            ulong iGuid = packetReader.ReadULong64();

            CharDeleteSQL charEnumSQL = new CharDeleteSQL(extendData, netState, (long)iGuid);
            WaitExecuteInfo <CharDeleteSQL> waitExecuteInfo = new WaitExecuteInfo <CharDeleteSQL>(charEnumSQL, WorldPacketHandlers.SQL_HandleCharDelete);

            ProcessServer.WowZoneCluster.World.WaitExecute.JoinWaitExecuteQueue(waitExecuteInfo);
        }
Exemple #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void World_HandleCancelTrade(NetState netState, PacketReader packetReader)
        {
            WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCancelTrade(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCancelTrade(...) - extendData.IsLoggedIn == false error!");
                return;
            }

            netState.Send(new Word_TradeStatus(TRADE_STATUS.TRADE_STATUS_CANCELLED));
        }
Exemple #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void World_HandleEnableMicrophone(NetState netState, PacketReader packetReader)
        {
            WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleEnableMicrophone(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleEnableMicrophone(...) - extendData.IsLoggedIn == false error!");
                return;
            }

            bool bVoiceEnabled = packetReader.ReadBoolean();
            bool bMicEnabled   = packetReader.ReadBoolean();
        }
Exemple #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void World_HandleChannelNumMembersQuery(NetState netState, PacketReader packetReader)
        {
            WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleChannelNumMembersQuery(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleChannelNumMembersQuery(...) - extendData.IsLoggedIn == false error!");
                return;
            }

            string strChannelName = packetReader.ReadUTF8String();

            netState.Send(new Word_ChannelNumMembersQueryResponse(strChannelName, 0, 0));
        }
Exemple #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void World_HandleCharEnum(NetState netState, PacketReader packetReader)
        {
            WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCharEnum(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCharEnum(...) - extendData.IsLoggedIn == false error!");
                return;
            }

            CharEnumSQL charEnumSQL = new CharEnumSQL(extendData, netState);
            WaitExecuteInfo <CharEnumSQL> waitExecuteInfo = new WaitExecuteInfo <CharEnumSQL>(charEnumSQL, WorldPacketHandlers.SQL_HandleCharEnum);

            ProcessServer.WowZoneCluster.World.WaitExecute.JoinWaitExecuteQueue(waitExecuteInfo);
        }
Exemple #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        public static void World_HandlePing(NetState netState, PacketReader packetReader)
        {
            WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandlePing(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandlePing(...) - extendData.IsLoggedIn == false error!");
                return;
            }

            uint iPing = packetReader.ReadUInt32();

            extendData.Ping.Latency = packetReader.ReadUInt32();

            netState.Send(new Word_Pong(iPing));
        }
Exemple #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="worldExtendData"></param>
 public CharLoginSQL(WorldExtendData worldExtendData, NetState netState, long iCharacterGuid)
 {
     m_WorldExtendData = worldExtendData;
     m_NetState        = netState;
     m_iCharacterGuid  = iCharacterGuid;
 }
Exemple #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="worldExtendData"></param>
 public CharEnumSQL(WorldExtendData worldExtendData, NetState netState)
 {
     m_WorldExtendData = worldExtendData;
     m_NetState        = netState;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="worldExtendData"></param>
 public CharLoginSQL( WorldExtendData worldExtendData, NetState netState, long iCharacterGuid )
 {
     m_WorldExtendData = worldExtendData;
     m_NetState = netState;
     m_iCharacterGuid = iCharacterGuid;
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        internal static void WorldProcessReceive(object sender, NetStateEventArgs eventArgs)
        {
            LOGs.WriteLine(LogMessageType.MSG_HACK, "World_ProcessReceive...... 0 = {0}", eventArgs.NetState.ReceiveBuffer.Length);

            if (eventArgs.NetState == null)
            {
                Debug.WriteLine("ProcessNet.World_ProcessReceive(...) - eventArgs.NetState == null error!");
                return;
            }

            ReceiveQueue receiveQueueBuffer = eventArgs.NetState.ReceiveBuffer;

            if (receiveQueueBuffer == null)
            {
                Debug.WriteLine("ProcessNet.World_ProcessReceive(...) - receiveQueueBuffer == null error!");
                return;
            }

            WorldExtendData extendData = eventArgs.NetState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("ProcessNet.World_ProcessReceive(...) - extendData == null error!");
                return;
            }

            if (receiveQueueBuffer.Length < extendData.ProcessReceiveData.Remaining)
            {
                                                                                       // 等待数据包的完整(Remaining 默认的大小为WORLD_HEAD_SIZE)
                return;
            }

            long iReceiveBufferLength = receiveQueueBuffer.Length; // 隔段时间就会有数据过来,所以可以不用锁定的,锁定了也没用,很难保证多线程中处理了所有的数据(指 Length)

            while (iReceiveBufferLength >= extendData.ProcessReceiveData.Remaining)
            {
                if (extendData.ProcessReceiveData.PacketBuffer == null)   // 如果空 代表是需要获取新的数据包和包头(Remaining == WORLD_HEAD_SIZE)
                {
                    // 获取空数据
                    byte[] packetBuffer = s_ProcessorBuffers.AcquireBuffer();

                    // 获取数据包头的内容
                    long iReturnPacketHeadSize = receiveQueueBuffer.Dequeue(ref packetBuffer, 0, WORLD_HEAD_SIZE);

                    // 获取的数据不相同
                    if (iReturnPacketHeadSize != WORLD_HEAD_SIZE)
                    {
                        Debug.WriteLine("ProcessNet.World_ProcessReceive(...) - iReturnPacketHeadSize != WORLD_HEAD_SIZE error!");

                        // 返回内存池
                        s_ProcessorBuffers.ReleaseBuffer(packetBuffer);

                        eventArgs.NetState.Dispose(); // 断开
                        return;
                    }

                    IPacketEncoder packetEncoder = eventArgs.NetState.PacketEncoder as IPacketEncoder;
                    if (packetEncoder == null)
                    {
                        Debug.WriteLine("ProcessNet.World_ProcessReceive(...) - packetEncoder == null error!");

                        // 返回内存池
                        s_ProcessorBuffers.ReleaseBuffer(packetBuffer);

                        eventArgs.NetState.Dispose(); // 断开
                        return;
                    }

                    // 解密数据包头
                    long iClientPacketHeader = WORLD_HEAD_SIZE;
                    packetEncoder.DecodeIncomingPacket(eventArgs.NetState, ref packetBuffer, ref iClientPacketHeader);

                    // 给出数据信息头
                    WOWClientPacketHeader clientPacketHeader = WOWClientPacketHeader.GetClientPacketHeader(packetBuffer);

                    int iRemaining = clientPacketHeader.PacketSize - 4; // -4 是代表剩余的数据包大小(为什么不是减6呢?)
                    if (receiveQueueBuffer.Length < iRemaining)
                    {
                                                                  // 等待数据包的完整
                        {
                            extendData.ProcessReceiveData.PacketBuffer = packetBuffer;
                            extendData.ProcessReceiveData.Remaining    = (uint)iRemaining;

                            return;
                        }
                    }

                    // 获取信息包数据的剩余内容
                    long iReturnPacketSize = receiveQueueBuffer.Dequeue(ref packetBuffer, WORLD_HEAD_SIZE, iRemaining /*获取剩余数据包大小的字节数*/);

                    // 获取的数据不相同
                    if (iReturnPacketSize != iRemaining)
                    {
                        Debug.WriteLine("ProcessNet.World_ProcessReceive(...) - iReturnPacketSize != iRemaining error!");

                        // 返回内存池
                        s_ProcessorBuffers.ReleaseBuffer(packetBuffer);

                        eventArgs.NetState.Dispose(); // 断开
                        return;
                    }

                    // 获取包的全部长度
                    long iPacketFullLength = iRemaining + WORLD_HEAD_SIZE;

                    // 读取的数据包
                    PacketReader packetReader = new PacketReader(packetBuffer, iPacketFullLength, WORLD_HEAD_SIZE /*包的ID大小-4个字节、长度大小-2个字节, 6个字节跳过*/);


                    //////////////////////////////////////////////////////////////////////////
                    // 输出信息包的日志
                    //////////////////////////////////////////////////////////////////////////
                    ProcessNet.LogServerPack(packetBuffer, iPacketFullLength, "World_In_Packets.log", eventArgs.NetState.ToString(), clientPacketHeader.PacketID, WordOpCodeName.GetWordOpCodeName(clientPacketHeader.PacketID));
                    //////////////////////////////////////////////////////////////////////////


                    // 获取处理数据包的实例
                    PacketHandler packetHandler = ProcessServer.WorldPacketHandlers.GetHandler(clientPacketHeader.PacketID);
                    if (packetHandler == null)   // 说明还没有解开当前的数据包内容
                    {
                        //////////////////////////////////////////////////////////////////////////
                        // 输出未知信息包的日志
                        //////////////////////////////////////////////////////////////////////////
                        ProcessNet.LogServerPack(packetBuffer, iPacketFullLength, "World_In_Unknown_Packets.log", eventArgs.NetState.ToString(), clientPacketHeader.PacketID, WordOpCodeName.GetWordOpCodeName(clientPacketHeader.PacketID));
                        //////////////////////////////////////////////////////////////////////////

                        // 返回内存池
                        s_ProcessorBuffers.ReleaseBuffer(packetBuffer);

                        // 获取剩下的数据长度
                        iReceiveBufferLength = receiveQueueBuffer.Length;

                        continue;
                    }

                    // 当前需处理的数据包的大小
                    long iPacketHandlerLength = packetHandler.Length;
                    if (iPacketHandlerLength > iPacketFullLength)   // 包需求的数据大小大于得到的数据大小
                    {
                        // 返回内存池
                        s_ProcessorBuffers.ReleaseBuffer(packetBuffer);

                        eventArgs.NetState.Dispose(); // 断开
                        return;
                    }

                    // 处理数据
                    packetHandler.OnReceive(eventArgs.NetState, packetReader);

                    // 返回内存池
                    s_ProcessorBuffers.ReleaseBuffer(packetBuffer);

                    // 获取剩下的数据长度
                    iReceiveBufferLength = receiveQueueBuffer.Length;
                }
                else    //已有数据包头获取剩余数据
                {
                    byte[] packetBuffer = extendData.ProcessReceiveData.PacketBuffer;

                    // 获取信息包数据的剩余内容
                    long iReturnPacketSize = receiveQueueBuffer.Dequeue(ref packetBuffer, WORLD_HEAD_SIZE, extendData.ProcessReceiveData.Remaining /*获取剩余数据包大小的字节数*/);

                    // 获取的数据不相同
                    if (iReturnPacketSize != extendData.ProcessReceiveData.Remaining)
                    {
                        Debug.WriteLine("ProcessNet.World_ProcessReceive(...) - iReturnPacketSize != Remaining error!");

                        // 恢复原始数据状态
                        extendData.ProcessReceiveData.PacketBuffer = null;
                        extendData.ProcessReceiveData.Remaining    = WORLD_HEAD_SIZE;

                        // 返回内存池
                        s_ProcessorBuffers.ReleaseBuffer(packetBuffer);

                        eventArgs.NetState.Dispose(); // 断开
                        return;
                    }

                    // 获取包的全部长度
                    long iPacketFullLength = extendData.ProcessReceiveData.Remaining + WORLD_HEAD_SIZE;

                    // 读取的数据包
                    PacketReader packetReader = new PacketReader(extendData.ProcessReceiveData.PacketBuffer, iPacketFullLength, WORLD_HEAD_SIZE /*包的ID大小-4个字节、长度大小-2个字节, 6个字节跳过*/);

                    // 给出数据信息头
                    WOWClientPacketHeader clientPacketHeader = WOWClientPacketHeader.GetClientPacketHeader(extendData.ProcessReceiveData.PacketBuffer);


                    //////////////////////////////////////////////////////////////////////////
                    // 输出信息包的日志
                    //////////////////////////////////////////////////////////////////////////
                    ProcessNet.LogServerPack(packetBuffer, iPacketFullLength, "World_In_Packets.log", eventArgs.NetState.ToString(), clientPacketHeader.PacketID, WordOpCodeName.GetWordOpCodeName(clientPacketHeader.PacketID));
                    //////////////////////////////////////////////////////////////////////////


                    // 获取处理数据包的实例
                    PacketHandler packetHandler = ProcessServer.WorldPacketHandlers.GetHandler(clientPacketHeader.PacketID);
                    if (packetHandler == null)   // 说明还没有解开当前的数据包内容
                    {
                        //////////////////////////////////////////////////////////////////////////
                        // 输出未知信息包的日志
                        //////////////////////////////////////////////////////////////////////////
                        ProcessNet.LogServerPack(packetBuffer, iPacketFullLength, "World_In_Unknown_Packets.log", eventArgs.NetState.ToString(), clientPacketHeader.PacketID, WordOpCodeName.GetWordOpCodeName(clientPacketHeader.PacketID));
                        //////////////////////////////////////////////////////////////////////////

                        // 恢复原始数据状态
                        extendData.ProcessReceiveData.PacketBuffer = null;
                        extendData.ProcessReceiveData.Remaining    = WORLD_HEAD_SIZE;

                        // 返回内存池
                        s_ProcessorBuffers.ReleaseBuffer(packetBuffer);

                        // 获取剩下的数据长度
                        iReceiveBufferLength = receiveQueueBuffer.Length;

                        continue;
                    }

                    // 当前需处理的数据包的大小
                    long iPacketHandlerLength = packetHandler.Length;
                    if (iPacketHandlerLength > iPacketFullLength)   // 包需求的数据大小大于得到的数据大小
                    {
                        // 恢复原始数据状态
                        extendData.ProcessReceiveData.PacketBuffer = null;
                        extendData.ProcessReceiveData.Remaining    = WORLD_HEAD_SIZE;

                        // 返回内存池
                        s_ProcessorBuffers.ReleaseBuffer(packetBuffer);

                        eventArgs.NetState.Dispose(); // 断开
                        return;
                    }

                    // 处理数据
                    packetHandler.OnReceive(eventArgs.NetState, packetReader);

                    // 返回内存池
                    s_ProcessorBuffers.ReleaseBuffer(extendData.ProcessReceiveData.PacketBuffer);

                    // 恢复原始数据状态
                    extendData.ProcessReceiveData.PacketBuffer = null;
                    extendData.ProcessReceiveData.Remaining    = WORLD_HEAD_SIZE;

                    // 获取剩下的数据长度
                    iReceiveBufferLength = receiveQueueBuffer.Length;
                }
            }
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="worldExtendData"></param>
 public CharEnumSQL( WorldExtendData worldExtendData, NetState netState )
 {
     m_WorldExtendData = worldExtendData;
     m_NetState = netState;
 }
Exemple #19
0
        /// <summary>
        ///
        /// </summary>
        internal static void InternalCallbackAuthenticate(NetState netState, PacketReader packetReader)
        {
            WorldExtendData worldExtendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (worldExtendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleAuthSession(...) - worldExtendData == null error!");

                netState.Send(new Word_AuthResponseError(ResponseCodes.AUTH_FAILED));
                return;
            }

            if (worldExtendData.IsLoggedIn == true)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleAuthSession(...) - worldExtendData.IsLoggedIn == true error!");

                netState.Send(new Word_AuthResponseError(ResponseCodes.AUTH_FAILED));
                return;
            }

            bool isNoError = packetReader.ReadBoolean();

            if (isNoError == false)
            {
                netState.Send(new Word_AuthResponseError(ResponseCodes.AUTH_FAILED));
                return;
            }

            // 读取数据
            uint        iAccountsGuid = packetReader.ReadUInt32();
            AccessLevel iAccessLevel  = (AccessLevel)packetReader.ReadInt32();
            bool        bIsTBC        = packetReader.ReadBoolean();

            byte[] byteSessionKey = new byte[40];
            packetReader.ReadBuffer(ref byteSessionKey, 0, 40);


            // 开始鉴别
            SHA1 sha1 = new SHA1CryptoServiceProvider();

            byte[] byteAccountName = worldExtendData.AuthSession.AccountName.ToArrayInByte(Encoding.ASCII);
            byte[] byteT           = ((uint)0).ToArrayInByte();
            byte[] byteClientSeed  = ((uint)worldExtendData.AuthSession.ClientSeed).ToArrayInByte();
            byte[] byteSeed        = ((uint)worldExtendData.ServerSeed).ToArrayInByte();

            byte[] tempData0  = byteAccountName.Coalition(byteT);
            byte[] tempData1  = tempData0.Coalition(byteClientSeed);
            byte[] tempData2  = tempData1.Coalition(byteSeed);
            byte[] tempData3  = tempData2.Coalition(byteSessionKey);
            byte[] byteResult = sha1.ComputeHash(tempData3);

            // 是否成功
            bool bIsOK = Algorithms.EqualCollections(byteResult, worldExtendData.AuthSession.Digest);

            if (bIsOK == false)
            {
                netState.Send(new Word_AuthResponseError((uint)ResponseCodes.AUTH_UNKNOWN_ACCOUNT));
                return;
            }

            // 初始化 加解密的Key
            worldExtendData.WowCrypt.InitKey(byteSessionKey, 40);

            worldExtendData.CommonData.AccountsGuid = iAccountsGuid;
            worldExtendData.CommonData.AccountName  = worldExtendData.AuthSession.AccountName;
            worldExtendData.CommonData.IsTBC        = bIsTBC;

            //WowPlayerInfo wowPlayerInfo = new WowPlayerInfo();

            //wowPlayerInfo.AccessLevel = iAccessLevel;
            //wowPlayerInfo.AccountName = worldExtendData.AuthSession.AccountName;
            //wowPlayerInfo.Serial = iAccountsGuid;
            //wowPlayerInfo.ClientBuild = worldExtendData.AuthSession.ClientBuild;
            //wowPlayerInfo.LastPing = DateTime.Now;
            //wowPlayerInfo.IsTBC = bIsTBC;
            //wowPlayerInfo.NetState = netState;

            //Program.BaseWorld.CharacterManager.AddCharacter( wowPlayerInfo.Serial, wowPlayerInfo );

            if (ProcessServer.WowZoneCluster.World.CharacterManager.Count < 600 || iAccessLevel == AccessLevel.GameMaster)
            {
                worldExtendData.IsLoggedIn = true;

                netState.Send(new Word_AuthResponse(bIsTBC));

                if (worldExtendData.AuthSession.AddonInfo != null)
                {
                    netState.Send(worldExtendData.AuthSession.AddonInfo);
                }
            }
            else
            {
                // 等待玩家的减少
                WaitQueueLogins.Enqueue(netState);
            }
        }
Exemple #20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void World_HandleCharCreate(NetState netState, PacketReader packetReader)
        {
            WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCharEnum(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("World_PacketHandlers.World_HandleCharEnum(...) - extendData.IsLoggedIn == false error!");
                return;
            }

            string strName     = packetReader.ReadUTF8StringSafe();
            byte   iRace       = packetReader.ReadByte();
            byte   iClass      = packetReader.ReadByte();
            byte   iGender     = packetReader.ReadByte();
            byte   iSkin       = packetReader.ReadByte();
            byte   iFace       = packetReader.ReadByte();
            byte   iHairStyle  = packetReader.ReadByte();
            byte   iHairColor  = packetReader.ReadByte();
            byte   iFacialHair = packetReader.ReadByte();
            byte   iOutFitId   = packetReader.ReadByte();

            if (WorldPacketHandlers.VerifyName(strName) == false)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            if (ProcessServer.WowZoneCluster.World.GlobalPlayerInfo.GetPlayerInfo(strName) != null)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            WowCharacterCreateInfo wowCharacterCreateInfo = ProcessServer.WowZoneCluster.World.GlobalCreateInfo.GetCreateInfo(iRace, iClass);

            if (wowCharacterCreateInfo == null)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            if ((iRace == WowRace.BloodElf || iRace == WowRace.Draenei) &&
                extendData.CommonData.IsTBC == false)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            WowCharacterLevelInfo[] wowCharacterLevelInfo = ProcessServer.WowZoneCluster.World.GlobalLevelInfo.GetLevelInfo(iRace, iClass);
            if (wowCharacterLevelInfo == null)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            WowCharacter wowPlayerInfo = new WowCharacter();

            wowPlayerInfo.Serial      = 0;
            wowPlayerInfo.IsTBC       = extendData.CommonData.IsTBC;
            wowPlayerInfo.AccountGuid = extendData.CommonData.AccountsGuid;

            wowPlayerInfo.Name       = strName;
            wowPlayerInfo.Race       = iRace;
            wowPlayerInfo.Class      = iClass;
            wowPlayerInfo.Gender     = iGender;
            wowPlayerInfo.Skin       = iSkin;
            wowPlayerInfo.Face       = iFace;
            wowPlayerInfo.HairStyle  = iHairStyle;
            wowPlayerInfo.HairColor  = iHairColor;
            wowPlayerInfo.FacialHair = iFacialHair;

            wowPlayerInfo.X      = wowCharacterCreateInfo.PositionX;
            wowPlayerInfo.Y      = wowCharacterCreateInfo.PositionY;
            wowPlayerInfo.Z      = wowCharacterCreateInfo.PositionZ;
            wowPlayerInfo.MapId  = wowCharacterCreateInfo.Map;
            wowPlayerInfo.ZoneId = wowCharacterCreateInfo.Zone;

            wowPlayerInfo.BindX      = 0;
            wowPlayerInfo.BindY      = 0;
            wowPlayerInfo.BindZ      = 0;
            wowPlayerInfo.BindMapId  = 0;
            wowPlayerInfo.BindZoneId = 0;

            ChrRacesEntry chrRacesEntry = DBCInstances.ChrRacesEntry.LookupIDEntry(iRace);

            if (chrRacesEntry == null)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            if (chrRacesEntry.m_TeamId == 7)
            {
                wowPlayerInfo.TeamId = WowTeam.ALLIANCE;
            }
            else
            {
                wowPlayerInfo.TeamId = WowTeam.HORDE;
            }

            ChrClassesEntry chrClassesEntry = DBCInstances.ChrClassesEntry.LookupIDEntry(iClass);

            if (chrClassesEntry == null)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            wowPlayerInfo.PowerType = chrClassesEntry.m_PowerType;

            switch (iRace)
            {
            case (byte)WowRace.Tauren:
                wowPlayerInfo.TaxiMask[0] = 1 << (22 - 1);

                break;

            case (byte)WowRace.Human:
                wowPlayerInfo.TaxiMask[0] = 1 << (2 - 1);

                break;

            case (byte)WowRace.Dwarf:
                wowPlayerInfo.TaxiMask[0] = 1 << (6 - 1);

                break;

            case (byte)WowRace.Gnome:
                wowPlayerInfo.TaxiMask[0] = 1 << (6 - 1);

                break;

            case (byte)WowRace.Orc:
                wowPlayerInfo.TaxiMask[0] = 1 << (23 - 1);

                break;

            case (byte)WowRace.Troll:
                wowPlayerInfo.TaxiMask[0] = 1 << (23 - 1);

                break;

            case (byte)WowRace.Undead:
                wowPlayerInfo.TaxiMask[0] = 1 << (11 - 1);

                break;

            case (byte)WowRace.Nightelf:
                wowPlayerInfo.TaxiMask[0] = 1 << (27 - 1);

                break;

            case (byte)WowRace.BloodElf:
                wowPlayerInfo.TaxiMask[2] = 1 << (18 - 1);

                break;

            case (byte)WowRace.Draenei:
                wowPlayerInfo.TaxiMask[2] = 1 << (30 - 1);

                break;
            }

            wowPlayerInfo.Size = (iRace == WowRace.Tauren) ? 1.3f : 1.0f;

            wowPlayerInfo.Health = wowCharacterLevelInfo[0].Health;
            wowPlayerInfo.Mana   = wowCharacterLevelInfo[0].Mana;
            wowPlayerInfo.Rage   = 0;
            wowPlayerInfo.Focus  = 0;
            wowPlayerInfo.Energy = 0;

            wowPlayerInfo.MaxHealth = wowCharacterLevelInfo[0].Health;
            wowPlayerInfo.MaxMana   = wowCharacterLevelInfo[0].Mana;
            wowPlayerInfo.MaxRage   = 0;
            wowPlayerInfo.MaxFocus  = 0;
            wowPlayerInfo.MaxEnergy = 0;

            wowPlayerInfo.BaseHealth = wowCharacterLevelInfo[0].Health;
            wowPlayerInfo.BaseMana   = wowCharacterLevelInfo[0].Mana;

            wowPlayerInfo.FactionTemplate = 0;
            wowPlayerInfo.Level           = 1;

            wowPlayerInfo.Strength  = wowCharacterLevelInfo[0].Strength;
            wowPlayerInfo.Agility   = wowCharacterLevelInfo[0].Agility;
            wowPlayerInfo.Stamina   = wowCharacterLevelInfo[0].Stamina;
            wowPlayerInfo.Intellect = wowCharacterLevelInfo[0].Intellect;
            wowPlayerInfo.Spirit    = wowCharacterLevelInfo[0].Spirit;

            wowPlayerInfo.BoundingRadius = 0.388999998569489f;
            wowPlayerInfo.CombatReach    = 1.5f;

            if (iGender == 0)
            {
                wowPlayerInfo.DisplayId       = wowCharacterCreateInfo.MaleDisplayId;
                wowPlayerInfo.NativeDisplayId = wowCharacterCreateInfo.MaleDisplayId;
            }
            else
            {
                wowPlayerInfo.DisplayId       = wowCharacterCreateInfo.FemaleDisplayId;
                wowPlayerInfo.NativeDisplayId = wowCharacterCreateInfo.FemaleDisplayId;
            }


            wowPlayerInfo.AttackPower = 0;
            wowPlayerInfo.NextLevelXP = 400;
            wowPlayerInfo.MaxLevel    = 10;

            for (uint iIndex = 0; iIndex < DBCInstances.FactionEntry.Count; iIndex++)
            {
                FactionEntry factionEntry = DBCInstances.FactionEntry.LookupRowEntry(iIndex);
                if (factionEntry == null)
                {
                    continue;
                }

                if (factionEntry.m_RepListId < 0)
                {
                    continue;
                }

                int iReputation = 0;
                if ((factionEntry.m_BaseRepMask1 & (1 << (iRace - 1))) != 0)
                {
                    iReputation = (int)factionEntry.m_BaseRepValue1;
                }
                else if ((factionEntry.m_BaseRepMask2 & (1 << (iRace - 1))) != 0)
                {
                    iReputation = (int)factionEntry.m_BaseRepValue2;
                }
                else if ((factionEntry.m_BaseRepMask3 & (1 << (iRace - 1))) != 0)
                {
                    iReputation = (int)factionEntry.m_BaseRepValue3;
                }
                else if ((factionEntry.m_BaseRepMask4 & (1 << (iRace - 1))) != 0)
                {
                    iReputation = (int)factionEntry.m_BaseRepValue4;
                }
                else
                {
                    continue;
                }

                WowReputation wowReputation = new WowReputation()
                {
                    FactionId  = factionEntry.ID,
                    Reputation = iReputation,
                };

                if ((int)wowReputation.CalcRating() <= (int)WowFactionRating.Hostile)
                {
                    wowReputation.Flag |= (byte)WowFactionFlag.FactionFlagAtWar;
                }

                if ((factionEntry.m_Team == 469 && wowPlayerInfo.TeamId == WowTeam.ALLIANCE) ||
                    (factionEntry.m_Team == 67 && wowPlayerInfo.TeamId == WowTeam.HORDE))
                {
                    wowReputation.Flag |= (byte)WowFactionFlag.FactionFlagVisible;
                }

                wowPlayerInfo.ReputationManager.AddReputation(wowReputation.FactionId, wowReputation);
            }

            foreach (WowPlayerInfoSkill wowPlayerInfoSkill in wowCharacterCreateInfo.WowPlayerSkills.Skills)
            {
                WowSkillTemplate wowSkillTemplate = ProcessServer.WowZoneCluster.World.GlobalSkillTemplates.GetSkillTemplate((long)wowPlayerInfoSkill.Skill) as WowSkillTemplate;
                if (wowSkillTemplate == null)
                {
                    continue;
                }

                WowSkill wowSkill = new WowSkill()
                {
                    Serial        = wowSkillTemplate.SkillId,
                    SkillTemplate = wowSkillTemplate
                };

                wowPlayerInfo.SkillManager.AddSkill(wowSkill.Serial, wowSkill);
            }

            foreach (WowPlayerInfoSpell wowPlayerInfoSpell in wowCharacterCreateInfo.WowPlayerSpells.Spells)
            {
                WowSpellTemplate wowSpellTemplate = ProcessServer.WowZoneCluster.World.GlobalSpellTemplates.GetSpellTemplate((long)wowPlayerInfoSpell.Spell) as WowSpellTemplate;
                if (wowSpellTemplate == null)
                {
                    continue;
                }

                WowSpell wowSpell = new WowSpell()
                {
                    Serial        = wowSpellTemplate.SpellId,
                    SpellTemplate = wowSpellTemplate
                };

                wowPlayerInfo.SpellManager.AddSpell(wowSpell.Serial, wowSpell);
            }

            foreach (WowPlayerInfoItem wowPlayerInfoItem in wowCharacterCreateInfo.WowPlayerItems.Items)
            {
                WowItemTemplate wowItemTemplate = ProcessServer.WowZoneCluster.World.ItemTemplateManager.GetItemTemplate((long)wowPlayerInfoItem.ItemId) as WowItemTemplate;
                if (wowItemTemplate == null)
                {
                    continue;
                }

                WowItemContainer equipmentBag = wowPlayerInfo.BagManager.EquipmentBag;
                if (equipmentBag == null)
                {
                    break;
                }

                WowItem wowItem = equipmentBag.FindSubItemAtSlot(wowItemTemplate.InventoryType) as WowItem;
                if (wowItem == null)
                {
                    wowItem = new WowItem()
                    {
                        ItemTemplate = wowItemTemplate
                    };

                    equipmentBag.AddSubItem(wowItemTemplate.InventoryType, wowItem);
                }
                else
                {
                    WowItemContainer mainBag = wowPlayerInfo.BagManager.MainBag;
                    if (mainBag == null)
                    {
                        break;
                    }

                    wowItem = new WowItem()
                    {
                        ItemTemplate = wowItemTemplate
                    };

                    mainBag.AddToFreeSlot(wowItem);
                }
            }


            foreach (WowPlayerInfoAction wowPlayerInfoAction in wowCharacterCreateInfo.WowPlayerActions.Actions)
            {
                WowActionBar wowActionBar = new WowActionBar()
                {
                    Serial = wowPlayerInfoAction.Button,
                    Action = wowPlayerInfoAction.Action,
                    Type   = wowPlayerInfoAction.Type
                };

                wowPlayerInfo.ActionBarManager.AddActionBar(wowActionBar.Serial, wowActionBar);
            }

            if (wowPlayerInfo.SaveNewCreature() == false)
            {
                netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE));
                return;
            }

            ProcessServer.WowZoneCluster.World.GlobalPlayerInfo.AddPlayerInfo(wowPlayerInfo.Name, wowPlayerInfo.Serial, wowPlayerInfo);

            netState.Send(new Word_CharCreateResponse());
        }