From 1fcf47cebd7dd17ea023b0ffd97849ab3cfda899 Mon Sep 17 00:00:00 2001 From: oldnapalm <38410858+oldnapalm@users.noreply.github.com> Date: Tue, 25 Jul 2023 16:43:37 -0300 Subject: [PATCH] Update master server, fix installer --- Client/Installer/MainWindow.xaml.cs | 22 ++++++++++------------ Client/Scripts/ClientSettings.cs | 4 ++-- Client/Scripts/Util/PedExtensions.cs | 2 +- Core/CoreUtils.cs | 9 ++++++--- Server/Settings.cs | 4 ++-- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Client/Installer/MainWindow.xaml.cs b/Client/Installer/MainWindow.xaml.cs index 38cfbe9..617c267 100644 --- a/Client/Installer/MainWindow.xaml.cs +++ b/Client/Installer/MainWindow.xaml.cs @@ -55,7 +55,7 @@ namespace RageCoop.Client.Installer var shvPath = Path.Combine(root, "ScriptHookV.dll"); var shvdnPath = Path.Combine(root, "ScriptHookVDotNetCore.dll"); var scriptsPath = Path.Combine(root, "Scripts"); - var installPath = Path.Combine(root, "RageCoop"); + var installPath = Path.Combine(root, "CoreScripts"); var legacyPath = Path.Combine(scriptsPath, "RageCoop"); if (Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName.StartsWith(installPath)) throw new InvalidOperationException( @@ -70,37 +70,35 @@ namespace RageCoop.Client.Installer if (!File.Exists(shvdnPath)) { - MessageBox.Show("Please install ScriptHookVDotNet first!"); + MessageBox.Show("Please install ScriptHookVDotNetCore first!"); Environment.Exit(1); } var shvdnVer = GetVer(shvdnPath); - if (shvdnVer < new Version(3, 5, 1)) + if (shvdnVer < new Version(1, 2, 1)) { - MessageBox.Show("Please update ScriptHookVDotNet to latest version!" + - $"\nCurrent version is {shvdnVer}, 3.5.1 or higher is required"); + MessageBox.Show("Please update ScriptHookVDotNetCore to latest version!" + + $"\nCurrent version is {shvdnVer}, 1.2.1 or higher is required"); Environment.Exit(1); } UpdateStatus("Removing old versions"); - foreach (var f in Directory.GetFiles(scriptsPath, "RageCoop.*", SearchOption.AllDirectories)) - File.Delete(f); + if (Directory.Exists(scriptsPath)) + foreach (var f in Directory.GetFiles(scriptsPath, "RageCoop.*", SearchOption.AllDirectories)) + File.Delete(f); // <= 1.5 installation check if (Directory.Exists(legacyPath)) Directory.Delete(legacyPath, true); foreach (var f in Directory.GetFiles(installPath, "*.dll", SearchOption.AllDirectories)) File.Delete(f); - if (File.Exists("Scripts/RageCoop.Core.dll") && File.Exists("Scripts/RageCoop.Client.dll") && - File.Exists("Loader/RageCoop.Client.Loader.dll")) + if (File.Exists("Scripts/RageCoop.Core.dll") && File.Exists("Scripts/RageCoop.Client.dll")) { UpdateStatus("Installing..."); CoreUtils.CopyFilesRecursively(new DirectoryInfo(Directory.GetCurrentDirectory()), new DirectoryInfo(installPath)); - File.Copy("Loader/RageCoop.Client.Loader.dll", Path.Combine(scriptsPath, "RageCoop.Client.Loader.dll"), - true); Finish(); } else @@ -114,7 +112,7 @@ namespace RageCoop.Client.Installer checkKeys: UpdateStatus("Checking conflicts"); var menyooConfig = Path.Combine(root, @"menyooStuff\menyooConfig.ini"); - var settingsPath = Path.Combine(root, SettingsPath); + var settingsPath = Path.Combine(installPath, "Data", "Setting.json"); ClientSettings settings = null; try { diff --git a/Client/Scripts/ClientSettings.cs b/Client/Scripts/ClientSettings.cs index 0dbd371..2c6d749 100644 --- a/Client/Scripts/ClientSettings.cs +++ b/Client/Scripts/ClientSettings.cs @@ -31,7 +31,7 @@ namespace RageCoop.Client /// /// Don't use it! /// - public string MasterServer { get; set; } = "https://masterserver.ragecoop.online/"; + public string MasterServer { get; set; } = "https://test.ragecoop.com/"; /// /// Don't use it! @@ -56,7 +56,7 @@ namespace RageCoop.Client /// /// Disable world NPC traffic, mission entities won't be affected /// - public bool DisableTraffic { get; set; } = true; + public bool DisableTraffic { get; set; } = false; /// /// Bring up pause menu but don't freeze time when FrontEndPauseAlternate(Esc) is pressed. diff --git a/Client/Scripts/Util/PedExtensions.cs b/Client/Scripts/Util/PedExtensions.cs index 76fc87c..306dfe0 100644 --- a/Client/Scripts/Util/PedExtensions.cs +++ b/Client/Scripts/Util/PedExtensions.cs @@ -354,7 +354,7 @@ namespace RageCoop.Client { result = true; } - else + else if (veh.GetPedOnSeat(seat) != null) { var isDead = veh.GetPedOnSeat(seat).IsDead; if (isDead) diff --git a/Core/CoreUtils.cs b/Core/CoreUtils.cs index 5738d04..3c6928f 100644 --- a/Core/CoreUtils.cs +++ b/Core/CoreUtils.cs @@ -31,7 +31,10 @@ namespace RageCoop.Core { internal static class CoreUtils { - private static readonly Random random = new(); + internal static Random SafeRandom => _randInstance.Value; + private static int _randSeed = Environment.TickCount; + private static readonly ThreadLocal _randInstance + = new(() => new Random(Interlocked.Increment(ref _randSeed))); private static readonly HashSet ToIgnore = new() { @@ -72,7 +75,7 @@ namespace RageCoop.Core public static int RandInt(int start, int end) { - return random.Next(start, end); + return SafeRandom.Next(start, end); } public static string GetTempDirectory(string dir = null) @@ -91,7 +94,7 @@ namespace RageCoop.Core { const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; return new string(Enumerable.Repeat(chars, length) - .Select(s => s[random.Next(s.Length)]).ToArray()); + .Select(s => s[SafeRandom.Next(s.Length)]).ToArray()); } public static Version GetLatestVersion(string branch = "dev-nightly") diff --git a/Server/Settings.cs b/Server/Settings.cs index e5dca74..7d9b0a3 100644 --- a/Server/Settings.cs +++ b/Server/Settings.cs @@ -28,7 +28,7 @@ public class Settings /// /// The website address to be shown on master server /// - public string Website { get; set; } = "https://ragecoop.online/"; + public string Website { get; set; } = "https://ragecoop.com/"; /// /// The description to be shown on master server @@ -58,7 +58,7 @@ public class Settings /// /// Master server address, mostly doesn't need to be changed. /// - public string MasterServer { get; set; } = "https://masterserver.ragecoop.online/"; + public string MasterServer { get; set; } = "https://test.ragecoop.com/"; /// /// See .