begin work on clientscript 2.

i got it to be backward compatible apparently.
This commit is contained in:
Bitl 2022-12-22 07:29:02 -07:00
parent f8d1f9406c
commit 220f4d3d75
1 changed files with 171 additions and 64 deletions

View File

@ -1024,6 +1024,48 @@ public class ClientManagement
#endif #endif
} }
#if URI
public static void ValidateFiles(string line, string validstart, string validend, Label label)
#else
public static void ValidateFiles(string line, string validstart, string validend)
#endif
{
string extractedFile = ScriptFuncs.ClientScript.GetArgsFromTag(line, validstart, validend);
if (!string.IsNullOrWhiteSpace(extractedFile))
{
string[] parsedFileParams = extractedFile.Split('|');
string filePath = parsedFileParams[0];
string fileMD5 = parsedFileParams[1];
string fullFilePath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\" + filePath;
if (!SecurityFuncs.CheckMD5(fileMD5, fullFilePath))
{
#if URI
UpdateStatus(label, "The client has been detected as modified.");
#elif LAUNCHER
Util.ConsolePrint("ERROR - Failed to launch Novetus. (The client has been detected as modified.)", 2);
#endif
#if LAUNCHER
if (!GlobalVars.isConsoleOnly)
{
MessageBox.Show("Failed to launch Novetus. (Error: The client has been detected as modified.)", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
#endif
#if URI
throw new IOException("The client has been detected as modified.");
#else
return;
#endif
}
else
{
GlobalVars.ValidatedExtraFiles += 1;
}
}
}
#if URI #if URI
public static void LaunchRBXClient(string ClientName, ScriptType type, bool no3d, bool nomap, EventHandler e, Label label) public static void LaunchRBXClient(string ClientName, ScriptType type, bool no3d, bool nomap, EventHandler e, Label label)
#else #else
@ -1110,61 +1152,63 @@ public class ClientManagement
string args = ""; string args = "";
GlobalVars.ValidatedExtraFiles = 0; GlobalVars.ValidatedExtraFiles = 0;
bool v1 = false;
if (info.CommandLineArgs.Contains("<") &&
info.CommandLineArgs.Contains("</") &&
info.CommandLineArgs.Contains(">"))
{
v1 = true;
}
if (!GlobalVars.AdminMode && !info.AlreadyHasSecurity) if (!GlobalVars.AdminMode && !info.AlreadyHasSecurity)
{ {
string validstart = "<validate>"; string validstart = "<validate>";
string validend = "</validate>"; string validend = "</validate>";
string validv2 = "validate=";
foreach (string line in info.CommandLineArgs.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) foreach (string line in info.CommandLineArgs.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{ {
if (line.Contains(validstart) && line.Contains(validend)) if (v1 && line.Contains(validstart) && line.Contains(validend))
{ {
string extractedFile = ScriptFuncs.ClientScript.GetArgsFromTag(line, validstart, validend); try
if (!string.IsNullOrWhiteSpace(extractedFile))
{ {
try
{
string[] parsedFileParams = extractedFile.Split('|');
string filePath = parsedFileParams[0];
string fileMD5 = parsedFileParams[1];
string fullFilePath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\" + filePath;
if (!SecurityFuncs.CheckMD5(fileMD5, fullFilePath))
{
#if URI #if URI
UpdateStatus(label, "The client has been detected as modified."); ValidateFiles(line, validstart, validend, label);
#elif LAUNCHER
Util.ConsolePrint("ERROR - Failed to launch Novetus. (The client has been detected as modified.)", 2);
#endif
#if LAUNCHER
if (!GlobalVars.isConsoleOnly)
{
MessageBox.Show("Failed to launch Novetus. (Error: The client has been detected as modified.)", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
#endif
#if URI
throw new IOException("The client has been detected as modified.");
#else #else
return; ValidateFiles(line, validstart, validend);
#endif #endif
} }
else
{
GlobalVars.ValidatedExtraFiles += 1;
}
}
#if URI || LAUNCHER || BASICLAUNCHER #if URI || LAUNCHER || BASICLAUNCHER
catch (Exception ex) catch (Exception ex)
{ {
Util.LogExceptions(ex); Util.LogExceptions(ex);
#else #else
catch (Exception) catch (Exception)
{ {
#endif #endif
continue; continue;
} }
}
else if (line.Contains(validv2))
{
try
{
#if URI
ValidateFiles(line, validv2, "", label);
#else
ValidateFiles(line, validv2, "");
#endif
}
#if URI || LAUNCHER || BASICLAUNCHER
catch (Exception ex)
{
Util.LogExceptions(ex);
#else
catch (Exception)
{
#endif
continue;
} }
} }
} }
@ -1198,8 +1242,8 @@ public class ClientManagement
else else
{ {
args = ScriptFuncs.ClientScript.CompileScript(ClientName, info.CommandLineArgs, args = ScriptFuncs.ClientScript.CompileScript(ClientName, info.CommandLineArgs,
ScriptFuncs.ClientScript.GetTagFromType(type, false, no3d), ScriptFuncs.ClientScript.GetTagFromType(type, false, no3d, v1),
ScriptFuncs.ClientScript.GetTagFromType(type, true, no3d), ScriptFuncs.ClientScript.GetTagFromType(type, true, no3d, v1),
mapfile, mapfile,
luafile, luafile,
rbxexe); rbxexe);
@ -1552,10 +1596,19 @@ public class ScriptFuncs
{ {
try try
{ {
int pFrom = code.IndexOf(tag) + tag.Length; if (string.IsNullOrEmpty(endtag))
int pTo = code.LastIndexOf(endtag); {
string result = code.Substring(pFrom, pTo - pFrom); //VERSION 2!!
return result; string result = code.Substring(code.IndexOf(tag) + tag.Length);
return result;
}
else
{
int pFrom = code.IndexOf(tag) + tag.Length;
int pTo = code.LastIndexOf(endtag);
string result = code.Substring(pFrom, pTo - pFrom);
return result;
}
} }
#if URI || LAUNCHER || BASICLAUNCHER #if URI || LAUNCHER || BASICLAUNCHER
catch (Exception ex) catch (Exception ex)
@ -1587,20 +1640,45 @@ public class ScriptFuncs
} }
} }
public static string GetTagFromType(ScriptType type, bool endtag, bool no3d) public static string GetTagFromType(ScriptType type, bool endtag, bool no3d, bool v1)
{ {
switch (type) if (v1)
{ {
case ScriptType.Client: switch (type)
return endtag ? "</client>" : "<client>"; {
case ScriptType.Server: case ScriptType.Client:
return no3d ? (endtag ? "</no3d>" : "<no3d>") : (endtag ? "</server>" : "<server>"); return endtag ? "</client>" : "<client>";
case ScriptType.Solo: case ScriptType.Server:
return endtag ? "</solo>" : "<solo>"; return no3d ? (endtag ? "</no3d>" : "<no3d>") : (endtag ? "</server>" : "<server>");
case ScriptType.Studio: case ScriptType.Solo:
return endtag ? "</studio>" : "<studio>"; return endtag ? "</solo>" : "<solo>";
default: case ScriptType.Studio:
return endtag ? "</studio>" : "<studio>";
default:
return "";
}
}
else
{
if (endtag == true)
{
//NO END TAGS.
return ""; return "";
}
switch (type)
{
case ScriptType.Client:
return "client=";
case ScriptType.Server:
return no3d ? "no3d=" : "server=";
case ScriptType.Solo:
return "solo=";
case ScriptType.Studio:
return "studio=";
default:
return "";
}
} }
} }
@ -1676,25 +1754,54 @@ public class ScriptFuncs
string start = tag; string start = tag;
string end = endtag; string end = endtag;
bool v1 = false;
if (code.Contains("<") &&
code.Contains("</") &&
code.Contains(">"))
{
v1 = true;
}
else
{
//make sure we have no end tags.
if (!string.IsNullOrWhiteSpace(end))
{
end = "";
}
}
FileFormat.ClientInfo info = ClientManagement.GetClientInfoValues(ClientName); FileFormat.ClientInfo info = ClientManagement.GetClientInfoValues(ClientName);
ScriptType type = GetTypeFromTag(start); ScriptType type = GetTypeFromTag(start);
//we must have the ending tag before we continue. //we must have the ending tag before we continue.
if (string.IsNullOrWhiteSpace(end)) if (v1 && string.IsNullOrWhiteSpace(end))
{ {
return ""; return "";
} }
if (usesharedtags) if (usesharedtags)
{ {
string sharedstart = "<shared>"; if (v1)
string sharedend = "</shared>";
if (code.Contains(sharedstart) && code.Contains(sharedend))
{ {
start = sharedstart; string sharedstart = "<shared>";
end = sharedend; string sharedend = "</shared>";
if (code.Contains(sharedstart) && code.Contains(sharedend))
{
start = sharedstart;
end = sharedend;
}
}
else
{
string sharedstart = "shared=";
if (code.Contains(sharedstart))
{
start = sharedstart;
}
} }
} }