From ed1a00932eb3265e4b458e6d1bc440b0f7242369 Mon Sep 17 00:00:00 2001 From: Le Duc Anh Date: Thu, 16 Oct 2025 10:50:59 +0700 Subject: [PATCH] reset the history pointer --- .../Scripts/Network/CSNetwork/NetworkManager.cs | 2 +- .../CSNetwork/Security/DecompressArcFourSecurity.cs | 9 ++------- .../Scripts/Network/CSNetwork/Security/StreamCompress.cs | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/NetworkManager.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/NetworkManager.cs index f44941284c..a93ec23bdd 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/NetworkManager.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/NetworkManager.cs @@ -379,7 +379,7 @@ namespace CSNetwork { currentIsec = _inputSecurity; } - + DecompressArcFourSecurity._logger = _logger; bool securityApplied = currentIsec != null && currentIsec.GetType() != typeof(NullSecurity); Octets dataToProcess; // This will hold the data block we decode from diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/Security/DecompressArcFourSecurity.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/Security/DecompressArcFourSecurity.cs index 5a2ee9a521..1ae3f57fe2 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/Security/DecompressArcFourSecurity.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/Security/DecompressArcFourSecurity.cs @@ -12,7 +12,7 @@ namespace CSNetwork.Security /// public class DecompressArcFourSecurity : BaseSecurity { - private static readonly IPrefixedLogger _logger = LoggerFactory.GetLogger(nameof(DecompressArcFourSecurity)); + public static IPrefixedLogger _logger = LoggerFactory.GetLogger(nameof(DecompressArcFourSecurity)); private ARCFourSecurity _arcFour; // Internal RC4 instance private byte[] _key; @@ -55,7 +55,6 @@ namespace CSNetwork.Security // or just to be safe. Ensure _arcFour.Update returns a *new* Octets. // *** If ARCFourSecurity.Update modified the input Octets in-place, this would be wrong. *** // *** Assuming ARCFourSecurity.Update follows the abstract Security pattern and returns new Octets *** - UnityEngine.Debug.Log($"ENCRYPTED: {data.RawBuffer[0]}"); decryptedData = _arcFour.Update(data); } @@ -76,15 +75,11 @@ namespace CSNetwork.Security Octets decompressedData; try { - UnityEngine.Debug.Log($"DECRYPTED: {decryptedData.RawBuffer[0]}"); decompressedData = decompressor.Update(decryptedData); } catch (Exception ex) { - //_logger.Log(LogType.Error, $"MPPC Decompression Error after decryption: {ex.Message}. Decrypted Length: {decryptedData.Length}"); - string firstBytes = BitConverter.ToString(decryptedData.RawBuffer, 0, Math.Min(decryptedData.Length, 16)); - _logger.Log(LogType.Debug, $"Decrypted Data (first {Math.Min(decryptedData.Length, 16)} bytes): {firstBytes}"); - _logger.LogException(ex); + _logger.Log(LogType.Info, $"{ex.Message} - {ex.StackTrace}"); throw new InvalidDataException("MPPC decompression failed after decryption.", ex); } diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/Security/StreamCompress.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/Security/StreamCompress.cs index b64048cd1d..3e4a3e9f49 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/Security/StreamCompress.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/Security/StreamCompress.cs @@ -149,7 +149,7 @@ namespace CSNetwork.Security Array.Copy(history, histhead, segment, 0, segment.Length); output.Insert(output.Size, segment); - if (histptr - histhead == MPPC_HIST_LEN) + if (histptr == MPPC_HIST_LEN) histptr = 0; histhead = histptr;