diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/Protocol.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/Protocol.cs index 78495654c6..81aa57a54a 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/Protocol.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/Protocol.cs @@ -166,7 +166,19 @@ namespace CSNetwork.Protocols private static bool ValidateProtocol(uint type, uint size) { var stub = _protocolMap.GetValueOrDefault(type); - return stub != null && size <= MaxProtocolSize; + if (stub == null) + { + _logger.Warning($"ValidateProtocol: Protocol type {type} not found. Returning false."); + return false; + } + + if (size > MaxProtocolSize) + { + _logger.Warning($"ValidateProtocol: Protocol type {type} size {size} is greater than MaxProtocolSize {MaxProtocolSize}. Returning false."); + return false; + } + + return true; } private const int MaxProtocolSize = 16 * 1024 * 1024; // 16MB max size diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/getcustomdata_re.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/getcustomdata_re.cs new file mode 100644 index 0000000000..6e8e9e76be --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/getcustomdata_re.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; + +namespace CSNetwork.Protocols +{ + public class getcustomdata_re : Protocol + { + public int Result { get; set; } + public int Roleid { get; set; } + public int Localsid { get; set; } + public Octets UiConfig { get; set; } + + public int retcode { get; set; } + public int roleid { get; set; } + public uint localsid { get; set; } + public uint cus_roleid { get; set; } + public Octets customdata {get; set;} + + public getcustomdata_re() : base(ProtocolType.PROTOCOL_GETCUSTOMDATA_RE) + { + customdata = new Octets(); + } + + public override Protocol Clone() => new getcustomdata_re + { + retcode = retcode, + roleid = roleid, + localsid = localsid, + cus_roleid = cus_roleid, + customdata = customdata + }; + + public override void Marshal(OctetsStream os) + { + os.Write(retcode); + os.Write(roleid); + os.Write(localsid); + os.Write(cus_roleid); + os.Write(customdata); + } + + public override void Unmarshal(OctetsStream os) + { + retcode = os.ReadInt32(); + roleid = os.ReadInt32(); + localsid = os.ReadUInt32(); + cus_roleid = os.ReadUInt32(); + customdata = os.ReadOctets(); + } + + public override int PriorPolicy() => 1; + + public override bool SizePolicy(int size) => size <= 4096; + } +} + diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/getcustomdata_re.cs.meta b/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/getcustomdata_re.cs.meta new file mode 100644 index 0000000000..8e5fadc8d8 --- /dev/null +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/Protocols/getcustomdata_re.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 6fa7e46f896407f499da351c8772b6d2 \ No newline at end of file