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); } }
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; } }
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); } }