Update GlobalFuncs.cs

This commit is contained in:
Bitl 2021-11-19 12:54:56 -07:00
parent 8544f4c25e
commit c2f8608e64
1 changed files with 30 additions and 56 deletions

View File

@ -2021,57 +2021,32 @@ public class GlobalFuncs
string args = ""; string args = "";
GlobalVars.ValidatedExtraFiles = 0; GlobalVars.ValidatedExtraFiles = 0;
if (!info.AlreadyHasSecurity) if (!info.AlreadyHasSecurity || !GlobalVars.AdminMode)
{ {
if (Regex.Match(GlobalVars.UserConfiguration.PlayerTripcode, "[^a-zA-Z0-9]") != Match.Empty || string validstart = "<validate>";
string.IsNullOrWhiteSpace(GlobalVars.UserConfiguration.PlayerTripcode)) string validend = "</validate>";
foreach (string line in info.CommandLineArgs.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{ {
#if URI if (line.Contains(validstart) && line.Contains(validend))
if (label != null)
{ {
label.Text = "The client has been detected as modified."; string extractedFile = ScriptFuncs.ClientScript.GetArgsFromTag(line, validstart, validend);
} if (!string.IsNullOrWhiteSpace(extractedFile))
#elif LAUNCHER
if (box != null)
{
ConsolePrint("ERROR - Failed to launch Novetus. (The client has been detected as modified.)", 2, box);
}
#elif CMD
ConsolePrint("ERROR - Failed to launch Novetus. (The client has been detected as modified.)", 2);
#endif
#if URI || LAUNCHER
MessageBox.Show("Failed to launch Novetus. (Error: The client has been detected as modified.)", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
#endif
return;
}
if (!GlobalVars.AdminMode)
{
string validstart = "<validate>";
string validend = "</validate>";
foreach (string line in info.CommandLineArgs.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
if (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[] parsedFileParams = extractedFile.Split('|'); string fileMD5 = parsedFileParams[1];
string filePath = parsedFileParams[0]; string fullFilePath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\" + filePath;
string fileMD5 = parsedFileParams[1];
string fullFilePath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\" + filePath;
if (!SecurityFuncs.CheckMD5(fileMD5, fullFilePath)) if (!SecurityFuncs.CheckMD5(fileMD5, fullFilePath))
{ {
#if URI #if URI
if (label != null) if (label != null)
{ {
label.Text = "The client has been detected as modified."; label.Text = "The client has been detected as modified.";
} }
#elif LAUNCHER #elif LAUNCHER
if (box != null) if (box != null)
{ {
@ -2082,25 +2057,24 @@ public class GlobalFuncs
#endif #endif
#if URI || LAUNCHER #if URI || LAUNCHER
MessageBox.Show("Failed to launch Novetus. (Error: The client has been detected as modified.)", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Failed to launch Novetus. (Error: The client has been detected as modified.)", "Novetus - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
#endif #endif
return; return;
}
else
{
GlobalVars.ValidatedExtraFiles += 1;
}
} }
#if URI || LAUNCHER || CMD || BASICLAUNCHER else
catch (Exception ex)
{ {
LogExceptions(ex); GlobalVars.ValidatedExtraFiles += 1;
}
}
#if URI || LAUNCHER || CMD || BASICLAUNCHER
catch (Exception ex)
{
LogExceptions(ex);
#else #else
catch (Exception) catch (Exception)
{ {
#endif #endif
continue; continue;
}
} }
} }
} }