split launcherfuncs part 2

This commit is contained in:
Bitl 2019-10-11 07:58:47 -07:00
parent c0d04a9db5
commit 76a3ba21e5
14 changed files with 1663 additions and 1837 deletions

View File

@ -7,8 +7,13 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System;
using System.IO;
using System.Reflection;
using System.Linq;
public class ClientScript public class ClientScript
{ {
private static string basedir = "rbxasset://../../../shareddata/charcustom/"; private static string basedir = "rbxasset://../../../shareddata/charcustom/";
private static string basemapdir = "rbxasset://../../../maps/"; private static string basemapdir = "rbxasset://../../../maps/";
private static string hatdir = basedir + "hats/"; private static string hatdir = basedir + "hats/";
@ -31,86 +36,50 @@ public class ClientScript
public static ScriptGenerator.ScriptType GetTypeFromTag(string tag, string endtag) public static ScriptGenerator.ScriptType GetTypeFromTag(string tag, string endtag)
{ {
if (tag.Contains("client") && endtag.Contains("client")) if (tag.Contains("client") && endtag.Contains("client")) {
{
return ScriptGenerator.ScriptType.Client; return ScriptGenerator.ScriptType.Client;
} } else if (tag.Contains("server") && endtag.Contains("server") || tag.Contains("no3d") && endtag.Contains("no3d")) {
else if (tag.Contains("server") && endtag.Contains("server") || tag.Contains("no3d") && endtag.Contains("no3d"))
{
return ScriptGenerator.ScriptType.Server; return ScriptGenerator.ScriptType.Server;
} } else if (tag.Contains("solo") && endtag.Contains("solo")) {
else if (tag.Contains("solo") && endtag.Contains("solo"))
{
return ScriptGenerator.ScriptType.Solo; return ScriptGenerator.ScriptType.Solo;
} } else if (tag.Contains("studio") && endtag.Contains("studio")) {
else if (tag.Contains("studio") && endtag.Contains("studio"))
{
return ScriptGenerator.ScriptType.Studio; return ScriptGenerator.ScriptType.Studio;
} } else {
else
{
return ScriptGenerator.ScriptType.None; return ScriptGenerator.ScriptType.None;
} }
} }
public static string GetRawArgsForType(ScriptGenerator.ScriptType type, string md5s, string luafile) public static string GetRawArgsForType(ScriptGenerator.ScriptType type, string md5s, string luafile)
{ {
if (type == ScriptGenerator.ScriptType.Client) if (type == ScriptGenerator.ScriptType.Client) {
{ if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == true) {
if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == true)
{
return "dofile('" + luafile + "'); _G.CSConnect(" + GlobalVars.UserID + ",'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.loadtext + "," + md5s + ")"; return "dofile('" + luafile + "'); _G.CSConnect(" + GlobalVars.UserID + ",'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.loadtext + "," + md5s + ")";
} } else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == true) {
else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == true)
{
return "dofile('" + luafile + "'); _G.CSConnect(" + GlobalVars.UserID + ",'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'Player'," + GlobalVars.loadtext + "," + md5s + ")"; return "dofile('" + luafile + "'); _G.CSConnect(" + GlobalVars.UserID + ",'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'Player'," + GlobalVars.loadtext + "," + md5s + ")";
} } else if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == false) {
else if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == false)
{
return "dofile('" + luafile + "'); _G.CSConnect(0,'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.loadtext + "," + md5s + ")"; return "dofile('" + luafile + "'); _G.CSConnect(0,'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.loadtext + "," + md5s + ")";
} } else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == false) {
else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == false)
{
return "dofile('" + luafile + "'); _G.CSConnect(0,'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'Player'," + GlobalVars.loadtext + "," + md5s + ")"; return "dofile('" + luafile + "'); _G.CSConnect(0,'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'Player'," + GlobalVars.loadtext + "," + md5s + ")";
} } else {
else
{
return "dofile('" + luafile + "'); _G.CSConnect(" + GlobalVars.UserID + ",'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.loadtext + "," + md5s + ")"; return "dofile('" + luafile + "'); _G.CSConnect(" + GlobalVars.UserID + ",'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.loadtext + "," + md5s + ")";
} }
} } else if (type == ScriptGenerator.ScriptType.Server) {
else if (type == ScriptGenerator.ScriptType.Server)
{
return "dofile('" + luafile + "'); _G.CSServer(" + GlobalVars.RobloxPort + "," + GlobalVars.PlayerLimit + "," + md5s + ")"; return "dofile('" + luafile + "'); _G.CSServer(" + GlobalVars.RobloxPort + "," + GlobalVars.PlayerLimit + "," + md5s + ")";
} } else if (type == ScriptGenerator.ScriptType.Solo) {
else if (type == ScriptGenerator.ScriptType.Solo) if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == true) {
{
if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == true)
{
return "dofile('" + luafile + "'); _G.CSSolo(" + GlobalVars.UserID + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.sololoadtext + ")"; return "dofile('" + luafile + "'); _G.CSSolo(" + GlobalVars.UserID + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.sololoadtext + ")";
} } else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == true) {
else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == true)
{
return "dofile('" + luafile + "'); _G.CSSolo(" + GlobalVars.UserID + ",'Player'," + GlobalVars.sololoadtext + ")"; return "dofile('" + luafile + "'); _G.CSSolo(" + GlobalVars.UserID + ",'Player'," + GlobalVars.sololoadtext + ")";
} } else if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == false) {
else if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == false)
{
return "dofile('" + luafile + "'); _G.CSSolo(0,'" + GlobalVars.PlayerName + "'," + GlobalVars.sololoadtext + ")"; return "dofile('" + luafile + "'); _G.CSSolo(0,'" + GlobalVars.PlayerName + "'," + GlobalVars.sololoadtext + ")";
} } else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == false) {
else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == false )
{
return "dofile('" + luafile + "'); _G.CSSolo(0,'Player'," + GlobalVars.sololoadtext + ")"; return "dofile('" + luafile + "'); _G.CSSolo(0,'Player'," + GlobalVars.sololoadtext + ")";
} } else {
else
{
return "dofile('" + luafile + "'); _G.CSSolo(" + GlobalVars.UserID + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.sololoadtext + ")"; return "dofile('" + luafile + "'); _G.CSSolo(" + GlobalVars.UserID + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.sololoadtext + ")";
} }
} } else if (type == ScriptGenerator.ScriptType.Studio) {
else if (type == ScriptGenerator.ScriptType.Studio)
{
return "dofile('" + luafile + "');"; return "dofile('" + luafile + "');";
} } else {
else
{
return ""; return "";
} }
} }
@ -122,20 +91,13 @@ public class ClientScript
public static int ConvertIconStringToInt() public static int ConvertIconStringToInt()
{ {
if (GlobalVars.Custom_Icon_Offline == "BC") if (GlobalVars.Custom_Icon_Offline == "BC") {
{
return 1; return 1;
} } else if (GlobalVars.Custom_Icon_Offline == "TBC") {
else if (GlobalVars.Custom_Icon_Offline == "TBC")
{
return 2; return 2;
} } else if (GlobalVars.Custom_Icon_Offline == "OBC") {
else if (GlobalVars.Custom_Icon_Offline == "OBC")
{
return 3; return 3;
} } else if (GlobalVars.Custom_Icon_Offline == "NBC") {
else if (GlobalVars.Custom_Icon_Offline == "NBC")
{
return 0; return 0;
} }
@ -144,29 +106,22 @@ public class ClientScript
public static string GetFolderAndMapName(string source, string seperator = " -") public static string GetFolderAndMapName(string source, string seperator = " -")
{ {
try try {
{
string result = source.Substring(0, source.IndexOf(seperator)); string result = source.Substring(0, source.IndexOf(seperator));
if (File.Exists(GlobalVars.MapsDir + @"\\" + result + @"\\" + source)) if (File.Exists(GlobalVars.MapsDir + @"\\" + result + @"\\" + source)) {
{
return result + @"\\" + source; return result + @"\\" + source;
} } else {
else
{
return ""; return "";
} }
} } catch (Exception) {
catch (Exception)
{
return ""; return "";
} }
} }
public static string CompileScript(string code, string tag, string endtag, string mapfile, string luafile, string rbxexe) public static string CompileScript(string code, string tag, string endtag, string mapfile, string luafile, string rbxexe)
{ {
if (GlobalVars.FixScriptMapMode) if (GlobalVars.FixScriptMapMode) {
{
ScriptGenerator.GenerateScriptForClient(GetTypeFromTag(tag, endtag), GlobalVars.SelectedClient); ScriptGenerator.GenerateScriptForClient(GetTypeFromTag(tag, endtag), GlobalVars.SelectedClient);
} }
@ -176,60 +131,60 @@ public class ClientScript
string md5script = GlobalVars.AlreadyHasSecurity != true ? SecurityFuncs.CalculateMD5(GlobalVars.ClientDir + @"\\" + GlobalVars.SelectedClient + @"\\content\\scripts\\" + GlobalVars.ScriptName + ".lua") : ""; string md5script = GlobalVars.AlreadyHasSecurity != true ? SecurityFuncs.CalculateMD5(GlobalVars.ClientDir + @"\\" + GlobalVars.SelectedClient + @"\\content\\scripts\\" + GlobalVars.ScriptName + ".lua") : "";
string md5exe = GlobalVars.AlreadyHasSecurity != true ? SecurityFuncs.CalculateMD5(rbxexe) : ""; string md5exe = GlobalVars.AlreadyHasSecurity != true ? SecurityFuncs.CalculateMD5(rbxexe) : "";
string md5s = "'" + md5exe + "','" + md5dir + "','" + md5script + "'"; string md5s = "'" + md5exe + "','" + md5dir + "','" + md5script + "'";
string compiled = extractedCode.Replace("%mapfile%",mapfile) string compiled = extractedCode.Replace("%mapfile%", mapfile)
.Replace("%luafile%",luafile) .Replace("%luafile%", luafile)
.Replace("%charapp%",GlobalVars.CharacterID) .Replace("%charapp%", GlobalVars.CharacterID)
.Replace("%ip%",GlobalVars.IP) .Replace("%ip%", GlobalVars.IP)
.Replace("%port%",GlobalVars.RobloxPort.ToString()) .Replace("%port%", GlobalVars.RobloxPort.ToString())
.Replace("%name%",GlobalVars.PlayerName) .Replace("%name%", GlobalVars.PlayerName)
.Replace("%icone%",ConvertIconStringToInt().ToString()) .Replace("%icone%", ConvertIconStringToInt().ToString())
.Replace("%icon%",GlobalVars.Custom_Icon_Offline) .Replace("%icon%", GlobalVars.Custom_Icon_Offline)
.Replace("%id%",GlobalVars.UserID.ToString()) .Replace("%id%", GlobalVars.UserID.ToString())
.Replace("%face%",GlobalVars.Custom_Face_Offline) .Replace("%face%", GlobalVars.Custom_Face_Offline)
.Replace("%head%",GlobalVars.Custom_Head_Offline) .Replace("%head%", GlobalVars.Custom_Head_Offline)
.Replace("%tshirt%",GlobalVars.Custom_T_Shirt_Offline) .Replace("%tshirt%", GlobalVars.Custom_T_Shirt_Offline)
.Replace("%shirt%",GlobalVars.Custom_Shirt_Offline) .Replace("%shirt%", GlobalVars.Custom_Shirt_Offline)
.Replace("%pants%",GlobalVars.Custom_Pants_Offline) .Replace("%pants%", GlobalVars.Custom_Pants_Offline)
.Replace("%hat1%",GlobalVars.Custom_Hat1ID_Offline) .Replace("%hat1%", GlobalVars.Custom_Hat1ID_Offline)
.Replace("%hat2%",GlobalVars.Custom_Hat2ID_Offline) .Replace("%hat2%", GlobalVars.Custom_Hat2ID_Offline)
.Replace("%hat3%",GlobalVars.Custom_Hat3ID_Offline) .Replace("%hat3%", GlobalVars.Custom_Hat3ID_Offline)
.Replace("%faced%",facedir + GlobalVars.Custom_Face_Offline) .Replace("%faced%", facedir + GlobalVars.Custom_Face_Offline)
.Replace("%headd%",headdir + GlobalVars.Custom_Head_Offline) .Replace("%headd%", headdir + GlobalVars.Custom_Head_Offline)
.Replace("%tshirtd%",tshirtdir + GlobalVars.Custom_T_Shirt_Offline) .Replace("%tshirtd%", tshirtdir + GlobalVars.Custom_T_Shirt_Offline)
.Replace("%shirtd%",shirtdir + GlobalVars.Custom_Shirt_Offline) .Replace("%shirtd%", shirtdir + GlobalVars.Custom_Shirt_Offline)
.Replace("%pantsd%",pantsdir + GlobalVars.Custom_Pants_Offline) .Replace("%pantsd%", pantsdir + GlobalVars.Custom_Pants_Offline)
.Replace("%hat1d%",hatdir + GlobalVars.Custom_Hat1ID_Offline) .Replace("%hat1d%", hatdir + GlobalVars.Custom_Hat1ID_Offline)
.Replace("%hat2d%",hatdir + GlobalVars.Custom_Hat2ID_Offline) .Replace("%hat2d%", hatdir + GlobalVars.Custom_Hat2ID_Offline)
.Replace("%hat3d%",hatdir + GlobalVars.Custom_Hat3ID_Offline) .Replace("%hat3d%", hatdir + GlobalVars.Custom_Hat3ID_Offline)
.Replace("%headcolor%",GlobalVars.HeadColorID.ToString()) .Replace("%headcolor%", GlobalVars.HeadColorID.ToString())
.Replace("%torsocolor%",GlobalVars.TorsoColorID.ToString()) .Replace("%torsocolor%", GlobalVars.TorsoColorID.ToString())
.Replace("%larmcolor%",GlobalVars.LeftArmColorID.ToString()) .Replace("%larmcolor%", GlobalVars.LeftArmColorID.ToString())
.Replace("%llegcolor%",GlobalVars.LeftLegColorID.ToString()) .Replace("%llegcolor%", GlobalVars.LeftLegColorID.ToString())
.Replace("%rarmcolor%",GlobalVars.RightArmColorID.ToString()) .Replace("%rarmcolor%", GlobalVars.RightArmColorID.ToString())
.Replace("%rlegcolor%",GlobalVars.RightLegColorID.ToString()) .Replace("%rlegcolor%", GlobalVars.RightLegColorID.ToString())
.Replace("%rlegcolor%",GlobalVars.SelectedClientMD5) .Replace("%rlegcolor%", GlobalVars.SelectedClientMD5)
.Replace("%md5launcher%",md5dir) .Replace("%md5launcher%", md5dir)
.Replace("%md5script%",GlobalVars.SelectedClientMD5) .Replace("%md5script%", GlobalVars.SelectedClientMD5)
.Replace("%md5exe%",GlobalVars.SelectedClientScriptMD5) .Replace("%md5exe%", GlobalVars.SelectedClientScriptMD5)
.Replace("%md5scriptd%",md5script) .Replace("%md5scriptd%", md5script)
.Replace("%md5exed%",md5exe) .Replace("%md5exed%", md5exe)
.Replace("%limit%",GlobalVars.PlayerLimit.ToString()) .Replace("%limit%", GlobalVars.PlayerLimit.ToString())
.Replace("%extra%",GlobalVars.Custom_Extra) .Replace("%extra%", GlobalVars.Custom_Extra)
.Replace("%extrad%",extradir + GlobalVars.Custom_Extra) .Replace("%extrad%", extradir + GlobalVars.Custom_Extra)
.Replace("%hat4d%",hatdir + GlobalVars.Custom_Extra) .Replace("%hat4d%", hatdir + GlobalVars.Custom_Extra)
.Replace("%args%",GetRawArgsFromTag(tag, endtag, md5s, luafile)) .Replace("%args%", GetRawArgsFromTag(tag, endtag, md5s, luafile))
.Replace("%facews%",GlobalVars.WebServer_FaceDir + GlobalVars.Custom_Face_Offline) .Replace("%facews%", GlobalVars.WebServer_FaceDir + GlobalVars.Custom_Face_Offline)
.Replace("%headws%",GlobalVars.WebServer_HeadDir + GlobalVars.Custom_Head_Offline) .Replace("%headws%", GlobalVars.WebServer_HeadDir + GlobalVars.Custom_Head_Offline)
.Replace("%tshirtws%",GlobalVars.WebServer_TShirtDir + GlobalVars.Custom_T_Shirt_Offline) .Replace("%tshirtws%", GlobalVars.WebServer_TShirtDir + GlobalVars.Custom_T_Shirt_Offline)
.Replace("%shirtws%",GlobalVars.WebServer_ShirtDir + GlobalVars.Custom_Shirt_Offline) .Replace("%shirtws%", GlobalVars.WebServer_ShirtDir + GlobalVars.Custom_Shirt_Offline)
.Replace("%pantsws%",GlobalVars.WebServer_PantsDir + GlobalVars.Custom_Pants_Offline) .Replace("%pantsws%", GlobalVars.WebServer_PantsDir + GlobalVars.Custom_Pants_Offline)
.Replace("%hat1ws%",GlobalVars.WebServer_HatDir + GlobalVars.Custom_Hat1ID_Offline) .Replace("%hat1ws%", GlobalVars.WebServer_HatDir + GlobalVars.Custom_Hat1ID_Offline)
.Replace("%hat2ws%",GlobalVars.WebServer_HatDir + GlobalVars.Custom_Hat2ID_Offline) .Replace("%hat2ws%", GlobalVars.WebServer_HatDir + GlobalVars.Custom_Hat2ID_Offline)
.Replace("%hat3ws%",GlobalVars.WebServer_HatDir + GlobalVars.Custom_Hat3ID_Offline) .Replace("%hat3ws%", GlobalVars.WebServer_HatDir + GlobalVars.Custom_Hat3ID_Offline)
.Replace("%extraws%",GlobalVars.WebServer_ExtraDir + GlobalVars.Custom_Extra) .Replace("%extraws%", GlobalVars.WebServer_ExtraDir + GlobalVars.Custom_Extra)
.Replace("%hat4ws%",GlobalVars.WebServer_HatDir + GlobalVars.Custom_Extra) .Replace("%hat4ws%", GlobalVars.WebServer_HatDir + GlobalVars.Custom_Extra)
.Replace("%bodycolors%",GlobalVars.WebServer_BodyColors) .Replace("%bodycolors%", GlobalVars.WebServer_BodyColors)
.Replace("%mapfiled%",basemapdir + GetFolderAndMapName(GlobalVars.Map)); .Replace("%mapfiled%", basemapdir + GetFolderAndMapName(GlobalVars.Map));
return compiled; return compiled;
} }
} }

View File

@ -7,8 +7,14 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Diagnostics;
using System.Linq;
public static class RichTextBoxExtensions public static class RichTextBoxExtensions
{ {
public static void AppendText(this RichTextBox box, string text, Color color) public static void AppendText(this RichTextBox box, string text, Color color)
{ {
box.SelectionStart = box.TextLength; box.SelectionStart = box.TextLength;
@ -18,24 +24,29 @@ public static class RichTextBoxExtensions
box.AppendText(text); box.AppendText(text);
box.SelectionColor = box.ForeColor; box.SelectionColor = box.ForeColor;
} }
} }
public static class ProcessExtensions public static class ProcessExtensions
{ {
public static bool IsRunning(this Process process) public static bool IsRunning(this Process process)
{ {
try {Process.GetProcessById(process.Id);} try {
catch (InvalidOperationException) { return false; } Process.GetProcessById(process.Id);
catch (ArgumentException){return false;} } catch (InvalidOperationException) {
return false;
} catch (ArgumentException) {
return false;
}
return true; return true;
} }
} }
public static class StringExtensions public static class StringExtensions
{ {
public static bool Contains(this string source, string toCheck, StringComparison comp) public static bool Contains(this string source, string toCheck, StringComparison comp)
{ {
if (source == null) return false; if (source == null)
return false;
return source.IndexOf(toCheck, comp) >= 0; return source.IndexOf(toCheck, comp) >= 0;
} }
} }

View File

@ -7,8 +7,12 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
public class CryptoRandom : RandomNumberGenerator using System;
{ using System.Security.Cryptography;
using System.Linq;
public class CryptoRandom : RandomNumberGenerator
{
private static RandomNumberGenerator r; private static RandomNumberGenerator r;
public CryptoRandom() public CryptoRandom()
@ -49,4 +53,4 @@
{ {
return Next(0, maxValue); return Next(0, maxValue);
} }
} }

View File

@ -7,9 +7,13 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
//Discord Rich Presence Integration :D using System;
public class DiscordRpc using System.Runtime.InteropServices;
{ using System.Linq;
//Discord Rich Presence Integration :D
public class DiscordRpc
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void ReadyCallback(); public delegate void ReadyCallback();
@ -41,20 +45,30 @@
[System.Serializable] [System.Serializable]
public struct RichPresence public struct RichPresence
{ {
public string state; /* max 128 bytes */ public string state;
public string details; /* max 128 bytes */ /* max 128 bytes */
public string details;
/* max 128 bytes */
public long startTimestamp; public long startTimestamp;
public long endTimestamp; public long endTimestamp;
public string largeImageKey; /* max 32 bytes */ public string largeImageKey;
public string largeImageText; /* max 128 bytes */ /* max 32 bytes */
public string smallImageKey; /* max 32 bytes */ public string largeImageText;
public string smallImageText; /* max 128 bytes */ /* max 128 bytes */
public string partyId; /* max 128 bytes */ public string smallImageKey;
/* max 32 bytes */
public string smallImageText;
/* max 128 bytes */
public string partyId;
/* max 128 bytes */
public int partySize; public int partySize;
public int partyMax; public int partyMax;
public string matchSecret; /* max 128 bytes */ public string matchSecret;
public string joinSecret; /* max 128 bytes */ /* max 128 bytes */
public string spectateSecret; /* max 128 bytes */ public string joinSecret;
/* max 128 bytes */
public string spectateSecret;
/* max 128 bytes */
public bool instance; public bool instance;
} }
@ -87,4 +101,4 @@
[DllImport("discord-rpc", EntryPoint = "Discord_Respond", CallingConvention = CallingConvention.Cdecl)] [DllImport("discord-rpc", EntryPoint = "Discord_Respond", CallingConvention = CallingConvention.Cdecl)]
public static extern void Respond(string userId, Reply reply); public static extern void Respond(string userId, Reply reply);
} }

View File

@ -7,10 +7,15 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System;
using System.IO;
using System.Reflection;
using System.Linq;
public static class GlobalVars public static class GlobalVars
{ {
public static string RootPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); public static string RootPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public static string BasePath = RootPath.Replace(@"\",@"\\"); public static string BasePath = RootPath.Replace(@"\", @"\\");
public static string DataPath = BasePath + "\\shareddata"; public static string DataPath = BasePath + "\\shareddata";
public static string ConfigDir = BasePath + "\\config"; public static string ConfigDir = BasePath + "\\config";
public static string ClientDir = BasePath + "\\clients"; public static string ClientDir = BasePath + "\\clients";
@ -31,7 +36,7 @@ public static class GlobalVars
public static string FullMapPath = ""; public static string FullMapPath = "";
public static int RobloxPort = 53640; public static int RobloxPort = 53640;
public static int DefaultRobloxPort = 53640; public static int DefaultRobloxPort = 53640;
public static int WebServer_Port = (RobloxPort+1); public static int WebServer_Port = (RobloxPort + 1);
public static int PlayerLimit = 12; public static int PlayerLimit = 12;
//player settings //player settings
public static int UserID = 0; public static int UserID = 0;
@ -71,7 +76,7 @@ public static class GlobalVars
public static int RightLegColorID = 119; public static int RightLegColorID = 119;
public static string loadtext = ""; public static string loadtext = "";
public static string sololoadtext = ""; public static string sololoadtext = "";
public static string CharacterID =""; public static string CharacterID = "";
public static string Custom_Extra = "NoExtra.rbxm"; public static string Custom_Extra = "NoExtra.rbxm";
public static bool Custom_Extra_ShowHats = false; public static bool Custom_Extra_ShowHats = false;
public static bool Custom_Extra_SelectionIsHat = false; public static bool Custom_Extra_SelectionIsHat = false;
@ -107,4 +112,4 @@ public static class GlobalVars
{ {
return string.Join(Environment.NewLine, args); return string.Join(Environment.NewLine, args);
} }
} }

View File

@ -7,18 +7,23 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Linq;
//credit to BLaZiNiX //credit to BLaZiNiX
public class IniFile public class IniFile
{ {
public string path; public string path;
[DllImport("kernel32")] [DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, private static extern long WritePrivateProfileString(string section,
string key,string val,string filePath); string key, string val, string filePath);
[DllImport("kernel32")] [DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, private static extern int GetPrivateProfileString(string section,
string key,string def, StringBuilder retVal, string key, string def, StringBuilder retVal,
int size,string filePath); int size, string filePath);
/// <summary> /// <summary>
/// INIFile Constructor. /// INIFile Constructor.
@ -37,9 +42,9 @@
/// Key Name /// Key Name
/// <PARAM name="Value"></PARAM> /// <PARAM name="Value"></PARAM>
/// Value Name /// Value Name
public void IniWriteValue(string Section,string Key,string Value) public void IniWriteValue(string Section, string Key, string Value)
{ {
WritePrivateProfileString(Section,Key,Value,this.path); WritePrivateProfileString(Section, Key, Value, this.path);
} }
/// <summary> /// <summary>
@ -49,12 +54,12 @@
/// <PARAM name="Key"></PARAM> /// <PARAM name="Key"></PARAM>
/// <PARAM name="Path"></PARAM> /// <PARAM name="Path"></PARAM>
/// <returns></returns> /// <returns></returns>
public string IniReadValue(string Section,string Key) public string IniReadValue(string Section, string Key)
{ {
StringBuilder temp = new StringBuilder(255); StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section,Key,"",temp, int i = GetPrivateProfileString(Section, Key, "", temp,
255, this.path); 255, this.path);
return temp.ToString(); return temp.ToString();
} }
} }

View File

@ -7,32 +7,14 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System; using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.IO; using System.IO;
using System.Diagnostics;
using System.Threading;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Linq; using System.Linq;
using System.ComponentModel;
using System.Net.Sockets;
using System.Net;
using Mono.Nat;
namespace NovetusShared /// <summary>
/// Description of LauncherFuncs.
/// </summary>
public class LauncherFuncs
{ {
/// <summary>
/// Description of LauncherFuncs.
/// </summary>
public class LauncherFuncs
{
public LauncherFuncs() public LauncherFuncs()
{ {
} }
@ -47,71 +29,61 @@ namespace NovetusShared
Decryptline1 = ini.IniReadValue(section, "CloseOnLaunch"); Decryptline1 = ini.IniReadValue(section, "CloseOnLaunch");
if (string.IsNullOrWhiteSpace(Decryptline1)) if (string.IsNullOrWhiteSpace(Decryptline1)) {
{
ini.IniWriteValue(section, "CloseOnLaunch", GlobalVars.CloseOnLaunch.ToString()); ini.IniWriteValue(section, "CloseOnLaunch", GlobalVars.CloseOnLaunch.ToString());
} }
Decryptline2 = ini.IniReadValue(section, "UserID"); Decryptline2 = ini.IniReadValue(section, "UserID");
if (string.IsNullOrWhiteSpace(Decryptline2)) if (string.IsNullOrWhiteSpace(Decryptline2)) {
{
ini.IniWriteValue(section, "UserID", GlobalVars.UserID.ToString()); ini.IniWriteValue(section, "UserID", GlobalVars.UserID.ToString());
} }
Decryptline3 = ini.IniReadValue(section, "PlayerName"); Decryptline3 = ini.IniReadValue(section, "PlayerName");
if (string.IsNullOrWhiteSpace(Decryptline3)) if (string.IsNullOrWhiteSpace(Decryptline3)) {
{
ini.IniWriteValue(section, "PlayerName", GlobalVars.PlayerName.ToString()); ini.IniWriteValue(section, "PlayerName", GlobalVars.PlayerName.ToString());
} }
Decryptline4 = ini.IniReadValue(section, "SelectedClient"); Decryptline4 = ini.IniReadValue(section, "SelectedClient");
if (string.IsNullOrWhiteSpace(Decryptline4)) if (string.IsNullOrWhiteSpace(Decryptline4)) {
{
ini.IniWriteValue(section, "SelectedClient", GlobalVars.SelectedClient.ToString()); ini.IniWriteValue(section, "SelectedClient", GlobalVars.SelectedClient.ToString());
} }
Decryptline5 = ini.IniReadValue(section, "Map"); Decryptline5 = ini.IniReadValue(section, "Map");
if (string.IsNullOrWhiteSpace(Decryptline5)) if (string.IsNullOrWhiteSpace(Decryptline5)) {
{
ini.IniWriteValue(section, "Map", GlobalVars.Map.ToString()); ini.IniWriteValue(section, "Map", GlobalVars.Map.ToString());
} }
Decryptline6 = ini.IniReadValue(section, "RobloxPort"); Decryptline6 = ini.IniReadValue(section, "RobloxPort");
if (string.IsNullOrWhiteSpace(Decryptline6)) if (string.IsNullOrWhiteSpace(Decryptline6)) {
{
ini.IniWriteValue(section, "RobloxPort", GlobalVars.RobloxPort.ToString()); ini.IniWriteValue(section, "RobloxPort", GlobalVars.RobloxPort.ToString());
} }
Decryptline7 = ini.IniReadValue(section, "PlayerLimit"); Decryptline7 = ini.IniReadValue(section, "PlayerLimit");
if (string.IsNullOrWhiteSpace(Decryptline7)) if (string.IsNullOrWhiteSpace(Decryptline7)) {
{
ini.IniWriteValue(section, "PlayerLimit", GlobalVars.PlayerLimit.ToString()); ini.IniWriteValue(section, "PlayerLimit", GlobalVars.PlayerLimit.ToString());
} }
Decryptline9 = ini.IniReadValue(section, "ShowHatsOnExtra"); Decryptline9 = ini.IniReadValue(section, "ShowHatsOnExtra");
if (string.IsNullOrWhiteSpace(Decryptline9)) if (string.IsNullOrWhiteSpace(Decryptline9)) {
{
ini.IniWriteValue(section, "ShowHatsOnExtra", GlobalVars.Custom_Extra_ShowHats.ToString()); ini.IniWriteValue(section, "ShowHatsOnExtra", GlobalVars.Custom_Extra_ShowHats.ToString());
} }
Decryptline10 = ini.IniReadValue(section, "UPnP"); Decryptline10 = ini.IniReadValue(section, "UPnP");
if (string.IsNullOrWhiteSpace(Decryptline10)) if (string.IsNullOrWhiteSpace(Decryptline10)) {
{
ini.IniWriteValue(section, "UPnP", GlobalVars.UPnP.ToString()); ini.IniWriteValue(section, "UPnP", GlobalVars.UPnP.ToString());
} }
Decryptline11 = ini.IniReadValue(section, "ItemMakerDisableHelpMessage"); Decryptline11 = ini.IniReadValue(section, "ItemMakerDisableHelpMessage");
if (string.IsNullOrWhiteSpace(Decryptline11)) if (string.IsNullOrWhiteSpace(Decryptline11)) {
{
ini.IniWriteValue(section, "ItemMakerDisableHelpMessage", GlobalVars.DisabledHelp.ToString()); ini.IniWriteValue(section, "ItemMakerDisableHelpMessage", GlobalVars.DisabledHelp.ToString());
} }
@ -142,7 +114,7 @@ namespace NovetusShared
bool bline11 = Convert.ToBoolean(Decryptline11); bool bline11 = Convert.ToBoolean(Decryptline11);
GlobalVars.DisabledHelp = bline11; GlobalVars.DisabledHelp = bline11;
ReadCustomizationValues(cfgpath.Replace(".ini","_customization.ini")); ReadCustomizationValues(cfgpath.Replace(".ini", "_customization.ini"));
} }
public static void WriteConfigValues(string cfgpath) public static void WriteConfigValues(string cfgpath)
@ -161,7 +133,7 @@ namespace NovetusShared
ini.IniWriteValue(section, "ShowHatsOnExtra", GlobalVars.Custom_Extra_ShowHats.ToString()); ini.IniWriteValue(section, "ShowHatsOnExtra", GlobalVars.Custom_Extra_ShowHats.ToString());
ini.IniWriteValue(section, "UPnP", GlobalVars.UPnP.ToString()); ini.IniWriteValue(section, "UPnP", GlobalVars.UPnP.ToString());
ini.IniWriteValue(section, "ItemMakerDisableHelpMessage", GlobalVars.DisabledHelp.ToString()); ini.IniWriteValue(section, "ItemMakerDisableHelpMessage", GlobalVars.DisabledHelp.ToString());
WriteCustomizationValues(cfgpath.Replace(".ini","_customization.ini")); WriteCustomizationValues(cfgpath.Replace(".ini", "_customization.ini"));
} }
public static void ResetConfigValues() public static void ResetConfigValues()
@ -190,71 +162,61 @@ namespace NovetusShared
Decryptline1 = ini.IniReadValue(section, "Hat1"); Decryptline1 = ini.IniReadValue(section, "Hat1");
if (string.IsNullOrWhiteSpace(Decryptline1)) if (string.IsNullOrWhiteSpace(Decryptline1)) {
{
ini.IniWriteValue(section, "Hat1", GlobalVars.Custom_Hat1ID_Offline.ToString()); ini.IniWriteValue(section, "Hat1", GlobalVars.Custom_Hat1ID_Offline.ToString());
} }
Decryptline2 = ini.IniReadValue(section, "Hat2"); Decryptline2 = ini.IniReadValue(section, "Hat2");
if (string.IsNullOrWhiteSpace(Decryptline2)) if (string.IsNullOrWhiteSpace(Decryptline2)) {
{
ini.IniWriteValue(section, "Hat2", GlobalVars.Custom_Hat2ID_Offline.ToString()); ini.IniWriteValue(section, "Hat2", GlobalVars.Custom_Hat2ID_Offline.ToString());
} }
Decryptline3 = ini.IniReadValue(section, "Hat3"); Decryptline3 = ini.IniReadValue(section, "Hat3");
if (string.IsNullOrWhiteSpace(Decryptline3)) if (string.IsNullOrWhiteSpace(Decryptline3)) {
{
ini.IniWriteValue(section, "Hat3", GlobalVars.Custom_Hat3ID_Offline.ToString()); ini.IniWriteValue(section, "Hat3", GlobalVars.Custom_Hat3ID_Offline.ToString());
} }
Decryptline16 = ini.IniReadValue(section, "Face"); Decryptline16 = ini.IniReadValue(section, "Face");
if (string.IsNullOrWhiteSpace(Decryptline16)) if (string.IsNullOrWhiteSpace(Decryptline16)) {
{
ini.IniWriteValue(section, "Face", GlobalVars.Custom_Face_Offline.ToString()); ini.IniWriteValue(section, "Face", GlobalVars.Custom_Face_Offline.ToString());
} }
Decryptline17 = ini.IniReadValue(section, "Head"); Decryptline17 = ini.IniReadValue(section, "Head");
if (string.IsNullOrWhiteSpace(Decryptline17)) if (string.IsNullOrWhiteSpace(Decryptline17)) {
{
ini.IniWriteValue(section, "Head", GlobalVars.Custom_Head_Offline.ToString()); ini.IniWriteValue(section, "Head", GlobalVars.Custom_Head_Offline.ToString());
} }
Decryptline18 = ini.IniReadValue(section, "TShirt"); Decryptline18 = ini.IniReadValue(section, "TShirt");
if (string.IsNullOrWhiteSpace(Decryptline18)) if (string.IsNullOrWhiteSpace(Decryptline18)) {
{
ini.IniWriteValue(section, "TShirt", GlobalVars.Custom_T_Shirt_Offline.ToString()); ini.IniWriteValue(section, "TShirt", GlobalVars.Custom_T_Shirt_Offline.ToString());
} }
Decryptline19 = ini.IniReadValue(section, "Shirt"); Decryptline19 = ini.IniReadValue(section, "Shirt");
if (string.IsNullOrWhiteSpace(Decryptline19)) if (string.IsNullOrWhiteSpace(Decryptline19)) {
{
ini.IniWriteValue(section, "Shirt", GlobalVars.Custom_Shirt_Offline.ToString()); ini.IniWriteValue(section, "Shirt", GlobalVars.Custom_Shirt_Offline.ToString());
} }
Decryptline20 = ini.IniReadValue(section, "Pants"); Decryptline20 = ini.IniReadValue(section, "Pants");
if (string.IsNullOrWhiteSpace(Decryptline20)) if (string.IsNullOrWhiteSpace(Decryptline20)) {
{
ini.IniWriteValue(section, "Pants", GlobalVars.Custom_Pants_Offline.ToString()); ini.IniWriteValue(section, "Pants", GlobalVars.Custom_Pants_Offline.ToString());
} }
Decryptline21 = ini.IniReadValue(section, "Icon"); Decryptline21 = ini.IniReadValue(section, "Icon");
if (string.IsNullOrWhiteSpace(Decryptline21)) if (string.IsNullOrWhiteSpace(Decryptline21)) {
{
ini.IniWriteValue(section, "Icon", GlobalVars.Custom_Icon_Offline.ToString()); ini.IniWriteValue(section, "Icon", GlobalVars.Custom_Icon_Offline.ToString());
} }
Decryptline23 = ini.IniReadValue(section, "Extra"); Decryptline23 = ini.IniReadValue(section, "Extra");
if (string.IsNullOrWhiteSpace(Decryptline23)) if (string.IsNullOrWhiteSpace(Decryptline23)) {
{
ini.IniWriteValue(section, "Extra", GlobalVars.Custom_Extra.ToString()); ini.IniWriteValue(section, "Extra", GlobalVars.Custom_Extra.ToString());
} }
@ -262,85 +224,73 @@ namespace NovetusShared
Decryptline4 = ini.IniReadValue(section2, "HeadColorID"); Decryptline4 = ini.IniReadValue(section2, "HeadColorID");
if (string.IsNullOrWhiteSpace(Decryptline4)) if (string.IsNullOrWhiteSpace(Decryptline4)) {
{
ini.IniWriteValue(section2, "HeadColorID", GlobalVars.HeadColorID.ToString()); ini.IniWriteValue(section2, "HeadColorID", GlobalVars.HeadColorID.ToString());
} }
Decryptline10 = ini.IniReadValue(section2, "HeadColorString"); Decryptline10 = ini.IniReadValue(section2, "HeadColorString");
if (string.IsNullOrWhiteSpace(Decryptline10)) if (string.IsNullOrWhiteSpace(Decryptline10)) {
{
ini.IniWriteValue(section2, "HeadColorString", GlobalVars.ColorMenu_HeadColor.ToString()); ini.IniWriteValue(section2, "HeadColorString", GlobalVars.ColorMenu_HeadColor.ToString());
} }
Decryptline5 = ini.IniReadValue(section2, "TorsoColorID"); Decryptline5 = ini.IniReadValue(section2, "TorsoColorID");
if (string.IsNullOrWhiteSpace(Decryptline5)) if (string.IsNullOrWhiteSpace(Decryptline5)) {
{
ini.IniWriteValue(section2, "TorsoColorID", GlobalVars.TorsoColorID.ToString()); ini.IniWriteValue(section2, "TorsoColorID", GlobalVars.TorsoColorID.ToString());
} }
Decryptline11 = ini.IniReadValue(section2, "TorsoColorString"); Decryptline11 = ini.IniReadValue(section2, "TorsoColorString");
if (string.IsNullOrWhiteSpace(Decryptline11)) if (string.IsNullOrWhiteSpace(Decryptline11)) {
{
ini.IniWriteValue(section2, "TorsoColorString", GlobalVars.ColorMenu_TorsoColor.ToString()); ini.IniWriteValue(section2, "TorsoColorString", GlobalVars.ColorMenu_TorsoColor.ToString());
} }
Decryptline6 = ini.IniReadValue(section2, "LeftArmColorID"); Decryptline6 = ini.IniReadValue(section2, "LeftArmColorID");
if (string.IsNullOrWhiteSpace(Decryptline6)) if (string.IsNullOrWhiteSpace(Decryptline6)) {
{
ini.IniWriteValue(section2, "LeftArmColorID", GlobalVars.LeftArmColorID.ToString()); ini.IniWriteValue(section2, "LeftArmColorID", GlobalVars.LeftArmColorID.ToString());
} }
Decryptline12 = ini.IniReadValue(section2, "LeftArmColorString"); Decryptline12 = ini.IniReadValue(section2, "LeftArmColorString");
if (string.IsNullOrWhiteSpace(Decryptline12)) if (string.IsNullOrWhiteSpace(Decryptline12)) {
{
ini.IniWriteValue(section2, "LeftArmColorString", GlobalVars.ColorMenu_LeftArmColor.ToString()); ini.IniWriteValue(section2, "LeftArmColorString", GlobalVars.ColorMenu_LeftArmColor.ToString());
} }
Decryptline7 = ini.IniReadValue(section2, "RightArmColorID"); Decryptline7 = ini.IniReadValue(section2, "RightArmColorID");
if (string.IsNullOrWhiteSpace(Decryptline7)) if (string.IsNullOrWhiteSpace(Decryptline7)) {
{
ini.IniWriteValue(section2, "RightArmColorID", GlobalVars.RightArmColorID.ToString()); ini.IniWriteValue(section2, "RightArmColorID", GlobalVars.RightArmColorID.ToString());
} }
Decryptline13 = ini.IniReadValue(section2, "RightArmColorString"); Decryptline13 = ini.IniReadValue(section2, "RightArmColorString");
if (string.IsNullOrWhiteSpace(Decryptline13)) if (string.IsNullOrWhiteSpace(Decryptline13)) {
{
ini.IniWriteValue(section2, "RightArmColorString", GlobalVars.ColorMenu_RightArmColor.ToString()); ini.IniWriteValue(section2, "RightArmColorString", GlobalVars.ColorMenu_RightArmColor.ToString());
} }
Decryptline8 = ini.IniReadValue(section2, "LeftLegColorID"); Decryptline8 = ini.IniReadValue(section2, "LeftLegColorID");
if (string.IsNullOrWhiteSpace(Decryptline8)) if (string.IsNullOrWhiteSpace(Decryptline8)) {
{
ini.IniWriteValue(section2, "LeftLegColorID", GlobalVars.LeftLegColorID.ToString()); ini.IniWriteValue(section2, "LeftLegColorID", GlobalVars.LeftLegColorID.ToString());
} }
Decryptline14 = ini.IniReadValue(section2, "LeftLegColorString"); Decryptline14 = ini.IniReadValue(section2, "LeftLegColorString");
if (string.IsNullOrWhiteSpace(Decryptline14)) if (string.IsNullOrWhiteSpace(Decryptline14)) {
{
ini.IniWriteValue(section2, "LeftLegColorString", GlobalVars.ColorMenu_LeftLegColor.ToString()); ini.IniWriteValue(section2, "LeftLegColorString", GlobalVars.ColorMenu_LeftLegColor.ToString());
} }
Decryptline9 = ini.IniReadValue(section2, "RightLegColorID"); Decryptline9 = ini.IniReadValue(section2, "RightLegColorID");
if (string.IsNullOrWhiteSpace(Decryptline9)) if (string.IsNullOrWhiteSpace(Decryptline9)) {
{
ini.IniWriteValue(section2, "RightLegColorID", GlobalVars.RightLegColorID.ToString()); ini.IniWriteValue(section2, "RightLegColorID", GlobalVars.RightLegColorID.ToString());
} }
Decryptline15 = ini.IniReadValue(section2, "RightLegColorString"); Decryptline15 = ini.IniReadValue(section2, "RightLegColorString");
if (string.IsNullOrWhiteSpace(Decryptline15)) if (string.IsNullOrWhiteSpace(Decryptline15)) {
{
ini.IniWriteValue(section2, "RightLegColorString", GlobalVars.ColorMenu_RightLegColor.ToString()); ini.IniWriteValue(section2, "RightLegColorString", GlobalVars.ColorMenu_RightLegColor.ToString());
} }
@ -348,15 +298,13 @@ namespace NovetusShared
Decryptline22 = ini.IniReadValue(section3, "CharacterID"); Decryptline22 = ini.IniReadValue(section3, "CharacterID");
if (string.IsNullOrWhiteSpace(Decryptline22)) if (string.IsNullOrWhiteSpace(Decryptline22)) {
{
ini.IniWriteValue(section3, "CharacterID", GlobalVars.CharacterID.ToString()); ini.IniWriteValue(section3, "CharacterID", GlobalVars.CharacterID.ToString());
} }
Decryptline24 = ini.IniReadValue(section3, "ExtraSelectionIsHat"); Decryptline24 = ini.IniReadValue(section3, "ExtraSelectionIsHat");
if (string.IsNullOrWhiteSpace(Decryptline24)) if (string.IsNullOrWhiteSpace(Decryptline24)) {
{
ini.IniWriteValue(section3, "ExtraSelectionIsHat", GlobalVars.Custom_Extra_SelectionIsHat.ToString()); ini.IniWriteValue(section3, "ExtraSelectionIsHat", GlobalVars.Custom_Extra_SelectionIsHat.ToString());
} }
@ -568,8 +516,7 @@ namespace NovetusShared
string line1; string line1;
string Decryptline1, Decryptline2, Decryptline3, Decryptline4, Decryptline5, Decryptline6, Decryptline7, Decryptline9, Decryptline10, Decryptline11; string Decryptline1, Decryptline2, Decryptline3, Decryptline4, Decryptline5, Decryptline6, Decryptline7, Decryptline9, Decryptline10, Decryptline11;
using(StreamReader reader = new StreamReader(clientpath)) using (StreamReader reader = new StreamReader(clientpath)) {
{
line1 = reader.ReadLine(); line1 = reader.ReadLine();
} }
@ -616,41 +563,25 @@ namespace NovetusShared
{ {
CryptoRandom random = new CryptoRandom(); CryptoRandom random = new CryptoRandom();
int randomID = 0; int randomID = 0;
int randIDmode = random.Next(0,7); int randIDmode = random.Next(0, 7);
if (randIDmode == 0) if (randIDmode == 0) {
{
randomID = random.Next(0, 99); randomID = random.Next(0, 99);
} } else if (randIDmode == 1) {
else if (randIDmode == 1)
{
randomID = random.Next(0, 999); randomID = random.Next(0, 999);
} } else if (randIDmode == 2) {
else if (randIDmode == 2)
{
randomID = random.Next(0, 9999); randomID = random.Next(0, 9999);
} } else if (randIDmode == 3) {
else if (randIDmode == 3)
{
randomID = random.Next(0, 99999); randomID = random.Next(0, 99999);
} } else if (randIDmode == 4) {
else if (randIDmode == 4)
{
randomID = random.Next(0, 999999); randomID = random.Next(0, 999999);
} } else if (randIDmode == 5) {
else if (randIDmode == 5)
{
randomID = random.Next(0, 9999999); randomID = random.Next(0, 9999999);
} } else if (randIDmode == 6) {
else if (randIDmode == 6)
{
randomID = random.Next(0, 99999999); randomID = random.Next(0, 99999999);
} } else if (randIDmode == 7) {
else if (randIDmode == 7)
{
randomID = random.Next(); randomID = random.Next();
} }
//2147483647 is max id. //2147483647 is max id.
GlobalVars.UserID = randomID; GlobalVars.UserID = randomID;
} }
}
} }

View File

@ -7,6 +7,13 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Linq;
/* /*
* so, in order for us to generate a good script, we have to: * so, in order for us to generate a good script, we have to:
* - specify the script header that gives us our setting adjustments * - specify the script header that gives us our setting adjustments
@ -18,8 +25,8 @@
* we also need to make sure that when we add the option, we'll need to adapt map loading to work RBX2007 style for the clients using the script generator. * we also need to make sure that when we add the option, we'll need to adapt map loading to work RBX2007 style for the clients using the script generator.
*/ */
public class ScriptGenerator public class ScriptGenerator
{ {
public ScriptGenerator() public ScriptGenerator()
{ {
} }
@ -36,12 +43,9 @@
public static string GetScriptFuncForType(ScriptType type, string client) public static string GetScriptFuncForType(ScriptType type, string client)
{ {
string rbxexe = ""; string rbxexe = "";
if (GlobalVars.LegacyMode == true) if (GlobalVars.LegacyMode == true) {
{
rbxexe = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\clients\\" + client + @"\\RobloxApp.exe"; rbxexe = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\clients\\" + client + @"\\RobloxApp.exe";
} } else {
else
{
rbxexe = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\clients\\" + client + @"\\RobloxApp_client.exe"; rbxexe = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\clients\\" + client + @"\\RobloxApp_client.exe";
} }
@ -49,86 +53,50 @@
string md5script = SecurityFuncs.CalculateMD5(GlobalVars.ClientDir + @"\\" + GlobalVars.SelectedClient + @"\\content\\scripts\\" + GlobalVars.ScriptName + ".lua"); string md5script = SecurityFuncs.CalculateMD5(GlobalVars.ClientDir + @"\\" + GlobalVars.SelectedClient + @"\\content\\scripts\\" + GlobalVars.ScriptName + ".lua");
string md5exe = SecurityFuncs.CalculateMD5(rbxexe); string md5exe = SecurityFuncs.CalculateMD5(rbxexe);
string md5s = "'" + md5exe + "','" + md5dir + "','" + md5script + "'"; string md5s = "'" + md5exe + "','" + md5dir + "','" + md5script + "'";
if (type == ScriptType.Client) if (type == ScriptType.Client) {
{ if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == true) {
if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == true)
{
return "_G.CSConnect(" + GlobalVars.UserID + ",'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.loadtext + "," + md5s + ")"; return "_G.CSConnect(" + GlobalVars.UserID + ",'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.loadtext + "," + md5s + ")";
} } else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == true) {
else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == true)
{
return "_G.CSConnect(" + GlobalVars.UserID + ",'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'Player'," + GlobalVars.loadtext + "," + md5s + ")"; return "_G.CSConnect(" + GlobalVars.UserID + ",'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'Player'," + GlobalVars.loadtext + "," + md5s + ")";
} } else if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == false) {
else if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == false)
{
return "_G.CSConnect(0,'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.loadtext + "," + md5s + ")"; return "_G.CSConnect(0,'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.loadtext + "," + md5s + ")";
} } else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == false) {
else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == false)
{
return "_G.CSConnect(0,'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'Player'," + GlobalVars.loadtext + "," + md5s + ")"; return "_G.CSConnect(0,'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'Player'," + GlobalVars.loadtext + "," + md5s + ")";
} } else {
else
{
return "_G.CSConnect(" + GlobalVars.UserID + ",'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.loadtext + "," + md5s + ")"; return "_G.CSConnect(" + GlobalVars.UserID + ",'" + GlobalVars.IP + "'," + GlobalVars.RobloxPort + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.loadtext + "," + md5s + ")";
} }
} } else if (type == ScriptType.Server) {
else if (type == ScriptType.Server)
{
return "_G.CSServer(" + GlobalVars.RobloxPort + "," + GlobalVars.PlayerLimit + "," + md5s + ")"; return "_G.CSServer(" + GlobalVars.RobloxPort + "," + GlobalVars.PlayerLimit + "," + md5s + ")";
} } else if (type == ScriptType.Solo) {
else if (type == ScriptType.Solo) if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == true) {
{
if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == true)
{
return "_G.CSSolo(" + GlobalVars.UserID + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.sololoadtext + ")"; return "_G.CSSolo(" + GlobalVars.UserID + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.sololoadtext + ")";
} } else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == true) {
else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == true)
{
return "_G.CSSolo(" + GlobalVars.UserID + ",'Player'," + GlobalVars.sololoadtext + ")"; return "_G.CSSolo(" + GlobalVars.UserID + ",'Player'," + GlobalVars.sololoadtext + ")";
} } else if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == false) {
else if (GlobalVars.UsesPlayerName == true && GlobalVars.UsesID == false)
{
return "_G.CSSolo(0,'" + GlobalVars.PlayerName + "'," + GlobalVars.sololoadtext + ")"; return "_G.CSSolo(0,'" + GlobalVars.PlayerName + "'," + GlobalVars.sololoadtext + ")";
} } else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == false) {
else if (GlobalVars.UsesPlayerName == false && GlobalVars.UsesID == false )
{
return "_G.CSSolo(0,'Player'," + GlobalVars.sololoadtext + ")"; return "_G.CSSolo(0,'Player'," + GlobalVars.sololoadtext + ")";
} } else {
else
{
return "_G.CSSolo(" + GlobalVars.UserID + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.sololoadtext + ")"; return "_G.CSSolo(" + GlobalVars.UserID + ",'" + GlobalVars.PlayerName + "'," + GlobalVars.sololoadtext + ")";
} }
} } else if (type == ScriptType.Studio) {
else if (type == ScriptType.Studio)
{
return ""; return "";
} } else {
else
{
return ""; return "";
} }
} }
public static string GetNameForType(ScriptType type) public static string GetNameForType(ScriptType type)
{ {
if (type == ScriptType.Client) if (type == ScriptType.Client) {
{
return "Client"; return "Client";
} } else if (type == ScriptType.Server) {
else if (type == ScriptType.Server)
{
return "Server"; return "Server";
} } else if (type == ScriptType.Solo) {
else if (type == ScriptType.Solo)
{
return "Play Solo"; return "Play Solo";
} } else if (type == ScriptType.Studio) {
else if (type == ScriptType.Studio)
{
return "Studio"; return "Studio";
} } else {
else
{
return ""; return "";
} }
} }
@ -273,4 +241,4 @@
return output; return output;
} }
*/ */
} }

View File

@ -7,11 +7,23 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System;
using System.IO;
using System.Diagnostics;
using System.Threading;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Linq;
using System.ComponentModel;
/// <summary> /// <summary>
/// Description of SecurityFuncs. /// Description of SecurityFuncs.
/// </summary> /// </summary>
public class SecurityFuncs public class SecurityFuncs
{ {
[DllImport("user32.dll")] [DllImport("user32.dll")]
static extern int SetWindowText(IntPtr hWnd, string text); static extern int SetWindowText(IntPtr hWnd, string text);
@ -54,11 +66,11 @@
public static void RegisterURLProtocol(string protocolName, string applicationPath, string description) public static void RegisterURLProtocol(string protocolName, string applicationPath, string description)
{ {
RegistryKey subKey = Registry.ClassesRoot.CreateSubKey(protocolName); RegistryKey subKey = Registry.ClassesRoot.CreateSubKey(protocolName);
subKey.SetValue((string) null, (object) description); subKey.SetValue((string)null, (object)description);
subKey.SetValue("URL Protocol", (object) string.Empty); subKey.SetValue("URL Protocol", (object)string.Empty);
Registry.ClassesRoot.CreateSubKey(protocolName + "\\Shell"); Registry.ClassesRoot.CreateSubKey(protocolName + "\\Shell");
Registry.ClassesRoot.CreateSubKey(protocolName + "\\Shell\\open"); Registry.ClassesRoot.CreateSubKey(protocolName + "\\Shell\\open");
Registry.ClassesRoot.CreateSubKey(protocolName + "\\Shell\\open\\command").SetValue((string) null, (object) ("\"" + applicationPath + "\" \"%1\"")); Registry.ClassesRoot.CreateSubKey(protocolName + "\\Shell\\open\\command").SetValue((string)null, (object)("\"" + applicationPath + "\" \"%1\""));
} }
public static long UnixTimeNow() public static long UnixTimeNow()
@ -69,97 +81,68 @@
public static bool checkClientMD5(string client) public static bool checkClientMD5(string client)
{ {
if (GlobalVars.AdminMode != true) if (GlobalVars.AdminMode != true) {
{ if (GlobalVars.AlreadyHasSecurity != true) {
if (GlobalVars.AlreadyHasSecurity != true)
{
string rbxexe = ""; string rbxexe = "";
if (GlobalVars.LegacyMode == true) if (GlobalVars.LegacyMode == true) {
{
rbxexe = GlobalVars.BasePath + "\\clients\\" + client + "\\RobloxApp.exe"; rbxexe = GlobalVars.BasePath + "\\clients\\" + client + "\\RobloxApp.exe";
} } else {
else
{
rbxexe = GlobalVars.BasePath + "\\clients\\" + client + "\\RobloxApp_client.exe"; rbxexe = GlobalVars.BasePath + "\\clients\\" + client + "\\RobloxApp_client.exe";
} }
using (var md5 = MD5.Create()) using (var md5 = MD5.Create()) {
{ using (var stream = File.OpenRead(rbxexe)) {
using (var stream = File.OpenRead(rbxexe))
{
byte[] hash = md5.ComputeHash(stream); byte[] hash = md5.ComputeHash(stream);
string clientMD5 = BitConverter.ToString(hash).Replace("-", ""); string clientMD5 = BitConverter.ToString(hash).Replace("-", "");
if (clientMD5.Equals(GlobalVars.SelectedClientMD5)) if (clientMD5.Equals(GlobalVars.SelectedClientMD5)) {
{
return true; return true;
} } else {
else
{
return false; return false;
} }
} }
} }
} } else {
else
{
return true; return true;
} }
} } else {
else
{
return true; return true;
} }
} }
public static bool checkScriptMD5(string client) public static bool checkScriptMD5(string client)
{ {
if (GlobalVars.AdminMode != true) if (GlobalVars.AdminMode != true) {
{ if (GlobalVars.AlreadyHasSecurity != true) {
if (GlobalVars.AlreadyHasSecurity != true)
{
string rbxscript = GlobalVars.BasePath + "\\clients\\" + client + "\\content\\scripts\\" + GlobalVars.ScriptName + ".lua"; string rbxscript = GlobalVars.BasePath + "\\clients\\" + client + "\\content\\scripts\\" + GlobalVars.ScriptName + ".lua";
using (var md5 = MD5.Create()) using (var md5 = MD5.Create()) {
{ using (var stream = File.OpenRead(rbxscript)) {
using (var stream = File.OpenRead(rbxscript))
{
byte[] hash = md5.ComputeHash(stream); byte[] hash = md5.ComputeHash(stream);
string clientMD5 = BitConverter.ToString(hash).Replace("-", ""); string clientMD5 = BitConverter.ToString(hash).Replace("-", "");
if (clientMD5.Equals(GlobalVars.SelectedClientScriptMD5)) if (clientMD5.Equals(GlobalVars.SelectedClientScriptMD5)) {
{
return true; return true;
} } else {
else
{
return false; return false;
} }
} }
} }
} } else {
else
{
return true; return true;
} }
} } else {
else
{
return true; return true;
} }
} }
public static string CalculateMD5(string filename) public static string CalculateMD5(string filename)
{ {
using (var md5 = MD5.Create()) using (var md5 = MD5.Create()) {
{ using (var stream = File.OpenRead(filename)) {
using (var stream = File.OpenRead(filename)) return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "");
{
return BitConverter.ToString(md5.ComputeHash(stream)).Replace("-","");
} }
} }
} }
public static bool IsElevated public static bool IsElevated {
{ get {
get
{
return WindowsIdentity.GetCurrent().Owner.IsWellKnown(WellKnownSidType.BuiltinAdministratorsSid); return WindowsIdentity.GetCurrent().Owner.IsWellKnown(WellKnownSidType.BuiltinAdministratorsSid);
} }
} }
@ -172,8 +155,7 @@
public static void RenameWindow(Process exe, ScriptGenerator.ScriptType type) public static void RenameWindow(Process exe, ScriptGenerator.ScriptType type)
{ {
if (GlobalVars.AlreadyHasSecurity != true) if (GlobalVars.AlreadyHasSecurity != true) {
{
int time = 500; int time = 500;
BackgroundWorker worker = new BackgroundWorker(); BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (obj, e) => WorkerDoWork(exe, type, time, worker, GlobalVars.SelectedClient); worker.DoWork += (obj, e) => WorkerDoWork(exe, type, time, worker, GlobalVars.SelectedClient);
@ -183,33 +165,25 @@
private static void WorkerDoWork(Process exe, ScriptGenerator.ScriptType type, int time, BackgroundWorker worker, string clientname) private static void WorkerDoWork(Process exe, ScriptGenerator.ScriptType type, int time, BackgroundWorker worker, string clientname)
{ {
if (exe.IsRunning() == true) if (exe.IsRunning() == true) {
{ while (exe.IsRunning() == true) {
while (exe.IsRunning() == true) if (exe.IsRunning() != true) {
{
if (exe.IsRunning() != true)
{
worker.DoWork -= (obj, e) => WorkerDoWork(exe, type, time, worker, clientname); worker.DoWork -= (obj, e) => WorkerDoWork(exe, type, time, worker, clientname);
worker.CancelAsync(); worker.CancelAsync();
worker.Dispose(); worker.Dispose();
break; break;
} }
if (type == ScriptGenerator.ScriptType.Client) if (type == ScriptGenerator.ScriptType.Client) {
{
SetWindowText(exe.MainWindowHandle, "Novetus " + GlobalVars.Version + " - " + clientname + " " + ScriptGenerator.GetNameForType(type) + " [" + GlobalVars.IP + ":" + GlobalVars.RobloxPort + "]" + RandomStringTitle()); SetWindowText(exe.MainWindowHandle, "Novetus " + GlobalVars.Version + " - " + clientname + " " + ScriptGenerator.GetNameForType(type) + " [" + GlobalVars.IP + ":" + GlobalVars.RobloxPort + "]" + RandomStringTitle());
} } else if (type == ScriptGenerator.ScriptType.Server || type == ScriptGenerator.ScriptType.Solo || type == ScriptGenerator.ScriptType.Studio) {
else if (type == ScriptGenerator.ScriptType.Server || type == ScriptGenerator.ScriptType.Solo || type == ScriptGenerator.ScriptType.Studio)
{
SetWindowText(exe.MainWindowHandle, "Novetus " + GlobalVars.Version + " - " + clientname + " " + ScriptGenerator.GetNameForType(type) + " [" + GlobalVars.Map + "]" + RandomStringTitle()); SetWindowText(exe.MainWindowHandle, "Novetus " + GlobalVars.Version + " - " + clientname + " " + ScriptGenerator.GetNameForType(type) + " [" + GlobalVars.Map + "]" + RandomStringTitle());
} }
Thread.Sleep(time); Thread.Sleep(time);
} }
} } else {
else
{
Thread.Sleep(time); Thread.Sleep(time);
RenameWindow(exe, type); RenameWindow(exe, type);
} }
} }
} }

View File

@ -7,31 +7,29 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System;
using System.IO;
using System.Linq;
public static class SplashReader public static class SplashReader
{ {
private static string RandomSplash() private static string RandomSplash()
{ {
string[] splashes = File.ReadAllLines(GlobalVars.ConfigDir + "\\splashes.txt"); string[] splashes = File.ReadAllLines(GlobalVars.ConfigDir + "\\splashes.txt");
string splash = ""; string splash = "";
try try {
{ splash = splashes[new CryptoRandom().Next(0, splashes.Length - 1)];
splash = splashes[new CryptoRandom().Next(0,splashes.Length-1)]; } catch (Exception) {
} try {
catch (Exception)
{
try
{
splash = splashes[0]; splash = splashes[0];
} } catch (Exception) {
catch (Exception)
{
splash = "missingno"; splash = "missingno";
return splash; return splash;
} }
} }
string formattedsplash = splash.Replace("%name%",GlobalVars.PlayerName); string formattedsplash = splash.Replace("%name%", GlobalVars.PlayerName);
return formattedsplash; return formattedsplash;
} }
@ -46,71 +44,40 @@ public static class SplashReader
DateTime today = DateTime.Now; DateTime today = DateTime.Now;
string splash = ""; string splash = "";
if (IsTheSameDay(today, new DateTime(today.Year,12,24)) || IsTheSameDay(today, new DateTime(today.Year,12,25))) if (IsTheSameDay(today, new DateTime(today.Year, 12, 24)) || IsTheSameDay(today, new DateTime(today.Year, 12, 25))) {
{
splash = "Merry Christmas!"; splash = "Merry Christmas!";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 12, 31)) || IsTheSameDay(today, new DateTime(today.Year, 1, 1))) {
else if (IsTheSameDay(today, new DateTime(today.Year,12,31)) || IsTheSameDay(today, new DateTime(today.Year,1,1)))
{
splash = "Happy New Year!"; splash = "Happy New Year!";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 10, 31))) {
else if (IsTheSameDay(today, new DateTime(today.Year,10,31)))
{
splash = "Happy Halloween!"; splash = "Happy Halloween!";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 6, 10))) {
else if (IsTheSameDay(today, new DateTime(today.Year,6,10)))
{
splash = "Happy Birthday, Bitl!"; splash = "Happy Birthday, Bitl!";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 8, 27))) {
else if (IsTheSameDay(today, new DateTime(today.Year,8,27)))
{
splash = "Happy Birthday, ROBLOX!"; splash = "Happy Birthday, ROBLOX!";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 10, 27))) {
else if (IsTheSameDay(today, new DateTime(today.Year,10,27)))
{
splash = "Happy Birthday, Novetus!"; splash = "Happy Birthday, Novetus!";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 2, 15))) {
else if (IsTheSameDay(today, new DateTime(today.Year,2,15)))
{
splash = "Happy Birthday, Carrot!"; splash = "Happy Birthday, Carrot!";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 6, 14))) {
else if (IsTheSameDay(today, new DateTime(today.Year,6,14)))
{
splash = "Happy Birthday, MAO!"; splash = "Happy Birthday, MAO!";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 9, 15))) {
else if (IsTheSameDay(today, new DateTime(today.Year,9,15)))
{
splash = "Happy Birthday, Coke!"; splash = "Happy Birthday, Coke!";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 5, 17))) {
else if (IsTheSameDay(today, new DateTime(today.Year,5,17)))
{
splash = "Happy Birthday, TheLivingBee!"; splash = "Happy Birthday, TheLivingBee!";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 10, 9))) {
else if (IsTheSameDay(today, new DateTime(today.Year,10,9)))
{
splash = "Happy Leif Erikson Day! HINGA DINGA DURGEN!"; splash = "Happy Leif Erikson Day! HINGA DINGA DURGEN!";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 10, 10))) {
else if (IsTheSameDay(today, new DateTime(today.Year,10,10)))
{
splash = "I used to wonder what friendship could be!"; splash = "I used to wonder what friendship could be!";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 4, 20))) {
else if (IsTheSameDay(today, new DateTime(today.Year,4,20)))
{
splash = "4/20 lol"; splash = "4/20 lol";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 4, 27))) {
else if (IsTheSameDay(today, new DateTime(today.Year,4,27)))
{
splash = "fluttershy is best pone"; splash = "fluttershy is best pone";
} } else if (IsTheSameDay(today, new DateTime(today.Year, 2, 11))) {
else if (IsTheSameDay(today, new DateTime(today.Year,2,11)))
{
splash = "RIP Erik Cassel"; splash = "RIP Erik Cassel";
} } else {
else
{
splash = RandomSplash(); splash = RandomSplash();
} }
return splash; return splash;
} }
} }

View File

@ -7,8 +7,13 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
public static class TextLineRemover public static class TextLineRemover
{ {
public static void RemoveTextLines(IList<string> linesToRemove, string filename, string tempFilename) public static void RemoveTextLines(IList<string> linesToRemove, string filename, string tempFilename)
{ {
// Initial values // Initial values
@ -17,27 +22,24 @@ public static class TextLineRemover
DateTime startTime = DateTime.Now; DateTime startTime = DateTime.Now;
// Read file // Read file
using (var sr = new StreamReader(filename)) using (var sr = new StreamReader(filename)) {
{
// Write new file // Write new file
using (var sw = new StreamWriter(tempFilename)) using (var sw = new StreamWriter(tempFilename)) {
{
// Read lines // Read lines
string line; string line;
while ((line = sr.ReadLine()) != null) while ((line = sr.ReadLine()) != null) {
{
lineNumber++; lineNumber++;
// Look for text to remove // Look for text to remove
if (!ContainsString(line, linesToRemove)) if (!ContainsString(line, linesToRemove)) {
{
// Keep lines that does not match // Keep lines that does not match
sw.WriteLine(line); sw.WriteLine(line);
} } else {
else
{
// Ignore lines that DO match // Ignore lines that DO match
linesRemoved++; linesRemoved++;
InvokeOnRemovedLine(new RemovedLineArgs { RemovedLine = line, RemovedLineNumber = lineNumber}); InvokeOnRemovedLine(new RemovedLineArgs {
RemovedLine = line,
RemovedLineNumber = lineNumber
});
} }
} }
} }
@ -50,14 +52,17 @@ public static class TextLineRemover
// Final calculations // Final calculations
DateTime endTime = DateTime.Now; DateTime endTime = DateTime.Now;
InvokeOnFinished(new FinishedArgs {LinesRemoved = linesRemoved, TotalLines = lineNumber, TotalTime = endTime.Subtract(startTime)}); InvokeOnFinished(new FinishedArgs {
LinesRemoved = linesRemoved,
TotalLines = lineNumber,
TotalTime = endTime.Subtract(startTime)
});
} }
private static bool ContainsString(string line, IEnumerable<string> linesToRemove) private static bool ContainsString(string line, IEnumerable<string> linesToRemove)
{ {
foreach (var lineToRemove in linesToRemove) foreach (var lineToRemove in linesToRemove) {
{ if (line.Contains(lineToRemove))
if(line.Contains(lineToRemove))
return true; return true;
} }
return false; return false;
@ -69,29 +74,31 @@ public static class TextLineRemover
public static void InvokeOnFinished(FinishedArgs args) public static void InvokeOnFinished(FinishedArgs args)
{ {
Finished handler = OnFinished; Finished handler = OnFinished;
if (handler != null) handler(null, args); if (handler != null)
handler(null, args);
} }
public static void InvokeOnRemovedLine(RemovedLineArgs args) public static void InvokeOnRemovedLine(RemovedLineArgs args)
{ {
RemovedLine handler = OnRemovedLine; RemovedLine handler = OnRemovedLine;
if (handler != null) handler(null, args); if (handler != null)
} handler(null, args);
} }
}
public delegate void Finished(object sender, FinishedArgs args); public delegate void Finished(object sender, FinishedArgs args);
public class FinishedArgs public class FinishedArgs
{ {
public int TotalLines { get; set; } public int TotalLines { get; set; }
public int LinesRemoved { get; set; } public int LinesRemoved { get; set; }
public TimeSpan TotalTime { get; set; } public TimeSpan TotalTime { get; set; }
} }
public delegate void RemovedLine(object sender, RemovedLineArgs args); public delegate void RemovedLine(object sender, RemovedLineArgs args);
public class RemovedLineArgs public class RemovedLineArgs
{ {
public string RemovedLine { get; set; } public string RemovedLine { get; set; }
public int RemovedLineNumber { get; set; } public int RemovedLineNumber { get; set; }
} }

View File

@ -7,8 +7,14 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
using System.Linq;
public static class TreeNodeHelper public static class TreeNodeHelper
{ {
public static void ListDirectory(TreeView treeView, string path) public static void ListDirectory(TreeView treeView, string path)
{ {
treeView.Nodes.Clear(); treeView.Nodes.Clear();
@ -28,15 +34,14 @@ public static class TreeNodeHelper
public static TreeNode SearchTreeView(string p_sSearchTerm, TreeNodeCollection p_Nodes) public static TreeNode SearchTreeView(string p_sSearchTerm, TreeNodeCollection p_Nodes)
{ {
foreach (TreeNode node in p_Nodes) foreach (TreeNode node in p_Nodes) {
{
if (node.Text == p_sSearchTerm) if (node.Text == p_sSearchTerm)
return node; return node;
if (node.Nodes.Count > 0) if (node.Nodes.Count > 0) {
{
TreeNode child = SearchTreeView(p_sSearchTerm, node.Nodes); TreeNode child = SearchTreeView(p_sSearchTerm, node.Nodes);
if (child != null) return child; if (child != null)
return child;
} }
} }
@ -45,29 +50,22 @@ public static class TreeNodeHelper
public static string GetFolderNameFromPrefix(string source, string seperator = " -") public static string GetFolderNameFromPrefix(string source, string seperator = " -")
{ {
try try {
{
string result = source.Substring(0, source.IndexOf(seperator)); string result = source.Substring(0, source.IndexOf(seperator));
if (Directory.Exists(GlobalVars.MapsDir + @"\\" + result)) if (Directory.Exists(GlobalVars.MapsDir + @"\\" + result)) {
{
return result + @"\\"; return result + @"\\";
} } else {
else
{
return ""; return "";
} }
} } catch (Exception) {
catch (Exception)
{
return ""; return "";
} }
} }
public static void CopyNodes(TreeNodeCollection oldcollection, TreeNodeCollection newcollection) public static void CopyNodes(TreeNodeCollection oldcollection, TreeNodeCollection newcollection)
{ {
foreach(TreeNode node in oldcollection) foreach (TreeNode node in oldcollection) {
{
newcollection.Add((TreeNode)node.Clone()); newcollection.Add((TreeNode)node.Clone());
} }
} }
@ -75,8 +73,7 @@ public static class TreeNodeHelper
public static List<TreeNode> GetAllNodes(this TreeView _self) public static List<TreeNode> GetAllNodes(this TreeView _self)
{ {
List<TreeNode> result = new List<TreeNode>(); List<TreeNode> result = new List<TreeNode>();
foreach (TreeNode child in _self.Nodes) foreach (TreeNode child in _self.Nodes) {
{
result.AddRange(child.GetAllNodes()); result.AddRange(child.GetAllNodes());
} }
return result; return result;
@ -86,10 +83,9 @@ public static class TreeNodeHelper
{ {
List<TreeNode> result = new List<TreeNode>(); List<TreeNode> result = new List<TreeNode>();
result.Add(_self); result.Add(_self);
foreach (TreeNode child in _self.Nodes) foreach (TreeNode child in _self.Nodes) {
{
result.AddRange(child.GetAllNodes()); result.AddRange(child.GetAllNodes());
} }
return result; return result;
} }
} }

View File

@ -7,12 +7,15 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System;
using System.Linq;
using Mono.Nat;
public static class UPnP public static class UPnP
{ {
public static void InitUPnP(EventHandler<DeviceEventArgs> DeviceFound, EventHandler<DeviceEventArgs> DeviceLost) public static void InitUPnP(EventHandler<DeviceEventArgs> DeviceFound, EventHandler<DeviceEventArgs> DeviceLost)
{ {
if (GlobalVars.UPnP == true) if (GlobalVars.UPnP == true) {
{
NatUtility.DeviceFound += DeviceFound; NatUtility.DeviceFound += DeviceFound;
NatUtility.DeviceLost += DeviceLost; NatUtility.DeviceLost += DeviceLost;
NatUtility.StartDiscovery(); NatUtility.StartDiscovery();
@ -21,12 +24,10 @@ public static class UPnP
public static void StartUPnP(INatDevice device, Protocol protocol, int port) public static void StartUPnP(INatDevice device, Protocol protocol, int port)
{ {
if (GlobalVars.UPnP == true) if (GlobalVars.UPnP == true) {
{
int map = device.GetSpecificMapping(protocol, port).PublicPort; int map = device.GetSpecificMapping(protocol, port).PublicPort;
if (map == -1) if (map == -1) {
{
device.CreatePortMap(new Mapping(protocol, port, port)); device.CreatePortMap(new Mapping(protocol, port, port));
} }
} }
@ -34,14 +35,12 @@ public static class UPnP
public static void StopUPnP(INatDevice device, Protocol protocol, int port) public static void StopUPnP(INatDevice device, Protocol protocol, int port)
{ {
if (GlobalVars.UPnP == true) if (GlobalVars.UPnP == true) {
{
int map = device.GetSpecificMapping(protocol, port).PublicPort; int map = device.GetSpecificMapping(protocol, port).PublicPort;
if (map != -1) if (map != -1) {
{
device.DeletePortMap(new Mapping(protocol, port, port)); device.DeletePortMap(new Mapping(protocol, port, port));
} }
} }
} }
} }

View File

@ -7,9 +7,19 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Threading;
using System.Text;
using System.Linq;
using System.Net.Sockets;
using System.Net;
//made by aksakalli //made by aksakalli
public class SimpleHTTPServer public class SimpleHTTPServer
{ {
private readonly string[] _indexFiles = { private readonly string[] _indexFiles = {
"index.html", "index.html",
@ -21,79 +31,78 @@
}; };
private static IDictionary<string, string> _mimeTypeMappings = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) { private static IDictionary<string, string> _mimeTypeMappings = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) {
{".asf", "video/x-ms-asf"}, { ".asf", "video/x-ms-asf" },
{".asx", "video/x-ms-asf"}, { ".asx", "video/x-ms-asf" },
{".avi", "video/x-msvideo"}, { ".avi", "video/x-msvideo" },
{".bin", "application/octet-stream"}, { ".bin", "application/octet-stream" },
{".cco", "application/x-cocoa"}, { ".cco", "application/x-cocoa" },
{".crt", "application/x-x509-ca-cert"}, { ".crt", "application/x-x509-ca-cert" },
{".css", "text/css"}, { ".css", "text/css" },
{".deb", "application/octet-stream"}, { ".deb", "application/octet-stream" },
{".der", "application/x-x509-ca-cert"}, { ".der", "application/x-x509-ca-cert" },
{".dll", "application/octet-stream"}, { ".dll", "application/octet-stream" },
{".dmg", "application/octet-stream"}, { ".dmg", "application/octet-stream" },
{".ear", "application/java-archive"}, { ".ear", "application/java-archive" },
{".eot", "application/octet-stream"}, { ".eot", "application/octet-stream" },
{".exe", "application/octet-stream"}, { ".exe", "application/octet-stream" },
{".flv", "video/x-flv"}, { ".flv", "video/x-flv" },
{".gif", "image/gif"}, { ".gif", "image/gif" },
{".hqx", "application/mac-binhex40"}, { ".hqx", "application/mac-binhex40" },
{".htc", "text/x-component"}, { ".htc", "text/x-component" },
{".htm", "text/html"}, { ".htm", "text/html" },
{".html", "text/html"}, { ".html", "text/html" },
{".ico", "image/x-icon"}, { ".ico", "image/x-icon" },
{".img", "application/octet-stream"}, { ".img", "application/octet-stream" },
{".iso", "application/octet-stream"}, { ".iso", "application/octet-stream" },
{".jar", "application/java-archive"}, { ".jar", "application/java-archive" },
{".jardiff", "application/x-java-archive-diff"}, { ".jardiff", "application/x-java-archive-diff" },
{".jng", "image/x-jng"}, { ".jng", "image/x-jng" },
{".jnlp", "application/x-java-jnlp-file"}, { ".jnlp", "application/x-java-jnlp-file" },
{".jpeg", "image/jpeg"}, { ".jpeg", "image/jpeg" },
{".jpg", "image/jpeg"}, { ".jpg", "image/jpeg" },
{".js", "application/x-javascript"}, { ".js", "application/x-javascript" },
{".mml", "text/mathml"}, { ".mml", "text/mathml" },
{".mng", "video/x-mng"}, { ".mng", "video/x-mng" },
{".mov", "video/quicktime"}, { ".mov", "video/quicktime" },
{".mp3", "audio/mpeg"}, { ".mp3", "audio/mpeg" },
{".mpeg", "video/mpeg"}, { ".mpeg", "video/mpeg" },
{".mpg", "video/mpeg"}, { ".mpg", "video/mpeg" },
{".msi", "application/octet-stream"}, { ".msi", "application/octet-stream" },
{".msm", "application/octet-stream"}, { ".msm", "application/octet-stream" },
{".msp", "application/octet-stream"}, { ".msp", "application/octet-stream" },
{".pdb", "application/x-pilot"}, { ".pdb", "application/x-pilot" },
{".pdf", "application/pdf"}, { ".pdf", "application/pdf" },
{".pem", "application/x-x509-ca-cert"}, { ".pem", "application/x-x509-ca-cert" },
{".php", "text/html"}, { ".php", "text/html" },
{".pl", "application/x-perl"}, { ".pl", "application/x-perl" },
{".pm", "application/x-perl"}, { ".pm", "application/x-perl" },
{".png", "image/png"}, { ".png", "image/png" },
{".prc", "application/x-pilot"}, { ".prc", "application/x-pilot" },
{".ra", "audio/x-realaudio"}, { ".ra", "audio/x-realaudio" },
{".rar", "application/x-rar-compressed"}, { ".rar", "application/x-rar-compressed" },
{".rpm", "application/x-redhat-package-manager"}, { ".rpm", "application/x-redhat-package-manager" },
{".rss", "text/xml"}, { ".rss", "text/xml" },
{".run", "application/x-makeself"}, { ".run", "application/x-makeself" },
{".sea", "application/x-sea"}, { ".sea", "application/x-sea" },
{".shtml", "text/html"}, { ".shtml", "text/html" },
{".sit", "application/x-stuffit"}, { ".sit", "application/x-stuffit" },
{".swf", "application/x-shockwave-flash"}, { ".swf", "application/x-shockwave-flash" },
{".tcl", "application/x-tcl"}, { ".tcl", "application/x-tcl" },
{".tk", "application/x-tcl"}, { ".tk", "application/x-tcl" },
{".txt", "text/plain"}, { ".txt", "text/plain" },
{".war", "application/java-archive"}, { ".war", "application/java-archive" },
{".wbmp", "image/vnd.wap.wbmp"}, { ".wbmp", "image/vnd.wap.wbmp" },
{".wmv", "video/x-ms-wmv"}, { ".wmv", "video/x-ms-wmv" },
{".xml", "text/xml"}, { ".xml", "text/xml" },
{".xpi", "application/x-xpinstall"}, { ".xpi", "application/x-xpinstall" },
{".zip", "application/zip"}, { ".zip", "application/zip" },
}; };
private Thread _serverThread; private Thread _serverThread;
private string _rootDirectory; private string _rootDirectory;
private HttpListener _listener; private HttpListener _listener;
private int _port; private int _port;
public int Port public int Port {
{
get { return _port; } get { return _port; }
private set { } private set { }
} }
@ -137,15 +146,11 @@
_listener = new HttpListener(); _listener = new HttpListener();
_listener.Prefixes.Add("http://*:" + _port.ToString() + "/"); _listener.Prefixes.Add("http://*:" + _port.ToString() + "/");
_listener.Start(); _listener.Start();
while (true) while (true) {
{ try {
try
{
HttpListenerContext context = _listener.GetContext(); HttpListenerContext context = _listener.GetContext();
Process(context); Process(context);
} } catch (Exception) {
catch (Exception)
{
} }
} }
@ -172,12 +177,9 @@
string filename = context.Request.Url.AbsolutePath; string filename = context.Request.Url.AbsolutePath;
filename = filename.Substring(1); filename = filename.Substring(1);
if (string.IsNullOrEmpty(filename)) if (string.IsNullOrEmpty(filename)) {
{ foreach (string indexFile in _indexFiles) {
foreach (string indexFile in _indexFiles) if (File.Exists(Path.Combine(_rootDirectory, indexFile))) {
{
if (File.Exists(Path.Combine(_rootDirectory, indexFile)))
{
filename = indexFile; filename = indexFile;
break; break;
} }
@ -186,14 +188,11 @@
filename = Path.Combine(_rootDirectory, filename); filename = Path.Combine(_rootDirectory, filename);
if (File.Exists(filename)) if (File.Exists(filename)) {
{ try {
try
{
var ext = new FileInfo(filename); var ext = new FileInfo(filename);
if (ext.Extension == ".php") if (ext.Extension == ".php") {
{
string output = ProcessPhpPage(GlobalVars.ConfigDir + "\\php\\php.exe", filename); string output = ProcessPhpPage(GlobalVars.ConfigDir + "\\php\\php.exe", filename);
byte[] input = ASCIIEncoding.UTF8.GetBytes(output); byte[] input = ASCIIEncoding.UTF8.GetBytes(output);
//Adding permanent http response headers //Adding permanent http response headers
@ -205,9 +204,7 @@
context.Response.OutputStream.Write(input, 0, input.Length); context.Response.OutputStream.Write(input, 0, input.Length);
context.Response.StatusCode = (int)HttpStatusCode.OK; context.Response.StatusCode = (int)HttpStatusCode.OK;
context.Response.OutputStream.Flush(); context.Response.OutputStream.Flush();
} } else {
else
{
Stream input = new FileStream(filename, FileMode.Open); Stream input = new FileStream(filename, FileMode.Open);
//Adding permanent http response headers //Adding permanent http response headers
string mime; string mime;
@ -225,17 +222,12 @@
context.Response.StatusCode = (int)HttpStatusCode.OK; context.Response.StatusCode = (int)HttpStatusCode.OK;
context.Response.OutputStream.Flush(); context.Response.OutputStream.Flush();
} }
} } catch (Exception) {
catch (Exception)
{
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
} }
} } else {
else if (context.Request.HttpMethod.Equals("GET") && filename.Contains("bodycolors.rbxm", StringComparison.OrdinalIgnoreCase)) {
{
if (context.Request.HttpMethod.Equals("GET") && filename.Contains("bodycolors.rbxm", StringComparison.OrdinalIgnoreCase))
{
string output = WebServerGenerator.GenerateBodyColorsXML(); string output = WebServerGenerator.GenerateBodyColorsXML();
byte[] input = ASCIIEncoding.UTF8.GetBytes(output); byte[] input = ASCIIEncoding.UTF8.GetBytes(output);
context.Response.ContentType = "text/xml"; context.Response.ContentType = "text/xml";
@ -243,9 +235,7 @@
context.Response.OutputStream.Write(input, 0, input.Length); context.Response.OutputStream.Write(input, 0, input.Length);
context.Response.StatusCode = (int)HttpStatusCode.OK; context.Response.StatusCode = (int)HttpStatusCode.OK;
context.Response.OutputStream.Flush(); context.Response.OutputStream.Flush();
} } else {
else
{
context.Response.StatusCode = (int)HttpStatusCode.NotFound; context.Response.StatusCode = (int)HttpStatusCode.NotFound;
} }
} }
@ -261,14 +251,14 @@
_serverThread.Start(); _serverThread.Start();
GlobalVars.IsWebServerOn = true; GlobalVars.IsWebServerOn = true;
} }
} }
public static class WebServerGenerator public static class WebServerGenerator
{ {
public static string GenerateBodyColorsXML() public static string GenerateBodyColorsXML()
{ {
string xmltemplate = GlobalVars.MultiLine(File.ReadAllLines(GlobalVars.CustomPlayerDir + "\\BodyColors.xml")); string xmltemplate = GlobalVars.MultiLine(File.ReadAllLines(GlobalVars.CustomPlayerDir + "\\BodyColors.xml"));
string xml = String.Format(xmltemplate, GlobalVars.HeadColorID, GlobalVars.LeftArmColorID, GlobalVars.LeftLegColorID, GlobalVars.RightArmColorID, GlobalVars.RightLegColorID, GlobalVars.TorsoColorID); string xml = String.Format(xmltemplate, GlobalVars.HeadColorID, GlobalVars.LeftArmColorID, GlobalVars.LeftLegColorID, GlobalVars.RightArmColorID, GlobalVars.RightLegColorID, GlobalVars.TorsoColorID);
return xml; return xml;
} }
} }