Example #1
0
    void CheckSingleComponentLogic(DebugMsg msg, ComponentInfo info)
    {
        RecordSystemBase   rsb = m_world.GetRecordSystemBase(info.m_compName);
        SingletonComponent sc  = rsb.GetSingletonRecord(msg.frame);

        if (sc == null)
        {
            //Debug.LogWarning("");
            return;
        }

        string content = Serializer.Serialize(sc);

        if (!content.Equals(info.content))
        {
            string log = "error: frame" + msg.frame + " currentFrame:" + m_world.FrameCount + " HashCode " + sc.GetHashCode() + " singleComp:" + info.m_compName + "\n remote:" + info.content + "\n local:" + content + "\n";
            Debug.LogWarning(log);
            rsb.PrintRecord(0);

            Time.timeScale = 0;
            OutPutDebugRecord();
        }
        else
        {
            //Debug.Log("singleComp correct ! frame " + msg.frame + " m_world:" + m_world.FrameCount + "\ncontent " + info.content);
        }
    }
Example #2
0
    //void CheckCurrentFrame(DebugMsg msg)
    //{
    //    //Debug.Log("CheckCurrentFrame " + msg.frame);
    //    for (int i = 0; i < msg.infos.Count; i++)
    //    {
    //        if (m_world.GetEntityIsExist(msg.infos[i].id))
    //        {
    //            EntityBase entity = m_world.GetEntity(msg.infos[i].id);

    //            for (int j = 0; j < msg.infos[i].infos.Count; j++)
    //            {
    //                if (msg.infos[i].infos[j].m_compName == "CommandComponent")
    //                {
    //                    CheckCommandLogic(msg, msg.infos[i], msg.infos[i].infos[j]);
    //                }
    //                else
    //                {
    //                    CheckCurrentComponentLogic(msg, entity, msg.infos[i], msg.infos[i].infos[j]);
    //                }
    //            }
    //        }
    //        else
    //        {
    //            //string log = "error not find entity frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + msg.infos[i].id + "\n";
    //            //Debug.LogWarning(log);
    //            //syncLog += log;
    //        }
    //    }

    //    for (int i = 0; i < msg.singleCompInfo.Count; i++)
    //    {
    //        CheckCurrentSingleComponentLogic(msg, msg.singleCompInfo[i]);
    //    }
    //}

    //void CheckHistotryFrame(DebugMsg msg)
    //{
    //    //Debug.Log("CheckHistotryFrame");
    //    for (int i = 0; i < msg.infos.Count; i++)
    //    {
    //        if (m_world.GetEntityIsExist(msg.infos[i].id))
    //        {
    //            for (int j = 0; j < msg.infos[i].infos.Count; j++)
    //            {
    //                if (msg.infos[i].infos[j].m_compName == "CommandComponent")
    //                {
    //                    CheckCommandLogic(msg, msg.infos[i], msg.infos[i].infos[j]);
    //                }
    //                else
    //                {
    //                    CheckComponentLogic(msg, msg.infos[i], msg.infos[i].infos[j]);
    //                }
    //            }
    //        }
    //        else
    //        {
    //            //string log = "error not find entity frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + msg.infos[i].id + "\n";
    //            //Debug.LogWarning(log);
    //        }
    //    }

    //    for (int i = 0; i < msg.singleCompInfo.Count; i++)
    //    {
    //        CheckSingleComponentLogic(msg, msg.singleCompInfo[i]);
    //    }
    //}

    //void CheckCurrentCommandLogic(DebugMsg msg, EntityBase entity, EntityInfo entityInfo, ComponentInfo compInfo)
    //{

    //}

    void CheckCurrentComponentLogic(DebugMsg msg, EntityBase entity, EntityInfo entityInfo, ComponentInfo compInfo)
    {
        //Debug.Log("CheckCurrentComponentLogic");

        if (!m_world.GetExistRecordSystem(compInfo.m_compName))
        {
            return;
        }

        ComponentBase compLocal = entity.GetComp(compInfo.m_compName);

        if (IsFilter(compInfo.m_compName))
        {
            string content = Serializer.Serialize(compLocal);

            if (!content.Equals(compInfo.content))
            {
                RecordSystemBase rsb = m_world.GetRecordSystemBase(compInfo.m_compName);

                string log = "error: frame" + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + entity.ID + " msg.id " + entityInfo.id + " comp:" + compInfo.m_compName + "\n remote:" + compInfo.content + "\n local:" + content + "\n";
                Debug.LogWarning(log);
                rsb.PrintRecord(entity.ID);

                //派发冲突
                GlobalEvent.DispatchEvent(c_isConflict, msg.frame);

                Time.timeScale = 0;
                OutPutDebugRecord();
            }
            else
            {
                //Debug.Log("ReceviceDebugMsg  correct! frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + entity.ID + " msg.id " + entityInfo.id + " comp:" + compInfo.m_compName + " content :" + compInfo.content);
            }
        }
    }
    void CheckComponentLogic(DebugMsg msg, EntityInfo entityInfo, ComponentInfo compInfo)
    {
        //Debug.Log("CheckComponentLogic");

        if (!m_world.GetExistRecordSystem(compInfo.m_compName))
        {
            return;
        }

        RecordSystemBase rsb       = m_world.GetRecordSystemBase(compInfo.m_compName);
        ComponentBase    compLocal = rsb.GetRecord(entityInfo.id, msg.frame);

        if (IsFilter(compInfo.m_compName))
        {
            if (compLocal != null)
            {
                string content = Serializer.Serialize(compLocal);

                if (!content.Equals(compInfo.content))
                {
                    string log = "error: frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + entityInfo.id + " comp:" + compInfo.m_compName
                                 + "\n remote:" + compInfo.content
                                 + "\n local:" + content + "\n";
                    Debug.LogWarning(log);
                    rsb.PrintRecord(entityInfo.id);

                    Time.timeScale = 0;
                    Record(log);
                    OutPutDebugRecord();
                }
                else
                {
                    //Debug.Log("ReceviceDebugMsg  correct! frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + entityInfo.id + " comp:" + compInfo.m_compName + " content :" + compInfo.content);
                }

                //派发冲突
                GlobalEvent.DispatchEvent(c_isConflict, msg.frame);
            }
            else
            {
                //string log = "not find Record ->> frame:" + msg.frame + " id " + entityInfo.id + " compName: " + compInfo.m_compName + " currentframe: " + m_world.FrameCount + " content " + compInfo.content;

                //Debug.LogWarning(log);
                //syncLog += log;
            }
        }
        else
        {
            Debug.Log("Not is filter " + compInfo.m_compName);
        }
    }
    void CheckCurrentSingleComponentLogic(DebugMsg msg, ComponentInfo info)
    {
        SingletonComponent sc = m_world.GetSingletonComp(info.m_compName);

        string content = Serializer.Serialize(sc);

        if (!content.Equals(info.content))
        {
            RecordSystemBase rsb = m_world.GetRecordSystemBase(info.m_compName);
            string           log = "error: frame" + msg.frame + " currentFrame:" + m_world.FrameCount + " singleComp:" + info.m_compName + "\n remote:" + info.content + "\n local:" + content + "\n";
            Debug.LogWarning(log);
            rsb.PrintRecord(0);
        }
        else
        {
            Debug.Log("singleComp correct ! frame " + msg.frame + " m_world:" + m_world.FrameCount + "\ncontent " + info.content);
        }
    }
Example #5
0
    void CheckCurrentSingleComponentLogic(DebugMsg msg, ComponentInfo info)
    {
        SingletonComponent sc = m_world.GetSingletonComp(info.m_compName);

        if (info.m_compName == "MapGridStateComponent")
        {
            //MapGridStateComponent lmsc = (MapGridStateComponent)sc;

            //MapGridStateComponent msc = des.Deserialize<MapGridStateComponent>(info.content);

            //if(!JudgeDict(msc.globalRandomCellHaveItemList, lmsc.globalRandomCellHaveItemList))
            //{
            //    string content = Serializer.Serialize(sc);
            //    string log = "error: frame" + msg.frame + " currentFrame:" + m_world.FrameCount + " singleComp:" + info.m_compName + "\n remote:" + info.content + "\n local:" + content + "\n";
            //    Debug.LogWarning(log);

            //    OutPutDebugRecord();
            //}
        }
        else
        {
            string content = Serializer.Serialize(sc);

            if (!content.Equals(info.content))
            {
                RecordSystemBase rsb = m_world.GetRecordSystemBase(info.m_compName);
                string           log = "error: frame" + msg.frame + " currentFrame:" + m_world.FrameCount + " singleComp:" + info.m_compName + "\n remote:" + info.content + "\n local:" + content + "\n";
                Debug.LogWarning(log);
                rsb.PrintRecord(0);

                Time.timeScale = 0;
                OutPutDebugRecord();
            }
            else
            {
                //Debug.Log("singleComp correct ! frame " + msg.frame + " m_world:" + m_world.FrameCount + "\ncontent " + info.content);
            }
        }
    }
    public void DebugLogic(DebugMsg msg)
    {
        if (msg.frame == m_world.FrameCount)
        {
            for (int i = 0; i < msg.infos.Count; i++)
            {
                if (m_world.GetEntityIsExist(msg.infos[i].id))
                {
                    EntityBase entity = m_world.GetEntity(msg.infos[i].id);

                    for (int j = 0; j < msg.infos[i].infos.Count; j++)
                    {
                        ComponentBase compLocal = entity.GetComp(msg.infos[i].infos[j].m_compName);

                        if (IsFilter(msg.infos[i].infos[j].m_compName))
                        {
                            string content = Serializer.Serialize(compLocal);

                            if (!content.Equals(msg.infos[i].infos[j].content))
                            {
                                RecordSystemBase rsb = m_world.GetRecordSystemBase(msg.infos[i].infos[j].m_compName);

                                string log = "error: frame" + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + entity.ID + " msg.id " + msg.infos[i].id + " comp:" + msg.infos[i].infos[j].m_compName + "\n remote:" + msg.infos[i].infos[j].content + "\n local:" + content + "\n";
                                Debug.LogWarning(log);
                                rsb.PrintRecord(entity.ID);
                                syncLog += log;

                                //派发冲突
                                GlobalEvent.DispatchEvent(c_isConflict, msg.frame);
                            }
                            else
                            {
                                //Debug.Log("ReceviceDebugMsg  correct! frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + entity.ID + " msg.id " + msg.infos[i].id + " comp:" + msg.infos[i].infos[j].m_compName + " content :"+ msg.infos[i].infos[j].content);
                            }
                        }
                    }
                }
                else
                {
                    string log = "error not find entity frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + msg.infos[i].id + "\n";
                    Debug.LogWarning(log);
                    syncLog += log;
                }
            }
        }
        else if (msg.frame < m_world.FrameCount)
        {
            for (int i = 0; i < msg.infos.Count; i++)
            {
                if (m_world.GetEntityIsExist(msg.infos[i].id))
                {
                    EntityBase entity = m_world.GetEntity(msg.infos[i].id);

                    for (int j = 0; j < msg.infos[i].infos.Count; j++)
                    {
                        if (msg.infos[i].infos[j].m_compName == "CommandComponent")
                        {
                            PlayerCommandRecordComponent pcrc      = m_world.GetEntity(msg.infos[i].id).GetComp <PlayerCommandRecordComponent>();
                            PlayerCommandBase            compLocal = pcrc.GetInputCahae(msg.frame);

                            if (compLocal == null)
                            {
                                return;
                            }

                            compLocal.time = 0;
                            string content = Serializer.Serialize(compLocal);

                            if (!content.Equals(msg.infos[i].infos[j].content))
                            {
                                string log = "error: frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + entity.ID + " msg.id " + msg.infos[i].id + " comp:" + msg.infos[i].infos[j].m_compName + "\n remote:" + msg.infos[i].infos[j].content + "\n local:" + content + "\n";
                                Debug.LogWarning(log);
                                string record = "";

                                for (int k = msg.frame; k > msg.frame - 10; k--)
                                {
                                    PlayerCommandBase tmp = pcrc.GetInputCahae(k);

                                    record += "\nframe " + k + " c: " + Serializer.Serialize(tmp);
                                }

                                Debug.Log(record);
                            }
                            else
                            {
                                //Debug.Log(" confirm " + msg.infos[i].infos[j].content);
                            }
                        }
                        else
                        {
                            RecordSystemBase rsb       = m_world.GetRecordSystemBase(msg.infos[i].infos[j].m_compName);
                            ComponentBase    compLocal = rsb.GetRecord(msg.infos[i].id, msg.frame);

                            if (IsFilter(msg.infos[i].infos[j].m_compName))
                            {
                                if (compLocal != null)
                                {
                                    string content = Serializer.Serialize(compLocal);

                                    if (!content.Equals(msg.infos[i].infos[j].content))
                                    {
                                        string log = "error: frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + entity.ID + " msg.id " + msg.infos[i].id + " comp:" + msg.infos[i].infos[j].m_compName + "\n remote:" + msg.infos[i].infos[j].content + "\n local:" + content + "\n";
                                        Debug.LogWarning(log);
                                        rsb.PrintRecord(entity.ID);

                                        syncLog += log;
                                    }
                                    else
                                    {
                                        //Debug.Log("ReceviceDebugMsg  correct! frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + entity.ID + " msg.id " + msg.infos[i].id + " comp:" + msg.infos[i].infos[j].m_compName + " content :" + msg.infos[i].infos[j].content);
                                    }

                                    //派发冲突
                                    GlobalEvent.DispatchEvent(c_isConflict, msg.frame);
                                }
                                else
                                {
                                    string log = "not find Record ->> frame:" + msg.frame + " id " + msg.infos[i].id + " compName: " + msg.infos[i].infos[j].m_compName + " currentframe: " + m_world.FrameCount + " content " + msg.infos[i].infos[j].content;

                                    //Debug.LogWarning(log);
                                    syncLog += log;
                                }
                            }
                        }
                    }
                }
                else
                {
                    //string log = "error not find entity frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + msg.infos[i].id + "\n";
                    //Debug.LogWarning(log);

                    //syncLog += log;
                }
            }
        }
        else
        {
            string log = "服务器超前 msg:" + msg.frame + " m_world:" + m_world.FrameCount + "\n";
            //Debug.LogWarning(log);
            syncLog += log;
        }
    }
Example #7
0
    public void ReceviceDebugMsg(DebugMsg msg, params object[] objs)
    {
        if (!isDebug)
        {
            return;
        }

        if (msg.frame == m_world.FrameCount)
        {
            for (int i = 0; i < msg.infos.Count; i++)
            {
                if (m_world.GetEntityIsExist(msg.infos[i].id))
                {
                    EntityBase entity = m_world.GetEntity(msg.infos[i].id);

                    for (int j = 0; j < msg.infos[i].infos.Count; j++)
                    {
                        ComponentBase compLocal = entity.GetComp(msg.infos[i].infos[j].m_compName);

                        string content = Serializer.Serialize(compLocal);

                        if (!content.Equals(msg.infos[i].infos[j].content))
                        {
                            RecordSystemBase rsb = m_world.GetRecordSystemBase(msg.infos[i].infos[j].m_compName);

                            Debug.LogWarning("error: frame" + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + entity.ID + " msg.id " + msg.infos[i].id + " comp:" + msg.infos[i].infos[j].m_compName + "\n remote:" + msg.infos[i].infos[j].content + "\n local:" + content);
                            rsb.PrintRecord(entity.ID);
                        }
                    }
                }
                else
                {
                    Debug.LogWarning("error not find entity frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + msg.infos[i].id);
                }
            }
        }
        else if (msg.frame < m_world.FrameCount)
        {
            for (int i = 0; i < msg.infos.Count; i++)
            {
                if (m_world.GetEntityIsExist(msg.infos[i].id))
                {
                    EntityBase entity = m_world.GetEntity(msg.infos[i].id);

                    for (int j = 0; j < msg.infos[i].infos.Count; j++)
                    {
                        RecordSystemBase rsb = m_world.GetRecordSystemBase(msg.infos[i].infos[j].m_compName);

                        ComponentBase compLocal = rsb.GetRecord(msg.infos[i].id, msg.frame);

                        if (compLocal != null)
                        {
                            string content = Serializer.Serialize(compLocal);

                            if (!content.Equals(msg.infos[i].infos[j].content))
                            {
                                Debug.LogWarning("error: frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + entity.ID + " msg.id " + msg.infos[i].id + " comp:" + msg.infos[i].infos[j].m_compName + "\n remote:" + msg.infos[i].infos[j].content + "\n local:" + content);
                                rsb.PrintRecord(entity.ID);
                            }
                        }
                        else
                        {
                            Debug.LogWarning("not find Record ->> frame:" + msg.frame + " id " + msg.infos[i].id + " compName: " + msg.infos[i].infos[j].m_compName);
                            rsb.PrintRecord(entity.ID);
                        }
                    }
                }
                else
                {
                    Debug.LogWarning("error not find entity frame " + msg.frame + " currentFrame:" + m_world.FrameCount + " id:" + msg.infos[i].id);
                }
            }
        }
        else
        {
            Debug.LogWarning("服务器超前 msg:" + msg.frame + " m_world:" + m_world.FrameCount);
        }
    }