Example #1
0
        private bool IsHistoryDifferentFrom(EntityMap remoteEntityMap)
        {
            PredictionCompareHandler <TPredictionComponent> compareHandler = new PredictionCompareHandler <TPredictionComponent>(_handler.RemoteHistoryId);
            SavedHistory history = GetTargetHistory(_handler.RemoteHistoryId);

            if (history != null)
            {
                EntityMapComparator.Diff(history.EntityMap, remoteEntityMap, compareHandler, "predicteCompare");
                if (compareHandler.IsDiff)
                {
                    SingletonManager.Get <DurationHelp>().IncreaseRewindCount();
                    _logger.InfoFormat("should rewind for history diff, historyId {0} {1}", _handler.RemoteHistoryId, history.HistoryId);
                }
                return(compareHandler.IsDiff);
            }
            int oldestHistory = _histories.Count > 0 ? _histories[0].HistoryId : 0;
            int latestHistory = _histories.Count > 0 ? _histories[_histories.Count - 1].HistoryId : 0;

            _logger.InfoFormat("should rewind for history not saved, historyId {0}, saved history = {1}-{2}", _handler.RemoteHistoryId, oldestHistory, latestHistory);
            return(true);
        }
Example #2
0
        public void RewindFirstSnapshot(EntityKey self)
        {
            var localEntityMapClone = PredictionEntityMap.Allocate(false);

            _handler.SetSelf(self);
            _handler.Update();
            localEntityMapClone.AddAll(_handler.LocalEntityMap);
            _logger.InfoFormat("{0}   {1}", _handler.LocalEntityMap.Count, localEntityMapClone.Count);
            PredictionCompareHandler <TPredictionComponent> compareHandler = new PredictionCompareHandler <TPredictionComponent>(_handler.RemoteHistoryId);

            EntityMapComparator.Diff(localEntityMapClone, _handler.RemoteEntityMap, compareHandler, "RewindFirstSnapshotompare");
            foreach (var gameEntity in _handler.RemoteEntityMap.ToArray())
            {
                foreach (var gameComponent in gameEntity.ComponentList)
                {
                    _logger.InfoFormat("{0}", gameComponent);
                }
            }
            PredictionRewindHandler <TPredictionComponent> rewindHandler = new PredictionRewindHandler <TPredictionComponent>(_handler);

            EntityMapComparator.Diff(localEntityMapClone, _handler.RemoteEntityMap, rewindHandler, "rewindFirstSnapshot");
            RefCounterRecycler.Instance.ReleaseReference(localEntityMapClone);
        }