private static bool ResponseIsCompatibleMimeType(NancyContext Context)
        {
            bool Status = false;

            try
            {
                if (Context.Response.ContentType != null)
                {
                    if (MimeTypes.Any(x => x == Context.Response.ContentType))
                    {
                        Status = true;
                    }
                    else if (MimeTypes.Any(x => Context.Response.ContentType.StartsWith($"{x};")))
                    {
                        Status = true;
                    }
                }

                if (EnableInsiderDeveloper.Allowed() && !Status)
                {
                    Log.Debug("Content Type? For " + Context.Request.Path + " " + Status);
                }
            }
            catch (Exception Error)
            {
                LogToFileAddons.OpenLog("ResponseIsCompatibleMimeType", null, Error, null, true);
            }
            return(Status);
        }
        private static bool RequestIsGzipCompatible(NancyContext Context)
        {
            bool Status = false;

            try
            {
                if (Context.Request.Headers.AcceptEncoding != null)
                {
                    if (Context.Request.Headers.AcceptEncoding.Any(x => x.Contains("gzip")))
                    {
                        Status = true;
                    }
                    else if (Context.Request.Headers.AcceptEncoding.Any(x => x.Contains("deflate")))
                    {
                        Status = true;
                    }
                }

                if (EnableInsiderDeveloper.Allowed() && !Status)
                {
                    Log.Debug("Gzip Compatible? For " + Context.Request.Path + " " + Status);
                }
            }
            catch (Exception Error)
            {
                LogToFileAddons.OpenLog("RequestIsGzipCompatible", null, Error, null, true);
            }
            return(Status);
        }
        private static bool ContentLengthIsTooSmall(NancyContext Context)
        {
            try
            {
                if (Context.Response.Headers == null)
                {
                    if (EnableInsiderDeveloper.Allowed())
                    {
                        Log.Debug("Headers is Null for " + Context.Request.Path);
                    }
                    return(true);
                }
                else
                {
                    if (!Context.Response.Headers.TryGetValue("Content-Length", out string ContentLength))
                    {
                        using (MemoryStream mm = new MemoryStream())
                        {
                            Context.Response.Contents.Invoke(mm);
                            mm.Flush();
                            ContentLength = mm.Length.ToString();
                        }
                    }
                    if (EnableInsiderDeveloper.Allowed())
                    {
                        Log.Debug($"GZip Content-Length of response is {ContentLength} for {Context.Request.Path}");
                    }

                    /* Wine Mono is Unable to Allow the Game to Continue compared to its Windows CounterPart */
                    if (long.Parse(ContentLength) > 0 || UnixOS.Detected())
                    {
                        return(false);
                    }
                    else
                    {
                        if (EnableInsiderDeveloper.Allowed())
                        {
                            Log.Debug($"GZip Content-Length is too small for {Context.Request.Path}");
                        }
                        return(true);
                    }
                }
            }
            catch (Exception Error)
            {
                LogToFileAddons.OpenLog("ContentLengthIsTooSmall", null, Error, null, true);
                return(true);
            }
        }
Example #4
0
 /// <summary>
 /// Executes the specified delegate on the thread that owns the control's underlying window handle.
 /// </summary>
 /// <returns>The delegate being invoked has no return value.</returns>
 /// <param name="Control_Form">Name of the Control</param>
 /// <param name="Action_Refresh">Parameters to be set for this Control</param>
 /// <param name="Window_Name">Name of the Parent Form</param>
 static public void SafeInvokeAction(this Control Control_Form, Action Action_Refresh, Form Window_Name)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(Window_Name.Name))
         {
             if (!(Application.OpenForms[Window_Name.Name] != null ? Application.OpenForms[Window_Name.Name].Disposing : true) && !Application.OpenForms[Window_Name.Name].IsDisposed)
             {
                 if (!Control_Form.IsDisposed || (Control_Form.IsHandleCreated && Control_Form.FindForm().IsHandleCreated))
                 {
                     if (!Control_Form.Disposing)
                     {
                         if (Control_Form.InvokeRequired)
                         {
                             Control_Form.Invoke(Action_Refresh);
                         }
                         else
                         {
                             Action_Refresh();
                         }
                     }
                     else
                     {
                         Log.Function("SafeInvokeAction".ToUpper() + "Control: " + Control_Form.Name + " is being Disposed");
                     }
                 }
                 else if (!Application.OpenForms[Window_Name.Name].IsDisposed)
                 {
                     Window_Name.Controls.Add(Control_Form);
                     SafeInvokeAction(Control_Form, Action_Refresh);
                     Log.Function("SafeInvokeAction: ".ToUpper() + "Control: " + Control_Form.Name + " was added to the Form: " + Window_Name.Name);
                 }
                 else if (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed())
                 {
                     Log.Function("SafeInvokeAction: ".ToUpper() + "Control: " + Control_Form + " <- Handle hasn't been Created or has been Disposed | Action: " + Action_Refresh + " Form: " + Window_Name);
                 }
             }
         }
         else if (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed())
         {
             Log.Function("SafeInvokeAction: ".ToUpper() + "Control: " + Control_Form + " Action: " + Action_Refresh + " Form: " + Window_Name + " <- Is Null");
         }
     }
     catch (Exception Error)
     {
         LogToFileAddons.OpenLog("Safe Invoker Action", null, Error, null, true);
     }
 }
        public static string Database(string Text_Request)
        {
            if (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed())
            {
                Log.Function("DATABASE: Requested: " + Text_Request + " Lang: " + Application_Language);
            }

            try
            {
                if (Lang_Launcher == null || ResetCache)
                {
                    switch (UI(Application_Language))
                    {
                    default:
                        Lang_Launcher = new ResourceManager("GameLauncher.App.Languages.English_Texts", Assembly.GetExecutingAssembly());
                        break;
                    }

                    ResetCache = false;
                }

                try
                {
                    if (!string.IsNullOrWhiteSpace(Text_Request) && Lang_Launcher != null)
                    {
                        return(Regex.Unescape(Lang_Launcher.GetString(Text_Request)));
                    }
                    else
                    {
                        return("Languages Programer ERROR");
                    }
                }
                catch (Exception Error)
                {
                    LogToFileAddons.OpenLog("Translations Database Selection", null, Error, null, true);
                    return("Languages Program ERROR");
                }
            }
            catch (Exception Error)
            {
                LogToFileAddons.OpenLog("Translations Database", null, Error, null, true);
                return("Languages ERROR");
            }
        }
Example #6
0
        public UpdatePopup()
        {
            DiscordLauncherPresence.Status("Start Up", "New Version Is Available: " + LauncherUpdateCheck.LatestLauncherBuild);
            InitializeComponent();
            SetVisuals();

            if (VisualsAPIChecker.GitHubAPI)
            {
                try
                {
                    ChangelogText.Text = (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed()) ?
                                         JsonConvert.DeserializeObject <List <GitHubRelease> >(LauncherUpdateCheck.VersionJSON)[0].Body.Replace("\r", Environment.NewLine) :
                                         JsonConvert.DeserializeObject <GitHubRelease>(LauncherUpdateCheck.VersionJSON).Body.Replace("\r", Environment.NewLine);
                }
                catch (Exception Error)
                {
                    LogToFileAddons.OpenLog("Update Popup", null, Error, null, true);
                    ChangelogText.Text = "\n" + Error.Message;
                    ChangelogBox.Text  = "Changelog Error:";
                }
            }
            else
            {
                ChangelogText.Text = "\nUnable to Retrieve Changelog";
                ChangelogBox.Text  = "Changelog Error:";
            }

            ChangelogText.Select(0, 0);
            ChangelogText.SelectionLength = 0;
            ChangelogText.TabStop         = false;

            Bitmap bitmap1 = Bitmap.FromHicon(SystemIcons.Information.Handle);

            UpdateIcon.Image = bitmap1;

            UpdateText.Text = "An update is available. Would you like to update?\nYour version: " + Application.ProductVersion +
                              "\nUpdated version: " + LauncherUpdateCheck.LatestLauncherBuild;

            this.UpdateButton.DialogResult = DialogResult.OK;
            this.IgnoreButton.DialogResult = DialogResult.Cancel;
            this.SkipButton.DialogResult   = DialogResult.Ignore;
        }
        private static bool ResponseIsCompressed(NancyContext Context)
        {
            bool Status = false;

            try
            {
                if (Context.Response.Headers.Keys != null)
                {
                    Status = Context.Response.Headers.Keys.Any(x => x.Contains("Content-Encoding"));
                }

                if (EnableInsiderDeveloper.Allowed() && !Status)
                {
                    Log.Debug("Is Compressed? For " + Context.Request.Path + " " + Status);
                }
            }
            catch (Exception Error)
            {
                LogToFileAddons.OpenLog("ResponseIsCompressed", null, Error, null, true);
            }
            return(Status);
        }
Example #8
0
 /// <summary>
 /// Executes the specified delegate on the thread that owns the control's underlying window handle.
 /// </summary>
 /// <returns>The delegate being invoked has no return value.</returns>
 /// <param name="Control_Form">Name of the Control</param>
 /// <param name="Action_Refresh">Parameters to be set for this Control</param>
 static public void SafeInvokeAction(this Control Control_Form, Action Action_Refresh)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(Control_Form.Name))
         {
             if (!Control_Form.IsDisposed || (Control_Form.IsHandleCreated && Control_Form.FindForm().IsHandleCreated))
             {
                 if (Control_Form.InvokeRequired)
                 {
                     Control_Form.Invoke(Action_Refresh);
                 }
                 else
                 {
                     Action_Refresh();
                 }
             }
             else if (!Control_Form.FindForm().IsDisposed)
             {
                 Control_Form.FindForm().Controls.Add(Control_Form);
                 SafeInvokeAction(Control_Form, Action_Refresh);
                 Log.Function("SafeInvokeAction: ".ToUpper() + "Control: " + Control_Form.Name + " was added to the Form: " + Control_Form.FindForm().Name);
             }
             else if (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed())
             {
                 Log.Function("SafeInvokeAction: ".ToUpper() + "Control: " + Control_Form + " <- Handle hasn't been Created or has been Disposed | Action: " + Action_Refresh);
             }
         }
         else if (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed())
         {
             Log.Function("SafeInvokeAction: ".ToUpper() + "Control: " + Control_Form + " <- Is Null | Action: " + Action_Refresh);
         }
     }
     catch (Exception Error)
     {
         LogToFileAddons.OpenLog("Safe Invoker Action [Control Only]", null, Error, null, true);
     }
 }
        private void StartGameScanner()
        {
            DiscordLauncherPresence.Status("Verify Scan", null);
            Log.Info("VERIFY HASH: Checking and Deleting '.orig' Files and Symbolic Folders");
            ScanProgressText.SafeInvokeAction(() => ScanProgressText.Text = "Removing any '.orig' Files in Game Directory");

            /* START Show Warning Text */
            VerifyHashText.SafeInvokeAction(() =>
            {
                VerifyHashText.ForeColor = Theming.WinFormWarningTextForeColor;
                VerifyHashText.Text      = "Warning:\nIf '.orig' Files Exist\nIt will be Removed Permanently";
            });
            /* END Show Warning Text */

            try
            {
                DirectoryInfo InstallationDirectory = new DirectoryInfo(FileSettingsSave.GameInstallation);

                foreach (DirectoryInfo FoldersWeFound in InstallationDirectory.GetDirectories())
                {
                    if (!ForceStopScan)
                    {
                        foreach (FileInfo FoundFile in InstallationDirectory.EnumerateFiles("*.orig", SearchOption.AllDirectories))
                        {
                            if (!ForceStopScan)
                            {
                                try
                                {
                                    FoundFile.Delete();
                                    LogVerify.Deleted("File: " + FoundFile.Name);
                                }
                                catch (Exception Error)
                                {
                                    DeletionError++;
                                    LogVerify.Error("File: " + FoundFile.Name + " Error: " + Error.Message);
                                    LogVerify.ErrorIC("File: " + FoundFile.Name + " Error: " + Error.HResult);
                                    LogVerify.ErrorFR("File: " + FoundFile.Name + " Error: " + Error.ToString());
                                }
                            }
                            else
                            {
                                break;
                            }
                        }

                        foreach (FileInfo FoundFile in FoldersWeFound.EnumerateFiles("*.orig", SearchOption.AllDirectories))
                        {
                            if (!ForceStopScan)
                            {
                                try
                                {
                                    FoundFile.Delete();
                                    LogVerify.Deleted("File: " + FoundFile.Name);
                                }
                                catch (Exception Error)
                                {
                                    DeletionError++;
                                    LogVerify.Error("File: " + FoundFile.Name + " Error: " + Error.Message);
                                    LogVerify.ErrorIC("File: " + FoundFile.Name + " Error: " + Error.HResult);
                                    LogVerify.ErrorFR("File: " + FoundFile.Name + " Error: " + Error.ToString());
                                }
                            }
                            else
                            {
                                break;
                            }
                        }

                        foreach (DirectoryInfo FoundDirectory in InstallationDirectory.EnumerateDirectories())
                        {
                            if (!ForceStopScan)
                            {
                                if (ModNetHandler.IsSymbolic(FoundDirectory.FullName))
                                {
                                    if (Directory.Exists(FoundDirectory.FullName))
                                    {
                                        try
                                        {
                                            Directory.Delete(FoundDirectory.FullName, true);
                                            LogVerify.Deleted("Folder: " + FoundDirectory.Name);
                                        }
                                        catch (Exception Error)
                                        {
                                            DeletionError++;
                                            LogVerify.Error("Folder: " + FoundDirectory.Name + " Error: " + Error.Message);
                                            LogVerify.ErrorIC("Folder: " + FoundDirectory.Name + " Error: " + Error.HResult);
                                            LogVerify.ErrorFR("Folder: " + FoundDirectory.Name + " Error: " + Error.ToString());
                                        }
                                    }
                                    else if (File.Exists(FoundDirectory.FullName))
                                    {
                                        try
                                        {
                                            File.Delete(FoundDirectory.FullName);
                                            LogVerify.Deleted("File: " + FoundDirectory.Name);
                                        }
                                        catch (Exception Error)
                                        {
                                            DeletionError++;
                                            LogVerify.Error("File: " + FoundDirectory.Name + " Error: " + Error.Message);
                                            LogVerify.ErrorIC("File: " + FoundDirectory.Name + " Error: " + Error.HResult);
                                            LogVerify.ErrorFR("File: " + FoundDirectory.Name + " Error: " + Error.ToString());
                                        }
                                    }
                                }
                            }
                            else
                            {
                                break;
                            }
                        }

                        foreach (DirectoryInfo FoundDirectory in FoldersWeFound.EnumerateDirectories())
                        {
                            if (!ForceStopScan)
                            {
                                if (ModNetHandler.IsSymbolic(FoundDirectory.FullName))
                                {
                                    if (Directory.Exists(FoundDirectory.FullName))
                                    {
                                        try
                                        {
                                            Directory.Delete(FoundDirectory.FullName, true);
                                            LogVerify.Deleted("Folder: " + FoundDirectory.Name);
                                        }
                                        catch (Exception Error)
                                        {
                                            DeletionError++;
                                            LogVerify.Error("Folder: " + FoundDirectory.Name + " Error: " + Error.Message);
                                            LogVerify.ErrorIC("Folder: " + FoundDirectory.Name + " Error: " + Error.HResult);
                                            LogVerify.ErrorFR("Folder: " + FoundDirectory.Name + " Error: " + Error.ToString());
                                        }
                                    }
                                    else if (File.Exists(FoundDirectory.FullName))
                                    {
                                        try
                                        {
                                            File.Delete(FoundDirectory.FullName);
                                            LogVerify.Deleted("File: " + FoundDirectory.Name);
                                        }
                                        catch (Exception Error)
                                        {
                                            DeletionError++;
                                            LogVerify.Error("File: " + FoundDirectory.Name + " Error: " + Error.Message);
                                            LogVerify.ErrorIC("File: " + FoundDirectory.Name + " Error: " + Error.HResult);
                                            LogVerify.ErrorFR("File: " + FoundDirectory.Name + " Error: " + Error.ToString());
                                        }
                                    }
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if (Directory.Exists(Path.Combine(FileSettingsSave.GameInstallation, "scripts")) && !ForceStopScan)
                {
                    DirectoryInfo ScriptsFolder = new DirectoryInfo(Path.Combine(FileSettingsSave.GameInstallation, "scripts"));

                    if (ScriptsFolder.EnumerateFiles().Count() > 1)
                    {
                        if (MessageBox.Show("Verify Hash has found files in the Scripts folder.\n" +
                                            "If you have installed custom Scripts or have not installed any Scripts" +
                                            "\n\nClick Yes, to Allow Deletion of Files" +
                                            "\nClick No, to Skip Deletion of Files", "VerifyHash", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            foreach (FileInfo FoundFile in ScriptsFolder.EnumerateFiles())
                            {
                                if (FoundFile.Name != "LangPicker.ini")
                                {
                                    try
                                    {
                                        File.Delete(FoundFile.FullName);
                                        LogVerify.Deleted("File: " + FoundFile.Name);
                                    }
                                    catch (Exception Error)
                                    {
                                        DeletionError++;
                                        LogVerify.Error("File: " + FoundFile.Name + " Error: " + Error.Message);
                                        LogVerify.ErrorIC("File: " + FoundFile.Name + " Error: " + Error.HResult);
                                        LogVerify.ErrorFR("File: " + FoundFile.Name + " Error: " + Error.ToString());
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception Error)
            {
                LogToFileAddons.OpenLog("VERIFY HASH", null, Error, null, true);
            }

            if (DeletionError != 0)
            {
                Log.Info("VERIFY HASH: Completed check for '.orig' Files and Symbolic Folders, BUT Encounterd a File or Folder Deletion Error. " +
                         "Check Verify.log for More Details");

                if (MessageBox.Show("Verify Hash has encountered File or Folder Deletion Errors.\n" +
                                    "Would you like to Open Verify.Log and Stop the Scanner?", "VerifyHash", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    string LogFile = Strings.Encode(Locations.LogVerify);
                    if (File.Exists(LogFile))
                    {
                        Process.Start(LogFile);
                    }

                    StopScanner_Click(null, null);
                }
            }
            else
            {
                Log.Info("VERIFY HASH: Completed check for '.orig' Files and Symbolic Folders");
            }

            if (!ForceStopScan)
            {
                try
                {
                    FunctionStatus.IsVerifyHashDisabled = true;

                    String[] getFilesToCheck = { };

                    if (File.Exists("checksums.dat") && EnableInsiderDeveloper.Allowed())
                    {
                        /* Read Local checksums.dat */
                        getFilesToCheck = File.ReadAllLines("checksums.dat");
                    }
                    else
                    {
                        /* Fetch and Read Remote checksums.dat */
                        ScanProgressText.SafeInvokeAction(() => ScanProgressText.Text = "Downloading Checksums File");

                        Uri URLCall = new Uri(FinalCDNURL + "/unpacked/checksums.dat");
                        ServicePointManager.FindServicePoint(URLCall).ConnectionLeaseTimeout = (int)TimeSpan.FromMinutes(1).TotalMilliseconds;
                        var Client = new WebClient
                        {
                            Encoding = Encoding.UTF8
                        };
                        if (!WebCalls.Alternative())
                        {
                            Client = new WebClientWithTimeout {
                                Encoding = Encoding.UTF8
                            };
                        }
                        else
                        {
                            Client.Headers.Add("user-agent", "SBRW Launcher " +
                                               Application.ProductVersion + " (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)");
                        }

                        bool ErrorFree = true;

                        try
                        {
                            getFilesToCheck = Client.DownloadString(URLCall).Split('\n');
                        }
                        catch (Exception Error)
                        {
                            LogToFileAddons.OpenLog("VERIFY HASH CHECKSUMS", "Downloading of the Checksums File has Encountered an Error", Error, "Error", false);
                            ErrorFree = false;
                        }
                        finally
                        {
                            if (Client != null)
                            {
                                Client.Dispose();
                            }
                        }

                        if (ErrorFree)
                        {
                            File.WriteAllLines("checksums.dat", getFilesToCheck);
                        }
                        else
                        {
                            StopScanner_Click(null, null);
                        }
                    }

                    scannedHashes = new string[getFilesToCheck.Length][];
                    for (var i = 0; i < getFilesToCheck.Length; i++)
                    {
                        if (!ForceStopScan)
                        {
                            scannedHashes[i] = getFilesToCheck[i].Split(' ');
                        }
                        else
                        {
                            break;
                        }
                    }
                    filesToScan       = scannedHashes.Length;
                    totalFilesScanned = 0;

                    /* START Show Warning Text */
                    VerifyHashText.SafeInvokeAction(() =>
                    {
                        VerifyHashText.ForeColor = Theming.WinFormWarningTextForeColor;
                        VerifyHashText.Text      = "Warning:\n Stopping the Scan before it is complete\nWill result in needing to start over!";
                    });
                    /* END Show Warning Text */

                    foreach (string[] file in scannedHashes)
                    {
                        if (!ForceStopScan)
                        {
                            String FileHash       = file[0].Trim();
                            String FileName       = file[1].Trim();
                            String RealPathToFile = FileSettingsSave.GameInstallation + FileName;

                            if (!File.Exists(RealPathToFile))
                            {
                                InvalidFileList.Add(FileName);
                                LogVerify.Missing("File: " + FileName);
                            }
                            else
                            {
                                if (FileHash != SHA.Files(RealPathToFile).Trim())
                                {
                                    InvalidFileList.Add(FileName);
                                    LogVerify.Invalid("File: " + FileName);
                                }
                                else
                                {
                                    LogVerify.Valid("File: " + FileName);
                                }
                            }
                            totalFilesScanned++;
                            ScanProgressText.SafeInvokeAction(() => ScanProgressText.Text = "Scanning Files: " + (totalFilesScanned * 100 / getFilesToCheck.Length) + "%");
                            ScanProgressBar.SafeInvokeAction(() => ScanProgressBar.Value  = totalFilesScanned * 100 / getFilesToCheck.Length);
                        }
                        else
                        {
                            break;
                        }
                    }

                    Log.Info("VERIFY HASH: Scan Completed");
                    if (!InvalidFileList.Any() || ForceStopScan)
                    {
                        StartScanner.SafeInvokeAction(() => StartScanner.Visible      = false);
                        StopScanner.SafeInvokeAction(() => StopScanner.Visible        = false);
                        ScanProgressText.SafeInvokeAction(() => ScanProgressText.Text = ForceStopScan ? "User Stopped Scan." : "Scan Complete. No Files Missing or Invalid!");

                        /* Hide the DownloadProgressBar as un-needed */
                        DownloadProgressBar.SafeInvokeAction(() => DownloadProgressBar.Visible   = false);
                        DownloadProgressText.SafeInvokeAction(() => DownloadProgressText.Visible = false);
                        /* Update the player messaging that we're done */
                        VerifyHashText.SafeInvokeAction(() =>
                        {
                            if (!ForceStopScan)
                            {
                                VerifyHashText.ForeColor = Theming.WinFormSuccessTextForeColor;
                            }
                            VerifyHashText.Text = ForceStopScan ? "Verify Hash Scan Process has been Terminated" : "Excellent News! There are ZERO\nmissing or invalid Gamefiles!";
                        });

                        Integrity();
                        GameScanner(false);
                    }
                    else
                    {
                        ScanProgressText.SafeInvokeAction(() => ScanProgressText.Text = "Found Invalid or Missing Files");

                        File.WriteAllLines("invalidfiles.dat", InvalidFileList);
                        Log.Info("VERIFY HASH: Found Invalid or Missing Files and will Start File Downloader");
                        CorruptedFilesFound();
                    }
                }
                catch (Exception Error)
                {
                    LogToFileAddons.OpenLog("VERIFY HASH", null, Error, null, true);
                }
            }
        }
Example #10
0
        private static void Start()
        {
            DiscordLauncherPresence.Start("Start Up", null);

            if (!UnixOS.Detected())
            {
                DiscordLauncherPresence.Status("Start Up", "Checking .NET Framework");
                try
                {
                    /* Check if User has a compatible .NET Framework Installed */
                    if (int.TryParse(RegistryCore.Read("Release", @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"), out int NetFrame_Version))
                    {
                        /* For now, allow edge case of Windows 8.0 to run .NET 4.6.1 where upgrading to 8.1 is not possible */
                        if (WindowsProductVersion.GetWindowsNumber() == 6.2 && NetFrame_Version <= 394254)
                        {
                            if (MessageBox.Show(null, Translations.Database("Program_TextBox_NetFrame_P1") +
                                                " .NETFramework, Version=v4.6.1 \n\n" + Translations.Database("Program_TextBox_NetFrame_P2"),
                                                "GameLauncher.exe - " + Translations.Database("Program_TextBox_NetFrame_P3"),
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
                            {
                                Process.Start("https://dotnet.microsoft.com/download/dotnet-framework/net461");
                            }

                            FunctionStatus.LauncherForceClose = true;
                        }
                        /* Otherwise, all other OS Versions should have 4.6.2 as a Minimum Version */
                        else if (NetFrame_Version <= 394802)
                        {
                            if (MessageBox.Show(null, Translations.Database("Program_TextBox_NetFrame_P1") +
                                                " .NETFramework, Version=v4.6.2 \n\n" + Translations.Database("Program_TextBox_NetFrame_P2"),
                                                "GameLauncher.exe - " + Translations.Database("Program_TextBox_NetFrame_P3"),
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
                            {
                                Process.Start("https://dotnet.microsoft.com/download/dotnet-framework");
                            }

                            FunctionStatus.LauncherForceClose = true;
                        }
                        else
                        {
                            Log.System("NET-FRAMEWORK: Supported Installed Version");
                        }
                    }
                    else
                    {
                        Log.Warning("NET-FRAMEWORK: Failed to Parse Version");
                    }
                }
                catch
                {
                    FunctionStatus.LauncherForceClose = true;
                }
            }

            if (FunctionStatus.LauncherForceClose)
            {
                FunctionStatus.ErrorCloseLauncher("Closing From .NET Framework Check", false);
            }
            else
            {
                /* Splash Screen */
                if (!Debugger.IsAttached)
                {
                    /* Starts Splash Screen */
                    SplashScreen.ThreadStatus("Start");
                }

                LogToFileAddons.RemoveLogs();
                Log.StartLogging();

                Log.Info("CURRENT DATE: " + Time.GetTime("Date"));
                Log.Checking("LAUNCHER MIGRATION: Appdata and/or Roaming Folders");
                /* Deletes Folders that will Crash the Launcher (Cleanup Migration) */
                try
                {
                    if (Directory.Exists(Strings.Encode(Path.Combine(Locations.LocalAppDataFolder, "Soapbox_Race_World"))))
                    {
                        Directory.Delete(Strings.Encode(Path.Combine(Locations.LocalAppDataFolder, "Soapbox_Race_World")), true);
                    }
                    if (Directory.Exists(Strings.Encode(Path.Combine(Locations.RoamingAppDataFolder, "Soapbox_Race_World"))))
                    {
                        Directory.Delete(Strings.Encode(Path.Combine(Locations.RoamingAppDataFolder, "Soapbox_Race_World")), true);
                    }
                    if (Directory.Exists(Strings.Encode(Path.Combine(Locations.LocalAppDataFolder, "SoapBoxRaceWorld"))))
                    {
                        Directory.Delete(Strings.Encode(Path.Combine(Locations.LocalAppDataFolder, "SoapBoxRaceWorld")), true);
                    }
                    if (Directory.Exists(Strings.Encode(Path.Combine(Locations.RoamingAppDataFolder, "SoapBoxRaceWorld"))))
                    {
                        Directory.Delete(Strings.Encode(Path.Combine(Locations.RoamingAppDataFolder, "SoapBoxRaceWorld")), true);
                    }
                    if (Directory.Exists(Strings.Encode(Path.Combine(Locations.LocalAppDataFolder, "WorldUnited.gg"))))
                    {
                        Directory.Delete(Strings.Encode(Path.Combine(Locations.LocalAppDataFolder, "WorldUnited.gg")), true);
                    }
                    if (Directory.Exists(Strings.Encode(Path.Combine(Locations.RoamingAppDataFolder, "WorldUnited.gg"))))
                    {
                        Directory.Delete(Strings.Encode(Path.Combine(Locations.RoamingAppDataFolder, "WorldUnited.gg")), true);
                    }
                }
                catch (Exception Error)
                {
                    LogToFileAddons.OpenLog("LAUNCHER MIGRATION", null, Error, null, true);
                }
                Log.Completed("LAUNCHER MIGRATION");

                Log.Checking("LAUNCHER XML: If File Exists or Not");
                DiscordLauncherPresence.Status("Start Up", "Checking if UserSettings XML Exists");
                /* Create Default Configuration Files (if they don't already exist) */
                if (!File.Exists(Locations.UserSettingsXML))
                {
                    try
                    {
                        if (!Directory.Exists(Locations.UserSettingsFolder))
                        {
                            Directory.CreateDirectory(Locations.UserSettingsFolder);
                        }

                        File.WriteAllBytes(Locations.UserSettingsXML, ExtractResource.AsByte("GameLauncher.Resources.UserSettings.UserSettings.xml"));
                    }
                    catch (Exception Error)
                    {
                        LogToFileAddons.OpenLog("LAUNCHER XML", null, Error, null, true);
                    }
                }
                Log.Completed("LAUNCHER XML");

                string Insider = string.Empty;
                if (EnableInsiderDeveloper.Allowed())
                {
                    Insider = "DEV TEST ";
                }
                else if (EnableInsiderBetaTester.Allowed())
                {
                    Insider = "BETA TEST ";
                }

                Log.Build(Insider + "BUILD: GameLauncher " + Application.ProductVersion + "_" + InsiderInfo.BuildNumberOnly());

                Log.Checking("OS: Detecting");
                DiscordLauncherPresence.Status("Start Up", "Checking Operating System");
                try
                {
                    if (UnixOS.Detected())
                    {
                        InformationCache.OSName = UnixOS.FullName();
                        Log.System("SYSTEM: Detected OS: " + InformationCache.OSName);
                    }
                    else
                    {
                        InformationCache.OSName = WindowsProductVersion.ConvertWindowsNumberToName();
                        Log.System("SYSTEM: Detected OS: " + InformationCache.OSName);
                        Log.System("SYSTEM: Windows Build: " + WindowsProductVersion.GetWindowsBuildNumber());
                        Log.System("SYSTEM: NT Version: " + Environment.OSVersion.VersionString);
                        Log.System("SYSTEM: Video Card: " + HardwareInfo.GPU.CardName());
                        Log.System("SYSTEM: Driver Version: " + HardwareInfo.GPU.DriverVersion());
                    }
                    Log.Completed("OS: Detected");
                }
                catch (Exception Error)
                {
                    LogToFileAddons.OpenLog("SYSTEM", null, Error, null, true);
                    FunctionStatus.LauncherForceCloseReason = "Code: 0\n" + Translations.Database("Program_TextBox_System_Detection") + "\n" + Error.Message;
                    FunctionStatus.LauncherForceClose       = true;
                }

                if (FunctionStatus.LauncherForceClose)
                {
                    FunctionStatus.ErrorCloseLauncher("Closing From Operating System Check", false);
                }
                else
                {
                    /* Set Launcher Directory */
                    Log.Checking("SETUP: Setting Launcher Folder Directory");
                    Directory.SetCurrentDirectory(Locations.LauncherFolder);
                    Log.Completed("SETUP: Current Directory now Set at -> " + Locations.LauncherFolder);

                    if (!UnixOS.Detected())
                    {
                        Log.Checking("FOLDER LOCATION: Checking Launcher Folder Directory");
                        DiscordLauncherPresence.Status("Start Up", "Checking Launcher Folder Locations");

                        switch (FunctionStatus.CheckFolder(Locations.LauncherFolder))
                        {
                        case FolderType.IsTempFolder:
                        case FolderType.IsUsersFolders:
                        case FolderType.IsProgramFilesFolder:
                        case FolderType.IsWindowsFolder:
                        case FolderType.IsRootFolder:
                            String Constructed_Msg = String.Empty;

                            Constructed_Msg += Translations.Database("Program_TextBox_Folder_Check_Launcher") + "\n\n";
                            Constructed_Msg += Translations.Database("Program_TextBox_Folder_Check_Launcher_P2") + "\n";
                            Constructed_Msg += "• X:\\GameLauncher.exe " + Translations.Database("Program_TextBox_Folder_Check_Launcher_P3") + "\n";
                            Constructed_Msg += "• C:\\Program Files\n";
                            Constructed_Msg += "• C:\\Program Files (x86)\n";
                            Constructed_Msg += "• C:\\Users " + Translations.Database("Program_TextBox_Folder_Check_Launcher_P4") + "\n";
                            Constructed_Msg += "• C:\\Windows\n\n";
                            Constructed_Msg += Translations.Database("Program_TextBox_Folder_Check_Launcher_P5") + "\n";
                            Constructed_Msg += "• 'C:\\Soapbox Race World' " + Translations.Database("Program_TextBox_Folder_Check_Launcher_P6") + " 'C:\\SBRW'\n";
                            Constructed_Msg += Translations.Database("Program_TextBox_Folder_Check_Launcher_P7") + "\n\n";

                            MessageBox.Show(null, Constructed_Msg, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            FunctionStatus.LauncherForceClose = true;
                            break;
                        }

                        Log.Completed("FOLDER LOCATION: Done");
                    }

                    if (FunctionStatus.LauncherForceClose)
                    {
                        FunctionStatus.ErrorCloseLauncher("Closing From Invalid Launcher Location", false);
                    }
                    else
                    {
                        Log.Checking("WRITE TEST: Launcher Folder Test");
                        if (!FunctionStatus.HasWriteAccessToFolder(Locations.LauncherFolder))
                        {
                            MessageBox.Show(Translations.Database("Program_TextBox_Folder_Write_Test"));
                        }
                        Log.Completed("WRITE TEST: Passed");

                        Log.Checking("INI FILES: Doing Nullsafe");
                        DiscordLauncherPresence.Status("Start Up", "Doing NullSafe ini Files");
                        FileSettingsSave.NullSafeSettings();
                        FileAccountSave.NullSafeAccount();
                        Log.Completed("INI FILES: Done");
                        /* Sets up Theming */
                        Theming.CheckIfThemeExists();

                        Log.Function("APPLICATION: Setting Language");
                        CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo(Translations.UI(Translations.Application_Language = FileSettingsSave.Lang.ToLower(), true));
                        Log.Completed("APPLICATION: Done Setting Language '" + Translations.UI(Translations.Application_Language) + "'");

                        /* Windows 7 TLS Check */
                        if (WindowsProductVersion.GetWindowsNumber() == 6.1)
                        {
                            Log.Checking("SSL/TLS: Windows 7 Detected");
                            DiscordLauncherPresence.Status("Start Up", "Checking Windows 7 SSL/TLS");

                            try
                            {
                                String MessageBoxPopupTLS = String.Empty;
                                string keyName            = @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client";
                                string subKey             = "DisabledByDefault";

                                if (Registry.GetValue(keyName, subKey, null) == null)
                                {
                                    MessageBoxPopupTLS = Translations.Database("Program_TextBox_W7_TLS_P1") + "\n\n";

                                    MessageBoxPopupTLS += "- HKLM/SYSTEM/CurrentControlSet/Control/SecurityProviders\n  /SCHANNEL/Protocols/TLS 1.2/Client\n";
                                    MessageBoxPopupTLS += "- Value: DisabledByDefault -> 0\n\n";

                                    MessageBoxPopupTLS += Translations.Database("Program_TextBox_W7_TLS_P2") + "\n\n";
                                    MessageBoxPopupTLS += Translations.Database("Program_TextBox_W7_TLS_P3");

                                    /* There is only 'OK' Available because this IS Required */
                                    if (MessageBox.Show(null, MessageBoxPopupTLS, "SBRW Launcher",
                                                        MessageBoxButtons.OK, MessageBoxIcon.Warning) == DialogResult.OK)
                                    {
                                        RegistryCore.Write("DisabledByDefault", 0x0,
                                                           @"SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client");
                                        MessageBox.Show(null, Translations.Database("Program_TextBox_W7_TLS_P4"),
                                                        "SBRW Launcher", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    }
                                    Log.Completed("SSL/TLS: Added Registry Key");
                                }
                                else
                                {
                                    Log.Completed("SSL/TLS: Done");
                                }
                            }
                            catch (Exception Error)
                            {
                                LogToFileAddons.OpenLog("SSL/TLS", null, Error, null, true);
                            }
                        }

                        /* Windows 7 HotFix Check */
                        if (WindowsProductVersion.GetWindowsNumber() == 6.1 && string.IsNullOrWhiteSpace(FileSettingsSave.Win7UpdatePatches))
                        {
                            Log.Checking("HotFixes: Windows 7 Detected");
                            DiscordLauncherPresence.Status("Start Up", "Checking Windows 7 HotFixes");

                            try
                            {
                                if (!ManagementSearcher.GetInstalledHotFix("KB3020369") || !ManagementSearcher.GetInstalledHotFix("KB3125574"))
                                {
                                    String MessageBoxPopupKB = String.Empty;
                                    MessageBoxPopupKB  = Translations.Database("Program_TextBox_W7_KB_P1") + "\n";
                                    MessageBoxPopupKB += Translations.Database("Program_TextBox_W7_KB_P2") + "\n\n";

                                    if (!ManagementSearcher.GetInstalledHotFix("KB3020369"))
                                    {
                                        MessageBoxPopupKB += "- " + Translations.Database("Program_TextBox_W7_KB_P3") + " KB3020369\n";
                                    }

                                    if (!ManagementSearcher.GetInstalledHotFix("KB3125574"))
                                    {
                                        MessageBoxPopupKB += "- " + Translations.Database("Program_TextBox_W7_KB_P3") + " KB3125574\n";
                                    }
                                    MessageBoxPopupKB += "\n" + Translations.Database("Program_TextBox_W7_KB_P4") + "\n";

                                    if (MessageBox.Show(null, MessageBoxPopupKB, "SBRW Launcher",
                                                        MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                                    {
                                        /* Since it's Informational we just need to know if they clicked 'OK' */
                                        FileSettingsSave.Win7UpdatePatches = "1";
                                    }
                                    else
                                    {
                                        /* or if they clicked 'Cancel' */
                                        FileSettingsSave.Win7UpdatePatches = "0";
                                    }

                                    FileSettingsSave.SaveSettings();
                                }

                                Log.Completed("HotFixes: Done");
                            }
                            catch (Exception Error)
                            {
                                LogToFileAddons.OpenLog("HotFixes", null, Error, null, true);
                            }
                        }
                    }

                    Log.Checking("JSON: Servers File");
                    try
                    {
                        if (File.Exists(Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameOldServersJSON))))
                        {
                            if (File.Exists(Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameNewServersJSON))))
                            {
                                File.Delete(Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameNewServersJSON)));
                            }

                            File.Move(
                                Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameOldServersJSON)),
                                Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameNewServersJSON)));
                            Log.Completed("JSON: Renaming Servers File");
                        }
                        else if (!File.Exists(Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameNewServersJSON))))
                        {
                            try
                            {
                                File.WriteAllText(
                                    Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameNewServersJSON)), "[]");
                                Log.Completed("JSON: Created Servers File");
                            }
                            catch (Exception Error)
                            {
                                LogToFileAddons.OpenLog("JSON SERVER FILE", null, Error, null, true);
                            }
                        }
                    }
                    catch (Exception Error)
                    {
                        LogToFileAddons.OpenLog("JSON SERVER FILE", null, Error, null, true);
                    }
                    Log.Checking("JSON: Done");

                    if (!string.IsNullOrWhiteSpace(FileSettingsSave.GameInstallation))
                    {
                        Log.Checking("CLEANLINKS: Game Path");
                        if (File.Exists(Locations.GameLinksFile))
                        {
                            ModNetHandler.CleanLinks(Locations.GameLinksFile, FileSettingsSave.GameInstallation);
                            Log.Completed("CLEANLINKS: Done");
                        }
                        else
                        {
                            Log.Completed("CLEANLINKS: Not Present");
                        }
                    }

                    Log.Checking("PROXY: Checking if Proxy Is Disabled from User Settings! It's value is " + FileSettingsSave.Proxy);
                    if (FileSettingsSave.Proxy == "0")
                    {
                        Log.Core("PROXY: Starting Proxy (From Startup)");
                        ServerProxy.Instance.Start("Splash Screen [Program.cs]");
                        Log.Completed("PROXY: Started");
                    }
                    else
                    {
                        Log.Completed("PROXY: Disabled");
                    }

                    Log.Info("REDISTRIBUTABLE: Moved to Function");
                    /* (Starts Function Chain) Check if Redistributable Packages are Installed */
                    Redistributable.Check();
                }
            }
        }
        public static void Latest()
        {
            Log.Checking("LAUNCHER UPDATE: Is Version Up to Date or not");
            DiscordLauncherPresence.Status("Start Up", "Checking Latest Launcher Release Information");
            try
            {
                Uri URLCall = new Uri((EnableInsiderBetaTester.Allowed() || EnableInsiderDeveloper.Allowed()) ?
                                      URLs.GitHub_Launcher_Beta : URLs.GitHub_Launcher_Stable);
                ServicePointManager.FindServicePoint(URLCall).ConnectionLeaseTimeout = (int)TimeSpan.FromMinutes(1).TotalMilliseconds;
                var Client = new WebClient
                {
                    Encoding = Encoding.UTF8
                };

                if (!WebCalls.Alternative())
                {
                    Client = new WebClientWithTimeout {
                        Encoding = Encoding.UTF8
                    };
                }
                else
                {
                    Client.Headers.Add("user-agent", "SBRW Launcher " +
                                       Application.ProductVersion + " (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)");
                }

                try
                {
                    VersionJSON = Client.DownloadString(URLCall);
                    VisualsAPIChecker.GitHubAPI = true;
                }
                catch (WebException Error)
                {
                    APIChecker.StatusCodes(URLCall.GetComponents(UriComponents.HttpRequestUrl, UriFormat.SafeUnescaped),
                                           Error, (HttpWebResponse)Error.Response);
                }
                catch (Exception Error)
                {
                    LogToFileAddons.OpenLog("LAUNCHER UPDATE [GITHUB]", null, Error, null, true);
                }
                finally
                {
                    if (Client != null)
                    {
                        Client.Dispose();
                    }
                }

                if (IsJSONValid.ValidJson(VersionJSON) && VisualsAPIChecker.GitHubAPI)
                {
                    LatestLauncherBuild = (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed()) ?
                                          JsonConvert.DeserializeObject <List <GitHubRelease> >(VersionJSON)[0].TagName :
                                          JsonConvert.DeserializeObject <GitHubRelease>(VersionJSON).TagName;
                    Log.Info("LAUNCHER UPDATE: GitHub Latest Version -> " + LatestLauncherBuild);
                    ValidJSONDownload = true;
                }
                else
                {
                    Log.Error("LAUNCHER UPDATE: Failed to retrieve Latest Build information from GitHub");
                    ValidJSONDownload = false;
                }
            }
            catch (Exception Error)
            {
                LogToFileAddons.OpenLog("LAUNCHER UPDATE [GITHUB]", null, Error, null, true);
            }

            Log.Completed("LAUNCHER UPDATE: Done");

            if (!UpdateStatusResult())
            {
                Log.Info("FIRST TIME RUN: Moved to Function");
                /* Do First Time Run Checks */
                FunctionStatus.FirstTimeRun();
            }
            else
            {
                if (DiscordLauncherPresence.Running())
                {
                    DiscordLauncherPresence.Stop("Close");
                }

                if (ServerProxy.Running())
                {
                    ServerProxy.Instance.Stop("Force Close");
                }

                Application.Exit();
            }
        }
        public void ChangeVisualStatus()
        {
            if (!string.IsNullOrWhiteSpace(LatestLauncherBuild))
            {
                if (Revisions > 0)
                {
                    string WhatBuildAmI;
                    if (EnableInsiderDeveloper.Allowed())
                    {
                        WhatBuildAmI = Translations.Database("LauncherUpdateCheck_VS_Insider_Dev");
                    }
                    else if (EnableInsiderBetaTester.Allowed())
                    {
                        WhatBuildAmI = Translations.Database("LauncherUpdateCheck_VS_Insider_Beta");
                    }
                    else
                    {
                        WhatBuildAmI = Translations.Database("LauncherUpdateCheck_VS_Insider_Unofficial");
                    }

                    text.Text = Translations.Database("LauncherUpdateCheck_VS_Insider") + "\n - " + WhatBuildAmI +
                                " " + Translations.Database("LauncherUpdateCheck_VS_Insider_Text_Build");
                    status.BackgroundImage = Theming.UpdateIconWarning;
                    text.ForeColor         = Theming.Warning;
                    description.Text       = Translations.Database("LauncherUpdateCheck_VS_Insider_Text_Stable") + " " + LatestLauncherBuild +
                                             "\n" + Translations.Database("LauncherUpdateCheck_VS_Insider_Text_Current") + " " + Application.ProductVersion;

                    if (!string.IsNullOrWhiteSpace(FileSettingsSave.IgnoreVersion))
                    {
                        FileSettingsSave.IgnoreVersion = String.Empty;
                        FileSettingsSave.SaveSettings();
                        Log.Info("IGNOREUPDATEVERSION: Cleared OLD IgnoreUpdateVersion Build Number. " +
                                 "You are currenly using a " + WhatBuildAmI + " Build!");
                    }
                }
                else if (Revisions == 0)
                {
                    text.Text = Translations.Database("LauncherUpdateCheck_VS_Text_No_Update");
                    status.BackgroundImage = Theming.UpdateIconSuccess;
                    text.ForeColor         = Theming.Sucess;
                    description.Text       = Translations.Database("LauncherUpdateCheck_VS_Text_Version") + " " + Application.ProductVersion;

                    if (FileSettingsSave.IgnoreVersion == Application.ProductVersion)
                    {
                        FileSettingsSave.IgnoreVersion = String.Empty;
                        FileSettingsSave.SaveSettings();
                        Log.Info("IGNOREUPDATEVERSION: Cleared OLD IgnoreUpdateVersion Build Number. You're now on the Latest Game Launcher!");
                    }
                }
                else
                {
                    text.Text = Translations.Database("LauncherUpdateCheck_VS_Text_Update");
                    status.BackgroundImage = Theming.UpdateIconWarning;
                    text.ForeColor         = Theming.Warning;
                    description.Text       = Translations.Database("LauncherUpdateCheck_VS_Text_Update_New") + " " + LatestLauncherBuild + "\n" +
                                             Translations.Database("LauncherUpdateCheck_VS_Insider_Text_Current") + " " + Application.ProductVersion;
                    UpgradeAvailable = true;
                    if (SkipAvailableUpgrade)
                    {
                        FileSettingsSave.IgnoreVersion = LatestLauncherBuild;
                        FileSettingsSave.SaveSettings();
                        Log.Info("IGNOREUPDATEVERSION: User had skipped latest Launcher Version!");
                    }
                }
            }
            else if (VisualsAPIChecker.GitHubAPI && !ValidJSONDownload)
            {
                text.Text = Translations.Database("LauncherUpdateCheck_VS_Text_Invalid_JSON");
                status.BackgroundImage = Theming.UpdateIconError;
                text.ForeColor         = Theming.Error;
                description.Text       = Translations.Database("LauncherUpdateCheck_VS_Text_Version") + " " + Application.ProductVersion;
            }
            else
            {
                text.Text = Translations.Database("LauncherUpdateCheck_VS_Text_Invalid_Error");
                status.BackgroundImage = Theming.UpdateIconUnknown;
                text.ForeColor         = Theming.ThirdTextForeColor;
                description.Text       = Translations.Database("LauncherUpdateCheck_VS_Text_Version") + " " + Application.ProductVersion;
            }
        }
        private static bool UpdateStatusResult()
        {
            bool StatusUpdate = false;

            if (!string.IsNullOrWhiteSpace(LatestLauncherBuild))
            {
                Revisions = CurrentLauncherBuild.CompareTo(LatestLauncherBuild);

                if (Revisions < 0)
                {
                    Log.Info("LAUNCHER POPUP: Checking if Popup is Required");

                    if (FileSettingsSave.IgnoreVersion != LatestLauncherBuild)
                    {
                        FunctionStatus.LoadingComplete = true;
                        SplashScreen.ThreadStatus("Stop");
                        UpdatePopupStoppedSplashScreen = true;

                        DialogResult UserResult = new UpdatePopup().ShowDialog();

                        if (UserResult == DialogResult.OK)
                        {
                            StatusUpdate = true;
                            string UpdaterPath = Strings.Encode(Path.Combine(Locations.LauncherFolder, Locations.NameUpdater));
                            if (File.Exists(UpdaterPath))
                            {
                                Process.Start(UpdaterPath, Process.GetCurrentProcess().Id.ToString() + " " +
                                              (EnableInsiderBetaTester.Allowed() || EnableInsiderDeveloper.Allowed() ? "Preview" : "Stable"));
                            }
                            else
                            {
                                Process.Start(@"https://github.com/SoapboxRaceWorld/GameLauncher_NFSW/releases/latest");
                                MessageBox.Show(null, Translations.Database("LauncherUpdateCheck_FS"), "GameLauncher", MessageBoxButtons.OK);
                            }
                        }
                        else if (UserResult == DialogResult.Ignore)
                        {
                            /* Save and Allow Version Update Skip Once user Reaches Main Screen */
                            SkipAvailableUpgrade = true;
                        }
                    }
                    else
                    {
                        Log.Completed("LAUNCHER POPUP: User Saved Skip Version Detected");
                    }
                }
                else
                {
                    Log.Completed("LAUNCHER POPUP: Update to Date");
                }
            }
            else
            {
                Log.Completed("LAUNCHER POPUP: Unable to run Update Popup (Null String)");
            }

            if (VersionJSON != null)
            {
                VersionJSON = null;
            }

            return(StatusUpdate);
        }
        public static void Get()
        {
            try
            {
                int    AmountOfRes     = 0;
                string JSONResolutions = string.Empty;

                List <JsonResolutions> LocalResolutionsList = new List <JsonResolutions>();
                DEVMODE vDevMode = new DEVMODE();

                JSONResolutions += "[";
                while (EnumDisplaySettings(null, AmountOfRes, ref vDevMode))
                {
                    JSONResolutions += "{\"resolution\": \"" + vDevMode.dmPelsWidth + "x" + vDevMode.dmPelsHeight + "\", \"dmPelsWidth\": \"" +
                                       vDevMode.dmPelsWidth + "\", \"dmPelsHeight\": \"" + vDevMode.dmPelsHeight + "\"},";
                    if (EnableInsiderDeveloper.Allowed())
                    {
                        Log.Debug("SCREENRESOLUTIONS: " + AmountOfRes + " Width: " + vDevMode.dmPelsWidth + " Height: " + vDevMode.dmPelsHeight +
                                  " Color: " + (1 << vDevMode.dmBitsPerPel) + " Frequency: " + vDevMode.dmDisplayFrequency);
                    }
                    AmountOfRes++;
                }

                if (!string.IsNullOrWhiteSpace(FileGameSettingsData.ScreenWidth) && !string.IsNullOrWhiteSpace(FileGameSettingsData.ScreenHeight))
                {
                    JSONResolutions += "{\"resolution\": \"" + FileGameSettingsData.ScreenWidth + "x" + FileGameSettingsData.ScreenHeight +
                                       "\", \"dmPelsWidth\": \"" + FileGameSettingsData.ScreenWidth + "\", \"dmPelsHeight\": \"" + FileGameSettingsData.ScreenHeight + "\"}";
                }
                JSONResolutions += "]";

                if (EnableInsiderDeveloper.Allowed())
                {
                    Log.Debug("SCREENRESOLUTIONS: LIST -> " + JSONResolutions);
                }

                try
                {
                    LocalResolutionsList.AddRange(JsonConvert.DeserializeObject <List <JsonResolutions> >(JSONResolutions));
                }
                catch (Exception Error)
                {
                    LogToFileAddons.OpenLog("SCREENRESOLUTIONS", null, Error, null, true);
                }

                try
                {
                    foreach (JsonResolutions CList in LocalResolutionsList)
                    {
                        if (List.FindIndex(i => string.Equals(i.Resolution, CList.Resolution)) == -1)
                        {
                            List.Add(CList);
                        }
                    }
                }
                catch (Exception Error)
                {
                    LogToFileAddons.OpenLog("SCREENRESOLUTIONS", null, Error, null, true);
                }
            }
            catch (Exception Error)
            {
                LogToFileAddons.OpenLog("SCREENRESOLUTIONS", null, Error, null, true);
            }
        }
        public static void CleanLinks(string LinksFile, string GamePath)
        {
            try
            {
                if (File.Exists(LinksFile))
                {
                    Log.Info("CLEANLINKS: Found Server Mod Files to remove {Process}");
                    string dir       = Strings.Encode(GamePath);
                    string linksPath = Strings.Encode(Path.Combine(GamePath, ".links"));
                    foreach (var readLine in File.ReadLines(linksPath))
                    {
                        var parts = readLine.Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

                        if (parts.Length != 2)
                        {
                            continue;
                        }

                        string loc     = parts[0];
                        int    type    = int.Parse(parts[1]);
                        string realLoc = Path.Combine(dir, loc);
                        if (type == 0)
                        {
                            string origPath = realLoc + ".orig";

                            if (IsSymbolic(realLoc) && File.Exists(realLoc))
                            {
                                File.Delete(realLoc);
                                if (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed())
                                {
                                    Log.Info("CLEANLINKS: Removed Symbolic File " + realLoc);
                                }
                                continue;
                            }
                            else if (!File.Exists(realLoc))
                            {
                                FileErrors++;

                                if (!File.Exists(origPath))
                                {
                                    Log.Warning("CLEANLINKS: .links file includes nonexistent file, but there is no .orig file: [" + realLoc + "] Skipping File");
                                    continue;
                                }
                                else if (File.Exists(origPath))
                                {
                                    Log.Error("CLEANLINKS: Found .orig file that should not be present. Deleting File: " + origPath);
                                    File.Delete(origPath);
                                    continue;
                                }
                                else
                                {
                                    Log.Error("CLEANLINKS: .links file includes nonexistent file. Skipping File: " + realLoc);
                                    continue;
                                }
                            }
                            else if (!File.Exists(origPath))
                            {
                                if (File.Exists(realLoc))
                                {
                                    File.Delete(realLoc);
                                }
                                continue;
                            }

                            try
                            {
                                if (File.Exists(realLoc))
                                {
                                    File.Delete(realLoc);
                                }

                                File.Move(origPath, realLoc);
                            }
                            catch (Exception Error)
                            {
                                FileErrors++;

                                Log.Error("CLEANLINKS: Error while deleting a file: {realLoc}");
                                LogToFileAddons.OpenLog("CLEANLINKS", null, Error, null, true);
                            }
                        }
                        else
                        {
                            if (IsSymbolic(realLoc) && Directory.Exists(realLoc))
                            {
                                Directory.Delete(realLoc, true);
                                if (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed())
                                {
                                    Log.Info("CLEANLINKS: Removed Symbolic Folder " + realLoc);
                                }
                                continue;
                            }
                            else if (!Directory.Exists(realLoc))
                            {
                                FileErrors++;

                                Log.Error("CLEANLINKS: .links file includes nonexistent directory. Skipping Directory: " + realLoc);
                                continue;
                            }

                            if (Directory.Exists(realLoc))
                            {
                                Directory.Delete(realLoc, true);
                            }
                        }
                    }

                    if (FileErrors > 0)
                    {
                        FileSettingsSave.GameIntegrity = "Bad";
                        FileSettingsSave.SaveSettings();
                        FileErrors = 0;
                    }

                    File.Delete(linksPath);
                }
            }
            catch (Exception Error)
            {
                LogToFileAddons.OpenLog("CLEANLINKS", null, Error, null, true);
            }
        }
Example #16
0
        public static string NodeReader(XmlDocument LocationData, string Type, string FullNodePath, string AttributeName)
        {
            try
            {
                if (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed())
                {
                    Log.Info("XMLSERVERCORE: Attmempting to Read XML [NodePath: '" + FullNodePath + "' Attribute: '" + AttributeName + "']");
                }
                if (Type == "InnerText")
                {
                    if (string.IsNullOrWhiteSpace(LocationData.SelectSingleNode(FullNodePath) != null ?
                                                  LocationData.SelectSingleNode(FullNodePath).InnerText : string.Empty))
                    {
                        if (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed())
                        {
                            Log.Info("XMLSERVERCORE: EMPTY VALUE - LAUNCHER");
                        }
                        return("EMPTY VALUE - LAUNCHER");
                    }

                    return(LocationData.SelectSingleNode(FullNodePath).InnerText);
                }
                else if (Type == "NodeOnly")
                {
                    if ((LocationData.SelectSingleNode(FullNodePath) ?? null) == null)
                    {
                        if (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed())
                        {
                            Log.Info("XMLSERVERCORE: INVALID NODE - LAUNCHER");
                        }
                        return("INVALID NODE - LAUNCHER");
                    }

                    return("VAILD NODE - LAUNCHER");
                }
                else
                {
                    return("UNKNOWN TYPE - LAUNCHER");
                }
            }
            catch (Exception Error)
            {
                if (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed())
                {
                    Log.Error("XMLSERVERCORE: Unable to Read XML [NodePath: '" + FullNodePath + "' Attribute: '" + AttributeName + "']" + Error.Message);
                    Log.ErrorIC("XMLSERVERCORE: " + Error.HResult);
                    Log.ErrorFR("XMLSERVERCORE: " + Error.ToString());
                }
                if (Type == "InnerText")
                {
                    if (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed())
                    {
                        Log.Error("XMLSERVERCORE: ERROR VALUE - LAUNCHER");
                    }
                    return("ERROR VALUE - LAUNCHER");
                }
                else if (Type == "NodeOnly")
                {
                    if (EnableInsiderDeveloper.Allowed() || EnableInsiderBetaTester.Allowed())
                    {
                        Log.Error("XMLSERVERCORE: ERROR NODE - LAUNCHER");
                    }
                    return("ERROR NODE - LAUNCHER");
                }
                else
                {
                    return("ERROR UNKNOWN TYPE - LAUNCHER");
                }
            }
        }
Example #17
0
        /// <summary>
        /// Form Url or Post Request to the Server for Login and Registration
        /// </summary>
        /// <remarks>Non Secure: Uses regualar URL Request. Secure: Uses Post Request</remarks>
        /// <returns>Receives UserId and Auth Key for Login. Sends Email and Password to Server</returns>
        /// <param name="ConnectionProtocol">Connection Protocol: Check AuthProtocol</param>
        /// <param name="Method">Form Type: "Login" or "Register"</param>
        public static void Client(string Method, bool Modern_Auth, String Email, String Password, String Token)
        {
            try
            {
                if (!Modern_Auth)
                {
                    Uri URLCall =
                        new Uri((Method == "Login") ? Tokens.IPAddress + "/User/authenticateUser?email=" + Email + "&password="******"/User/createUser?email=" + Email + "&password="******"&inviteTicket=" + Token : ""));
                    ServicePointManager.FindServicePoint(URLCall).ConnectionLeaseTimeout = (int)TimeSpan.FromMinutes(1).TotalMilliseconds;
                    var Client = new WebClient
                    {
                        Encoding = Encoding.UTF8
                    };

                    if (!WebCalls.Alternative())
                    {
                        Client = new WebClientWithTimeout {
                            Encoding = Encoding.UTF8
                        };
                    }
                    else
                    {
                        Client.Headers.Add("user-agent", "SBRW Launcher " +
                                           Application.ProductVersion + " (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)");
                        Client.Headers["X-HWID"]       = HardwareID.FingerPrint.Value();
                        Client.Headers["X-HiddenHWID"] = HardwareID.FingerPrint.ValueAlt();
                        Client.Headers["X-UserAgent"]  = "GameLauncherReborn " +
                                                         Application.ProductVersion + " WinForms (+https://github.com/SoapBoxRaceWorld/GameLauncher_NFSW)";
                        Client.Headers["X-GameLauncherHash"]        = WebHelpers.Value();
                        Client.Headers["X-GameLauncherCertificate"] = CertificateStore.LauncherSerial;
                        Client.Headers["X-DiscordID"] = DiscordLauncherPresence.UserID;
                    }

                    try
                    {
                        if (Method == "Login")
                        {
                            LoginResponse = Client.DownloadString(URLCall);
                        }
                        else
                        {
                            LoginResponse = Client.DownloadString(URLCall);
                        }
                    }
                    catch
                    {
                        throw;
                    }
                    finally
                    {
                        if (Client != null)
                        {
                            Client.Dispose();
                        }
                    }
                }
                else
                {
                    string ServerUrl = Tokens.IPAddress + "/User/modernAuth";
                    if (Method == "Register")
                    {
                        ServerUrl = Tokens.IPAddress + "/User/modernRegister";
                    }

                    Uri SendRequest = new Uri(ServerUrl);
                    ServicePointManager.FindServicePoint(SendRequest).ConnectionLeaseTimeout = (int)TimeSpan.FromSeconds(30).TotalMilliseconds;

                    HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(SendRequest);
                    httpWebRequest.ContentType = "application/json";
                    httpWebRequest.Method      = "POST";
                    httpWebRequest.Timeout     = (int)TimeSpan.FromSeconds(30).TotalMilliseconds;

                    using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                    {
                        String JSON;

                        if (Method == "Login")
                        {
                            JSON = new JavaScriptSerializer().Serialize(new { Email, Password, upgrade = true });
                        }
                        else
                        {
                            JSON = new JavaScriptSerializer().Serialize(new { Email, Password, Ticket = Token });
                        }

                        streamWriter.Write(JSON);
                    }

                    ServerResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                    using (var sr = new StreamReader(ServerResponse.GetResponseStream()))
                    {
                        ServerErrorCode = (int)ServerResponse.StatusCode;
                        LoginResponse   = sr.ReadToEnd();
                    }
                }
            }
            catch (WebException Error)
            {
                LogToFileAddons.OpenLog("CLIENT [LOGIN/REGISTER]", null, Error, null, true);

                ServerResponse = (HttpWebResponse)Error.Response;

                if (ServerResponse == null)
                {
                    ServerErrorCode = 500;
                    LoginResponse   = Modern_Auth ? "{\"error\":\"Failed to get reply from server. Please retry.\"}" :
                                      "<LoginStatusVO><UserId>0</UserId><Description>Failed to get reply from server. Please retry.</Description></LoginStatusVO>";
                }
                else
                {
                    using (var sr = new StreamReader(ServerResponse.GetResponseStream()))
                    {
                        ServerErrorCode     = (int)ServerResponse.StatusCode;
                        ServerErrorResponse = Modern_Auth ? "{\"error\":\"" + ServerResponse.StatusDescription + "\"}" : null;
                        LoginResponse       = sr.ReadToEnd();
                    }
                }
            }

            if (!Modern_Auth)
            {
                if (string.IsNullOrWhiteSpace(LoginResponse))
                {
                    Tokens.Error = "Server Seems to be Offline.";
                }
                else
                {
                    XmlDocument sbrwXml        = new XmlDocument();
                    var         msgBoxInfo     = string.Empty;
                    bool        XMLIsErrorFree = true;

                    try
                    {
                        if (EnableInsiderDeveloper.Allowed())
                        {
                            Log.Info("Authentication: Received XML -> " + LoginResponse);
                        }

                        sbrwXml.LoadXml(LoginResponse);

                        if (EnableInsiderDeveloper.Allowed())
                        {
                            Log.Info("Authentication: Loaded XML -> " + sbrwXml.OuterXml);
                        }
                    }
                    catch (Exception Error)
                    {
                        LogToFileAddons.OpenLog("XML LOGIN", null, Error, null, true);

                        XMLIsErrorFree = false;
                        msgBoxInfo     = "An error occured: " + Error.Message;
                    }

                    if (XMLIsErrorFree == true)
                    {
                        if (XMLServerCore.NodeReader(sbrwXml, "NodeOnly", "LoginStatusVO", "NodeOnly") == "VAILD NODE - LAUNCHER")
                        {
                            if (XMLServerCore.NodeReader(sbrwXml, "InnerText", "LoginStatusVO/Ban", "InnerText") != "EMPTY VALUE - LAUNCHER")
                            {
                                if (XMLServerCore.NodeReader(sbrwXml, "NodeOnly", "LoginStatusVO/Description", "NodeOnly") == "VAILD NODE - LAUNCHER")
                                {
                                    msgBoxInfo += XMLServerCore.NodeReader(sbrwXml, "InnerText", "LoginStatusVO/Description", "InnerText");
                                }
                                else
                                {
                                    msgBoxInfo = string.Format("You got banned on {0}.", Tokens.ServerName) + "\n";

                                    if (XMLServerCore.NodeReader(sbrwXml, "NodeOnly", "LoginStatusVO/Ban/Reason", "NodeOnly") != "INVALID NODE - LAUNCHER")
                                    {
                                        msgBoxInfo += "Reason: " + XMLServerCore.NodeReader(sbrwXml, "InnerText", "LoginStatusVO/Ban/Reason", "InnerText") + "\n";
                                    }
                                    else
                                    {
                                        msgBoxInfo += "Reason: Unknown \n";
                                    }

                                    if (XMLServerCore.NodeReader(sbrwXml, "NodeOnly", "LoginStatusVO/Ban/Expires", "NodeOnly") != "INVALID NODE - LAUNCHER")
                                    {
                                        msgBoxInfo += "Ban Expires: " + XMLServerCore.NodeReader(sbrwXml, "InnerText", "LoginStatusVO/Ban/Expires", "InnerText");
                                    }
                                    else
                                    {
                                        msgBoxInfo += "Banned Forever";
                                    }
                                }
                            }
                            else if (XMLServerCore.NodeReader(sbrwXml, "InnerText", "LoginStatusVO/UserId", "InnerText") == "0")
                            {
                                if (XMLServerCore.NodeReader(sbrwXml, "NodeOnly", "LoginStatusVO/Description", "NodeOnly") != "ERROR NODE - LAUNCHER" &&
                                    XMLServerCore.NodeReader(sbrwXml, "InnerText", "LoginStatusVO/Description", "InnerText") != "EMPTY VALUE - LAUNCHER")
                                {
                                    if (XMLServerCore.NodeReader(sbrwXml, "InnerText", "LoginStatusVO/Description", "InnerText") == "LOGIN ERROR")
                                    {
                                        msgBoxInfo += "Invalid E-mail or Password";
                                    }
                                    else
                                    {
                                        msgBoxInfo += XMLServerCore.NodeReader(sbrwXml, "InnerText", "LoginStatusVO/Description", "InnerText");
                                    }
                                }
                                else
                                {
                                    msgBoxInfo += "ERROR " + ServerErrorCode + ": " + XMLServerCore.NodeReader(sbrwXml, "InnerText", "html/body", "InnerText");
                                }
                            }

                            if (string.IsNullOrWhiteSpace(msgBoxInfo) || msgBoxInfo == "SERVER FULL")
                            {
                                if (Method == "Login" && string.IsNullOrWhiteSpace(msgBoxInfo))
                                {
                                    Tokens.UserId     = XMLServerCore.NodeReader(sbrwXml, "InnerText", "LoginStatusVO/UserId", "InnerText");
                                    Tokens.LoginToken = XMLServerCore.NodeReader(sbrwXml, "InnerText", "LoginStatusVO/LoginToken", "InnerText");

                                    if (XMLServerCore.NodeReader(sbrwXml, "NodeOnly", "LoginStatusVO/Warning", null) == "VAILD NODE - LAUNCHER")
                                    {
                                        Tokens.Warning = XMLServerCore.NodeReader(sbrwXml, "InnerText", "LoginStatusVO/Warning", "InnerText");
                                    }
                                }
                                else if (Method == "Register")
                                {
                                    string MessageSuccess;
                                    string MessageServerWelcome = string.Empty;

                                    if (!string.IsNullOrWhiteSpace(InformationCache.SelectedServerJSON.messageSrv))
                                    {
                                        if (InformationCache.SelectedServerJSON.messageSrv.ToLower().Contains("welcome"))
                                        {
                                            MessageServerWelcome = InformationCache.SelectedServerJSON.messageSrv + "\n";
                                        }
                                        else
                                        {
                                            MessageServerWelcome = "Welcome: " + InformationCache.SelectedServerJSON.messageSrv + "\n";
                                        }
                                    }

                                    if (msgBoxInfo == "SERVER FULL")
                                    {
                                        MessageSuccess = string.Format(MessageServerWelcome + "Successfully registered on {0}. However, server is actually full, " +
                                                                       "therefore you cannot play it right now.", Tokens.ServerName);
                                    }
                                    else
                                    {
                                        MessageSuccess = string.Format(MessageServerWelcome + "Successfully registered on {0}. You can log in now.", Tokens.ServerName);
                                    }

                                    Tokens.Success = MessageSuccess;
                                }
                                else
                                {
                                    Tokens.Error = msgBoxInfo;
                                }
                            }
                            else
                            {
                                Tokens.Error = msgBoxInfo;
                            }
                        }
                        else
                        {
                            Log.Error("Authentication: Unable to Read XML File Due to the Node 'LoginStatusVO' having an Error");
                            Tokens.Error = "Unable to Read XML File Due to the Node 'LoginStatusVO' having an Error\nERROR NODE - LAUNCHER";
                        }
                    }
                    else
                    {
                        Log.Error("Authentication: Unable to Read XML File -> " + msgBoxInfo);
                        Tokens.Error = msgBoxInfo;
                    }
                }
            }
            else
            {
                if (String.IsNullOrWhiteSpace(LoginResponse))
                {
                    Tokens.Error = "Server seems to be offline.";
                }
                else
                {
                    ModernAuthObject ServerObjectResponse;

                    try
                    {
                        ServerObjectResponse = JsonConvert.DeserializeObject <ModernAuthObject>(LoginResponse);
                    }
                    catch
                    {
                        ServerObjectResponse = JsonConvert.DeserializeObject <ModernAuthObject>(ServerErrorResponse);
                    }

                    if (String.IsNullOrWhiteSpace(ServerObjectResponse.Error) || ServerObjectResponse.Error == "SERVER FULL")
                    {
                        if (Method == "Login")
                        {
                            Tokens.UserId     = ServerObjectResponse.UserId;
                            Tokens.LoginToken = ServerObjectResponse.Token;

                            if (!String.IsNullOrWhiteSpace(ServerObjectResponse.Warning))
                            {
                                Tokens.Warning = ServerObjectResponse.Warning;
                            }
                        }
                        else if (Method == "Register")
                        {
                            string MessageSuccess;
                            string MessageServerWelcome = string.Empty;

                            if (!string.IsNullOrWhiteSpace(InformationCache.SelectedServerJSON.messageSrv))
                            {
                                if (InformationCache.SelectedServerJSON.messageSrv.ToLower().Contains("welcome"))
                                {
                                    MessageServerWelcome = InformationCache.SelectedServerJSON.messageSrv + "\n";
                                }
                                else
                                {
                                    MessageServerWelcome = "Welcome: " + InformationCache.SelectedServerJSON.messageSrv + "\n";
                                }
                            }

                            if (ServerObjectResponse.Error == "SERVER FULL")
                            {
                                MessageSuccess = string.Format(MessageServerWelcome + "Successfully registered on {0}. However, server is actually full, " +
                                                               "therefore you cannot play it right now.", Tokens.ServerName);
                            }
                            else
                            {
                                MessageSuccess = string.Format(MessageServerWelcome + "Successfully registered on {0}. You can log in now.", Tokens.ServerName);
                            }

                            Tokens.Success = MessageSuccess;
                        }
                    }
                    else
                    {
                        Tokens.Error = ServerObjectResponse.Error;
                    }
                }
            }
        }