This commit is contained in:
hahwu 2025-11-21 18:54:50 +08:00
parent d0aec519d1
commit 1dfa4cda64

View File

@ -1,10 +1,9 @@
package game package game
import ( import (
"bytes"
"context" "context"
"database/sql" "database/sql"
"encoding/gob" "encoding/json"
"errors" "errors"
"math" "math"
"server/GoUtil" "server/GoUtil"
@ -980,14 +979,8 @@ func (p *Player) UpdateUserInfo() {
simple.ActLog = p.PlayMod.getFriendMod().GetActLogLast() simple.ActLog = p.PlayMod.getFriendMod().GetActLogLast()
simple.Physiology = p.PlayMod.getPlayroomMod().GetPhysiologyList() simple.Physiology = p.PlayMod.getPlayroomMod().GetPhysiologyList()
// 使用 gob 编码替代 json生成更紧凑的二进制 //TODO 存储到redis 在新版本中将优化成gob进行压缩
var buf bytes.Buffer value, _ := json.Marshal(simple)
enc := gob.NewEncoder(&buf)
if err := enc.Encode(simple); err != nil {
log.Debug("gob encode simple failed: %v", err)
return
}
value := buf.Bytes()
IdStr := strconv.Itoa(int(p.M_DwUin)) IdStr := strconv.Itoa(int(p.M_DwUin))
go db.RedisSetKeyBytes(IdStr, value, 0) go db.RedisSetKeyBytes(IdStr, value, 0)
} }