From f555fef48dbbead6cc6dddd802c4d963793a2f99 Mon Sep 17 00:00:00 2001 From: Sardelka9515 Date: Mon, 13 Feb 2023 17:51:18 +0800 Subject: [PATCH] Optimize imports --- Client/Scripts/Main.cs | 26 +++++++++---------- Client/Scripts/Menus/Sub/DebugMenu.cs | 2 +- Client/Scripts/Menus/Sub/ServersMenu.cs | 2 +- Client/Scripts/Networking/DownloadManager.cs | 21 +++++++-------- Client/Scripts/Networking/HolePunch.cs | 16 ++++++------ Client/Scripts/Networking/Networking.cs | 8 +++--- Client/Scripts/Networking/Receive.cs | 16 ++++++------ Client/Scripts/Networking/Send.cs | 2 +- Client/Scripts/PlayerList.cs | 2 +- Client/Scripts/RageCoop.Client.csproj | 2 +- Client/Scripts/Scripting/API.Exports.cs | 2 +- Client/Scripts/Scripting/API.cs | 4 +-- Client/Scripts/Scripting/Resources.cs | 12 +++------ Client/Scripts/Shared.cs | 1 + Client/Scripts/Sync/Entities/Ped/SyncedPed.cs | 2 +- Client/Scripts/Sync/EntityPool.cs | 14 +++++----- Client/Scripts/Sync/SyncEvents.cs | 2 +- Client/Scripts/ThreadManager.cs | 8 +++--- Client/Scripts/Util/PedExtensions.cs | 2 +- Client/Scripts/Util/Util.cs | 4 +-- Client/Scripts/Util/WeaponUtil.cs | 2 +- Client/Scripts/WorldThread.cs | 8 +++--- 22 files changed, 77 insertions(+), 81 deletions(-) diff --git a/Client/Scripts/Main.cs b/Client/Scripts/Main.cs index 9ed4dbf..7cbf0e6 100644 --- a/Client/Scripts/Main.cs +++ b/Client/Scripts/Main.cs @@ -31,10 +31,10 @@ namespace RageCoop.Client internal static Settings Settings = null; internal static Chat MainChat = null; internal static Stopwatch Counter = new Stopwatch(); - internal static Logger Logger = null; + internal static Logger Log = null; internal static ulong Ticked = 0; internal static Vector3 PlayerPosition; - internal static Resources Resources = null; + internal static Resources MainRes = null; public static Ped P; public static float FPS; @@ -59,7 +59,7 @@ namespace RageCoop.Client Util.SaveSettings(); } - Logger = new Logger() + Log = new Logger() { Writers = new List { CoreUtils.OpenWriter(LogPath) }, #if DEBUG @@ -68,7 +68,7 @@ namespace RageCoop.Client LogLevel = Settings.LogLevel, #endif }; - Logger.OnFlush += (line, formatted) => + Log.OnFlush += (line, formatted) => { switch (line.LogLevel) { @@ -102,14 +102,14 @@ namespace RageCoop.Client WorldThread.DoQueuedActions(); if (IsUnloading) { - Logger.Dispose(); + Log.Dispose(); Networking.Peer?.Dispose(); ThreadManager.OnUnload(); } } catch (Exception ex) { - Logger.Error(ex); + Log.Error(ex); } } protected override void OnStart() @@ -121,11 +121,11 @@ namespace RageCoop.Client throw new NotSupportedException("Please update your GTA5 to v1.0.1290 or newer!"); } - Resources = new Resources(); + MainRes = new Resources(); - Logger.Info( + Log.Info( $"Main script initialized"); BaseScript.OnStart(); @@ -160,7 +160,7 @@ namespace RageCoop.Client } catch (Exception ex) { - Logger.Error(ex); + Log.Error(ex); } @@ -198,7 +198,7 @@ namespace RageCoop.Client { P.Health = 1; Game.Player.WantedLevel = 0; - Logger.Debug("Player died."); + Log.Debug("Player died."); API.Events.InvokePlayerDied(); } @@ -387,14 +387,14 @@ namespace RageCoop.Client Notification.Show("~g~Connected!"); }); - Logger.Info(">> Connected <<"); + Log.Info(">> Connected <<"); } public static void CleanUp(string reason) { if (reason != "Abort") { - Logger.Info($">> Disconnected << reason: {reason}"); + Log.Info($">> Disconnected << reason: {reason}"); API.QueueAction(() => { Notification.Show("~r~Disconnected: " + reason); }); } @@ -412,7 +412,7 @@ namespace RageCoop.Client Call(SET_ENABLE_VEHICLE_SLIPSTREAMING, false); CoopMenu.DisconnectedMenuSetting(); LocalPlayerID = default; - Resources.Unload(); + MainRes.Unload(); }); Memory.RestorePatches(); #if CEF diff --git a/Client/Scripts/Menus/Sub/DebugMenu.cs b/Client/Scripts/Menus/Sub/DebugMenu.cs index 38db9e8..6f6b862 100644 --- a/Client/Scripts/Menus/Sub/DebugMenu.cs +++ b/Client/Scripts/Menus/Sub/DebugMenu.cs @@ -62,7 +62,7 @@ namespace RageCoop.Client } catch (Exception ex) { - Main.Logger.Error(ex); + Log.Error(ex); } }; Menu.Add(SimulatedLatencyItem); diff --git a/Client/Scripts/Menus/Sub/ServersMenu.cs b/Client/Scripts/Menus/Sub/ServersMenu.cs index 588bc4a..5c20af0 100644 --- a/Client/Scripts/Menus/Sub/ServersMenu.cs +++ b/Client/Scripts/Menus/Sub/ServersMenu.cs @@ -59,7 +59,7 @@ namespace RageCoop.Client.Menus var realUrl = Main.Settings.MasterServer; serverList = null; try { serverList = JsonDeserialize>(DownloadString(realUrl)); } - catch (Exception ex) { Main.Logger.Error(ex); } + catch (Exception ex) { Log.Error(ex); } // Need to be processed in main thread API.QueueAction(() => diff --git a/Client/Scripts/Networking/DownloadManager.cs b/Client/Scripts/Networking/DownloadManager.cs index 23f4868..1deee2f 100644 --- a/Client/Scripts/Networking/DownloadManager.cs +++ b/Client/Scripts/Networking/DownloadManager.cs @@ -33,7 +33,7 @@ namespace RageCoop.Client var packet = new Packets.FileTransferComplete(); packet.Deserialize(data); - Main.Logger.Debug($"Finalizing download:{packet.ID}"); + Log.Debug($"Finalizing download:{packet.ID}"); Complete(packet.ID); // Inform the server that the download is completed @@ -48,13 +48,13 @@ namespace RageCoop.Client try { Directory.CreateDirectory(ResourceFolder); - Main.Resources.Load(ResourceFolder, _resources.ToArray()); + MainRes.Load(ResourceFolder, _resources.ToArray()); return new Packets.FileTransferResponse { ID = 0, Response = FileResponse.Loaded }; } catch (Exception ex) { - Main.Logger.Error("Error occurred when loading server resource"); - Main.Logger.Error(ex); + Log.Error("Error occurred when loading server resource"); + Log.Error(ex); return new Packets.FileTransferResponse { ID = 0, Response = FileResponse.LoadFailed }; } }); @@ -68,13 +68,13 @@ namespace RageCoop.Client public static bool AddFile(int id, string name, long length) { var path = $"{ResourceFolder}\\{name}"; - Main.Logger.Debug($"Downloading file to {path} , id:{id}"); + Log.Debug($"Downloading file to {path} , id:{id}"); if (!Directory.Exists(Directory.GetParent(path).FullName)) Directory.CreateDirectory(Directory.GetParent(path).FullName); if (FileAlreadyExists(ResourceFolder, name, length)) { - Main.Logger.Debug($"File already exists! canceling download:{name}"); + Log.Debug($"File already exists! canceling download:{name}"); DownloadCompleted?.Invoke(null, Path.Combine(ResourceFolder, name)); return false; } @@ -82,7 +82,7 @@ namespace RageCoop.Client /* if (!name.EndsWith(".zip")) { - Main.Logger.Error($"File download blocked! [{name}]"); + Log.Error($"File download blocked! [{name}]"); return false; } */ @@ -114,7 +114,6 @@ namespace RageCoop.Client if (File.Exists(filePath)) { if (new FileInfo(filePath).Length == length) return true; - // Delete the file because the length is wrong (maybe the file was updated) File.Delete(filePath); } @@ -129,7 +128,7 @@ namespace RageCoop.Client if (InProgressDownloads.TryGetValue(id, out var file)) file.Stream.Write(chunk, 0, chunk.Length); else - Main.Logger.Trace($"Received unhandled file chunk:{id}"); + Log.Trace($"Received unhandled file chunk:{id}"); } } @@ -139,12 +138,12 @@ namespace RageCoop.Client { InProgressDownloads.Remove(id); f.Dispose(); - Main.Logger.Info($"Download finished:{f.FileName}"); + Log.Info($"Download finished:{f.FileName}"); DownloadCompleted?.Invoke(null, Path.Combine(ResourceFolder, f.FileName)); } else { - Main.Logger.Error($"Download not found! {id}"); + Log.Error($"Download not found! {id}"); } } diff --git a/Client/Scripts/Networking/HolePunch.cs b/Client/Scripts/Networking/HolePunch.cs index 702d751..abd7dba 100644 --- a/Client/Scripts/Networking/HolePunch.cs +++ b/Client/Scripts/Networking/HolePunch.cs @@ -27,7 +27,7 @@ namespace RageCoop.Client if (p.InternalEndPoint != null && p.ExternalEndPoint != null && (p.Connection == null || p.Connection.Status == NetConnectionStatus.Disconnected)) { - Main.Logger.Trace( + Log.Trace( $"Sending HolePunch message to {p.InternalEndPoint},{p.ExternalEndPoint}. {p.Username}:{p.ID}"); var msg = Networking.Peer.CreateMessage(); new Packets.HolePunch @@ -41,7 +41,7 @@ namespace RageCoop.Client } catch (Exception ex) { - Main.Logger.Error(ex); + Log.Error(ex); } } @@ -49,31 +49,31 @@ namespace RageCoop.Client { if (PlayerList.Players.TryGetValue(p.TargetID, out var player)) { - Main.Logger.Debug($"{p.TargetID},{player.Username} added to HolePunch target"); + Log.Debug($"{p.TargetID},{player.Username} added to HolePunch target"); player.InternalEndPoint = CoreUtils.StringToEndPoint(p.TargetInternal); player.ExternalEndPoint = CoreUtils.StringToEndPoint(p.TargetExternal); player.ConnectWhenPunched = p.Connect; } else { - Main.Logger.Warning("No player with specified TargetID found for hole punching:" + p.TargetID); + Log.Warning("No player with specified TargetID found for hole punching:" + p.TargetID); } } public static void Punched(Packets.HolePunch p, IPEndPoint from) { - Main.Logger.Debug($"HolePunch message received from:{from}, status:{p.Status}"); + Log.Debug($"HolePunch message received from:{from}, status:{p.Status}"); if (PlayerList.Players.TryGetValue(p.Puncher, out var puncher)) { - Main.Logger.Debug("Puncher identified as: " + puncher.Username); + Log.Debug("Puncher identified as: " + puncher.Username); puncher.HolePunchStatus = (byte)(p.Status + 1); if (p.Status >= 3) { - Main.Logger.Debug("HolePunch sucess: " + from + ", " + puncher.ID); + Log.Debug("HolePunch sucess: " + from + ", " + puncher.ID); if (puncher.ConnectWhenPunched && (puncher.Connection == null || puncher.Connection.Status == NetConnectionStatus.Disconnected)) { - Main.Logger.Debug("Connecting to peer: " + from); + Log.Debug("Connecting to peer: " + from); var msg = Networking.Peer.CreateMessage(); new Packets.P2PConnect { ID = Main.LocalPlayerID }.Pack(msg); puncher.Connection = Networking.Peer.Connect(from, msg); diff --git a/Client/Scripts/Networking/Networking.cs b/Client/Scripts/Networking/Networking.cs index ce893bd..32ba2af 100644 --- a/Client/Scripts/Networking/Networking.cs +++ b/Client/Scripts/Networking/Networking.cs @@ -30,7 +30,7 @@ namespace RageCoop.Client static Networking() { - Security = new Security(Main.Logger); + Security = new Security(Log); } public static float Latency => ServerConnection.AverageRoundtripTime / 2; @@ -113,7 +113,7 @@ namespace RageCoop.Client } catch (Exception ex) { - Main.Logger.Error(ex); + Log.Error(ex); } }; API.QueueAction(() => { Notification.Show("~y~Trying to connect..."); }); @@ -149,7 +149,7 @@ namespace RageCoop.Client } catch (Exception ex) { - Main.Logger.Error("Cannot connect to server: ", ex); + Log.Error("Cannot connect to server: ", ex); API.QueueAction(() => Notification.Show("Cannot connect to server: " + ex.Message)); } @@ -185,7 +185,7 @@ namespace RageCoop.Client }; PlayerList.SetPlayer(packet.PedID, packet.Username); - Main.Logger.Debug($"player connected:{p.Username}"); + Log.Debug($"player connected:{p.Username}"); API.QueueAction(() => Notification.Show($"~h~{p.Username}~h~ connected.")); } diff --git a/Client/Scripts/Networking/Receive.cs b/Client/Scripts/Networking/Receive.cs index 5cae2f0..cd863d2 100644 --- a/Client/Scripts/Networking/Receive.cs +++ b/Client/Scripts/Networking/Receive.cs @@ -50,11 +50,11 @@ namespace RageCoop.Client if (PlayerList.Players.TryGetValue(p.ID, out var player)) { player.Connection = message.SenderConnection; - Main.Logger.Debug($"Direct connection to {player.Username} established"); + Log.Debug($"Direct connection to {player.Username} established"); } else { - Main.Logger.Info( + Log.Info( $"Unidentified peer connection from {message.SenderEndPoint} was rejected."); message.SenderConnection.Disconnect("eat poop"); } @@ -104,7 +104,7 @@ namespace RageCoop.Client } else { - Main.Logger.Debug("Did not find a request handler of type: " + realType); + Log.Debug("Did not find a request handler of type: " + realType); } break; @@ -123,8 +123,8 @@ namespace RageCoop.Client Notification.Show($"~r~~h~Packet Error {ex.Message}"); return true; }); - Main.Logger.Error($"[{packetType}] {ex.Message}"); - Main.Logger.Error(ex); + Log.Error($"[{packetType}] {ex.Message}"); + Log.Error(ex); Peer.Shutdown($"Packet Error [{packetType}]"); } @@ -156,7 +156,7 @@ namespace RageCoop.Client case NetIncomingMessageType.ErrorMessage: case NetIncomingMessageType.WarningMessage: case NetIncomingMessageType.VerboseDebugMessage: - Main.Logger.Trace(message.ReadString()); + Log.Trace(message.ReadString()); break; } @@ -277,7 +277,7 @@ namespace RageCoop.Client { var c = EntityPool.GetPedByID(packet.ID); if (c == null) - // Main.Logger.Debug($"Creating character for incoming sync:{packet.ID}"); + // Log.Debug($"Creating character for incoming sync:{packet.ID}"); EntityPool.ThreadSafe.Add(c = new SyncedPed(packet.ID)); var flags = packet.Flags; c.ID = packet.ID; @@ -360,7 +360,7 @@ namespace RageCoop.Client if (p == null) { if (packet.Flags.HasProjDataFlag(ProjectileDataFlags.Exploded)) return; - // Main.Logger.Debug($"Creating new projectile: {(WeaponHash)packet.WeaponHash}"); + // Log.Debug($"Creating new projectile: {(WeaponHash)packet.WeaponHash}"); EntityPool.ThreadSafe.Add(p = new SyncedProjectile(packet.ID)); } diff --git a/Client/Scripts/Networking/Send.cs b/Client/Scripts/Networking/Send.cs index ef026cc..8152e78 100644 --- a/Client/Scripts/Networking/Send.cs +++ b/Client/Scripts/Networking/Send.cs @@ -47,7 +47,7 @@ namespace RageCoop.Client var veh = ped.CurrentVehicle?.GetSyncEntity() ?? ped.VehicleTryingToEnter?.GetSyncEntity() ?? ped.LastVehicle?.GetSyncEntity(); p.VehicleID = veh?.ID ?? 0; - if (p.VehicleID == 0) Main.Logger.Error("Invalid vehicle"); + if (p.VehicleID == 0) Log.Error("Invalid vehicle"); if (p.Speed == 5) p.Seat = ped.GetSeatTryingToEnter(); else diff --git a/Client/Scripts/PlayerList.cs b/Client/Scripts/PlayerList.cs index 19252fa..2f9e0a3 100644 --- a/Client/Scripts/PlayerList.cs +++ b/Client/Scripts/PlayerList.cs @@ -58,7 +58,7 @@ namespace RageCoop.Client public static void SetPlayer(int id, string username, float latency = 0) { - Main.Logger.Debug($"{id},{username},{latency}"); + Log.Debug($"{id},{username},{latency}"); if (Players.TryGetValue(id, out var p)) { p.Username = username; diff --git a/Client/Scripts/RageCoop.Client.csproj b/Client/Scripts/RageCoop.Client.csproj index 728ab5d..ea84f13 100644 --- a/Client/Scripts/RageCoop.Client.csproj +++ b/Client/Scripts/RageCoop.Client.csproj @@ -1,6 +1,6 @@  - false + true net7.0 None Library diff --git a/Client/Scripts/Scripting/API.Exports.cs b/Client/Scripts/Scripting/API.Exports.cs index 94ce262..9afd60c 100644 --- a/Client/Scripts/Scripting/API.Exports.cs +++ b/Client/Scripts/Scripting/API.Exports.cs @@ -76,7 +76,7 @@ namespace RageCoop.Client.Scripting } catch (Exception ex) { - Main.Logger.Error(ex); + Log.Error(ex); SetLastResult(ex.ToString()); return 0; } diff --git a/Client/Scripts/Scripting/API.cs b/Client/Scripts/Scripting/API.cs index 308a1ec..78b3a80 100644 --- a/Client/Scripts/Scripting/API.cs +++ b/Client/Scripts/Scripting/API.cs @@ -168,7 +168,7 @@ namespace RageCoop.Client.Scripting { var args = new CustomEventReceivedArgs { Hash = p.Hash, Args = p.Args }; - // Main.Logger.Debug($"CustomEvent:\n"+args.Args.DumpWithType()); + // Log.Debug($"CustomEvent:\n"+args.Args.DumpWithType()); if (CustomEventHandlers.TryGetValue(p.Hash, out var handlers)) handlers.ForEach(x => { x.Invoke(args); }); @@ -400,7 +400,7 @@ namespace RageCoop.Client.Scripting [Remoting] public static ClientResource GetResource(string name) { - if (Main.Resources.LoadedResources.TryGetValue(name, out var resource)) + if (MainRes.LoadedResources.TryGetValue(name, out var resource)) return resource; return null; diff --git a/Client/Scripts/Scripting/Resources.cs b/Client/Scripts/Scripting/Resources.cs index 51a432d..a3c60d3 100644 --- a/Client/Scripts/Scripting/Resources.cs +++ b/Client/Scripts/Scripting/Resources.cs @@ -34,7 +34,7 @@ namespace RageCoop.Client.Scripting public Resources() { - Logger = Main.Logger; + Logger = Log; } private Logger Logger { get; } @@ -52,20 +52,18 @@ namespace RageCoop.Client.Scripting Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories).Where(x => x.CanBeIgnored()) .ForEach(File.Delete); - // TODO Core.ScheduleLoad()... + // TODO: Core.ScheduleLoad()... } public void Unload() { - // TODO Core.ScheduleUnload()... + // TODO: Core.ScheduleUnload()... } private ClientResource Unpack(string zipPath, string dataFolderRoot) { var r = new ClientResource { - Logger = Logger, - Scripts = new List(), Name = Path.GetFileNameWithoutExtension(zipPath), DataFolder = Path.Combine(dataFolderRoot, Path.GetFileNameWithoutExtension(zipPath)), ScriptsDirectory = Path.Combine(TempPath, Path.GetFileNameWithoutExtension(zipPath)) @@ -86,7 +84,6 @@ namespace RageCoop.Client.Scripting IsDirectory = true, Name = dir.Substring(scriptsDir.Length + 1).Replace('\\', '/') }); - var assemblies = new Dictionary(); foreach (var file in Directory.GetFiles(scriptsDir, "*", SearchOption.AllDirectories)) { if (Path.GetFileName(file).CanBeIgnored()) @@ -105,9 +102,8 @@ namespace RageCoop.Client.Scripting } var relativeName = file.Substring(scriptsDir.Length + 1).Replace('\\', '/'); - var rfile = new ResourceFile + var rfile = new ClientFile { - GetStream = () => { return new FileStream(file, FileMode.Open, FileAccess.Read); }, IsDirectory = false, Name = relativeName }; diff --git a/Client/Scripts/Shared.cs b/Client/Scripts/Shared.cs index 0736987..039dff6 100644 --- a/Client/Scripts/Shared.cs +++ b/Client/Scripts/Shared.cs @@ -3,6 +3,7 @@ global using GTA.Native; global using static GTA.Native.Function; global using static GTA.Native.Hash; global using static RageCoop.Client.Shared; +global using static RageCoop.Client.Main; global using Console = GTA.Console; global using static RageCoop.Core.Shared; using System.IO; diff --git a/Client/Scripts/Sync/Entities/Ped/SyncedPed.cs b/Client/Scripts/Sync/Entities/Ped/SyncedPed.cs index a5660b2..c9a8eff 100644 --- a/Client/Scripts/Sync/Entities/Ped/SyncedPed.cs +++ b/Client/Scripts/Sync/Entities/Ped/SyncedPed.cs @@ -175,7 +175,7 @@ namespace RageCoop.Client { if (MainPed.Exists()) { - // Main.Logger.Debug($"Removing ped {ID}. Reason:CreateCharacter"); + // Log.Debug($"Removing ped {ID}. Reason:CreateCharacter"); MainPed.Kill(); MainPed.MarkAsNoLongerNeeded(); MainPed.Delete(); diff --git a/Client/Scripts/Sync/EntityPool.cs b/Client/Scripts/Sync/EntityPool.cs index e817a5e..143689d 100644 --- a/Client/Scripts/Sync/EntityPool.cs +++ b/Client/Scripts/Sync/EntityPool.cs @@ -102,11 +102,11 @@ namespace RageCoop.Client var player = GetPedByID(Main.LocalPlayerID); if (player == null) { - Main.Logger.Debug($"Creating SyncEntity for player, handle:{p.Handle}"); + Log.Debug($"Creating SyncEntity for player, handle:{p.Handle}"); var c = new SyncedPed(p); Main.LocalPlayerID = c.OwnerID = c.ID; Add(c); - Main.Logger.Debug($"Local player ID is:{c.ID}"); + Log.Debug($"Local player ID is:{c.ID}"); PlayerList.SetPlayer(c.ID, Main.Settings.Username); return true; } @@ -155,7 +155,7 @@ namespace RageCoop.Client if (p != null) { if (PedsByHandle.ContainsKey(p.Handle)) PedsByHandle.Remove(p.Handle); - // Main.Logger.Debug($"Removing ped {c.ID}. Reason:{reason}"); + // Log.Debug($"Removing ped {c.ID}. Reason:{reason}"); p.AttachedBlip?.Delete(); p.Kill(); p.Model.MarkAsNoLongerNeeded(); @@ -208,7 +208,7 @@ namespace RageCoop.Client if (veh != null) { if (VehiclesByHandle.ContainsKey(veh.Handle)) VehiclesByHandle.Remove(veh.Handle); - // Main.Logger.Debug($"Removing vehicle {v.ID}. Reason:{reason}"); + // Log.Debug($"Removing vehicle {v.ID}. Reason:{reason}"); veh.AttachedBlip?.Delete(); veh.Model.MarkAsNoLongerNeeded(); veh.MarkAsNoLongerNeeded(); @@ -255,7 +255,7 @@ namespace RageCoop.Client if (p != null) { if (ProjectilesByHandle.ContainsKey(p.Handle)) ProjectilesByHandle.Remove(p.Handle); - Main.Logger.Debug($"Removing projectile {sp.ID}. Reason:{reason}"); + Log.Debug($"Removing projectile {sp.ID}. Reason:{reason}"); p.Explode(); } @@ -364,7 +364,7 @@ namespace RageCoop.Client continue; } - // Main.Logger.Trace($"Creating SyncEntity for ped, handle:{p.Handle}"); + // Log.Trace($"Creating SyncEntity for ped, handle:{p.Handle}"); c = new SyncedPed((Ped)Entity.FromHandle(p)); Add(c); @@ -441,7 +441,7 @@ namespace RageCoop.Client continue; } } - // Main.Logger.Debug($"Creating SyncEntity for vehicle, handle:{veh.Handle}"); + // Log.Debug($"Creating SyncEntity for vehicle, handle:{veh.Handle}"); Add(new SyncedVehicle(cveh)); } diff --git a/Client/Scripts/Sync/SyncEvents.cs b/Client/Scripts/Sync/SyncEvents.cs index f7ac543..5ec52ba 100644 --- a/Client/Scripts/Sync/SyncEvents.cs +++ b/Client/Scripts/Sync/SyncEvents.cs @@ -74,7 +74,7 @@ namespace RageCoop.Client { return; // p = Game.Player.Character; - // Main.Logger.Warning("Failed to find owner for bullet"); + // Log.Warning("Failed to find owner for bullet"); } var damage = (int)p.GetWeaponDamage(weaponHash); diff --git a/Client/Scripts/ThreadManager.cs b/Client/Scripts/ThreadManager.cs index 0e292f5..79984f7 100644 --- a/Client/Scripts/ThreadManager.cs +++ b/Client/Scripts/ThreadManager.cs @@ -40,15 +40,15 @@ namespace RageCoop.Client catch (ThreadInterruptedException) { } catch (Exception ex) { - Main.Logger.Error($"Unhandled exception caught in thread {Environment.CurrentManagedThreadId}", ex); + Log.Error($"Unhandled exception caught in thread {Environment.CurrentManagedThreadId}", ex); } finally { - Main.Logger.Debug($"Thread stopped: " + Environment.CurrentManagedThreadId); + Log.Debug($"Thread stopped: " + Environment.CurrentManagedThreadId); } }); created.Name = name; - Main.Logger.Debug($"Thread created: {name}, id: {created.ManagedThreadId}"); + Log.Debug($"Thread created: {name}, id: {created.ManagedThreadId}"); _threads.Add(created); if (startNow) created.Start(); return created; @@ -63,7 +63,7 @@ namespace RageCoop.Client { if (thread.IsAlive) { - Main.Logger.Debug($"Waiting for thread {thread.ManagedThreadId} to stop"); + Log.Debug($"Waiting for thread {thread.ManagedThreadId} to stop"); // thread.Interrupt(); PlatformNotSupportedException ? thread.Join(); } diff --git a/Client/Scripts/Util/PedExtensions.cs b/Client/Scripts/Util/PedExtensions.cs index 59a8170..8569f32 100644 --- a/Client/Scripts/Util/PedExtensions.cs +++ b/Client/Scripts/Util/PedExtensions.cs @@ -309,7 +309,7 @@ namespace RageCoop.Client case WeaponHash.MG: return new string[2] { "weapons@machinegun@mg_str", "reload_aim" }; default: - Main.Logger.Warning( + Log.Warning( $"~r~Reloading failed! Weapon ~g~[{ped.Weapons.Current.Hash}]~r~ could not be found!"); return null; } diff --git a/Client/Scripts/Util/Util.cs b/Client/Scripts/Util/Util.cs index eb814b3..0586769 100644 --- a/Client/Scripts/Util/Util.cs +++ b/Client/Scripts/Util/Util.cs @@ -111,7 +111,7 @@ namespace RageCoop.Client } catch (Exception ex) { - Main.Logger?.Error(ex); + Log?.Error(ex); File.WriteAllText(path, JsonSerialize(settings = new Settings())); } @@ -131,7 +131,7 @@ namespace RageCoop.Client } catch (Exception ex) { - Main.Logger?.Error(ex); + Log?.Error(ex); return false; } } diff --git a/Client/Scripts/Util/WeaponUtil.cs b/Client/Scripts/Util/WeaponUtil.cs index b5d8dda..60e4420 100644 --- a/Client/Scripts/Util/WeaponUtil.cs +++ b/Client/Scripts/Util/WeaponUtil.cs @@ -34,7 +34,7 @@ namespace RageCoop.Client if (File.Exists(WeaponFixDataPath)) WeaponFix = JsonDeserialize(File.ReadAllText(WeaponFixDataPath)); else - Main.Logger.Warning("Weapon fix data not found"); + Log.Warning("Weapon fix data not found"); } public static void DumpWeaponFix(string path) diff --git a/Client/Scripts/WorldThread.cs b/Client/Scripts/WorldThread.cs index 1270983..04d1317 100644 --- a/Client/Scripts/WorldThread.cs +++ b/Client/Scripts/WorldThread.cs @@ -50,7 +50,7 @@ namespace RageCoop.Client } catch (Exception ex) { - Main.Logger.Error(ex); + Log.Error(ex); } if (!Networking.IsOnServer) return; @@ -139,7 +139,7 @@ namespace RageCoop.Client if (c == null || (c.IsLocal && ped.Handle != Game.Player.Character.Handle && ped.PopulationType != EntityPopulationType.Mission)) { - Main.Logger.Trace($"Removing ped {ped.Handle}. Reason:RemoveTraffic"); + Log.Trace($"Removing ped {ped.Handle}. Reason:RemoveTraffic"); ped.CurrentVehicle?.Delete(); ped.Kill(); ped.Delete(); @@ -154,7 +154,7 @@ namespace RageCoop.Client // Don't delete player's vehicle continue; if (v == null || (v.IsLocal && veh.PopulationType != EntityPopulationType.Mission)) - // Main.Logger.Debug($"Removing Vehicle {veh.Handle}. Reason:ClearTraffic"); + // Log.Debug($"Removing Vehicle {veh.Handle}. Reason:ClearTraffic"); veh.Delete(); } @@ -181,7 +181,7 @@ namespace RageCoop.Client } catch (Exception ex) { - Main.Logger.Error(ex); + Log.Error(ex); QueuedActions.Remove(action); } }