コード例 #1
0
    private static void OnClientSyncTime(ClientSyncTimeEvent e)
    {
        if (e.isDistortionSyncEvent)
        {
            // Set ping
            double calculatedPingTime = Math.Max((clientTimeNoDistortion - e.clientSendTime) / 2.0, 0.0);
            singleton._serverPingTime = (calculatedPingTime + singleton._serverPingTime * 3.0) / 4.0;

            double calculatedServerWatchDialation = Math.Min(Math.Max(-_serverWatchDialationLimits,
                                                                      (clientTimeNoDistortion) - e.serverLifeTime),
                                                             _serverWatchDialationLimits);

            FFSystem.ResetClientWatch();
            singleton._serverLifeTime = e.serverLifeTime + singleton._serverPingTime;

            // _serverWatchDialation average
            singleton._serverWatchDialation = (calculatedServerWatchDialation + singleton._serverWatchDialation) / 2.0;
            //_serverWatchDialation = calculatedServerWatchDialation; // debug (non-averaged)

            Debug.Log("ClientSyncTimeEvent (Dialation Event)" +
                      "\nCalculated Dialation: " + calculatedServerWatchDialation +
                      "\nCalculated Ping: " + calculatedPingTime); // debug
        }
        else
        {
            // Set ping
            double calculatedPingTime = Math.Max(clientTimeNoDistortion - e.clientSendTime, 0.0);
            singleton._serverPingTime = (calculatedPingTime + singleton._serverPingTime * 4.0) / 5.0;
            //_serverPingTime = calculatedPingTime;

            /*Debug.Log("ClientSyncTimeEvent" +
             *  "\nCalculated Ping: " + calculatedPingTime); *///debug
        }
    }
コード例 #2
0
    private static void OnClientSyncTime(ClientSyncTimeEvent e)
    {
        if(e.isDistortionSyncEvent)
        {
            // Set ping
            double calculatedPingTime = Math.Max((clientTimeNoDistortion - e.clientSendTime) / 2.0, 0.0);
            singleton._serverPingTime = (calculatedPingTime + singleton._serverPingTime * 3.0) / 4.0;

            double calculatedServerWatchDialation = Math.Min(Math.Max(-_serverWatchDialationLimits,
                (clientTimeNoDistortion) - e.serverLifeTime),
                _serverWatchDialationLimits);

            FFSystem.ResetClientWatch();
            singleton._serverLifeTime = e.serverLifeTime + singleton._serverPingTime;

            // _serverWatchDialation average
            singleton._serverWatchDialation = (calculatedServerWatchDialation + singleton._serverWatchDialation) / 2.0;
            //_serverWatchDialation = calculatedServerWatchDialation; // debug (non-averaged)

            Debug.Log("ClientSyncTimeEvent (Dialation Event)" +
                "\nCalculated Dialation: " + calculatedServerWatchDialation +
                "\nCalculated Ping: " + calculatedPingTime);  // debug
        }
        else
        {
            // Set ping
            double calculatedPingTime = Math.Max(clientTimeNoDistortion - e.clientSendTime, 0.0);
            singleton._serverPingTime = (calculatedPingTime + singleton._serverPingTime * 4.0) / 5.0;
            //_serverPingTime = calculatedPingTime;

            /*Debug.Log("ClientSyncTimeEvent" +
                "\nCalculated Ping: " + calculatedPingTime); */ //debug
        }
    }