Changed ID to NetHandle. Configure() removed from COOPAPI and replaced by its own functions

This commit is contained in:
EntenKoeniq
2021-12-14 22:39:15 +01:00
parent 721da34e36
commit 98295fee3a
12 changed files with 179 additions and 144 deletions

View File

@ -7,7 +7,7 @@ namespace CoopServer
{
public class Client
{
public long ID = 0;
public long NetHandle = 0;
public float Latency = 0.0f;
public PlayerData Player;
private readonly Dictionary<string, object> CustomData = new();
@ -48,18 +48,18 @@ namespace CoopServer
#region FUNCTIONS
public void Kick(string[] reason)
{
Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == ID)?.Disconnect(string.Join(" ", reason));
Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == NetHandle)?.Disconnect(string.Join(" ", reason));
}
public void Kick(string reason)
{
Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == ID)?.Disconnect(reason);
Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == NetHandle)?.Disconnect(reason);
}
public void SendChatMessage(string message, string from = "Server")
{
try
{
NetConnection userConnection = Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == ID);
NetConnection userConnection = Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == NetHandle);
if (userConnection == null)
{
return;
@ -85,10 +85,10 @@ namespace CoopServer
{
try
{
NetConnection userConnection = Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == ID);
NetConnection userConnection = Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == NetHandle);
if (userConnection == null)
{
Logging.Error($"[Client->SendNativeCall(ulong hash, params object[] args)]: Connection \"{ID}\" not found!");
Logging.Error($"[Client->SendNativeCall(ulong hash, params object[] args)]: Connection \"{NetHandle}\" not found!");
return;
}
@ -124,10 +124,10 @@ namespace CoopServer
{
try
{
NetConnection userConnection = Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == ID);
NetConnection userConnection = Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == NetHandle);
if (userConnection == null)
{
Logging.Error($"[Client->SendNativeResponse(Action<object> callback, ulong hash, Type type, params object[] args)]: Connection \"{ID}\" not found!");
Logging.Error($"[Client->SendNativeResponse(Action<object> callback, ulong hash, Type type, params object[] args)]: Connection \"{NetHandle}\" not found!");
return;
}
@ -178,7 +178,7 @@ namespace CoopServer
Hash = hash,
Args = arguments,
Type = returnType,
ID = id
NetHandle = id
};
NetOutgoingMessage outgoingMessage = Server.MainNetServer.CreateMessage();
@ -195,7 +195,7 @@ namespace CoopServer
{
try
{
NetConnection userConnection = Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == ID);
NetConnection userConnection = Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == NetHandle);
if (userConnection == null)
{
return;
@ -204,7 +204,7 @@ namespace CoopServer
NetOutgoingMessage outgoingMessage = Server.MainNetServer.CreateMessage();
new ModPacket()
{
ID = 0,
NetHandle = 0,
Target = 0,
Mod = mod,
CustomPacketID = customID,