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 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; return;
} }

View File

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

View File

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

View File

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

View File

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

View File

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