i cannot believe this code had to be rewritten again!

This commit is contained in:
Bitl 2020-07-14 19:02:42 -07:00
parent 6b5a3d6316
commit 5def12095a
4 changed files with 120 additions and 69 deletions

View File

@ -74,7 +74,7 @@ using System.Globalization;
if (!SelectedClientInfo.LegacyMode)
{
ClientName = "\\RobloxApp_Client.exe";
ClientName = "\\RobloxApp_client.exe";
}
else
{

View File

@ -498,11 +498,26 @@ public class GlobalFuncs
return GlobalPaths.AltBaseGameDir + "temp.rbxl";
}
//NOT FOR SDK.
public static FileFormat.ClientInfo GetClientInfoValues(string ClientName)
{
string name = ClientName;
FileFormat.ClientInfo info = new FileFormat.ClientInfo();
string clientpath = GlobalPaths.ClientDir + @"\\" + name + @"\\clientinfo.nov";
LoadClientValues(info, clientpath);
return info;
}
public static void LoadClientValues(string clientpath)
{
string file, usesplayername, usesid, warning,
legacymode, clientmd5, scriptmd5,
desc, fix2007, alreadyhassecurity,
LoadClientValues(GlobalVars.SelectedClientInfo, clientpath);
}
public static void LoadClientValues(FileFormat.ClientInfo info, string clientpath)
{
string file, usesplayername, usesid, warning,
legacymode, clientmd5, scriptmd5,
desc, fix2007, alreadyhassecurity,
nographicsoptions, commandlineargs;
using (StreamReader reader = new StreamReader(clientpath))
@ -533,17 +548,17 @@ public class GlobalFuncs
commandlineargs = SecurityFuncs.Base64Decode(result[10]);
}
GlobalVars.SelectedClientInfo.UsesPlayerName = Convert.ToBoolean(usesplayername);
GlobalVars.SelectedClientInfo.UsesID = Convert.ToBoolean(usesid);
GlobalVars.SelectedClientInfo.Warning = warning;
GlobalVars.SelectedClientInfo.LegacyMode = Convert.ToBoolean(legacymode);
GlobalVars.SelectedClientInfo.ClientMD5 = clientmd5;
GlobalVars.SelectedClientInfo.ScriptMD5 = scriptmd5;
GlobalVars.SelectedClientInfo.Description = desc;
GlobalVars.SelectedClientInfo.Fix2007 = Convert.ToBoolean(fix2007);
GlobalVars.SelectedClientInfo.AlreadyHasSecurity = Convert.ToBoolean(alreadyhassecurity);
GlobalVars.SelectedClientInfo.NoGraphicsOptions = Convert.ToBoolean(nographicsoptions);
GlobalVars.SelectedClientInfo.CommandLineArgs = commandlineargs;
info.UsesPlayerName = Convert.ToBoolean(usesplayername);
info.UsesID = Convert.ToBoolean(usesid);
info.Warning = warning;
info.LegacyMode = Convert.ToBoolean(legacymode);
info.ClientMD5 = clientmd5;
info.ScriptMD5 = scriptmd5;
info.Description = desc;
info.Fix2007 = Convert.ToBoolean(fix2007);
info.AlreadyHasSecurity = Convert.ToBoolean(alreadyhassecurity);
info.NoGraphicsOptions = Convert.ToBoolean(nographicsoptions);
info.CommandLineArgs = commandlineargs;
}
public static void ReShade(string cfgpath, string cfgname, bool write)
@ -773,6 +788,11 @@ public class GlobalFuncs
}
public static void UpdateRichPresence(GlobalVars.LauncherState state, string mapname, bool initial = false)
{
UpdateRichPresence(state, GlobalVars.UserConfiguration.SelectedClient, mapname, initial);
}
public static void UpdateRichPresence(GlobalVars.LauncherState state, string clientname, string mapname, bool initial = false)
{
if (GlobalVars.UserConfiguration.DiscordPresence)
{
@ -789,30 +809,30 @@ public class GlobalFuncs
case GlobalVars.LauncherState.InLauncher:
GlobalVars.presence.smallImageKey = GlobalVars.image_inlauncher;
GlobalVars.presence.state = "In Launcher";
GlobalVars.presence.details = "Selected " + GlobalVars.UserConfiguration.SelectedClient;
GlobalVars.presence.details = "Selected " + clientname;
GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version;
GlobalVars.presence.smallImageText = "In Launcher";
break;
case GlobalVars.LauncherState.InMPGame:
GlobalVars.presence.smallImageKey = GlobalVars.image_ingame;
GlobalVars.presence.details = ValidMapname;
GlobalVars.presence.state = "In " + GlobalVars.UserConfiguration.SelectedClient + " Multiplayer Game";
GlobalVars.presence.state = "In " + clientname + " Multiplayer Game";
GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version;
GlobalVars.presence.smallImageText = "In " + GlobalVars.UserConfiguration.SelectedClient + " Multiplayer Game";
GlobalVars.presence.smallImageText = "In " + clientname + " Multiplayer Game";
break;
case GlobalVars.LauncherState.InSoloGame:
GlobalVars.presence.smallImageKey = GlobalVars.image_ingame;
GlobalVars.presence.details = ValidMapname;
GlobalVars.presence.state = "In " + GlobalVars.UserConfiguration.SelectedClient + " Solo Game";
GlobalVars.presence.state = "In " + clientname + " Solo Game";
GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version;
GlobalVars.presence.smallImageText = "In " + GlobalVars.UserConfiguration.SelectedClient + " Solo Game";
GlobalVars.presence.smallImageText = "In " + clientname + " Solo Game";
break;
case GlobalVars.LauncherState.InStudio:
GlobalVars.presence.smallImageKey = GlobalVars.image_instudio;
GlobalVars.presence.details = ValidMapname;
GlobalVars.presence.state = "In " + GlobalVars.UserConfiguration.SelectedClient + " Studio";
GlobalVars.presence.state = "In " + clientname + " Studio";
GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version;
GlobalVars.presence.smallImageText = "In " + GlobalVars.UserConfiguration.SelectedClient + " Studio";
GlobalVars.presence.smallImageText = "In " + clientname + " Studio";
break;
case GlobalVars.LauncherState.InCustomization:
GlobalVars.presence.smallImageKey = GlobalVars.image_incustomization;
@ -831,9 +851,9 @@ public class GlobalFuncs
case GlobalVars.LauncherState.LoadingURI:
GlobalVars.presence.smallImageKey = GlobalVars.image_ingame;
GlobalVars.presence.details = ValidMapname;
GlobalVars.presence.state = "Joining a " + GlobalVars.UserConfiguration.SelectedClient + " Multiplayer Game";
GlobalVars.presence.state = "Joining a " + clientname + " Multiplayer Game";
GlobalVars.presence.largeImageText = GlobalVars.UserConfiguration.PlayerName + " | Novetus " + GlobalVars.ProgramInformation.Version;
GlobalVars.presence.smallImageText = "Joining a " + GlobalVars.UserConfiguration.SelectedClient + " Multiplayer Game";
GlobalVars.presence.smallImageText = "Joining a " + clientname + " Multiplayer Game";
break;
default:
break;
@ -939,6 +959,11 @@ public class GlobalFuncs
}
public static string GetLuaFileName()
{
return GetLuaFileName(GlobalVars.UserConfiguration.SelectedClient);
}
public static string GetLuaFileName(string ClientName)
{
string luafile = "";
@ -948,39 +973,44 @@ public class GlobalFuncs
}
else
{
luafile = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\content\\scripts\\" + GlobalPaths.ScriptGenName + ".lua";
luafile = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\content\\scripts\\" + GlobalPaths.ScriptGenName + ".lua";
}
return luafile;
}
public static string GetClientEXEDir(ScriptType type)
{
return GetClientEXEDir(GlobalVars.UserConfiguration.SelectedClient, type);
}
public static string GetClientEXEDir(string ClientName, ScriptType type)
{
string rbxexe = "";
if (GlobalVars.SelectedClientInfo.LegacyMode)
{
rbxexe = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\RobloxApp.exe";
rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\RobloxApp.exe";
}
else
{
switch (type)
{
case ScriptType.Client:
rbxexe = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\RobloxApp_client.exe";
rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\RobloxApp_client.exe";
break;
case ScriptType.Server:
rbxexe = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\RobloxApp_server.exe";
rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\RobloxApp_server.exe";
break;
case ScriptType.Studio:
rbxexe = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\RobloxApp_studio.exe";
rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\RobloxApp_studio.exe";
break;
case ScriptType.Solo:
case ScriptType.EasterEgg:
rbxexe = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\RobloxApp_solo.exe";
rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\RobloxApp_solo.exe";
break;
case ScriptType.None:
default:
rbxexe = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\RobloxApp.exe";
rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\RobloxApp.exe";
break;
}
}
@ -1020,23 +1050,24 @@ public class GlobalFuncs
ReadClientValues(ClientName);
#endif
string luafile = GetLuaFileName();
string rbxexe = GetClientEXEDir(type);
string luafile = GetLuaFileName(ClientName);
string rbxexe = GetClientEXEDir(ClientName, type);
string mapfile = type.Equals(ScriptType.EasterEgg) ? GlobalPaths.ConfigDirData + "\\Appreciation.rbxl" : (nomap ? "" : GlobalVars.UserConfiguration.MapPath);
string mapname = type.Equals(ScriptType.EasterEgg) ? "" : (nomap ? "" : GlobalVars.UserConfiguration.Map);
FileFormat.ClientInfo info = GetClientInfoValues(ClientName);
string quote = "\"";
string args = "";
if (GlobalVars.SelectedClientInfo.CommandLineArgs.Equals("%args%"))
if (info.CommandLineArgs.Equals("%args%"))
{
if (!GlobalVars.SelectedClientInfo.Fix2007)
if (!info.Fix2007)
{
args = quote
+ mapfile
+ "\" -script \""
+ ChangeGameSettings()
+ " dofile('" + luafile + "'); "
+ ScriptFuncs.Generator.GetScriptFuncForType(type)
+ ScriptFuncs.Generator.GetScriptFuncForType(ClientName, type)
+ "; "
+ (!string.IsNullOrWhiteSpace(GlobalPaths.AddonScriptPath) ? " dofile('" + GlobalPaths.AddonScriptPath + "');" : "")
+ quote
@ -1044,7 +1075,7 @@ public class GlobalFuncs
}
else
{
ScriptFuncs.Generator.GenerateScriptForClient(type);
ScriptFuncs.Generator.GenerateScriptForClient(ClientName, type);
args = "-script "
+ quote
+ luafile
@ -1058,7 +1089,7 @@ public class GlobalFuncs
}
else
{
args = ScriptFuncs.ClientScript.CompileScript(GlobalVars.SelectedClientInfo.CommandLineArgs,
args = ScriptFuncs.ClientScript.CompileScript(ClientName, info.CommandLineArgs,
ScriptFuncs.ClientScript.GetTagFromType(type, false, no3d),
ScriptFuncs.ClientScript.GetTagFromType(type, true, no3d),
mapfile,
@ -1079,11 +1110,11 @@ public class GlobalFuncs
{
if (!GlobalVars.AdminMode)
{
if (GlobalVars.SelectedClientInfo.AlreadyHasSecurity != true)
if (info.AlreadyHasSecurity != true)
{
if (SecurityFuncs.checkClientMD5(GlobalVars.UserConfiguration.SelectedClient) && SecurityFuncs.checkScriptMD5(GlobalVars.UserConfiguration.SelectedClient))
if (SecurityFuncs.checkClientMD5(ClientName) && SecurityFuncs.checkScriptMD5(ClientName))
{
OpenClient(type, rbxexe, args, mapname, e);
OpenClient(type, rbxexe, args, ClientName, mapname, e);
}
else
{
@ -1108,17 +1139,17 @@ public class GlobalFuncs
}
else
{
OpenClient(type, rbxexe, args, mapname, e);
OpenClient(type, rbxexe, args, ClientName, mapname, e);
}
}
else
{
OpenClient(type, rbxexe, args, mapname, e);
OpenClient(type, rbxexe, args, ClientName, mapname, e);
}
}
else
{
OpenClient(type, rbxexe, args, mapname, e);
OpenClient(type, rbxexe, args, ClientName, mapname, e);
}
}
#if URI || LAUNCHER || CMD
@ -1147,7 +1178,7 @@ public class GlobalFuncs
}
}
private static void OpenClient(ScriptType type, string rbxexe, string args, string mapname, EventHandler e)
private static void OpenClient(ScriptType type, string rbxexe, string args, string clientname, string mapname, EventHandler e)
{
Process client = new Process();
client.StartInfo.FileName = rbxexe;
@ -1159,10 +1190,10 @@ public class GlobalFuncs
}
client.Start();
client.PriorityClass = ProcessPriorityClass.RealTime;
SecurityFuncs.RenameWindow(client, type, mapname);
SecurityFuncs.RenameWindow(client, type, clientname, mapname);
if (e != null)
{
UpdateRichPresence(GetStateForType(type), mapname);
UpdateRichPresence(GetStateForType(type), clientname, mapname);
}
#if CMD
GlobalVars.ProcessID = client.Id;

View File

@ -27,33 +27,40 @@ public class ScriptFuncs
{
public static string GetScriptFuncForType(ScriptType type)
{
return GetScriptFuncForType(GlobalVars.UserConfiguration.SelectedClient, type);
}
public static string GetScriptFuncForType(string ClientName, ScriptType type)
{
FileFormat.ClientInfo info = GlobalFuncs.GetClientInfoValues(ClientName);
string rbxexe = "";
if (GlobalVars.SelectedClientInfo.LegacyMode)
if (info.LegacyMode)
{
rbxexe = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\RobloxApp.exe";
rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\RobloxApp.exe";
}
else
{
rbxexe = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\RobloxApp_client.exe";
rbxexe = GlobalPaths.ClientDir + @"\\" + ClientName + @"\\RobloxApp_client.exe";
}
#if LAUNCHER
string md5dir = !GlobalVars.SelectedClientInfo.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(Assembly.GetExecutingAssembly().Location) : "";
string md5dir = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(Assembly.GetExecutingAssembly().Location) : "";
#else
string md5dir = !GlobalVars.SelectedClientInfo.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.RootPathLauncher + "\\Novetus.exe") : "";
string md5dir = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.RootPathLauncher + "\\Novetus.exe") : "";
#endif
string md5script = !GlobalVars.SelectedClientInfo.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua") : "";
string md5exe = !GlobalVars.SelectedClientInfo.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(rbxexe) : "";
string md5script = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.ClientDir + @"\\" + ClientName + @"\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua") : "";
string md5exe = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(rbxexe) : "";
string md5s = "'" + md5exe + "','" + md5dir + "','" + md5script + "'";
switch (type)
{
case ScriptType.Client:
return "_G.CSConnect("
+ (GlobalVars.SelectedClientInfo.UsesID ? GlobalVars.UserConfiguration.UserID : 0) + ",'"
+ (info.UsesID ? GlobalVars.UserConfiguration.UserID : 0) + ",'"
+ GlobalVars.IP + "',"
+ GlobalVars.UserConfiguration.RobloxPort + ",'"
+ (GlobalVars.SelectedClientInfo.UsesPlayerName ? GlobalVars.UserConfiguration.PlayerName : "Player") + "',"
+ (info.UsesPlayerName ? GlobalVars.UserConfiguration.PlayerName : "Player") + "',"
+ GlobalVars.Loadout + ","
+ md5s + ",'"
+ GlobalVars.UserConfiguration.PlayerTripcode + "')";
@ -65,8 +72,8 @@ public class ScriptFuncs
case ScriptType.Solo:
case ScriptType.EasterEgg:
return "_G.CSSolo("
+ (GlobalVars.SelectedClientInfo.UsesID ? GlobalVars.UserConfiguration.UserID : 0) + ",'"
+ (GlobalVars.SelectedClientInfo.UsesPlayerName ? GlobalVars.UserConfiguration.PlayerName : "Player") + "',"
+ (info.UsesID ? GlobalVars.UserConfiguration.UserID : 0) + ",'"
+ (info.UsesPlayerName ? GlobalVars.UserConfiguration.PlayerName : "Player") + "',"
+ GlobalVars.soloLoadout + ")";
case ScriptType.Studio:
return "_G.CSStudio()";
@ -93,7 +100,13 @@ public class ScriptFuncs
return "N/A";
}
}
public static void GenerateScriptForClient(ScriptType type)
{
GenerateScriptForClient(GlobalVars.UserConfiguration.SelectedClient, type);
}
public static void GenerateScriptForClient(string ClientName, ScriptType type)
{
string code = GlobalFuncs.MultiLine(
"--Load Script",
@ -106,7 +119,7 @@ public class ScriptFuncs
List<string> list = new List<string>(Regex.Split(code, Environment.NewLine));
string[] convertedList = list.ToArray();
File.WriteAllLines(GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\content\\scripts\\" + GlobalPaths.ScriptGenName + ".lua", convertedList);
File.WriteAllLines(GlobalPaths.ClientDir + @"\\" + ClientName + @"\\content\\scripts\\" + GlobalPaths.ScriptGenName + ".lua", convertedList);
}
}
#endregion
@ -244,10 +257,17 @@ public class ScriptFuncs
}
public static string CompileScript(string code, string tag, string endtag, string mapfile, string luafile, string rbxexe, bool usesharedtags = true)
{
return CompileScript(GlobalVars.UserConfiguration.SelectedClient, code, tag, endtag, mapfile, luafile, rbxexe, usesharedtags);
}
public static string CompileScript(string ClientName, string code, string tag, string endtag, string mapfile, string luafile, string rbxexe, bool usesharedtags = true)
{
string start = tag;
string end = endtag;
FileFormat.ClientInfo info = GlobalFuncs.GetClientInfoValues(ClientName);
ScriptType type = GetTypeFromTag(start);
//we must have the ending tag before we continue.
@ -268,7 +288,7 @@ public class ScriptFuncs
}
}
if (GlobalVars.SelectedClientInfo.Fix2007)
if (info.Fix2007)
{
Generator.GenerateScriptForClient(type);
}
@ -281,12 +301,12 @@ public class ScriptFuncs
}
#if LAUNCHER
string md5dir = !GlobalVars.SelectedClientInfo.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(Assembly.GetExecutingAssembly().Location) : "";
string md5dir = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(Assembly.GetExecutingAssembly().Location) : "";
#else
string md5dir = !GlobalVars.SelectedClientInfo.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.RootPathLauncher + "\\Novetus.exe") : "";
string md5dir = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.RootPathLauncher + "\\Novetus.exe") : "";
#endif
string md5script = !GlobalVars.SelectedClientInfo.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua") : "";
string md5exe = !GlobalVars.SelectedClientInfo.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(rbxexe) : "";
string md5script = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\content\\scripts\\" + GlobalPaths.ScriptName + ".lua") : "";
string md5exe = !info.AlreadyHasSecurity ? SecurityFuncs.GenerateMD5(rbxexe) : "";
string md5s = "'" + md5exe + "','" + md5dir + "','" + md5script + "'";
string compiled = extractedCode.Replace("%version%", GlobalVars.ProgramInformation.Version)
.Replace("%mapfile%", mapfile)
@ -321,8 +341,8 @@ public class ScriptFuncs
.Replace("%rarmcolor%", GlobalVars.UserCustomization.RightArmColorID.ToString())
.Replace("%rlegcolor%", GlobalVars.UserCustomization.RightLegColorID.ToString())
.Replace("%md5launcher%", md5dir)
.Replace("%md5script%", GlobalVars.SelectedClientInfo.ScriptMD5)
.Replace("%md5exe%", GlobalVars.SelectedClientInfo.ClientMD5)
.Replace("%md5script%", info.ScriptMD5)
.Replace("%md5exe%", info.ClientMD5)
.Replace("%md5scriptd%", md5script)
.Replace("%md5exed%", md5exe)
.Replace("%limit%", GlobalVars.UserConfiguration.PlayerLimit.ToString())

View File

@ -174,13 +174,13 @@ public class SecurityFuncs
return new String(' ', random.Next(20));
}
public static void RenameWindow(Process exe, ScriptType type, string mapname)
public static void RenameWindow(Process exe, ScriptType type, string clientname, string mapname)
{
if (!GlobalVars.SelectedClientInfo.AlreadyHasSecurity)
{
int time = 500;
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (obj, e) => WorkerDoWork(exe, type, time, worker, GlobalVars.UserConfiguration.SelectedClient, mapname);
worker.DoWork += (obj, e) => WorkerDoWork(exe, type, time, worker, clientname, mapname);
worker.RunWorkerAsync();
}
}
@ -238,7 +238,7 @@ public class SecurityFuncs
else
{
Thread.Sleep(time);
RenameWindow(exe, type, mapname);
RenameWindow(exe, type, clientname, mapname);
}
}