Added proper UDP features. No proper implementation yet.

This commit is contained in:
Bitl 2020-06-28 12:56:34 -07:00
parent 296a80fb86
commit 7b23076c85
8 changed files with 111 additions and 16 deletions

View File

@ -147,7 +147,8 @@ public static class GlobalVars
public static bool ReadyToLaunch = false;
//server settings.
public static bool UPnP = false;
public static string Map = "";
public static bool UDP = true;
public static string Map = "";
public static string FullMapPath = "";
public static int RobloxPort = 53640;
public static int DefaultRobloxPort = 53640;

View File

@ -58,6 +58,7 @@ public class LauncherFuncs
ini.IniWriteValue(section, "ReShade", GlobalVars.ReShade.ToString());
ini.IniWriteValue(section, "QualityLevel", GlobalVars.QualityLevel.ToString());
ini.IniWriteValue(section, "OldLayout", GlobalVars.OldLayout.ToString());
ini.IniWriteValue(section, "UDP", GlobalVars.UDP.ToString());
}
else
{
@ -65,7 +66,7 @@ public class LauncherFuncs
string Decryptline1, Decryptline2, Decryptline3, Decryptline4,
Decryptline5, Decryptline6, Decryptline7, Decryptline9, Decryptline10,
Decryptline11, Decryptline12, Decryptline13, Decryptline14, Decryptline15,
Decryptline16, Decryptline17, Decryptline20, Decryptline21;
Decryptline16, Decryptline17, Decryptline20, Decryptline21, Decryptline22;
IniFile ini = new IniFile(cfgpath);
@ -216,6 +217,14 @@ public class LauncherFuncs
Decryptline21 = ini.IniReadValue(section, "OldLayout");
}
Decryptline22 = ini.IniReadValue(section, "UDP");
if (string.IsNullOrWhiteSpace(Decryptline21))
{
ini.IniWriteValue(section, "UDP", GlobalVars.UDP.ToString());
Decryptline21 = ini.IniReadValue(section, "UDP");
}
bool bline1 = Convert.ToBoolean(Decryptline1);
GlobalVars.CloseOnLaunch = bline1;
@ -275,6 +284,8 @@ public class LauncherFuncs
GlobalVars.QualityLevel = iline20;
bool bline21 = Convert.ToBoolean(Decryptline21);
GlobalVars.OldLayout = bline21;
bool bline22 = Convert.ToBoolean(Decryptline22);
GlobalVars.UDP = bline22;
}
Customization(GlobalVars.ConfigDir + "\\" + GlobalVars.ConfigNameCustomization, write);
@ -674,6 +685,7 @@ public class LauncherFuncs
GlobalVars.PlayerLimit = 12;
GlobalVars.Custom_Extra_ShowHats = false;
GlobalVars.UPnP = false;
GlobalVars.UDP = true;
GlobalVars.DisabledHelp = false;
GlobalVars.DiscordPresence = true;
GlobalVars.MapPath = GlobalVars.MapsDir + @"\\" + GlobalVars.DefaultMap;

View File

@ -8,6 +8,7 @@
*/
using System;
using LiteNetLib;
using Mono.Nat;
public static class UPnP
@ -42,4 +43,52 @@ public static class UPnP
}
}
}
}
public static class UDP
{
private static NetManager StartUDPListener(int port = -1)
{
if (GlobalVars.UDP == true)
{
EventBasedNetListener listener = new EventBasedNetListener();
NetManager list = new NetManager(listener);
if (port > -1)
{
list.Start(port);
}
else
{
list.Start();
}
return list;
}
return null;
}
public static NetManager StartClient(string ip, int port)
{
if (GlobalVars.UDP == true)
{
//we don't need a port here, we are a client.
NetManager client = StartUDPListener();
client.Connect(ip, port, "");
return client;
}
return null;
}
public static NetManager StartServer(int port)
{
if (GlobalVars.UDP == true)
{
NetManager server = StartUDPListener(port);
return server;
}
return null;
}
}

View File

@ -27,7 +27,7 @@
<Compile Include="$(MSBuildThisFileDirectory)SplashReader.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TextLineRemover.cs" />
<Compile Include="$(MSBuildThisFileDirectory)TreeNodeHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)UPnP.cs" />
<Compile Include="$(MSBuildThisFileDirectory)NetFuncs.cs" />
<Compile Include="$(MSBuildThisFileDirectory)URI.cs" />
<Compile Include="$(MSBuildThisFileDirectory)WebServer.cs" />
</ItemGroup>

View File

@ -380,6 +380,7 @@ namespace NovetusLauncher
this.checkBox8.Text = "Toggle UDP Hole Punching (WIP)";
this.checkBox8.UseVisualStyleBackColor = true;
this.checkBox8.CheckedChanged += new System.EventHandler(this.checkBox8_CheckedChanged);
this.checkBox8.Click += new System.EventHandler(this.CheckBox4Click);
//
// label19
//

View File

@ -547,8 +547,15 @@ namespace NovetusLauncher
numericUpDown2.Value = Convert.ToDecimal(GlobalVars.RobloxPort);
label37.Text = GlobalVars.IP;
label38.Text = GlobalVars.RobloxPort.ToString();
checkBox4.Checked = GlobalVars.UPnP;
checkBox2.Checked = GlobalVars.DiscordPresence;
if (GlobalVars.UDP == false && GlobalVars.UPnP == true)
{
checkBox4.Checked = GlobalVars.UPnP;
}
else if (GlobalVars.UDP == true && GlobalVars.UPnP == false)
{
checkBox8.Checked = GlobalVars.UDP;
}
checkBox2.Checked = GlobalVars.DiscordPresence;
checkBox5.Checked = GlobalVars.ReShade;
checkBox6.Checked = GlobalVars.ReShadeFPSDisplay;
checkBox7.Checked = GlobalVars.ReShadePerformanceMode;
@ -1576,7 +1583,7 @@ namespace NovetusLauncher
else if (checkBox4.Checked == false)
{
GlobalVars.UPnP = false;
//checkBox8.Checked = GlobalVars.UDP;
checkBox8.Checked = GlobalVars.UDP;
}
}
@ -1874,7 +1881,16 @@ namespace NovetusLauncher
private void checkBox8_CheckedChanged(object sender, EventArgs e)
{
}
if (checkBox8.Checked == true)
{
GlobalVars.UDP = true;
checkBox4.Checked = false;
}
else if (checkBox8.Checked == false)
{
GlobalVars.UDP = false;
checkBox4.Checked = GlobalVars.UPnP;
}
}
}
}

View File

@ -380,6 +380,7 @@ namespace NovetusLauncher
this.checkBox8.Text = "Toggle UDP\r\nHole Punching (WIP)";
this.checkBox8.UseVisualStyleBackColor = true;
this.checkBox8.CheckedChanged += new System.EventHandler(this.checkBox8_CheckedChanged);
this.checkBox8.Click += new System.EventHandler(this.CheckBox4Click);
//
// label19
//

View File

@ -545,7 +545,14 @@ namespace NovetusLauncher
numericUpDown2.Value = Convert.ToDecimal(GlobalVars.RobloxPort);
label37.Text = GlobalVars.IP;
label38.Text = GlobalVars.RobloxPort.ToString();
checkBox4.Checked = GlobalVars.UPnP;
if (GlobalVars.UDP == false && GlobalVars.UPnP == true)
{
checkBox4.Checked = GlobalVars.UPnP;
}
else if (GlobalVars.UDP == true && GlobalVars.UPnP == false)
{
checkBox8.Checked = GlobalVars.UDP;
}
checkBox2.Checked = GlobalVars.DiscordPresence;
ConsolePrint("Config loaded.", 3);
@ -1542,7 +1549,7 @@ namespace NovetusLauncher
else if (checkBox4.Checked == false)
{
GlobalVars.UPnP = false;
//checkBox8.Checked = GlobalVars.UDP;
checkBox8.Checked = GlobalVars.UDP;
}
}
@ -1793,10 +1800,18 @@ namespace NovetusLauncher
Application.Restart();
}
private void checkBox8_CheckedChanged(object sender, EventArgs e)
{
}
}
private void checkBox8_CheckedChanged(object sender, EventArgs e)
{
if (checkBox8.Checked == true)
{
GlobalVars.UDP = true;
checkBox4.Checked = false;
}
else if (checkBox8.Checked == false)
{
GlobalVars.UDP = false;
checkBox4.Checked = GlobalVars.UPnP;
}
}
}
}