Update() приватный Метод

private Update ( ) : void
Результат void
Пример #1
0
        public void Run()
        {
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Item));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Items.Components.ItemComponent));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Hull));

            Init();
            StartServer();

            DateTime prevTime = DateTime.Now;

            while (ShouldRun)
            {
                prevTime = DateTime.Now;

                DebugConsole.Update();
                if (Screen.Selected != null)
                {
                    Screen.Selected.Update((float)Timing.Step);
                }
                Server.Update((float)Timing.Step);
                CoroutineManager.Update((float)Timing.Step, (float)Timing.Step);

                int frameTime = DateTime.Now.Subtract(prevTime).Milliseconds;
                Thread.Sleep(Math.Max((int)(Timing.Step * 1000.0) - frameTime, 0));
            }

            CloseServer();
        }
Пример #2
0
 void Update()
 {
     if (mGame != null && mGame.isListening)
     {
         mGame.Update();
     }
 }
Пример #3
0
 public void Update(float deltaTime)
 {
     m_gameServer.Update();
     ProcessMessages();
     m_match.Update(deltaTime);
     UpdateClients();
 }
Пример #4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            // Mise à jour du serveur.
            m_server.Update(gameTime);

            // Si on n'a pas ajouté le contrôleur au serveur, l'update ne se fait
            // pas automatiquement => on la fait manuellement.
            if (SpectateMode)
            {
                m_controler.Update(gameTime);
            }

            m_controler.ClientUpdate(gameTime);

            // Mise à jour des entrées claviers.
            Input.Update();

            base.Update(gameTime);
        }
Пример #5
0
        private void RegisterBot(Bot bot, GameServerRequest gsr)
        {
            IPEndPoint ipendpoint = ((IPEndPoint)gsr.Socket.RemoteEndPoint);

            int index = bot.Manager.Servers.FindIndex(f => f.IP == ipendpoint.Address);

            if (index >= 0)
            {
                return;
            }

            SINGLE_SERVER_ID++;

            GameServer gameserver = new GameServer(gsr.Socket, bot.Manager.Config.TCPPassword, SINGLE_SERVER_ID, gsr.Arguments);
            GameServer gs         = bot.Manager.Servers.Find(srv => srv.SteamID == gameserver.SteamID);

            if (gs == null)
            {
                bot.Manager.Servers.Add(gameserver);
            }
            else
            {
                gs.Update(gameserver);
            }
        }
Пример #6
0
    public void Update(float deltaTime)
    {
        m_gameServer.Update();

        //var message = m_gameServer.GetMessage();
        //if (message == null)
        //    return;
    }
Пример #7
0
 public override void update(double timeSinceLastFrame)
 {
     if (thisServer != null && thisServer.Started)
     {
         thisServer.Update();
         thisServer.GetServerState(ref serverState);
     }
 }
Пример #8
0
        private void JobServer()
        {
            while (m_server != null)
            {
                m_server.Update();

                Task.Delay(TimeSpan.Zero).Wait();
            }
        }
Пример #9
0
        private void timer_fastUpdate_Tick(object sender, EventArgs e)
        {
            // 한 프레임에 더 많은 처리를 하도록 함.
            int loopCount = 32 + m_server.UserDirector.LoginUsersCount * 64;

            for (int i = 0; i < loopCount; ++i)
            {
                m_server.Update();
            }
        }
Пример #10
0
        public void Run()
        {
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Item));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Items.Components.ItemComponent));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Hull));

            Init();
            StartServer();

            Timing.Accumulator = 0.0;

            double frequency = (double)Stopwatch.Frequency;

            if (frequency <= 1500)
            {
                DebugConsole.NewMessage("WARNING: Stopwatch frequency under 1500 ticks per second. Expect significant syncing accuracy issues.", Color.Yellow);
            }

            Stopwatch stopwatch = Stopwatch.StartNew();
            long      prevTicks = stopwatch.ElapsedTicks;

            while (ShouldRun)
            {
                long   currTicks   = stopwatch.ElapsedTicks;
                double elapsedTime = (currTicks - prevTicks) / frequency;
                Timing.Accumulator += elapsedTime;
                Timing.TotalTime   += elapsedTime;
                prevTicks           = currTicks;
                while (Timing.Accumulator >= Timing.Step)
                {
                    DebugConsole.Update();
                    if (Screen.Selected != null)
                    {
                        Screen.Selected.Update((float)Timing.Step);
                    }
                    Server.Update((float)Timing.Step);
                    SteamManager.Update((float)Timing.Step);
                    CoroutineManager.Update((float)Timing.Step, (float)Timing.Step);

                    Timing.Accumulator -= Timing.Step;
                }
                int frameTime = (int)(((double)(stopwatch.ElapsedTicks - prevTicks) / frequency) * 1000.0);
                Thread.Sleep(Math.Max(((int)(Timing.Step * 1000.0) - frameTime) / 2, 0));
            }
            stopwatch.Stop();

            CloseServer();

            SteamManager.ShutDown();
            if (GameSettings.SendUserStatistics)
            {
                GameAnalytics.OnStop();
            }
        }
Пример #11
0
        public void GameServer_OnRequestGame_IsInLobby()
        {
            var client = JsonNetGame.ConnectTo(AppId, "127.0.0.1", Port);

            client.Init();

            _server.Update();
            client.Update();

            int i = 0;
        }
Пример #12
0
 public override void update(double timeSinceLastFrame)
 {
     if (thisServer != null && thisServer.Started)
     {
         thisServer.Update();
         thisServer.GetServerState(ref serverState);
         if (!isEscapeMenuOpened)
         {
             serverpanel.setAllParamValues(serverState);
         }
     }
 }
Пример #13
0
        public void Teleport(int newX, int newY)
        {
            Logger.DebugPrint("Teleporting: " + Username + " to: " + newX.ToString() + "," + newY.ToString());

            X = newX;
            Y = newY;

            byte[] MovementPacket = PacketBuilder.CreateMovementPacket(X, Y, CharacterId, Facing, PacketBuilder.DIRECTION_TELEPORT, true);
            LoggedinClient.SendPacket(MovementPacket);
            GameServer.UpdateWeather(LoggedinClient);
            GameServer.Update(LoggedinClient);
        }
Пример #14
0
        public static void Main(string[] args)
        {
            Console.CancelKeyPress += (s, e) => _isExiting = true;
            Logger.AddSink(Console.WriteLine);

            var server = new GameServer(AppId, Port);

            server.Init();
            while (!_isExiting)
            {
                server.Update();
            }
            server.Dispose();
        }
Пример #15
0
        static void RunServer()
        {
            try
            {
                TimeStat  timeAll         = new TimeStat();
                LockTimer perfUpdateTimer = new LockTimer(60 * 1000);
                perfUpdateTimer.Trigger();

                while (true)
                {
                    timeAll.Start();

                    GameTime.Update();
                    OnTick?.Invoke();

                    GameTime.Update();
                    GUCTimer.Update(GameTime.Ticks); // move to new thread?

                    //Run the dispatcher
                    GUCDispatcher.Execute();


                    GameTime.Update();
                    GameServer.Update(); //process received packets

                    GameTime.Update();
                    WorldObjects.World.ForEach(w => w.OnTick(GameTime.Ticks));

                    long elapsed = timeAll.Stop();
                    if (perfUpdateTimer.IsReady)
                    {
                        Logger.Log("Performance: {0:0}ms avg, {1:0}ms max. RAM: {2:0.0}MB", timeAll.Average, timeAll.Maximum, Process.GetCurrentProcess().PrivateMemorySize64 / 1000000d);
                        timeAll.Reset();
                    }

                    long diff = (updateRate - elapsed) / TimeSpan.TicksPerMillisecond;
                    if (diff > 0)
                    {
                        Thread.Sleep((int)diff);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.LogError(e.Source + "<br>" + e.Message + "<br>" + e.StackTrace);
            }
        }
Пример #16
0
        public void Teleport(int newX, int newY)
        {
            Logger.DebugPrint("Teleporting: " + Username + " to: " + newX.ToString() + "," + newY.ToString());

            User[] onScreenBefore = GameServer.GetOnScreenUsers(X, Y, true, true);
            User[] onScreenNow    = GameServer.GetOnScreenUsers(newX, newY, true, true);

            X = newX;
            Y = newY;

            byte[] MovementPacket = PacketBuilder.CreateMovementPacket(X, Y, CharacterId, Facing, PacketBuilder.DIRECTION_TELEPORT, true);
            LoggedinClient.SendPacket(MovementPacket);
            GameServer.UpdateWeather(LoggedinClient);


            User[] goneOffScreen = onScreenBefore.Except(onScreenNow).ToArray();
            User[] goneOnScreen  = onScreenNow.Except(onScreenBefore).ToArray();


            // Players now offscreen tell the client is at 1000,1000.
            foreach (User offScreenUsers in goneOffScreen)
            {
                if (offScreenUsers.Id == this.Id)
                {
                    continue;
                }

                byte[] playerInfoBytes = PacketBuilder.CreatePlayerInfoUpdateOrCreate(1000 + 4, 1000 + 1, this.Facing, this.CharacterId, this.Username);
                offScreenUsers.LoggedinClient.SendPacket(playerInfoBytes);
            }

            // Tell players now on screen there locations
            foreach (User onScreenUsers in goneOnScreen)
            {
                if (onScreenUsers.Id == this.Id)
                {
                    continue;
                }

                byte[] playerInfoBytes = PacketBuilder.CreatePlayerInfoUpdateOrCreate(onScreenUsers.X, onScreenUsers.Y, onScreenUsers.Facing, onScreenUsers.CharacterId, onScreenUsers.Username);
                LoggedinClient.SendPacket(playerInfoBytes);
            }


            GameServer.Update(LoggedinClient);
        }
Пример #17
0
 internal void TempUpdateServer()
 {
     server.Update();
 }
Пример #18
0
        public void Run()
        {
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Item));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Items.Components.ItemComponent));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Hull));

            Init();
            StartServer();

            DefaultServerStartup();

            Timing.Accumulator = 0.0;

            double frequency = (double)Stopwatch.Frequency;

            if (frequency <= 1500)
            {
                DebugConsole.NewMessage("WARNING: Stopwatch frequency under 1500 ticks per second. Expect significant syncing accuracy issues.", Color.Yellow);
            }

            int            MaximumSamples          = 5;
            Queue <double> sampleBuffer            = new Queue <double>();
            double         CurrentUpdatesPerSecond = 0;
            double         AverageUpdatesPerSecond = 0;

            GameMain.NilMod.SuccesfulStart = true;

            stopwatch = Stopwatch.StartNew();
            prevTicks = stopwatch.ElapsedTicks;
            while (ShouldRun)
            {
                long currTicks = stopwatch.ElapsedTicks;
                //Necessary for some timing
                //Timing.TotalTime = stopwatch.ElapsedMilliseconds / 1000;
                //Timing.Accumulator += (double)(currTicks - prevTicks) / frequency;
                double elapsedTime = (currTicks - prevTicks) / frequency;
                Timing.Accumulator += elapsedTime;
                Timing.TotalTime   += elapsedTime;
                prevTicks           = currTicks;

                if (GameMain.NilMod.UseExperimentalFPSLagPrevention)
                {
                    if ((int)AverageUpdatesPerSecond <= 2)
                    {
                        Timing.Step = 1.0 / 8.0;
                        FarseerPhysics.Settings.VelocityIterations    = 10;
                        FarseerPhysics.Settings.PositionIterations    = 4;
                        FarseerPhysics.Settings.TOIPositionIterations = 25;
                        FarseerPhysics.Settings.TOIVelocityIterations = 10;
                    }
                    else if ((int)AverageUpdatesPerSecond <= 4)
                    {
                        Timing.Step = 1.0 / 10.0;
                        FarseerPhysics.Settings.VelocityIterations    = 10;
                        FarseerPhysics.Settings.PositionIterations    = 4;
                        FarseerPhysics.Settings.TOIPositionIterations = 25;
                        FarseerPhysics.Settings.TOIVelocityIterations = 10;
                    }
                    else if ((int)AverageUpdatesPerSecond <= 6)
                    {
                        Timing.Step = 1.0 / 12.0;
                        FarseerPhysics.Settings.VelocityIterations    = 10;
                        FarseerPhysics.Settings.PositionIterations    = 4;
                        FarseerPhysics.Settings.TOIPositionIterations = 25;
                        FarseerPhysics.Settings.TOIVelocityIterations = 10;
                    }
                    else if ((int)AverageUpdatesPerSecond <= 8)
                    {
                        Timing.Step = 1.0 / 15.0;
                        FarseerPhysics.Settings.VelocityIterations    = 9;
                        FarseerPhysics.Settings.PositionIterations    = 4;
                        FarseerPhysics.Settings.TOIPositionIterations = 22;
                        FarseerPhysics.Settings.TOIVelocityIterations = 9;
                    }
                    else if ((int)AverageUpdatesPerSecond <= 10)
                    {
                        Timing.Step = 1.0 / 20.0;
                        FarseerPhysics.Settings.VelocityIterations    = 9;
                        FarseerPhysics.Settings.PositionIterations    = 4;
                        FarseerPhysics.Settings.TOIPositionIterations = 22;
                        FarseerPhysics.Settings.TOIVelocityIterations = 9;
                    }
                    else if ((int)AverageUpdatesPerSecond <= 12)
                    {
                        Timing.Step = 1.0 / 25.0;
                        FarseerPhysics.Settings.VelocityIterations    = 9;
                        FarseerPhysics.Settings.PositionIterations    = 4;
                        FarseerPhysics.Settings.TOIPositionIterations = 22;
                        FarseerPhysics.Settings.TOIVelocityIterations = 9;
                    }
                    else if ((int)AverageUpdatesPerSecond <= 14)
                    {
                        Timing.Step = 1.0 / 30.0;
                        FarseerPhysics.Settings.VelocityIterations    = 8;
                        FarseerPhysics.Settings.PositionIterations    = 3;
                        FarseerPhysics.Settings.TOIPositionIterations = 20;
                        FarseerPhysics.Settings.TOIVelocityIterations = 8;
                    }
                    else if ((int)AverageUpdatesPerSecond <= 16)
                    {
                        Timing.Step = 1.0 / 35.0;
                        FarseerPhysics.Settings.VelocityIterations    = 8;
                        FarseerPhysics.Settings.PositionIterations    = 3;
                        FarseerPhysics.Settings.TOIPositionIterations = 20;
                        FarseerPhysics.Settings.TOIVelocityIterations = 8;
                    }
                    else if ((int)AverageUpdatesPerSecond <= 18)
                    {
                        Timing.Step = 1.0 / 40.0;
                        FarseerPhysics.Settings.VelocityIterations    = 8;
                        FarseerPhysics.Settings.PositionIterations    = 3;
                        FarseerPhysics.Settings.TOIPositionIterations = 20;
                        FarseerPhysics.Settings.TOIVelocityIterations = 8;
                    }
                    else if ((int)AverageUpdatesPerSecond <= 20)
                    {
                        Timing.Step = 1.0 / 45.0;
                        FarseerPhysics.Settings.VelocityIterations    = 8;
                        FarseerPhysics.Settings.PositionIterations    = 3;
                        FarseerPhysics.Settings.TOIPositionIterations = 20;
                        FarseerPhysics.Settings.TOIVelocityIterations = 8;
                    }
                    else if ((int)AverageUpdatesPerSecond <= 22)
                    {
                        Timing.Step = 1.0 / 50.0;
                        FarseerPhysics.Settings.VelocityIterations    = 8;
                        FarseerPhysics.Settings.PositionIterations    = 3;
                        FarseerPhysics.Settings.TOIPositionIterations = 20;
                        FarseerPhysics.Settings.TOIVelocityIterations = 8;
                    }
                    else if ((int)AverageUpdatesPerSecond <= 25)
                    {
                        Timing.Step = 1.0 / 55.0;
                        FarseerPhysics.Settings.VelocityIterations    = 8;
                        FarseerPhysics.Settings.PositionIterations    = 3;
                        FarseerPhysics.Settings.TOIPositionIterations = 20;
                        FarseerPhysics.Settings.TOIVelocityIterations = 8;
                    }
                    else
                    {
                        Timing.Step = 1.0 / 60.0;
                        FarseerPhysics.Settings.VelocityIterations    = 8;
                        FarseerPhysics.Settings.PositionIterations    = 3;
                        FarseerPhysics.Settings.TOIPositionIterations = 20;
                        FarseerPhysics.Settings.TOIVelocityIterations = 8;
                    }
                }
                else
                {
                    Timing.Step = 1.0 / 60.0;
                    FarseerPhysics.Settings.VelocityIterations    = 8;
                    FarseerPhysics.Settings.PositionIterations    = 3;
                    FarseerPhysics.Settings.TOIPositionIterations = 20;
                    FarseerPhysics.Settings.TOIVelocityIterations = 8;
                }

                while (Timing.Accumulator >= Timing.Step)
                {
                    DebugConsole.Update();

                    NilMod.Update((float)Timing.Step);

                    if (Screen.Selected != null)
                    {
                        Screen.Selected.Update((float)Timing.Step);
                    }
                    Server.Update((float)Timing.Step);
                    CoroutineManager.Update((float)Timing.Step, (float)Timing.Step);

                    CurrentUpdatesPerSecond = (1.0 / Timing.Step);

                    sampleBuffer.Enqueue(CurrentUpdatesPerSecond);

                    if (sampleBuffer.Count > MaximumSamples)
                    {
                        sampleBuffer.Dequeue();
                        AverageUpdatesPerSecond = sampleBuffer.Average(i => i);
                    }
                    else
                    {
                        AverageUpdatesPerSecond = CurrentUpdatesPerSecond;
                    }

                    Timing.Accumulator -= Timing.Step;
                }
                int frameTime = (int)(((double)(stopwatch.ElapsedTicks - prevTicks) / frequency) * 1000.0);
                Thread.Sleep(Math.Max(((int)((double)(1d / 60d) * 1000.0) - frameTime) / 2, 0));
            }
            stopwatch.Stop();

            CloseServer();
        }
Пример #19
0
        public void Run()
        {
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Item));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Items.Components.ItemComponent));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Hull));

            TryStartChildServerRelay();
            Init();
            StartServer();

            ResetFrameTime();

            double frequency = (double)Stopwatch.Frequency;

            if (frequency <= 1500)
            {
                DebugConsole.NewMessage("WARNING: Stopwatch frequency under 1500 ticks per second. Expect significant syncing accuracy issues.", Color.Yellow);
            }

            stopwatch = Stopwatch.StartNew();
            long prevTicks = stopwatch.ElapsedTicks;

            while (ShouldRun)
            {
                long   currTicks   = stopwatch.ElapsedTicks;
                double elapsedTime = Math.Max(currTicks - prevTicks, 0) / frequency;
                Timing.Accumulator += elapsedTime;
                if (Timing.Accumulator > 1.0)
                {
                    //prevent spiral of death
                    Timing.Accumulator = Timing.Step;
                }
                prevTicks = currTicks;
                while (Timing.Accumulator >= Timing.Step)
                {
                    Timing.TotalTime += Timing.Step;
                    DebugConsole.Update();
                    if (GameSession?.GameMode == null || !GameSession.GameMode.Paused)
                    {
                        Screen.Selected?.Update((float)Timing.Step);
                    }
                    Server.Update((float)Timing.Step);
                    if (Server == null)
                    {
                        break;
                    }
                    SteamManager.Update((float)Timing.Step);
                    TaskPool.Update();
                    CoroutineManager.Update((float)Timing.Step, (float)Timing.Step);

                    Timing.Accumulator -= Timing.Step;
                }

#if !DEBUG
                if (Server?.OwnerConnection == null)
                {
                    DebugConsole.UpdateCommandLine((int)(Timing.Accumulator * 800));
                }
                else
                {
                    DebugConsole.Clear();
                }
#else
                DebugConsole.UpdateCommandLine((int)(Timing.Accumulator * 800));
#endif

                int frameTime = (int)(((double)(stopwatch.ElapsedTicks - prevTicks) / frequency) * 1000.0);
                frameTime = Math.Max(0, frameTime);

                Thread.Sleep(Math.Max(((int)(Timing.Step * 1000.0) - frameTime) / 2, 0));
            }
            stopwatch.Stop();

            CloseServer();

            SteamManager.ShutDown();

            SaveUtil.CleanUnnecessarySaveFiles();

            if (GameSettings.SaveDebugConsoleLogs)
            {
                DebugConsole.SaveLogs();
            }
            if (GameSettings.SendUserStatistics)
            {
                GameAnalytics.OnQuit();
            }

            MainThread = null;
        }
Пример #20
0
        static void OnChatMsgRecieved(SteamFriends.ChatMsgCallback callback)
        {
            MsgsTotal += 1;
            MsgsInt   += 1;
            SteamID postID   = callback.ChatterID;
            string  postName = "";
            string  gameName = "";

            if (callback.ChatMsgType == EChatEntryType.ChatMsg)
            {
                if (callback.Message == "!a2")
                {
                    if ((lastcmd - DateTime.Now).TotalSeconds < -5)
                    {
                        rageCounter = 0;
                        lastcmd     = DateTime.Now;
                        GameServer server = new GameServer("91.121.140.129", 2702);
                        server.Update();
                        Console.WriteLine((lastcmd - DateTime.Now).TotalSeconds);
                        string srvDetails = "Players: " + (server.Players.Count - 2).ToString();
                        steamFriends.SendChatRoomMessage(Convert.ToUInt64(###############), EChatEntryType.ChatMsg, srvDetails);
                    }
                    else
                    {
                        rageCounter += 1;
                        if (rageCounter > 3)
                        {
                            steamFriends.SendChatRoomMessage(Convert.ToUInt64(###############), EChatEntryType.ChatMsg, "F**k off.");
                            rageCounter = 0;
                        }
                    }
                }
                postName = steamFriends.GetFriendPersonaName(Convert.ToUInt64(postID));
                gameName = steamFriends.GetFriendGamePlayedName(Convert.ToUInt64(postID));
                Console.Clear();
                Console.WriteLine("*****************Noah-Bawt*****************");
                Console.WriteLine("Total Messages: {0}", MsgsTotal.ToString());
                Console.WriteLine("*******************************************");
                Console.WriteLine();
            }
            else if (callback.ChatMsgType == EChatEntryType.WasBanned || callback.ChatMsgType == EChatEntryType.WasKicked)
            {
                postName = "Madmin";
                gameName = "";
                Console.Clear();
                Console.WriteLine("*****************Noah-Bawt*****************");
                Console.WriteLine("Total Messages: {0}", MsgsTotal.ToString());
                Console.WriteLine("*******************************************");
                Console.WriteLine();
            }
            if (callback.ChatMsgType == EChatEntryType.WasBanned || (callback.ChatMsgType == EChatEntryType.WasKicked && callback.Message != "!a2" && callback.Message != "!a2list") || callback.ChatMsgType == EChatEntryType.ChatMsg)
            {
                try
                {
                    SQLiteConnection cnn       = new SQLiteConnection("Data Source=steamchat.sqlite");
                    SQLiteCommand    mycommand = new SQLiteCommand(cnn);
                    mycommand.CommandText = "INSERT INTO logs (user, steamID, msg, time, game) VALUES(@p1, @p2, @p3, @p4, @p5)";
                    mycommand.CommandType = CommandType.Text;
                    mycommand.Parameters.Add(new SQLiteParameter("@p1", postName));
                    mycommand.Parameters.Add(new SQLiteParameter("@p2", Convert.ToUInt64(postID)));
                    mycommand.Parameters.Add(new SQLiteParameter("@p3", callback.Message));
                    mycommand.Parameters.Add(new SQLiteParameter("@p4", Convert.ToString(DateTime.Now)));
                    mycommand.Parameters.Add(new SQLiteParameter("@p5", gameName));
                    cnn.Open();
                    mycommand.ExecuteNonQuery();
                    cnn.Close();
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
            if (MsgsInt == 100)
            {
                MsgsInt = 0;
            }
        }
Пример #21
0
 private void Update()
 {
     gameServer.Update();
 }
Пример #22
0
    void Update()
    {
        var startTime = System.DateTime.Now;
        int aa        = System.Environment.TickCount;

        gameServer.Update();
        float tt = (float)(System.DateTime.Now - startTime).TotalMilliseconds;

        gameServer.networkManager.steptimeTotal += tt;

        if (gameServer.GetRoom(0).gameMap.GetFrame() > 50)
        {
            if (gameServer.networkManager.MaxStep < tt)
            {
                gameServer.networkManager.MaxStep = tt;
            }
        }

//         TCuurent = "Frame " + System.String.Format("{0, 6}", gameServer.GetRoom(0).gameMap.GetFrame()) +
//              "  rec " + System.String.Format("{0, 6}", gameServer.networkManager.ReciveTotal) +
//              "  send " + System.String.Format("{0, 6}", gameServer.networkManager.SendTotal) +
//              "  time " + tt + "ms";
        a++;
        //if (a > 5)

        if (gameServer.GetRoom(0).bStart)
        {
            int FrameCount = gameServer.GetRoom(0).gameMap.GetFrame();
            if (FrameCount < 1)
            {
                FrameCount = 1;
            }
            TCuurent = "total player " + gameServer.GetRoom(1).gameMap.Players.Count +
                       " Frame " + System.String.Format("{0, 6}", gameServer.GetRoom(0).gameMap.GetFrame()) + "\n" +
                       " total rec " + ((float)gameServer.networkManager.ReciveTotal / 1000000).ToString("f3") + " MB " +
                       " send " + ((float)gameServer.networkManager.SendTotal / 1000000).ToString("f3") + " MB " +
                       " time " + gameServer.networkManager.steptimeTotal + " ms\n" +
                       " aver  rec " + ((float)gameServer.networkManager.ReciveTotal / 1000 / FrameCount).ToString("f3") + " KB " +
                       " send " + ((float)gameServer.networkManager.SendTotal / 1000 / FrameCount).ToString("f3") + " KB " +
                       " time " + gameServer.networkManager.steptimeTotal / FrameCount + " ms\n" +
                       " max  rec " + (gameServer.networkManager.MaxRecive / 1000).ToString("f3") + " KB " +
                       " send " + (gameServer.networkManager.MaxSend / 1000).ToString("f3") + " KB " +
                       " time " + gameServer.networkManager.MaxStep + " ms\n" +
                       " curr  rec " + gameServer.networkManager.CurrentRecive.ToString().PadLeft(6, '_') +
                       " send " + gameServer.networkManager.CurrentSend.ToString().PadLeft(6, '_') +
                       " time " + tt + " ms";
#if UNITY_EDITOR
            UnityEngine.Debug.Log(TCuurent);
#endif

            var tbuffer = System.Text.Encoding.UTF8.GetBytes(TCuurent.Replace("\n", "") + "\n");
            Ts.Write(tbuffer, 0, tbuffer.Length);
            Ts.Flush();
        }
        else
        {
            TCuurent = "connect Count " + gameServer.GetRoom(0).players.Count;
#if UNITY_EDITOR
            // UnityEngine.Debug.Log(TCuurent);
#endif
        }


        // TS.Enqueue(tts);

        //  if(0)
    }
Пример #23
0
        public void SendUpdate()
        {
            bool nUpdate             = ShouldCalculateSightCircle();
            HashSet <IntPoint> sight = Parent.BlockSight == 0 ? SightCircle :
                                       nUpdate?CalculateSightCircle() : CalculatedSightCircle;

            List <TileData>         tiles      = new List <TileData>();
            List <ObjectDefinition> adds       = new List <ObjectDefinition>();
            List <ObjectDrop>       drops      = new List <ObjectDrop>();
            HashSet <int>           droppedIds = new HashSet <int>();

            if (nUpdate)
            {
                //Get tiles
                foreach (IntPoint p in sight)
                {
                    int  x    = p.X + (int)Position.X;
                    int  y    = p.Y + (int)Position.Y;
                    Tile tile = Parent.GetTile(x, y);

                    if (tile == null || TileUpdates[x, y] == tile.UpdateCount)
                    {
                        continue;
                    }

                    tiles.Add(new TileData
                    {
                        TileType = tile.Type,
                        X        = (short)x,
                        Y        = (short)y
                    });

                    TileUpdates[x, y] = tile.UpdateCount;
                }

                //Add statics
                foreach (IntPoint p in SightCircle)
                {
                    int x = p.X + (int)Position.X;
                    int y = p.Y + (int)Position.Y;

                    Tile tile = Parent.GetTile(x, y);
                    if (tile == null || tile.StaticObject == null)
                    {
                        continue;
                    }

                    if (TileUpdates[x, y] == tile.UpdateCount)
                    {
                        if (Entities.Add(tile.StaticObject))
                        {
                            adds.Add(tile.StaticObject.GetObjectDefinition());
                            EntityUpdates.Add(tile.StaticObject.Id, tile.StaticObject.UpdateCount);
                        }
                    }
                }
            }

            foreach (Entity en in Parent.PlayerChunks.HitTest(Position, SightRadius))
            {
                if (Entities.Add(en))
                {
                    adds.Add(en.GetObjectDefinition());
                    EntityUpdates.Add(en.Id, en.UpdateCount);
                }
            }

            //Add players
            foreach (Player player in Parent.Players.Values)
            {
                if (Entities.Add(player))
                {
                    adds.Add(player.GetObjectDefinition());
                    EntityUpdates.Add(player.Id, player.UpdateCount);
                }
            }

            //Add entities
            foreach (Entity en in Parent.EntityChunks.HitTest(Position, SightRadius))
            {
                IntPoint point = new IntPoint
                {
                    X = (int)en.Position.X - (int)Position.X,
                    Y = (int)en.Position.Y - (int)Position.Y
                };

                if (en is Container)
                {
                    if ((en as Container).OwnerId != -1 && (en as Container).OwnerId != Id)
                    {
                        continue;
                    }
                }

                if (sight.Contains(point) && Entities.Add(en))
                {
                    adds.Add(en.GetObjectDefinition());
                    EntityUpdates.Add(en.Id, en.UpdateCount);
                }
            }

            //Remove entities and statics (as they end up in the same Entities dictionary
            foreach (Entity en in Entities)
            {
                IntPoint point = new IntPoint
                {
                    X = (int)en.Position.X - (int)Position.X,
                    Y = (int)en.Position.Y - (int)Position.Y
                };

                if (en.Desc.Static)
                {
                    if (en.Parent == null || !SightCircle.Contains(point))
                    {
                        drops.Add(en.GetObjectDrop());
                        droppedIds.Add(en.Id);
                        EntityUpdates.Remove(en.Id);
                    }
                }
                else
                {
                    if (en.Parent == null || (!sight.Contains(point) && !en.Desc.Player))
                    {
                        drops.Add(en.GetObjectDrop());
                        droppedIds.Add(en.Id);
                        EntityUpdates.Remove(en.Id);
                    }
                }
            }

            Entities.RemoveWhere(k => droppedIds.Contains(k.Id));

            if (tiles.Count > 0 || adds.Count > 0 || drops.Count > 0)
            {
                Client.Send(GameServer.Update(tiles, adds, drops));
                FameStats.TilesUncovered += tiles.Count;
            }
        }