예제 #1
0
        public virtual void Tick()
        {
            FrameCounter++;

            if (MyFakes.ENABLE_MULTIPLAYER_CONSTRAINT_COMPENSATION && IsServer && FrameCounter % 2 == 0)
            {
                MySyncGlobal.SendSimulationInfo();
            }

            if (IsServer && (MySession.Static.ElapsedGameTime - m_lastSentTimeTimestamp).Seconds > 30)
            {
                m_lastSentTimeTimestamp = MySession.Static.ElapsedGameTime;
                MySyncGlobal.SendElapsedGameTime();
            }

            int currentTotalTime = MySandboxGame.TotalTimeInMilliseconds;

            if (currentTotalTime - m_lastKickUpdate > 20000)
            {
                m_tmpClientList.Clear();
                foreach (var client in m_kickedClients.Keys)
                {
                    m_tmpClientList.Add(client);
                }

                foreach (var client in m_tmpClientList)
                {
                    if (currentTotalTime - m_kickedClients[client] > KICK_TIMEOUT_MS)
                    {
                        m_kickedClients.Remove(client);
                    }
                }
                m_tmpClientList.Clear();

                m_lastKickUpdate = currentTotalTime;
            }

            ReplicationLayer.Update();
            if (VRageRender.Profiler.MyRenderProfiler.ProfilerVisible)
            {
                ReplicationLayer.ReportReplicatedObjects();
            }

            // TODO: Remove
            //if (IsServer)
            //{
            //    SendServerPhysicsUpdate();
            //}

            Sync.Layer.TransportLayer.Tick();

            VRage.Trace.MyTrace.Send(VRage.Trace.TraceWindow.Multiplayer, "============ Frame end ============");
            NetProfiler.Commit();
        }
예제 #2
0
        public virtual void Tick()
        {
            FrameCounter++;

            if (MyFakes.ENABLE_MULTIPLAYER_CONSTRAINT_COMPENSATION && IsServer && FrameCounter % 2 == 0)
            {
                MySyncGlobal.SendSimulationInfo();
            }

            if (IsServer && (MySession.Static.ElapsedGameTime - m_lastSentTimeTimestamp).Seconds > 30)
            {
                m_lastSentTimeTimestamp = MySession.Static.ElapsedGameTime;
                MySyncGlobal.SendElapsedGameTime();
            }

            int currentTotalTime = MySandboxGame.TotalTimeInMilliseconds;

            if (currentTotalTime - m_lastKickUpdate > 20000)
            {
                m_tmpClientList.Clear();
                foreach (var client in m_kickedClients.Keys)
                {
                    m_tmpClientList.Add(client);
                }

                foreach (var client in m_tmpClientList)
                {
                    if (currentTotalTime - m_kickedClients[client] > KICK_TIMEOUT_MS)
                    {
                        m_kickedClients.Remove(client);
                    }
                }
                m_tmpClientList.Clear();

                m_lastKickUpdate = currentTotalTime;
            }

            foreach (var e in m_registeredEntities)
            {
                e.Tick();
            }
            var old = m_registeredEntities;

            m_registeredEntities    = m_newRegisteredEntities;
            m_newRegisteredEntities = old;
            m_newRegisteredEntities.Clear();

            VRage.Trace.MyTrace.Send(VRage.Trace.TraceWindow.Multiplayer, "============ Frame end ============");
        }