NetworkClient.connection: use explicit type NetworkConnectionToServer to reduce chance of bugs

This commit is contained in:
mischa 2024-10-07 11:36:32 +02:00
parent 2277d66cea
commit 6bc974618a
3 changed files with 8 additions and 2 deletions

View File

@ -52,7 +52,7 @@ public static partial class NetworkClient
new Dictionary<uint, NetworkIdentity>();
/// <summary>Client's NetworkConnection to server.</summary>
public static NetworkConnection connection { get; internal set; }
public static NetworkConnectionToServer connection { get; internal set; }
/// <summary>True if client is ready (= joined world).</summary>
// TODO redundant state. point it to .connection.isReady instead (& test)

View File

@ -9,4 +9,10 @@ public FakeNetworkConnectionToClient() : base(1) {}
public override void Disconnect() {}
internal override void Send(ArraySegment<byte> segment, int channelId = 0) {}
}
public class FakeNetworkConnectionToServer : NetworkConnectionToServer
{
public override void Disconnect() {}
internal override void Send(ArraySegment<byte> segment, int channelId = 0) {}
}
}

View File

@ -534,7 +534,7 @@ public void ApplyPayload_LocalPlayerAddsIdentityToConnection()
payload = default,
};
NetworkClient.connection = new FakeNetworkConnectionToClient();
NetworkClient.connection = new FakeNetworkConnectionToServer();
NetworkClient.ready = true;
NetworkClient.ApplySpawnPayload(identity, msg);