Exemplo n.º 1
0
    public static bool ProcessData(int CmdID, object Para)
    {
        bool bResult = true;

        if (Para is gate.GateMessage.MessageContent)
        {
            gate.GateMessage.MessageContent msg = Para as gate.GateMessage.MessageContent;
            int nErrorCode         = 0;
            gate.ErrorMessage emsg = msg.error_message;
            if (emsg != null)
            {
                if (emsg.code > 0)
                {
                    FileLog.ProtocolDump(emsg);
                    nErrorCode = emsg.code;
                    NGUIUtil.DebugLog(string.Format("CmdID={0},errorCode={1},description={2}",
                                                    CmdID, emsg.code, emsg.description));
                    bResult = false;
                    //return false; //如取名重名也会返回error_message.code>0,所以这里不宜return,否则客户端hook代码不会执行
                }
            }

            object data = null;
            if (bResult && msg.network_message != null)   //如果失败了,有可能msg.network_message为null
            {
                data = protobufM.Deserialize(msg.proto_name, msg.network_message);
            }
            //dump
            FileLog.ProtocolDumpwrite(CmdID.ToString());
            FileLog.ProtocolDumpwriteXml(CmdID.ToString());
            if (CmdID != 9999)
            {
                FileLog.ProtocolDump(data);
            }

            //统一在外围直接解析,不到具体的DC去
            if (bResult == true)
            {
                int DcBlock = CmdID / 100;
                switch (DcBlock)
                {
                case 2:
                    bResult = SoldierDC.ProcessData(CmdID, nErrorCode, data);
                    break;

                case 5:
                    bResult = ShipPlanDC.ProcessData(CmdID, nErrorCode, data);
                    break;

                case 6:
                    bResult = UserDC.ProcessData(CmdID, nErrorCode, data);
                    break;

                case 7:
                    bResult = StageDC.ProcessData(CmdID, nErrorCode, data);
                    break;

                case 8:
                    bResult = ItemDC.ProcessData(CmdID, nErrorCode, data);
                    break;

                case 9:
                    bResult = BuildDC.ProcessData(CmdID, nErrorCode, data);
                    break;

                case 11:
                    bResult = BlackScienceDC.ProcessData(CmdID, nErrorCode, data);
                    break;
                }
            }
            ProcessRealHooks(CmdID, nErrorCode);
        }


        return(bResult);
    }