mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 14:22:26 +08:00
拆分了聊天数据,减小玩家数据结构大小
This commit is contained in:
@@ -25,6 +25,23 @@ func DeepCopy(dst, src any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func DeepMarshal(src any) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
err := gob.NewEncoder(&buf).Encode(src)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func DeepUnmarshal(dst any, data []byte) error {
|
||||
err := gob.NewDecoder(bytes.NewBuffer(data)).Decode(dst)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CopyProtoBufSameField(dst, src pb.Message) ([]string, error) {
|
||||
data, err := protojson.Marshal(src)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user