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

            ProfilerShort.Begin("SendElapsedGameTime");
            if (IsServer && (MySession.Static.ElapsedGameTime - m_lastSentTimeTimestamp).Seconds > 30)
            {
                m_lastSentTimeTimestamp = MySession.Static.ElapsedGameTime;
                SendElapsedGameTime();
            }
            ProfilerShort.End();

            ProfilerShort.Begin("Client kick update");
            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;
            }
            ProfilerShort.End();

            ProfilerShort.Begin("ReplicationLayer.SendUpdate");
            ReplicationLayer.SendUpdate();
            ProfilerShort.End();

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

            SendWorlds();
            SendProfilers();

            ProfilerShort.Begin("TransportLayer.Tick");
            Sync.Layer.TransportLayer.Tick();
            ProfilerShort.End();

            ProfilerShort.Begin("Trace, NetProfiler.Commit");
            //VRage.Trace.MyTrace.Send(VRage.Trace.TraceWindow.Multiplayer, "============ Frame end ============");
            NetProfiler.Commit();
            ProfilerShort.End();
        }
Example #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;
            }

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