Пример #1
0
        public void Update(GGPOSession ggpo, int[] players, int numPlayers)
        {
            var stats = new GGPONetworkStats();
            int i     = 0;

            this.numPlayers = numPlayers;

            if (graphSize < MaxGraphSize)
            {
                i = graphSize++;
            }
            else
            {
                i = firstGraphIndex;
                firstGraphIndex = (firstGraphIndex + 1) % MaxGraphSize;
            }

            for (int j = 0; j < numPlayers; j++)
            {
                ggpo.GetNetworkStats(players[j], out stats);

                // Ping
                pingGraph[j][i] = (int)stats.Ping;

                // Frame Advantage
                localFairnessGraph[j][i]  = stats.LocalFramesBehind;
                remoteFairnessGraph[j][i] = stats.RemoteFramesBehind;
                if (stats.LocalFramesBehind < 0 && stats.RemoteFramesBehind < 0)
                {
                    // Both think it's unfair (which, ironically, is fair).  Scale both and subtrace.
                    fairnessGraph[i] = Math.Abs(Math.Abs(stats.LocalFramesBehind) - Math.Abs(stats.RemoteFramesBehind));
                }
                else if (stats.LocalFramesBehind > 0 && stats.RemoteFramesBehind > 0)
                {
                    // Impossible!  Unless the network has negative transmit time.  Odd....
                    fairnessGraph[i] = 0;
                }
                else
                {
                    // They disagree.  Add.
                    fairnessGraph[i] = Math.Abs(stats.LocalFramesBehind) + Math.Abs(stats.RemoteFramesBehind);
                }
            }

            long now = Utility.GetCurrentTime();

            if (now > lastTextUpdateTime + 500)
            {
                lblNetworkLag.Text  = $"{stats.Ping} ms";
                lblFrameLag.Text    = $"{stats.Ping * 60 / 1000f:F1}";
                lblBandwidth.Text   = $"{stats.KbpsSent / 8f:F2} kilobytes/sec";
                lblLocalAhead.Text  = $"{stats.LocalFramesBehind} frames";
                lblRemoteAhead.Text = $"{stats.RemoteFramesBehind} frames";

                lastTextUpdateTime = now;
            }
        }
Пример #2
0
        private void UpdateStats(int i, int j, GGPONetworkStats stats)
        {
            /*
             * Random graphs
             */
            if (j == 0)
            {
                _remote_queue_graph[i] = stats.recv_queue_len;
                _send_queue_graph[i]   = stats.send_queue_len;
            }

            /*
             * Ping
             */
            _ping_graph[j][i] = stats.ping;

            /*
             * Frame Advantage
             */
            _local_fairness_graph[j][i]  = stats.local_frames_behind;
            _remote_fairness_graph[j][i] = stats.remote_frames_behind;
            if (stats.local_frames_behind < 0 && stats.remote_frames_behind < 0)
            {
                /*
                 * Both think it's unfair (which, ironically, is fair).  Scale both and subtrace.
                 */
                _fairness_graph[i] = Mathf.Abs(Mathf.Abs(stats.local_frames_behind) - Mathf.Abs(stats.remote_frames_behind));
            }
            else if (stats.local_frames_behind > 0 && stats.remote_frames_behind > 0)
            {
                /*
                 * Impossible!  Unless the network has negative transmit time.  Odd....
                 */
                _fairness_graph[i] = 0;
            }
            else
            {
                /*
                 * They disagree.  Add.
                 */
                _fairness_graph[i] = Mathf.Abs(stats.local_frames_behind) + Mathf.Abs(stats.remote_frames_behind);
            }

            int now = Utils.TimeGetTime();

            if (now > _last_text_update_time + 500)
            {
                networkLag             = $"{stats.ping} ms";
                frameLag               = $"{((stats.ping != 0) ? stats.ping * 60f / 1000f : 0f)} frames";
                bandwidth              = $"{stats.kbps_sent / 8f} kilobytes/sec";
                localAhead             = $"{stats.local_frames_behind} frames";
                remoteAhead            = $"{stats.remote_frames_behind} frames";
                _last_text_update_time = now;
            }
        }
Пример #3
0
        public static int GetNetworkStats(int phandle, out GGPONetworkStats stats)
        {
            stats = new GGPONetworkStats();
            var result = GGPO.GetNetworkStats(ggpo, phandle,
                                              out stats.send_queue_len,
                                              out stats.recv_queue_len,
                                              out stats.ping,
                                              out stats.kbps_sent,
                                              out stats.local_frames_behind,
                                              out stats.remote_frames_behind
                                              );

            return(result);
        }
Пример #4
0
        public override GGPOErrorCode GetNetworkStats(int playerHandle, out GGPONetworkStats stats)
        {
            stats = null;

            GGPOErrorCode result = PlayerHandleToQueue(playerHandle, out int queue);

            if (result != GGPOErrorCode.Success)
            {
                return(result);
            }

            endpoints[queue].GetNetworkStats(out stats);
            return(GGPOErrorCode.OK);
        }
Пример #5
0
        /*
         * Advances the game state by exactly 1 frame using the inputs specified
         * for player 1 and player 2.
         */

        private void AdvanceFrame(long[] inputs, int disconnect_flags)
        {
            if (Game == null)
            {
                LogPlugin("GameState is null what?");
            }
            Game.Update(inputs, disconnect_flags);

            // update the checksums to display in the top of the window. this helps to detect desyncs.
            GameInfo.now.framenumber = Game.Framenumber;
            GameInfo.now.checksum    = Game.Checksum;
            if ((Game.Framenumber % 90) == 0)
            {
                GameInfo.periodic = GameInfo.now;
            }

            // Notify ggpo that we've moved forward exactly 1 frame.
            CheckAndReport(GGPO.Session.AdvanceFrame());

            // Update the performance monitor display.
            int[] handles = new int[MAX_PLAYERS];
            int   count   = 0;

            for (int i = 0; i < GameInfo.players.Length; i++)
            {
                if (GameInfo.players[i].type == GGPOPlayerType.GGPO_PLAYERTYPE_REMOTE)
                {
                    handles[count++] = GameInfo.players[i].handle;
                }
            }

            var statss = new GGPONetworkStats[count];

            for (int i = 0; i < count; ++i)
            {
                CheckAndReport(GGPO.Session.GetNetworkStats(handles[i], out statss[i]));
            }
            perf?.ggpoutil_perfmon_update(statss);
        }