Exemplo n.º 1
0
        public override void SetMaxClientsPerIp(int max)
        {
            var config = Config;

            config.MaxClientsPerIp = Math.Clamp(max, 1, config.MaxClients);
            Config = config;
        }
Exemplo n.º 2
0
        public override void Tick()
        {
            if (!IsDummy && !Server.ClientInGame(ClientId))
            {
                return;
            }

            var info = Server.ClientInfo(ClientId);

            Latency.Accumulate   += info.Latency;
            Latency.AccumulateMax = Math.Max(Latency.AccumulateMax, info.Latency);
            Latency.AccumulateMin = Math.Min(Latency.AccumulateMin, info.Latency);

            if (Server.Tick % Server.TickSpeed == 0)
            {
                Latency.Average       = Latency.Accumulate / Server.TickSpeed;
                Latency.Max           = Latency.AccumulateMax;
                Latency.Min           = Latency.AccumulateMin;
                Latency.Accumulate    = 0;
                Latency.AccumulateMin = 1000;
                Latency.AccumulateMax = 0;
            }

            if (Character != null && !Character.IsAlive)
            {
                Character = null;
            }

            if (GameContext.GameController.GamePaused)
            {
                RespawnTick++;
                DieTick++;
                LastActionTick++;
                TeamChangeTick++;
            }
            else
            {
                if (Character == null)
                {
                    if (Team == Team.Spectators && SpectatorMode == SpectatorMode.FreeView)
                    {
                        ViewPos -= new Vector2(
                            Math.Clamp(ViewPos.x - LatestActivity.TargetX, -500f, 500f),
                            Math.Clamp(ViewPos.y - LatestActivity.TargetY, -400f, 400f)
                            );
                    }

                    if (DieTick + Server.TickSpeed * 3 <= Server.Tick && !DeadSpectatorMode)
                    {
                        Respawn();
                    }

                    if (Team == Team.Spectators && SpectatorFlag != null)
                    {
                        SpectatorId = SpectatorFlag.Carrier?.Player.ClientId ?? -1;
                    }

                    if (Spawning && RespawnTick <= Server.Tick)
                    {
                        TryRespawn();
                    }
                }
                else if (Character.IsAlive)
                {
                    ViewPos = Character.Position;
                }

                if (!DeadSpectatorMode && LastActionTick != Server.Tick)
                {
                    InactivityTickCounter++;
                }
            }
        }