//frame update public void SavePredictionCompoments(int seqHistoryId) { EntityMap localEntites = provider.LocalEntityMap; #pragma warning disable RefCounter001,RefCounter002 EntityMap remoteEntities = PredictionEntityMap.Allocate(); #pragma warning restore RefCounter001,RefCounter002 EntityMapDeepCloner.Clone(remoteEntities, localEntites, CloneFilter.Instance); HistoryEntityMap historyEntityMap = GetTargetHistory(seqHistoryId); if (historyEntityMap == null) { logger.DebugFormat("SavePredictionCompoments1 {0}", seqHistoryId); historyEntityMap = new HistoryEntityMap(seqHistoryId, remoteEntities); histories.Enqueue(historyEntityMap); } else { logger.DebugFormat("Recplce SavePredictionCompoments {0}", seqHistoryId); RefCounterRecycler.Instance.ReleaseReference(historyEntityMap.EntityMap); historyEntityMap.EntityMap = remoteEntities; } if (histories.Count > MaxHistory) { var tdhistory = histories.Dequeue(); RefCounterRecycler.Instance.ReleaseReference(tdhistory.EntityMap); } }
private bool IsHistoryDifferentFrom(EntityMap remoteEntityMap) { checkDiffHandler.SetRemoteCmdSeq(provider.LastSelfUserCmdSeqId); HistoryEntityMap historyEntityMap = GetTargetHistory(provider.LastSelfUserCmdSeqId); if (historyEntityMap != null) { EntityMapCompareExecutor.Diff(historyEntityMap.EntityMap, remoteEntityMap, checkDiffHandler, "predicteCompare", gameEntityComparator); if (checkDiffHandler.IsDiff) { SingletonManager.Get <DurationHelp>().IncreaseRewindCount(); logger.InfoFormat("should rewind for history diff, historyId {0} {1}", provider.LastSelfUserCmdSeqId, historyEntityMap.SeqId); } return(checkDiffHandler.IsDiff); } int oldestHistory = histories.Count > 0 ? histories.First().SeqId : 0; int latestHistory = histories.Count > 0 ? histories.Last().SeqId : 0; logger.InfoFormat("should rewind for history not saved, historyId {0}, saved history = {1}-{2}", provider.LastSelfUserCmdSeqId, oldestHistory, latestHistory); return(true); }