Fixed null values
This commit is contained in:
@@ -122,6 +122,7 @@ namespace SeamlessClientPlugin
|
|||||||
|
|
||||||
public void Init(object gameInstance)
|
public void Init(object gameInstance)
|
||||||
{
|
{
|
||||||
|
Patches.GetPatches();
|
||||||
TryShow("Running Seamless Client Plugin v[" + Version + "]");
|
TryShow("Running Seamless Client Plugin v[" + Version + "]");
|
||||||
PingTimer.Elapsed += PingTimer_Elapsed;
|
PingTimer.Elapsed += PingTimer_Elapsed;
|
||||||
PingTimer.Start();
|
PingTimer.Start();
|
||||||
|
@@ -164,7 +164,7 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SeamlessTransfer\PingServer.cs" />
|
<Compile Include="SeamlessTransfer\PingServer.cs" />
|
||||||
<Compile Include="Messages\Transfer.cs" />
|
<Compile Include="Messages\Transfer.cs" />
|
||||||
<Compile Include="SeamlessTransfer\Patches.cs" />
|
<Compile Include="Utilities\Patches.cs" />
|
||||||
<Compile Include="SeamlessTransfer\SwitchServers.cs" />
|
<Compile Include="SeamlessTransfer\SwitchServers.cs" />
|
||||||
<Compile Include="Utilities\Utility.cs" />
|
<Compile Include="Utilities\Utility.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@@ -23,22 +23,19 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
Transfer = ClientTransfer;
|
Transfer = ClientTransfer;
|
||||||
Request = Transfer.WorldRequest;
|
Request = Transfer.WorldRequest;
|
||||||
|
|
||||||
|
|
||||||
if (Transfer.TargetServerID == 0)
|
if (Transfer.TargetServerID == 0)
|
||||||
{
|
{
|
||||||
SeamlessClient.TryShow("This is not a valid server!");
|
SeamlessClient.TryShow("This is not a valid server!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SeamlessClient.TryShow("Beginning Redirect to server: " + Transfer.TargetServerID);
|
SeamlessClient.TryShow("Beginning Redirect to server: " + Transfer.TargetServerID);
|
||||||
MyGameService.OnPingServerResponded += PingResponded;
|
MyGameService.OnPingServerResponded += PingResponded;
|
||||||
MyGameService.OnPingServerFailedToRespond += FailedToRespond;
|
MyGameService.OnPingServerFailedToRespond += FailedToRespond;
|
||||||
|
|
||||||
MyGameService.PingServer(Transfer.IPAdress);
|
MyGameService.PingServer(Transfer.IPAdress);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PingResponded(object sender, MyGameServerItem e)
|
private static void PingResponded(object sender, MyGameServerItem e)
|
||||||
@@ -56,9 +53,7 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
private static void FailedToRespond(object sender, EventArgs e)
|
private static void FailedToRespond(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// If the target server failed to respond, we need to exit/return to menu
|
// If the target server failed to respond, we need to exit/return to menu
|
||||||
|
|
||||||
UnRegisterEvents();
|
UnRegisterEvents();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -44,8 +44,8 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Static FieldInfos */
|
/* Static FieldInfos and PropertyInfos */
|
||||||
public static FieldInfo MySessionLayer { get; private set; }
|
public static PropertyInfo MySessionLayer { get; private set; }
|
||||||
public static FieldInfo VirtualClients { get; private set; }
|
public static FieldInfo VirtualClients { get; private set; }
|
||||||
public static FieldInfo AdminSettings { get; private set; }
|
public static FieldInfo AdminSettings { get; private set; }
|
||||||
public static FieldInfo RemoteAdminSettings { get; private set; }
|
public static FieldInfo RemoteAdminSettings { get; private set; }
|
||||||
@@ -80,8 +80,8 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
MyMultiplayerClientBaseConstructor = GetConstructor(MyMultiplayerClientBase, BindingFlags.Instance | BindingFlags.NonPublic, new Type[] { typeof(MySyncLayer) });
|
MyMultiplayerClientBaseConstructor = GetConstructor(MyMultiplayerClientBase, BindingFlags.Instance | BindingFlags.NonPublic, new Type[] { typeof(MySyncLayer) });
|
||||||
|
|
||||||
|
|
||||||
/* Get Fields */
|
/* Get Fields and Properties */
|
||||||
MySessionLayer = GetField(typeof(MySession), "SyncLayer", BindingFlags.Instance | BindingFlags.Public);
|
MySessionLayer = GetProperty(typeof(MySession), "SyncLayer", BindingFlags.Instance | BindingFlags.Public);
|
||||||
VirtualClients = GetField(typeof(MySession), "VirtualClients", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
VirtualClients = GetField(typeof(MySession), "VirtualClients", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||||
AdminSettings = GetField(typeof(MySession), "m_adminSettings", BindingFlags.Instance | BindingFlags.NonPublic);
|
AdminSettings = GetField(typeof(MySession), "m_adminSettings", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
RemoteAdminSettings = GetField(typeof(MySession), "m_remoteAdminSettings", BindingFlags.Instance | BindingFlags.NonPublic);
|
RemoteAdminSettings = GetField(typeof(MySession), "m_remoteAdminSettings", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
@@ -266,6 +266,26 @@ namespace SeamlessClientPlugin.SeamlessTransfer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static PropertyInfo GetProperty(Type type, string PropertyName, BindingFlags Flags)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PropertyInfo FoundProperty = type.GetProperty(PropertyName, Flags);
|
||||||
|
|
||||||
|
if (FoundProperty == null)
|
||||||
|
throw new NullReferenceException($"Property for {PropertyName} is null!");
|
||||||
|
|
||||||
|
|
||||||
|
return FoundProperty;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception Ex)
|
||||||
|
{
|
||||||
|
throw Ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static ConstructorInfo GetConstructor(Type type, BindingFlags Flags, Type[] Types)
|
private static ConstructorInfo GetConstructor(Type type, BindingFlags Flags, Type[] Types)
|
||||||
{
|
{
|
||||||
|
|
Reference in New Issue
Block a user