Small changes and bug fixes

This commit is contained in:
EntenKoeniq 2021-12-10 16:25:59 +01:00
parent d244cd393a
commit 3bcda302fe
6 changed files with 42 additions and 31 deletions

View File

@ -539,7 +539,7 @@ namespace CoopClient
}
else
{
GTA.UI.Notification.Show("[DecodeNativeCall][" + packet.Hash + "]: Type of argument not found!");
GTA.UI.Notification.Show("[DecodeNativeResponse][" + packet.Hash + "]: Type of argument not found!");
return;
}

View File

@ -84,12 +84,14 @@ namespace CoopServer
NetConnection userConnection = Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == ID);
if (userConnection == null)
{
Logging.Error($"[Client->SendNativeCall(ulong hash, params object[] args)]: Connection \"{ID}\" not found!");
return;
}
List<NativeArgument> arguments = Util.ParseNativeArguments(args);
if (arguments == null)
if (arguments == null || args.Length == 0)
{
Logging.Error($"[Client->SendNativeCall(ulong hash, params object[] args)]: Missing arguments!");
return;
}
@ -116,6 +118,7 @@ namespace CoopServer
NetConnection userConnection = Server.MainNetServer.Connections.Find(x => x.RemoteUniqueIdentifier == ID);
if (userConnection == null)
{
Logging.Error($"[Client->SendNativeResponse(Action<object> callback, ulong hash, Type type, params object[] args)]: Connection \"{ID}\" not found!");
return;
}
@ -143,12 +146,14 @@ namespace CoopServer
}
else
{
Logging.Error($"[Client->SendNativeResponse(Action<object> callback, ulong hash, Type type, params object[] args)]: Argument does not exist!");
return;
}
List<NativeArgument> arguments = Util.ParseNativeArguments(args);
if (arguments == null)
{
Logging.Error($"[Client->SendNativeResponse(Action<object> callback, ulong hash, Type type, params object[] args)]: One or more arguments do not exist!");
return;
}

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<AssemblyVersion>1.4.6.0001</AssemblyVersion>
<AssemblyVersion>1.4.7.0001</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<RepositoryUrl>https://github.com/GTACOOP-R/GTACoop-R</RepositoryUrl>
</PropertyGroup>

View File

@ -193,6 +193,7 @@ namespace CoopServer
private void Listen()
{
Logging.Info("Listening for clients");
Logging.Info("Please use CTRL + C if you want to stop the server!");
while (!Program.ReadyToStop)
{

View File

@ -238,9 +238,10 @@ namespace CoopServer
return;
}
List<NativeArgument> arguments;
if ((arguments = Util.ParseNativeArguments(args)) == null)
List<NativeArgument> arguments = Util.ParseNativeArguments(args);
if (arguments == null)
{
Logging.Error($"[ServerScript->SendNativeCallToAll(ulong hash, params object[] args)]: One or more arguments do not exist!");
return;
}

View File

@ -12,36 +12,40 @@ namespace CoopServer
{
public static List<NativeArgument> ParseNativeArguments(params object[] args)
{
List<NativeArgument> result = new();
List<NativeArgument> result = null;
foreach (object arg in args)
if (args != null && args.Length > 0)
{
Type typeOf = arg.GetType();
result = new();
if (typeOf == typeof(int))
foreach (object arg in args)
{
result.Add(new IntArgument() { Data = (int)arg });
}
else if (typeOf == typeof(bool))
{
result.Add(new BoolArgument() { Data = (bool)arg });
}
else if (typeOf == typeof(float))
{
result.Add(new FloatArgument() { Data = (float)arg });
}
else if (typeOf == typeof(string))
{
result.Add(new StringArgument() { Data = (string)arg });
}
else if (typeOf == typeof(LVector3))
{
result.Add(new LVector3Argument() { Data = (LVector3)arg });
}
else
{
Logging.Error("[Util->ParseNativeArguments(params object[] args)]: Type of argument not found!");
return null;
Type typeOf = arg.GetType();
if (typeOf == typeof(int))
{
result.Add(new IntArgument() { Data = (int)arg });
}
else if (typeOf == typeof(bool))
{
result.Add(new BoolArgument() { Data = (bool)arg });
}
else if (typeOf == typeof(float))
{
result.Add(new FloatArgument() { Data = (float)arg });
}
else if (typeOf == typeof(string))
{
result.Add(new StringArgument() { Data = (string)arg });
}
else if (typeOf == typeof(LVector3))
{
result.Add(new LVector3Argument() { Data = (LVector3)arg });
}
else
{
return null;
}
}
}