Disabled UDP code.

This commit is contained in:
Bitl 2020-07-01 15:36:54 -07:00
parent e19511f2f2
commit 6ae445a9e0
13 changed files with 163 additions and 173 deletions

View File

@ -74,9 +74,6 @@
<HintPath>..\packages\DotNetZip.1.11.0\lib\net20\DotNetZip.dll</HintPath> <HintPath>..\packages\DotNetZip.1.11.0\lib\net20\DotNetZip.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="LiteNetLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LiteNetLib.0.9.2.2\lib\net35\LiteNetLib.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp"> <Reference Include="Microsoft.CSharp">
<RequiredTargetFramework>4.0</RequiredTargetFramework> <RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference> </Reference>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="DotNetZip" version="1.11.0" targetFramework="net40" /> <package id="DotNetZip" version="1.11.0" targetFramework="net40" />
<package id="LiteNetLib" version="0.9.2.2" targetFramework="net40" />
<package id="Microsoft.Bcl" version="1.1.8" targetFramework="net40" /> <package id="Microsoft.Bcl" version="1.1.8" targetFramework="net40" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" /> <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" /> <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />

View File

@ -7,7 +7,7 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using LiteNetLib; //using LiteNetLib;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
@ -143,14 +143,14 @@ public static class GlobalVars
public static readonly string ScriptName = "CSMPFunctions"; public static readonly string ScriptName = "CSMPFunctions";
public static readonly string ScriptGenName = "CSMPBoot"; public static readonly string ScriptGenName = "CSMPBoot";
public static SimpleHTTPServer WebServer = null; public static SimpleHTTPServer WebServer = null;
public static NetManager WebServerUDPInstance = null; //public static NetManager WebServerUDPInstance = null;
public static bool IsWebServerOn = false; public static bool IsWebServerOn = false;
public static bool IsSnapshot = false; public static bool IsSnapshot = false;
//vars for loader //vars for loader
public static bool ReadyToLaunch = false; public static bool ReadyToLaunch = false;
//server settings. //server settings.
public static bool UPnP = false; public static bool UPnP = false;
public static bool UDP = true; //public static bool UDP = true;
public static string Map = ""; public static string Map = "";
public static string FullMapPath = ""; public static string FullMapPath = "";
public static int RobloxPort = 53640; public static int RobloxPort = 53640;

View File

@ -58,15 +58,16 @@ public class LauncherFuncs
ini.IniWriteValue(section, "ReShade", GlobalVars.ReShade.ToString()); ini.IniWriteValue(section, "ReShade", GlobalVars.ReShade.ToString());
ini.IniWriteValue(section, "QualityLevel", GlobalVars.QualityLevel.ToString()); ini.IniWriteValue(section, "QualityLevel", GlobalVars.QualityLevel.ToString());
ini.IniWriteValue(section, "OldLayout", GlobalVars.OldLayout.ToString()); ini.IniWriteValue(section, "OldLayout", GlobalVars.OldLayout.ToString());
ini.IniWriteValue(section, "UDP", GlobalVars.UDP.ToString()); //ini.IniWriteValue(section, "UDP", GlobalVars.UDP.ToString());
} }
else else
{ {
//redo the way this handles reading invalid values.
//READ //READ
string Decryptline1, Decryptline2, Decryptline3, Decryptline4, string Decryptline1, Decryptline2, Decryptline3, Decryptline4,
Decryptline5, Decryptline6, Decryptline7, Decryptline9, Decryptline10, Decryptline5, Decryptline6, Decryptline7, Decryptline9, Decryptline10,
Decryptline11, Decryptline12, Decryptline13, Decryptline14, Decryptline15, Decryptline11, Decryptline12, Decryptline13, Decryptline14, Decryptline15,
Decryptline16, Decryptline17, Decryptline20, Decryptline21, Decryptline22; Decryptline16, Decryptline17, Decryptline20, Decryptline21;//, Decryptline22;
IniFile ini = new IniFile(cfgpath); IniFile ini = new IniFile(cfgpath);
@ -217,13 +218,14 @@ public class LauncherFuncs
Decryptline21 = ini.IniReadValue(section, "OldLayout"); Decryptline21 = ini.IniReadValue(section, "OldLayout");
} }
/*
Decryptline22 = ini.IniReadValue(section, "UDP"); Decryptline22 = ini.IniReadValue(section, "UDP");
if (string.IsNullOrWhiteSpace(Decryptline21)) if (string.IsNullOrWhiteSpace(Decryptline21))
{ {
ini.IniWriteValue(section, "UDP", GlobalVars.UDP.ToString()); ini.IniWriteValue(section, "UDP", GlobalVars.UDP.ToString());
Decryptline21 = ini.IniReadValue(section, "UDP"); Decryptline21 = ini.IniReadValue(section, "UDP");
} }*/
bool bline1 = Convert.ToBoolean(Decryptline1); bool bline1 = Convert.ToBoolean(Decryptline1);
GlobalVars.CloseOnLaunch = bline1; GlobalVars.CloseOnLaunch = bline1;
@ -284,8 +286,8 @@ public class LauncherFuncs
GlobalVars.QualityLevel = iline20; GlobalVars.QualityLevel = iline20;
bool bline21 = Convert.ToBoolean(Decryptline21); bool bline21 = Convert.ToBoolean(Decryptline21);
GlobalVars.OldLayout = bline21; GlobalVars.OldLayout = bline21;
bool bline22 = Convert.ToBoolean(Decryptline22); //bool bline22 = Convert.ToBoolean(Decryptline22);
GlobalVars.UDP = bline22; //GlobalVars.UDP = bline22;
} }
Customization(GlobalVars.ConfigDir + "\\" + GlobalVars.ConfigNameCustomization, write); Customization(GlobalVars.ConfigDir + "\\" + GlobalVars.ConfigNameCustomization, write);
@ -685,7 +687,7 @@ public class LauncherFuncs
GlobalVars.PlayerLimit = 12; GlobalVars.PlayerLimit = 12;
GlobalVars.Custom_Extra_ShowHats = false; GlobalVars.Custom_Extra_ShowHats = false;
GlobalVars.UPnP = false; GlobalVars.UPnP = false;
GlobalVars.UDP = true; //GlobalVars.UDP = true;
GlobalVars.DisabledHelp = false; GlobalVars.DisabledHelp = false;
GlobalVars.DiscordPresence = true; GlobalVars.DiscordPresence = true;
GlobalVars.MapPath = GlobalVars.MapsDir + @"\\" + GlobalVars.DefaultMap; GlobalVars.MapPath = GlobalVars.MapsDir + @"\\" + GlobalVars.DefaultMap;

View File

@ -8,7 +8,7 @@
*/ */
using System; using System;
using LiteNetLib; //using LiteNetLib;
using Mono.Nat; using Mono.Nat;
public static class UPnP public static class UPnP
@ -45,6 +45,7 @@ public static class UPnP
} }
} }
/*
public static class UDP public static class UDP
{ {
private static NetManager StartUDPListener(int port = -1) private static NetManager StartUDPListener(int port = -1)
@ -74,7 +75,10 @@ public static class UDP
{ {
//we don't need a port here, we are a client. //we don't need a port here, we are a client.
NetManager client = StartUDPListener(); NetManager client = StartUDPListener();
EventBasedNatPunchListener natPunchListener = new EventBasedNatPunchListener();
client.Connect(ip, port, ""); client.Connect(ip, port, "");
client.NatPunchEnabled = true;
client.NatPunchModule.Init(natPunchListener);
return client; return client;
} }
@ -86,9 +90,12 @@ public static class UDP
if (GlobalVars.UDP == true) if (GlobalVars.UDP == true)
{ {
NetManager server = StartUDPListener(port); NetManager server = StartUDPListener(port);
EventBasedNatPunchListener natPunchListener = new EventBasedNatPunchListener();
server.NatPunchEnabled = true;
server.NatPunchModule.Init(natPunchListener);
return server; return server;
} }
return null; return null;
} }
} }*/

View File

@ -57,7 +57,7 @@ namespace NovetusLauncher
this.button1 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox1 = new System.Windows.Forms.TextBox();
this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage();
this.checkBox8 = new System.Windows.Forms.CheckBox(); //this.checkBox8 = new System.Windows.Forms.CheckBox();
this.label19 = new System.Windows.Forms.Label(); this.label19 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox(); this.textBox3 = new System.Windows.Forms.TextBox();
this.label17 = new System.Windows.Forms.Label(); this.label17 = new System.Windows.Forms.Label();
@ -348,7 +348,7 @@ namespace NovetusLauncher
// //
// tabPage2 // tabPage2
// //
this.tabPage2.Controls.Add(this.checkBox8); //this.tabPage2.Controls.Add(this.checkBox8);
this.tabPage2.Controls.Add(this.label19); this.tabPage2.Controls.Add(this.label19);
this.tabPage2.Controls.Add(this.textBox3); this.tabPage2.Controls.Add(this.textBox3);
this.tabPage2.Controls.Add(this.label17); this.tabPage2.Controls.Add(this.label17);
@ -372,6 +372,7 @@ namespace NovetusLauncher
// //
// checkBox8 // checkBox8
// //
/*
this.checkBox8.AutoSize = true; this.checkBox8.AutoSize = true;
this.checkBox8.Location = new System.Drawing.Point(326, 182); this.checkBox8.Location = new System.Drawing.Point(326, 182);
this.checkBox8.Name = "checkBox8"; this.checkBox8.Name = "checkBox8";
@ -380,7 +381,7 @@ namespace NovetusLauncher
this.checkBox8.Text = "Toggle UDP Hole Punching (WIP)"; this.checkBox8.Text = "Toggle UDP Hole Punching (WIP)";
this.checkBox8.UseVisualStyleBackColor = true; this.checkBox8.UseVisualStyleBackColor = true;
this.checkBox8.CheckedChanged += new System.EventHandler(this.checkBox8_CheckedChanged); this.checkBox8.CheckedChanged += new System.EventHandler(this.checkBox8_CheckedChanged);
this.checkBox8.Click += new System.EventHandler(this.CheckBox4Click); this.checkBox8.Click += new System.EventHandler(this.CheckBox4Click);*/
// //
// label19 // label19
// //
@ -1591,6 +1592,6 @@ namespace NovetusLauncher
private System.Windows.Forms.ComboBox comboBox2; private System.Windows.Forms.ComboBox comboBox2;
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button36; private System.Windows.Forms.Button button36;
private System.Windows.Forms.CheckBox checkBox8; //private System.Windows.Forms.CheckBox checkBox8;
} }
} }

View File

@ -181,10 +181,6 @@ namespace NovetusLauncher
try try
{ {
GlobalVars.WebServer = new SimpleHTTPServer(GlobalVars.ServerDir, GlobalVars.WebServer_Port); GlobalVars.WebServer = new SimpleHTTPServer(GlobalVars.ServerDir, GlobalVars.WebServer_Port);
if (GlobalVars.UDP)
{
GlobalVars.WebServerUDPInstance = UDP.StartServer(GlobalVars.WebServer_Port);
}
ConsolePrint("WebServer: Server is running on port: " + GlobalVars.WebServer.Port.ToString(), 3); ConsolePrint("WebServer: Server is running on port: " + GlobalVars.WebServer.Port.ToString(), 3);
} }
catch (Exception ex) when (!Env.Debugging) catch (Exception ex) when (!Env.Debugging)
@ -207,10 +203,6 @@ namespace NovetusLauncher
try try
{ {
ConsolePrint("WebServer: Server has stopped on port: " + GlobalVars.WebServer.Port.ToString(), 2); ConsolePrint("WebServer: Server has stopped on port: " + GlobalVars.WebServer.Port.ToString(), 2);
if (GlobalVars.UDP)
{
GlobalVars.WebServerUDPInstance.Stop();
}
GlobalVars.WebServer.Stop(); GlobalVars.WebServer.Stop();
} }
catch (Exception ex) when (!Env.Debugging) catch (Exception ex) when (!Env.Debugging)
@ -562,6 +554,7 @@ namespace NovetusLauncher
numericUpDown2.Value = Convert.ToDecimal(GlobalVars.RobloxPort); numericUpDown2.Value = Convert.ToDecimal(GlobalVars.RobloxPort);
label37.Text = GlobalVars.IP; label37.Text = GlobalVars.IP;
label38.Text = GlobalVars.RobloxPort.ToString(); label38.Text = GlobalVars.RobloxPort.ToString();
/*
if (GlobalVars.UDP == false && GlobalVars.UPnP == true) if (GlobalVars.UDP == false && GlobalVars.UPnP == true)
{ {
checkBox4.Checked = GlobalVars.UPnP; checkBox4.Checked = GlobalVars.UPnP;
@ -569,7 +562,7 @@ namespace NovetusLauncher
else if (GlobalVars.UDP == true && GlobalVars.UPnP == false) else if (GlobalVars.UDP == true && GlobalVars.UPnP == false)
{ {
checkBox8.Checked = GlobalVars.UDP; checkBox8.Checked = GlobalVars.UDP;
} }*/
checkBox2.Checked = GlobalVars.DiscordPresence; checkBox2.Checked = GlobalVars.DiscordPresence;
checkBox5.Checked = GlobalVars.ReShade; checkBox5.Checked = GlobalVars.ReShade;
checkBox6.Checked = GlobalVars.ReShadeFPSDisplay; checkBox6.Checked = GlobalVars.ReShadeFPSDisplay;
@ -923,7 +916,8 @@ namespace NovetusLauncher
richTextBox1.AppendText(Environment.NewLine); richTextBox1.AppendText(Environment.NewLine);
} }
//Rewrite these into one function. Preferably global.
void StartClient() void StartClient()
{ {
string luafile = LauncherFuncs.GetLuaFileName(); string luafile = LauncherFuncs.GetLuaFileName();
@ -1179,7 +1173,58 @@ namespace NovetusLauncher
MessageBox.Show("Failed to launch Novetus. (Error: " + ex.Message + ")","Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Failed to launch Novetus. (Error: " + ex.Message + ")","Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
void StartEasterEgg()
{
label12.Text = "<3";
string luafile = LauncherFuncs.GetLuaFileName();
string rbxexe = LauncherFuncs.GetClientEXEDir(ScriptGenerator.ScriptType.EasterEgg);
string mapfile = GlobalVars.ConfigDirData + "\\Appreciation.rbxl";
string quote = "\"";
string args = "";
if (GlobalVars.CustomArgs.Equals("%args%"))
{
if (!GlobalVars.FixScriptMapMode)
{
args = quote + mapfile + "\" -script \"" + LauncherFuncs.ChangeGameSettings() + " dofile('" + luafile + "'); " + ScriptGenerator.GetScriptFuncForType(ScriptGenerator.ScriptType.EasterEgg) + quote;
}
else
{
ScriptGenerator.GenerateScriptForClient(ScriptGenerator.ScriptType.EasterEgg);
args = "-script " + quote + luafile + quote + " " + quote + mapfile + quote;
}
}
else
{
args = ClientScript.CompileScript(GlobalVars.CustomArgs, "<solo>", "</solo>", mapfile, luafile, rbxexe);
}
try
{
ConsolePrint("Easter Egg Loaded.", 6);
Process client = new Process();
client.StartInfo.FileName = rbxexe;
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.EasterEgg, "");
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InEasterEggGame, "");
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
ClientExited();
}
catch (Exception ex) when (!Env.Debugging)
{
ConsolePrint("ERROR - Failed to launch Easter Egg. (" + ex.Message + ")", 2);
MessageBox.Show("Failed to launch Easter Egg. (Error: " + ex.Message + ")", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
void ConsoleProcessCommands(string command) void ConsoleProcessCommands(string command)
{ {
if (string.Compare(command,"server",true, CultureInfo.InvariantCulture) == 0) if (string.Compare(command,"server",true, CultureInfo.InvariantCulture) == 0)
@ -1604,12 +1649,12 @@ namespace NovetusLauncher
if (checkBox4.Checked == true) if (checkBox4.Checked == true)
{ {
GlobalVars.UPnP = true; GlobalVars.UPnP = true;
checkBox8.Checked = false; //checkBox8.Checked = false;
} }
else if (checkBox4.Checked == false) else if (checkBox4.Checked == false)
{ {
GlobalVars.UPnP = false; GlobalVars.UPnP = false;
checkBox8.Checked = GlobalVars.UDP; //checkBox8.Checked = GlobalVars.UDP;
} }
} }
@ -1771,57 +1816,6 @@ namespace NovetusLauncher
} }
} }
void StartEasterEgg()
{
label12.Text = "<3";
string luafile = LauncherFuncs.GetLuaFileName();
string rbxexe = LauncherFuncs.GetClientEXEDir(ScriptGenerator.ScriptType.EasterEgg);
string mapfile = GlobalVars.ConfigDirData + "\\Appreciation.rbxl";
string quote = "\"";
string args = "";
if (GlobalVars.CustomArgs.Equals("%args%"))
{
if (!GlobalVars.FixScriptMapMode)
{
args = quote + mapfile + "\" -script \"" + LauncherFuncs.ChangeGameSettings() + " dofile('" + luafile + "'); " + ScriptGenerator.GetScriptFuncForType(ScriptGenerator.ScriptType.EasterEgg) + quote;
}
else
{
ScriptGenerator.GenerateScriptForClient(ScriptGenerator.ScriptType.EasterEgg);
args = "-script " + quote + luafile + quote + " " + quote + mapfile + quote;
}
}
else
{
args = ClientScript.CompileScript(GlobalVars.CustomArgs, "<solo>", "</solo>", mapfile, luafile, rbxexe);
}
try
{
ConsolePrint("Easter Egg Loaded.", 6);
Process client = new Process();
client.StartInfo.FileName = rbxexe;
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.EasterEgg, "");
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InEasterEggGame, "");
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
ClientExited();
}
catch (Exception ex) when (!Env.Debugging)
{
ConsolePrint("ERROR - Failed to launch Easter Egg. (" + ex.Message + ")", 2);
MessageBox.Show("Failed to launch Easter Egg. (Error: " + ex.Message + ")", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void checkBox5_CheckedChanged(object sender, EventArgs e) private void checkBox5_CheckedChanged(object sender, EventArgs e)
{ {
if (checkBox5.Checked == true) if (checkBox5.Checked == true)
@ -1901,6 +1895,7 @@ namespace NovetusLauncher
Application.Restart(); Application.Restart();
} }
/*
private void checkBox8_CheckedChanged(object sender, EventArgs e) private void checkBox8_CheckedChanged(object sender, EventArgs e)
{ {
if (checkBox8.Checked == true) if (checkBox8.Checked == true)
@ -1913,6 +1908,6 @@ namespace NovetusLauncher
GlobalVars.UDP = false; GlobalVars.UDP = false;
checkBox4.Checked = GlobalVars.UPnP; checkBox4.Checked = GlobalVars.UPnP;
} }
} }*/
} }
} }

View File

@ -59,7 +59,7 @@ namespace NovetusLauncher
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox1 = new System.Windows.Forms.TextBox();
this.tabPage2 = new System.Windows.Forms.TabPage(); this.tabPage2 = new System.Windows.Forms.TabPage();
this.checkBox8 = new System.Windows.Forms.CheckBox(); //this.checkBox8 = new System.Windows.Forms.CheckBox();
this.label19 = new System.Windows.Forms.Label(); this.label19 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox(); this.textBox3 = new System.Windows.Forms.TextBox();
this.label17 = new System.Windows.Forms.Label(); this.label17 = new System.Windows.Forms.Label();
@ -348,7 +348,7 @@ namespace NovetusLauncher
// //
// tabPage2 // tabPage2
// //
this.tabPage2.Controls.Add(this.checkBox8); //this.tabPage2.Controls.Add(this.checkBox8);
this.tabPage2.Controls.Add(this.label19); this.tabPage2.Controls.Add(this.label19);
this.tabPage2.Controls.Add(this.textBox3); this.tabPage2.Controls.Add(this.textBox3);
this.tabPage2.Controls.Add(this.label17); this.tabPage2.Controls.Add(this.label17);
@ -372,6 +372,7 @@ namespace NovetusLauncher
// //
// checkBox8 // checkBox8
// //
/*
this.checkBox8.AutoSize = true; this.checkBox8.AutoSize = true;
this.checkBox8.Location = new System.Drawing.Point(296, 182); this.checkBox8.Location = new System.Drawing.Point(296, 182);
this.checkBox8.Name = "checkBox8"; this.checkBox8.Name = "checkBox8";
@ -380,7 +381,7 @@ namespace NovetusLauncher
this.checkBox8.Text = "Toggle UDP\r\nHole Punching (WIP)"; this.checkBox8.Text = "Toggle UDP\r\nHole Punching (WIP)";
this.checkBox8.UseVisualStyleBackColor = true; this.checkBox8.UseVisualStyleBackColor = true;
this.checkBox8.CheckedChanged += new System.EventHandler(this.checkBox8_CheckedChanged); this.checkBox8.CheckedChanged += new System.EventHandler(this.checkBox8_CheckedChanged);
this.checkBox8.Click += new System.EventHandler(this.CheckBox4Click); this.checkBox8.Click += new System.EventHandler(this.CheckBox4Click);*/
// //
// label19 // label19
// //
@ -1495,6 +1496,6 @@ namespace NovetusLauncher
private System.Windows.Forms.ComboBox comboBox2; private System.Windows.Forms.ComboBox comboBox2;
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button36; private System.Windows.Forms.Button button36;
private System.Windows.Forms.CheckBox checkBox8; //private System.Windows.Forms.CheckBox checkBox8;
} }
} }

View File

@ -16,7 +16,7 @@ using System.ComponentModel;
using System.Reflection; using System.Reflection;
using Mono.Nat; using Mono.Nat;
using System.Globalization; using System.Globalization;
using LiteNetLib; //using LiteNetLib;
namespace NovetusLauncher namespace NovetusLauncher
{ {
@ -169,21 +169,17 @@ namespace NovetusLauncher
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "", true); LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "", true);
} }
} }
#endregion #endregion
#region Web Server #region Web Server
//udp clients will connect to the web server alongside the game. //udp clients will connect to the web server alongside the game.
void StartWebServer() void StartWebServer()
{ {
if (SecurityFuncs.IsElevated) if (SecurityFuncs.IsElevated)
{ {
try try
{ {
GlobalVars.WebServer = new SimpleHTTPServer(GlobalVars.ServerDir, GlobalVars.WebServer_Port); GlobalVars.WebServer = new SimpleHTTPServer(GlobalVars.ServerDir, GlobalVars.WebServer_Port);
if (GlobalVars.UDP)
{
GlobalVars.WebServerUDPInstance = UDP.StartServer(GlobalVars.WebServer_Port);
}
ConsolePrint("WebServer: Server is running on port: " + GlobalVars.WebServer.Port.ToString(), 3); ConsolePrint("WebServer: Server is running on port: " + GlobalVars.WebServer.Port.ToString(), 3);
} }
catch (Exception ex) when (!Env.Debugging) catch (Exception ex) when (!Env.Debugging)
@ -206,10 +202,6 @@ namespace NovetusLauncher
try try
{ {
ConsolePrint("WebServer: Server has stopped on port: " + GlobalVars.WebServer.Port.ToString(), 2); ConsolePrint("WebServer: Server has stopped on port: " + GlobalVars.WebServer.Port.ToString(), 2);
if (GlobalVars.UDP)
{
GlobalVars.WebServerUDPInstance.Stop();
}
GlobalVars.WebServer.Stop(); GlobalVars.WebServer.Stop();
} }
catch (Exception ex) when (!Env.Debugging) catch (Exception ex) when (!Env.Debugging)
@ -561,6 +553,7 @@ namespace NovetusLauncher
numericUpDown2.Value = Convert.ToDecimal(GlobalVars.RobloxPort); numericUpDown2.Value = Convert.ToDecimal(GlobalVars.RobloxPort);
label37.Text = GlobalVars.IP; label37.Text = GlobalVars.IP;
label38.Text = GlobalVars.RobloxPort.ToString(); label38.Text = GlobalVars.RobloxPort.ToString();
/*
if (GlobalVars.UDP == false && GlobalVars.UPnP == true) if (GlobalVars.UDP == false && GlobalVars.UPnP == true)
{ {
checkBox4.Checked = GlobalVars.UPnP; checkBox4.Checked = GlobalVars.UPnP;
@ -568,7 +561,7 @@ namespace NovetusLauncher
else if (GlobalVars.UDP == true && GlobalVars.UPnP == false) else if (GlobalVars.UDP == true && GlobalVars.UPnP == false)
{ {
checkBox8.Checked = GlobalVars.UDP; checkBox8.Checked = GlobalVars.UDP;
} }*/
checkBox2.Checked = GlobalVars.DiscordPresence; checkBox2.Checked = GlobalVars.DiscordPresence;
ConsolePrint("Config loaded.", 3); ConsolePrint("Config loaded.", 3);
@ -891,6 +884,7 @@ namespace NovetusLauncher
richTextBox1.AppendText(Environment.NewLine); richTextBox1.AppendText(Environment.NewLine);
} }
//Rewrite these into one function. Preferably global.
void StartClient() void StartClient()
{ {
string luafile = LauncherFuncs.GetLuaFileName(); string luafile = LauncherFuncs.GetLuaFileName();
@ -1097,7 +1091,6 @@ namespace NovetusLauncher
} }
} }
void StartStudio(bool nomap) void StartStudio(bool nomap)
{ {
string luafile = LauncherFuncs.GetLuaFileName(); string luafile = LauncherFuncs.GetLuaFileName();
@ -1148,7 +1141,63 @@ namespace NovetusLauncher
MessageBox.Show("Failed to launch Novetus. (Error: " + ex.Message + ")","Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Failed to launch Novetus. (Error: " + ex.Message + ")","Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
void StartEasterEgg()
{
label12.Text = "<3";
string luafile = LauncherFuncs.GetLuaFileName();
string rbxexe = LauncherFuncs.GetClientEXEDir(ScriptGenerator.ScriptType.EasterEgg);
string mapfile = GlobalVars.ConfigDirData + "\\Appreciation.rbxl";
string quote = "\"";
string args = "";
if (GlobalVars.CustomArgs.Equals("%args%"))
{
if (!GlobalVars.FixScriptMapMode)
{
args = quote + mapfile + "\" -script \"" + LauncherFuncs.ChangeGameSettings() + " dofile('" + luafile + "'); " + ScriptGenerator.GetScriptFuncForType(ScriptGenerator.ScriptType.EasterEgg) + quote;
}
else
{
ScriptGenerator.GenerateScriptForClient(ScriptGenerator.ScriptType.EasterEgg);
args = "-script " + quote + luafile + quote + " " + quote + mapfile + quote;
}
}
else
{
args = ClientScript.CompileScript(GlobalVars.CustomArgs, "<solo>", "</solo>", mapfile, luafile, rbxexe);
}
try
{
ConsolePrint("Easter Egg Loaded.", 6);
Process client = new Process();
client.StartInfo.FileName = rbxexe;
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.EasterEgg, "");
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InEasterEggGame, "");
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
label12.Text = LocalVars.prevsplash;
if (GlobalVars.CloseOnLaunch == true)
{
Visible = true;
}
}
catch (Exception ex) when (!Env.Debugging)
{
ConsolePrint("ERROR - Failed to launch Easter Egg. (" + ex.Message + ")", 2);
MessageBox.Show("Failed to launch Easter Egg. (Error: " + ex.Message + ")", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
void ConsoleProcessCommands(string command) void ConsoleProcessCommands(string command)
{ {
if (string.Compare(command,"server",true, CultureInfo.InvariantCulture) == 0) if (string.Compare(command,"server",true, CultureInfo.InvariantCulture) == 0)
@ -1573,12 +1622,12 @@ namespace NovetusLauncher
if (checkBox4.Checked == true) if (checkBox4.Checked == true)
{ {
GlobalVars.UPnP = true; GlobalVars.UPnP = true;
checkBox8.Checked = false; //checkBox8.Checked = false;
} }
else if (checkBox4.Checked == false) else if (checkBox4.Checked == false)
{ {
GlobalVars.UPnP = false; GlobalVars.UPnP = false;
checkBox8.Checked = GlobalVars.UDP; //checkBox8.Checked = GlobalVars.UDP;
} }
} }
@ -1740,61 +1789,7 @@ namespace NovetusLauncher
} }
} }
void StartEasterEgg()
{
label12.Text = "<3";
string luafile = LauncherFuncs.GetLuaFileName();
string rbxexe = LauncherFuncs.GetClientEXEDir(ScriptGenerator.ScriptType.EasterEgg);
string mapfile = GlobalVars.ConfigDirData + "\\Appreciation.rbxl";
string quote = "\"";
string args = "";
if (GlobalVars.CustomArgs.Equals("%args%"))
{
if (!GlobalVars.FixScriptMapMode)
{
args = quote + mapfile + "\" -script \"" + LauncherFuncs.ChangeGameSettings() + " dofile('" + luafile + "'); " + ScriptGenerator.GetScriptFuncForType(ScriptGenerator.ScriptType.EasterEgg) + quote;
}
else
{
ScriptGenerator.GenerateScriptForClient(ScriptGenerator.ScriptType.EasterEgg);
args = "-script " + quote + luafile + quote + " " + quote + mapfile + quote;
}
}
else
{
args = ClientScript.CompileScript(GlobalVars.CustomArgs, "<solo>", "</solo>", mapfile, luafile, rbxexe);
}
try
{
ConsolePrint("Easter Egg Loaded.", 6);
Process client = new Process();
client.StartInfo.FileName = rbxexe;
client.StartInfo.Arguments = args;
client.EnableRaisingEvents = true;
ReadClientValues(GlobalVars.SelectedClient);
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, ScriptGenerator.ScriptType.EasterEgg, "");
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InEasterEggGame, "");
//while (!client.HasExited && client.Responding)
//{
//insert events
//GlobalVars.Delay(15);
//}
client.WaitForExit();
LauncherFuncs.UpdateRichPresence(LauncherFuncs.LauncherState.InLauncher, "");
label12.Text = LocalVars.prevsplash;
if (GlobalVars.CloseOnLaunch == true)
{
Visible = true;
}
}
catch (Exception ex) when (!Env.Debugging)
{
ConsolePrint("ERROR - Failed to launch Easter Egg. (" + ex.Message + ")", 2);
MessageBox.Show("Failed to launch Easter Egg. (Error: " + ex.Message + ")", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
void SettingsButtonClick(object sender, EventArgs e) void SettingsButtonClick(object sender, EventArgs e)
{ {
@ -1830,6 +1825,7 @@ namespace NovetusLauncher
Application.Restart(); Application.Restart();
} }
/*
private void checkBox8_CheckedChanged(object sender, EventArgs e) private void checkBox8_CheckedChanged(object sender, EventArgs e)
{ {
if (checkBox8.Checked == true) if (checkBox8.Checked == true)
@ -1842,6 +1838,6 @@ namespace NovetusLauncher
GlobalVars.UDP = false; GlobalVars.UDP = false;
checkBox4.Checked = GlobalVars.UPnP; checkBox4.Checked = GlobalVars.UPnP;
} }
} }*/
} }
} }

View File

@ -76,9 +76,6 @@
<HintPath>..\packages\DotNetZip.1.11.0\lib\net20\DotNetZip.dll</HintPath> <HintPath>..\packages\DotNetZip.1.11.0\lib\net20\DotNetZip.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="LiteNetLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LiteNetLib.0.9.2.2\lib\net35\LiteNetLib.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath> <HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
<Private>True</Private> <Private>True</Private>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="DotNetZip" version="1.11.0" targetFramework="net40" /> <package id="DotNetZip" version="1.11.0" targetFramework="net40" />
<package id="LiteNetLib" version="0.9.2.2" targetFramework="net40" />
<package id="Microsoft.Bcl" version="1.1.8" targetFramework="net40" /> <package id="Microsoft.Bcl" version="1.1.8" targetFramework="net40" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" /> <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" /> <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />

View File

@ -44,9 +44,6 @@
<HintPath>..\packages\DotNetZip.1.11.0\lib\net20\DotNetZip.dll</HintPath> <HintPath>..\packages\DotNetZip.1.11.0\lib\net20\DotNetZip.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="LiteNetLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LiteNetLib.0.9.2.2\lib\net35\LiteNetLib.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath> <HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
<Private>True</Private> <Private>True</Private>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="DotNetZip" version="1.11.0" targetFramework="net40" /> <package id="DotNetZip" version="1.11.0" targetFramework="net40" />
<package id="LiteNetLib" version="0.9.2.2" targetFramework="net40" />
<package id="Microsoft.Bcl" version="1.1.8" targetFramework="net40" /> <package id="Microsoft.Bcl" version="1.1.8" targetFramework="net40" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" /> <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" /> <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />