diff --git a/RageCoop.Client/Networking/DownloadManager.cs b/RageCoop.Client/Networking/DownloadManager.cs index 703738c..e7c5621 100644 --- a/RageCoop.Client/Networking/DownloadManager.cs +++ b/RageCoop.Client/Networking/DownloadManager.cs @@ -14,6 +14,10 @@ namespace RageCoop.Client { var fr = new Packets.FileTransferRequest(); fr.Unpack(data); + if (fr.Name.EndsWith(".zip")) + { + _zips.Add(fr.Name); + } return new Packets.FileTransferResponse() { ID= fr.ID, @@ -39,7 +43,7 @@ namespace RageCoop.Client { try { - Main.Resources.Load(ResourceFolder); + Main.Resources.Load(ResourceFolder,_zips.ToArray()); return new Packets.FileTransferResponse() { ID=0, Response=FileResponse.Loaded }; } catch(Exception ex) @@ -57,6 +61,7 @@ namespace RageCoop.Client } } private static readonly Dictionary InProgressDownloads = new Dictionary(); + private static readonly List _zips = new List(); public static bool AddFile(int id, string name, long length) { Main.Logger.Debug($"Downloading file to {ResourceFolder}\\{name} , id:{id}"); @@ -140,6 +145,10 @@ namespace RageCoop.Client { InProgressDownloads.Remove(id); f.Dispose(); + if (f.FileName.EndsWith(".zip")) + { + _zips.Add(f.FileName); + } Main.Logger.Info($"Download finished:{f.FileName}"); } else @@ -166,6 +175,7 @@ namespace RageCoop.Client File.Delete(zip); } } + _zips.Clear(); } } diff --git a/RageCoop.Client/PlayerList.cs b/RageCoop.Client/PlayerList.cs index 5dc1ac4..7fe5464 100644 --- a/RageCoop.Client/PlayerList.cs +++ b/RageCoop.Client/PlayerList.cs @@ -92,7 +92,10 @@ namespace RageCoop.Client public static PlayerData GetPlayer(SyncedPed p) { var player = GetPlayer(p.ID); - player.Character=p; + if (player!=null) + { + player.Character=p; + } return player; } public static void RemovePlayer(int id) diff --git a/RageCoop.Client/Scripting/Resources.cs b/RageCoop.Client/Scripting/Resources.cs index 6eb821b..867a85d 100644 --- a/RageCoop.Client/Scripting/Resources.cs +++ b/RageCoop.Client/Scripting/Resources.cs @@ -82,21 +82,13 @@ namespace RageCoop.Client.Scripting /// /// Load all resources from the server /// - /// The path to the directory containing all resources to load. - public void Load(string path) + public void Load(string path,string[] zips) { Unload(); - foreach (var d in Directory.GetDirectories(path)) + foreach (var zip in zips) { - if(Path.GetFileName(d).ToLower() != "data") - { - Directory.Delete(d, true); - } - } - Directory.CreateDirectory(path); - foreach (var zipPath in Directory.GetFiles(path,"*.zip",SearchOption.TopDirectoryOnly)) - { - Logger?.Info($"Loading resource: {Path.GetFileNameWithoutExtension(zipPath)}"); + var zipPath=Path.Combine(path, zip); + Logger?.Info($"Loading resource: {Path.GetFileNameWithoutExtension(zip)}"); LoadResource(new ZipFile(zipPath),Path.Combine(path,"data")); } StartAll(); diff --git a/RageCoop.Client/Sync/Entities/SyncedEntity.cs b/RageCoop.Client/Sync/Entities/SyncedEntity.cs index e4bc77a..c32443d 100644 --- a/RageCoop.Client/Sync/Entities/SyncedEntity.cs +++ b/RageCoop.Client/Sync/Entities/SyncedEntity.cs @@ -71,7 +71,6 @@ namespace RageCoop.Client /// /// internal protected bool _lastFrozen=false; - internal bool IsFrozen { get; set; } = false; internal int ModelHash { get; set; } internal Vector3 Position { get; set; } internal Vector3 Rotation { get; set; } diff --git a/RageCoop.Client/Sync/Entities/SyncedPed.cs b/RageCoop.Client/Sync/Entities/SyncedPed.cs index be8442f..0a5d908 100644 --- a/RageCoop.Client/Sync/Entities/SyncedPed.cs +++ b/RageCoop.Client/Sync/Entities/SyncedPed.cs @@ -332,11 +332,6 @@ namespace RageCoop.Client private void DisplayOnFoot() { - if (IsFrozen != _lastFrozen) - { - MainPed.SetFrozen(IsFrozen); - _lastFrozen=IsFrozen; - } if (IsInParachuteFreeFall) { MainPed.PositionNoOffset = Vector3.Lerp(MainPed.Position, Position + Velocity, 0.5f); diff --git a/RageCoop.Client/Sync/Entities/SyncedVehicle.cs b/RageCoop.Client/Sync/Entities/SyncedVehicle.cs index 8da1b12..d8636e3 100644 --- a/RageCoop.Client/Sync/Entities/SyncedVehicle.cs +++ b/RageCoop.Client/Sync/Entities/SyncedVehicle.cs @@ -127,20 +127,10 @@ namespace RageCoop.Client { MainVehicle.CustomSteeringAngle((float)(Math.PI / 180) * SteeringAngle); } - if (MainVehicle.ThrottlePower!=ThrottlePower) - { - MainVehicle.ThrottlePower=ThrottlePower; - } - if (MainVehicle.BrakePower!=BrakePower) - { - MainVehicle.BrakePower=BrakePower; - } - if (IsFrozen != _lastFrozen) - { - MainVehicle.SetFrozen(IsFrozen); - _lastFrozen=IsFrozen; - } - else if (MainVehicle.Position.DistanceTo(Position)<5) + MainVehicle.ThrottlePower=ThrottlePower; + MainVehicle.BrakePower=BrakePower; + + if (MainVehicle.Position.DistanceTo(Position)<5) { MainVehicle.Velocity = Velocity+5*(Position+Velocity*SyncParameters.PositioinPredictionDefault - MainVehicle.Position); if (IsFlipped) diff --git a/RageCoop.Client/toc.yml b/RageCoop.Client/toc.yml deleted file mode 100644 index 59f8010..0000000 --- a/RageCoop.Client/toc.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: Articles - href: articles/ -- name: Api Documentation - href: api/ - homepage: api/index.md diff --git a/RageCoop.Core/toc.yml b/RageCoop.Core/toc.yml deleted file mode 100644 index 59f8010..0000000 --- a/RageCoop.Core/toc.yml +++ /dev/null @@ -1,5 +0,0 @@ -- name: Articles - href: articles/ -- name: Api Documentation - href: api/ - homepage: api/index.md diff --git a/RageCoop.Server/Scripting/API.cs b/RageCoop.Server/Scripting/API.cs index 64ef371..f59c3c6 100644 --- a/RageCoop.Server/Scripting/API.cs +++ b/RageCoop.Server/Scripting/API.cs @@ -304,7 +304,7 @@ namespace RageCoop.Server.Scripting /// /// Register an handler to the specifed event hash, one event can have multiple handlers. /// - /// An unique identifier of the event, you can hash your event name with + /// An unique identifier of the event, you can hash your event name with /// An handler to be invoked when the event is received from the server. public void RegisterCustomEventHandler(int hash,Action handler) {