diff --git a/Assets/GameScripts/HotFix/GameLogic/Network/ProtobufUtility.cs b/Assets/GameScripts/HotFix/GameLogic/Network/ProtobufUtility.cs
index 05171715..3515375e 100644
--- a/Assets/GameScripts/HotFix/GameLogic/Network/ProtobufUtility.cs
+++ b/Assets/GameScripts/HotFix/GameLogic/Network/ProtobufUtility.cs
@@ -2,8 +2,10 @@
using System.ComponentModel;
using System.IO;
using System.Linq;
+using System.Text;
using GameProto;
using Google.Protobuf;
+using TEngine;
///
@@ -22,7 +24,7 @@ public partial class ProtobufUtility
{
((IMessage)message).WriteTo(stream);
}
-
+
///
/// 消息压入内存流。
///
@@ -32,7 +34,7 @@ public partial class ProtobufUtility
{
((IMessage)message).WriteTo(stream);
}
-
+
///
/// 消息压入内存流。
///
@@ -135,7 +137,7 @@ public partial class ProtobufUtility
{
return ((IMessage)message).ToByteArray();
}
-
+
///
/// 序列化protobuf
///
@@ -151,11 +153,26 @@ public partial class ProtobufUtility
///
///
///
+ ///
+ ///
///
- public static T Deserialize(byte[] dataBytes) where T : IMessage, new()
+ public static T Deserialize(byte[] dataBytes, int offset, int bodyCount) where T : IMessage, new()
{
T msg = new T();
- msg = (T)msg.Descriptor.Parser.ParseFrom(dataBytes);
+ msg = (T)msg.Descriptor.Parser.ParseFrom(dataBytes, offset, bodyCount);
+ return msg;
+ }
+
+ ///
+ /// 反序列化protobuf
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static CSPkg Deserialize(byte[] dataBytes, int offset, int bodyCount)
+ {
+ var msg = (CSPkg)CSPkg.Descriptor.Parser.ParseFrom(dataBytes, offset, bodyCount);
return msg;
}
@@ -168,4 +185,33 @@ public partial class ProtobufUtility
{
return cmdMerge & 65535;
}
+
+
+ private static readonly StringBuilder StringBuilder = new StringBuilder();
+
+ public static string GetBuffer(byte[] buffer)
+ {
+ StringBuilder.Length = 0;
+ StringBuilder.Append("[");
+ for (int i = 0; i < buffer.Length; i++)
+ {
+ if (i == buffer.Length - 1)
+ {
+ StringBuilder.Append(buffer[i]);
+ StringBuilder.Append("]");
+ }
+ else
+ {
+ StringBuilder.Append(buffer[i]);
+ StringBuilder.Append(",");
+ }
+ }
+
+ return StringBuilder.ToString();
+ }
+
+ public static void PrintBuffer(byte[] buffer)
+ {
+ Log.Debug(GetBuffer(buffer));
+ }
}
\ No newline at end of file