Added checks to prevent simulations to be ran on non Servers
This commit is contained in:
parent
a24588e6a7
commit
9c11fa07e5
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
|
|
||||||
namespace MLAPI.MonoBehaviours.Core
|
namespace MLAPI.MonoBehaviours.Core
|
||||||
@ -10,6 +11,11 @@ namespace MLAPI.MonoBehaviours.Core
|
|||||||
|
|
||||||
public static void Simulate(float secondsAgo, Action action)
|
public static void Simulate(float secondsAgo, Action action)
|
||||||
{
|
{
|
||||||
|
if(!NetworkingManager.singleton.isServer)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("MLAPI: Lag compensation simulations are only to be ran on the server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (int i = 0; i < SimulationObjects.Count; i++)
|
for (int i = 0; i < SimulationObjects.Count; i++)
|
||||||
{
|
{
|
||||||
SimulationObjects[i].ReverseTransform(secondsAgo);
|
SimulationObjects[i].ReverseTransform(secondsAgo);
|
||||||
@ -26,6 +32,11 @@ namespace MLAPI.MonoBehaviours.Core
|
|||||||
private static byte error = 0;
|
private static byte error = 0;
|
||||||
public static void Simulate(int clientId, Action action)
|
public static void Simulate(int clientId, Action action)
|
||||||
{
|
{
|
||||||
|
if (!NetworkingManager.singleton.isServer)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("MLAPI: Lag compensation simulations are only to be ran on the server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
float milisecondsDelay = NetworkTransport.GetCurrentRTT(NetworkingManager.singleton.hostId, clientId, out error) / 2f;
|
float milisecondsDelay = NetworkTransport.GetCurrentRTT(NetworkingManager.singleton.hostId, clientId, out error) / 2f;
|
||||||
Simulate(milisecondsDelay * 1000f, action);
|
Simulate(milisecondsDelay * 1000f, action);
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,8 @@ namespace MLAPI
|
|||||||
(messagesProcessed < NetworkConfig.MaxMessagesPerFrame || NetworkConfig.MaxMessagesPerFrame < 0));
|
(messagesProcessed < NetworkConfig.MaxMessagesPerFrame || NetworkConfig.MaxMessagesPerFrame < 0));
|
||||||
|
|
||||||
}
|
}
|
||||||
LagCompensationManager.AddFrames();
|
if (isServer)
|
||||||
|
LagCompensationManager.AddFrames();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator ApprovalTimeout(int clientId)
|
private IEnumerator ApprovalTimeout(int clientId)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user