mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2025-12-19 18:32:23 +08:00
优化客户端协议代理
This commit is contained in:
2
Makefile
2
Makefile
@@ -108,7 +108,7 @@ gen_client_proto:
|
||||
rm -rf client_proto_gen.go && \
|
||||
go test -count=1 -v -run TestClientProtoGen . && \
|
||||
rm -rf proto/*.pb.go && \
|
||||
find proto -name '*.proto' | xargs -n 1000 protoc --proto_path=proto --go_out=proto
|
||||
find proto -name '*.proto' | xargs -n 1 protoc --proto_path=proto --go_out=proto
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
|
||||
@@ -8,6 +8,5 @@
|
||||
|
||||
> 1. 在此目录下建立proto目录
|
||||
> 2. 将对应版本的proto协议文件和client_cmd.csv协议号文件复制到proto目录下
|
||||
> 3. 到项目根目录下执行`make gen_client_proto`(本操作可能会修改proto文件,请注意备份)
|
||||
> 4. 执行`protoc --go_out=. *.proto`,将proto目录下的proto协议文件编译成pb.go
|
||||
> 5. 将gate服务器的配置文件中开启client_proto_proxy_enable客户端协议代理功能
|
||||
> 3. 到项目根目录下执行`make gen_client_proto`
|
||||
> 4. 将gate服务器的配置文件中开启client_proto_proxy_enable客户端协议代理功能
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package client_proto
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -33,15 +31,13 @@ func TestClientProtoGen(t *testing.T) {
|
||||
clientCmdData := string(clientCmdFile)
|
||||
clientCmdLineList := strings.Split(clientCmdData, "\n")
|
||||
// 生成代码文件
|
||||
var fileDataBuffer bytes.Buffer
|
||||
fileDataBuffer.WriteString(`package client_proto
|
||||
|
||||
import (
|
||||
"hk4e/gate/client_proto/proto"
|
||||
)
|
||||
|
||||
func (c *ClientCmdProtoMap) LoadClientCmdIdAndCmdName() {
|
||||
`)
|
||||
fileData := "package client_proto\n"
|
||||
fileData += "\n"
|
||||
fileData += "import (\n"
|
||||
fileData += "\t\"hk4e/gate/client_proto/proto\"\n"
|
||||
fileData += ")\n"
|
||||
fileData += "\n"
|
||||
fileData += "func (c *ClientCmdProtoMap) LoadClientCmdIdAndCmdName() {\n"
|
||||
for _, clientCmdLine := range clientCmdLineList {
|
||||
// 清理空格以及换行符之类的
|
||||
clientCmdLine = strings.TrimSpace(clientCmdLine)
|
||||
@@ -54,125 +50,22 @@ func (c *ClientCmdProtoMap) LoadClientCmdIdAndCmdName() {
|
||||
}
|
||||
cmdName := item[0]
|
||||
cmdId := item[1]
|
||||
_, err = fmt.Fprintf(&fileDataBuffer, ` c.clientCmdIdCmdNameMap[uint16(%s)] = "%s"
|
||||
c.clientCmdNameCmdIdMap["%s"] = uint16(%s)
|
||||
`, cmdId, cmdName, cmdName, cmdId)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fileData += "\tc.clientCmdIdCmdNameMap[uint16(" + cmdId + ")] = \"" + cmdName + "\"\n"
|
||||
fileData += "\tc.clientCmdNameCmdIdMap[\"" + cmdName + "\"] = uint16(" + cmdId + ")\n"
|
||||
}
|
||||
fileDataBuffer.WriteString(`}
|
||||
|
||||
func (c *ClientCmdProtoMap) GetClientProtoObjByName(protoObjName string) any {
|
||||
switch protoObjName {
|
||||
`)
|
||||
fileData += "}\n"
|
||||
fileData += "\n"
|
||||
fileData += "func (c *ClientCmdProtoMap) GetClientProtoObjByName(protoObjName string) any {\n"
|
||||
fileData += "\tswitch protoObjName {\n"
|
||||
for _, protoObjName := range protoObjNameList {
|
||||
_, err = fmt.Fprintf(&fileDataBuffer, ` case "%s":
|
||||
return new(proto.%s)
|
||||
`, protoObjName, protoObjName)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fileData += "\tcase \"" + protoObjName + "\":\n\t\treturn new(proto." + protoObjName + ")\n"
|
||||
}
|
||||
fileDataBuffer.WriteString(` default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
`)
|
||||
err = os.WriteFile("./client_proto_gen.go", fileDataBuffer.Bytes(), 0644)
|
||||
fileData += "\tdefault:\n"
|
||||
fileData += "\t\treturn nil\n"
|
||||
fileData += "\t}\n"
|
||||
fileData += "}\n"
|
||||
err = os.WriteFile("./client_proto_gen.go", []byte(fileData), 0644)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// 处理枚举
|
||||
for _, entry := range dir {
|
||||
rawFileData, err := os.ReadFile("./proto/" + entry.Name())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
rawFileStr := string(rawFileData)
|
||||
rawFileLine := strings.Split(rawFileStr, "\n")
|
||||
var newFileBuffer bytes.Buffer
|
||||
for i := 0; i < len(rawFileLine); i++ {
|
||||
line := rawFileLine[i]
|
||||
newFileBuffer.WriteString(line + "\n")
|
||||
if !strings.Contains(line, "enum") {
|
||||
continue
|
||||
}
|
||||
split := strings.Split(strings.TrimSpace(line), " ")
|
||||
if len(split) != 3 || split[0] != "enum" || split[2] != "{" {
|
||||
continue
|
||||
}
|
||||
enumName := split[1]
|
||||
// 从protocol/proto_hk4e下复制同名的枚举类替换掉原proto文件里的内容
|
||||
refEnum := FindEnumInDirFile("../../protocol/proto_hk4e", enumName)
|
||||
if refEnum == nil {
|
||||
continue
|
||||
}
|
||||
for _, ref := range refEnum {
|
||||
newFileBuffer.WriteString(ref + "\n")
|
||||
}
|
||||
i++
|
||||
for {
|
||||
nextLine := rawFileLine[i]
|
||||
if !strings.Contains(nextLine, "}") {
|
||||
i++
|
||||
} else {
|
||||
newFileBuffer.WriteString(nextLine + "\n")
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
err = os.WriteFile("./proto/"+entry.Name(), newFileBuffer.Bytes(), 0644)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func FindEnumInDirFile(path string, name string) (lineList []string) {
|
||||
dir, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, entry := range dir {
|
||||
if entry.IsDir() {
|
||||
ret := FindEnumInDirFile(path+"/"+entry.Name(), name)
|
||||
if ret != nil {
|
||||
return ret
|
||||
}
|
||||
continue
|
||||
}
|
||||
fileData, err := os.ReadFile(path + "/" + entry.Name())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fileStr := string(fileData)
|
||||
fileLine := strings.Split(fileStr, "\n")
|
||||
for i := 0; i < len(fileLine); i++ {
|
||||
line := fileLine[i]
|
||||
if !strings.Contains(line, "enum") {
|
||||
continue
|
||||
}
|
||||
split := strings.Split(strings.TrimSpace(line), " ")
|
||||
if len(split) != 3 || split[0] != "enum" || split[2] != "{" {
|
||||
continue
|
||||
}
|
||||
enumName := split[1]
|
||||
if enumName != name {
|
||||
continue
|
||||
}
|
||||
i++
|
||||
lineList := make([]string, 0)
|
||||
for {
|
||||
nextLine := fileLine[i]
|
||||
if !strings.Contains(nextLine, "}") {
|
||||
lineList = append(lineList, nextLine)
|
||||
} else {
|
||||
return lineList
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ func (k *KcpConnectManager) run() {
|
||||
regionEc2b := random.NewEc2b()
|
||||
regionEc2b.SetSeed(ec2b.Seed())
|
||||
// 3.7的时候修改了xor 首包无需使用加密密钥
|
||||
if k.getGateMaxVersion() < 3.7 {
|
||||
if k.getGateMaxVersion() < 370 {
|
||||
k.dispatchKey = regionEc2b.XorKey()
|
||||
} else {
|
||||
// 全部填充为0 不然会出问题
|
||||
@@ -125,10 +125,10 @@ func (k *KcpConnectManager) Close() {
|
||||
}
|
||||
|
||||
// getGateMaxVersion 获取gate最大可兼容的版本
|
||||
func (k *KcpConnectManager) getGateMaxVersion() (maxVersion float64) {
|
||||
func (k *KcpConnectManager) getGateMaxVersion() (maxVersion int) {
|
||||
versionSplit := strings.Split(config.GetConfig().Hk4e.Version, ",")
|
||||
for _, verStr := range versionSplit {
|
||||
version, err := strconv.ParseFloat(verStr, 64)
|
||||
version, err := strconv.Atoi(verStr)
|
||||
if err != nil {
|
||||
logger.Error("version a to i error: %v", err)
|
||||
return
|
||||
|
||||
@@ -56,14 +56,11 @@ func ProtoDecode(kcpMsg *KcpMsg,
|
||||
logger.Error("get server proto obj is nil, serverCmdId: %v", serverCmdId)
|
||||
return protoMsgList
|
||||
}
|
||||
delList, err := object.CopyProtoBufSameField(serverProtoObj, clientProtoObj)
|
||||
err = object.CopyProtoBufSameField(serverProtoObj, clientProtoObj)
|
||||
if err != nil {
|
||||
logger.Error("copy proto obj error: %v", err)
|
||||
return protoMsgList
|
||||
}
|
||||
if len(delList) != 0 {
|
||||
logger.Error("delete field name list: %v, cmdName: %v", delList, cmdName)
|
||||
}
|
||||
ConvClientPbDataToServer(serverProtoObj, clientCmdProtoMap)
|
||||
serverProtoData, err := pb.Marshal(serverProtoObj)
|
||||
if err != nil {
|
||||
@@ -168,14 +165,11 @@ func ProtoDecodePayloadLoop(cmdId uint16, protoData []byte, protoMessageList *[]
|
||||
logger.Error("get server proto obj is nil, serverCmdId: %v", serverCmdId)
|
||||
continue
|
||||
}
|
||||
delList, err := object.CopyProtoBufSameField(serverProtoObj, clientProtoObj)
|
||||
err = object.CopyProtoBufSameField(serverProtoObj, clientProtoObj)
|
||||
if err != nil {
|
||||
logger.Error("copy proto obj error: %v", err)
|
||||
continue
|
||||
}
|
||||
if len(delList) != 0 {
|
||||
logger.Error("delete field name list: %v, cmdName: %v", delList, cmdName)
|
||||
}
|
||||
ConvClientPbDataToServer(serverProtoObj, clientCmdProtoMap)
|
||||
serverProtoData, err := pb.Marshal(serverProtoObj)
|
||||
if err != nil {
|
||||
@@ -251,14 +245,11 @@ func ProtoEncode(protoMsg *ProtoMsg,
|
||||
logger.Error("get client proto obj is nil, cmdName: %v", cmdName)
|
||||
return nil
|
||||
}
|
||||
delList, err := object.CopyProtoBufSameField(clientProtoObj, serverProtoObj)
|
||||
err = object.CopyProtoBufSameField(clientProtoObj, serverProtoObj)
|
||||
if err != nil {
|
||||
logger.Error("copy proto obj error: %v", err)
|
||||
return nil
|
||||
}
|
||||
if len(delList) != 0 {
|
||||
logger.Error("delete field name list: %v, cmdName: %v", delList, cmdName)
|
||||
}
|
||||
ConvServerPbDataToClient(clientProtoObj, clientCmdProtoMap)
|
||||
clientProtoData, err := pb.Marshal(clientProtoObj)
|
||||
if err != nil {
|
||||
@@ -327,7 +318,7 @@ func ConvClientPbDataToServerCore(protoObjName string, serverProtoObj pb.Message
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, err = object.CopyProtoBufSameField(serverProtoObj, clientProtoObj)
|
||||
err = object.CopyProtoBufSameField(serverProtoObj, clientProtoObj)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -347,7 +338,7 @@ func ConvServerPbDataToClientCore(protoObjName string, serverProtoObj pb.Message
|
||||
if clientProtoObj == nil {
|
||||
return
|
||||
}
|
||||
_, err = object.CopyProtoBufSameField(clientProtoObj, serverProtoObj)
|
||||
err = object.CopyProtoBufSameField(clientProtoObj, serverProtoObj)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package alg
|
||||
|
||||
import (
|
||||
"math"
|
||||
)
|
||||
|
||||
// AoiManager aoi管理模块
|
||||
type AoiManager struct {
|
||||
// 区域边界坐标
|
||||
@@ -22,17 +26,27 @@ func NewAoiManager() (r *AoiManager) {
|
||||
}
|
||||
|
||||
// SetAoiRange 设置aoi区域边界坐标
|
||||
func (a *AoiManager) SetAoiRange(minX, maxX, minY, maxY, minZ, maxZ int16) {
|
||||
func (a *AoiManager) SetAoiRange(minX, maxX, minY, maxY, minZ, maxZ int16) bool {
|
||||
if minX >= maxX || minY >= maxY || minZ >= maxZ {
|
||||
return false
|
||||
}
|
||||
a.minX = minX
|
||||
a.maxX = maxX
|
||||
a.minY = minY
|
||||
a.maxY = maxY
|
||||
a.minZ = minZ
|
||||
a.maxZ = maxZ
|
||||
return true
|
||||
}
|
||||
|
||||
// Init3DRectAoiManager 初始化3D矩形aoi区域
|
||||
func (a *AoiManager) Init3DRectAoiManager(numX, numY, numZ int16) {
|
||||
func (a *AoiManager) Init3DRectAoiManager(numX, numY, numZ int16) bool {
|
||||
if numX <= 0 || numY <= 0 || numZ <= 0 {
|
||||
return false
|
||||
}
|
||||
if uint64(numX)*uint64(numY)*uint64(numZ) >= math.MaxUint32 {
|
||||
return false
|
||||
}
|
||||
a.numX = numX
|
||||
a.numY = numY
|
||||
a.numZ = numZ
|
||||
@@ -43,19 +57,12 @@ func (a *AoiManager) Init3DRectAoiManager(numX, numY, numZ int16) {
|
||||
// 利用格子坐标得到格子id gid从0开始按xzy的顺序增长
|
||||
gid := uint32(y)*(uint32(a.numX)*uint32(a.numZ)) + uint32(z)*uint32(a.numX) + uint32(x)
|
||||
// 初始化一个格子放在aoi中的map里 key是当前格子的id
|
||||
grid := NewGrid(
|
||||
gid,
|
||||
a.minX+x*a.GridXLen(),
|
||||
a.minX+(x+1)*a.GridXLen(),
|
||||
a.minY+y*a.GridYLen(),
|
||||
a.minY+(y+1)*a.GridYLen(),
|
||||
a.minZ+z*a.GridZLen(),
|
||||
a.minZ+(z+1)*a.GridZLen(),
|
||||
)
|
||||
grid := NewGrid(gid)
|
||||
a.gridMap[gid] = grid
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// GridXLen 每个格子在x轴方向的长度
|
||||
@@ -75,6 +82,9 @@ func (a *AoiManager) GridZLen() int16 {
|
||||
|
||||
// GetGidByPos 通过坐标获取对应的格子id
|
||||
func (a *AoiManager) GetGidByPos(x, y, z float32) uint32 {
|
||||
if !a.IsValidAoiPos(x, y, z) {
|
||||
return math.MaxUint32
|
||||
}
|
||||
gx := (int16(x) - a.minX) / a.GridXLen()
|
||||
gy := (int16(y) - a.minY) / a.GridYLen()
|
||||
gz := (int16(z) - a.minZ) / a.GridZLen()
|
||||
@@ -98,7 +108,7 @@ func (a *AoiManager) GetSurrGridListByGid(gid uint32) []*Grid {
|
||||
// 判断grid是否存在
|
||||
grid, exist := a.gridMap[gid]
|
||||
if !exist {
|
||||
return gridList
|
||||
return nil
|
||||
}
|
||||
// 添加自己
|
||||
if grid != nil {
|
||||
@@ -177,6 +187,9 @@ func (a *AoiManager) GetSurrGridListByGid(gid uint32) []*Grid {
|
||||
func (a *AoiManager) GetObjectListByPos(x, y, z float32) map[int64]any {
|
||||
// 根据坐标得到当前坐标属于哪个格子id
|
||||
gid := a.GetGidByPos(x, y, z)
|
||||
if gid == math.MaxUint32 {
|
||||
return nil
|
||||
}
|
||||
// 根据格子id得到周边格子的信息
|
||||
gridList := a.GetSurrGridListByGid(gid)
|
||||
objectListLen := 0
|
||||
@@ -205,59 +218,53 @@ func (a *AoiManager) GetObjectListByGid(gid uint32) map[int64]any {
|
||||
}
|
||||
|
||||
// AddObjectToGrid 添加一个object到一个格子中
|
||||
func (a *AoiManager) AddObjectToGrid(objectId int64, object any, gid uint32) {
|
||||
func (a *AoiManager) AddObjectToGrid(objectId int64, object any, gid uint32) bool {
|
||||
grid := a.gridMap[gid]
|
||||
if grid == nil {
|
||||
return
|
||||
return false
|
||||
}
|
||||
grid.AddObject(objectId, object)
|
||||
return true
|
||||
}
|
||||
|
||||
// RemoveObjectFromGrid 移除一个格子中的object
|
||||
func (a *AoiManager) RemoveObjectFromGrid(objectId int64, gid uint32) {
|
||||
func (a *AoiManager) RemoveObjectFromGrid(objectId int64, gid uint32) bool {
|
||||
grid := a.gridMap[gid]
|
||||
if grid == nil {
|
||||
return
|
||||
return false
|
||||
}
|
||||
grid.RemoveObject(objectId)
|
||||
return true
|
||||
}
|
||||
|
||||
// AddObjectToGridByPos 通过坐标添加一个object到一个格子中
|
||||
func (a *AoiManager) AddObjectToGridByPos(objectId int64, object any, x, y, z float32) {
|
||||
func (a *AoiManager) AddObjectToGridByPos(objectId int64, object any, x, y, z float32) bool {
|
||||
gid := a.GetGidByPos(x, y, z)
|
||||
a.AddObjectToGrid(objectId, object, gid)
|
||||
if gid == math.MaxUint32 {
|
||||
return false
|
||||
}
|
||||
return a.AddObjectToGrid(objectId, object, gid)
|
||||
}
|
||||
|
||||
// RemoveObjectFromGridByPos 通过坐标把一个object从对应的格子中删除
|
||||
func (a *AoiManager) RemoveObjectFromGridByPos(objectId int64, x, y, z float32) {
|
||||
func (a *AoiManager) RemoveObjectFromGridByPos(objectId int64, x, y, z float32) bool {
|
||||
gid := a.GetGidByPos(x, y, z)
|
||||
a.RemoveObjectFromGrid(objectId, gid)
|
||||
if gid == math.MaxUint32 {
|
||||
return false
|
||||
}
|
||||
return a.RemoveObjectFromGrid(objectId, gid)
|
||||
}
|
||||
|
||||
// Grid 地图格子
|
||||
type Grid struct {
|
||||
gid uint32 // 格子id
|
||||
// 格子边界坐标
|
||||
// 目前开发阶段暂时用不到 节省点内存
|
||||
// minX int16
|
||||
// maxX int16
|
||||
// minY int16
|
||||
// maxY int16
|
||||
// minZ int16
|
||||
// maxZ int16
|
||||
gid uint32 // 格子id
|
||||
objectMap map[int64]any // k:objectId v:对象
|
||||
}
|
||||
|
||||
// NewGrid 初始化格子
|
||||
func NewGrid(gid uint32, minX, maxX, minY, maxY, minZ, maxZ int16) (r *Grid) {
|
||||
func NewGrid(gid uint32) (r *Grid) {
|
||||
r = new(Grid)
|
||||
r.gid = gid
|
||||
// r.minX = minX
|
||||
// r.maxX = maxX
|
||||
// r.minY = minY
|
||||
// r.maxY = maxY
|
||||
// r.minZ = minZ
|
||||
// r.maxZ = maxZ
|
||||
r.objectMap = make(map[int64]any)
|
||||
return r
|
||||
}
|
||||
|
||||
@@ -3,11 +3,8 @@ package object
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
pb "google.golang.org/protobuf/proto"
|
||||
)
|
||||
@@ -42,74 +39,20 @@ func DeepUnmarshal(dst any, data []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func CopyProtoBufSameField(dst, src pb.Message) ([]string, error) {
|
||||
data, err := protojson.Marshal(src)
|
||||
func CopyProtoBufSameField(dst, src pb.Message) error {
|
||||
data, err := protojson.MarshalOptions{
|
||||
UseEnumNumbers: true,
|
||||
}.Marshal(src)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
delList := make([]string, 0)
|
||||
loopCount := 0
|
||||
for {
|
||||
loopCount++
|
||||
if loopCount > 1000 {
|
||||
return nil, errors.New("loop count limit")
|
||||
}
|
||||
err = protojson.Unmarshal(data, dst)
|
||||
if err != nil {
|
||||
if !strings.Contains(err.Error(), "unknown field") {
|
||||
return nil, err
|
||||
}
|
||||
split := strings.Split(err.Error(), "\"")
|
||||
if len(split) != 3 {
|
||||
return nil, err
|
||||
}
|
||||
fieldName := split[1]
|
||||
jsonObj := make(map[string]any)
|
||||
err = json.Unmarshal(data, &jsonObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
DeleteAllKeyNameFromStringAnyMap(jsonObj, fieldName)
|
||||
delList = append(delList, fieldName)
|
||||
data, err = json.Marshal(jsonObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
continue
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
return delList, nil
|
||||
}
|
||||
|
||||
func DeleteAllKeyNameFromStringAnyMap(src map[string]any, keyName string) {
|
||||
for key, value := range src {
|
||||
vm, ok := value.(map[string]any)
|
||||
if ok {
|
||||
DeleteAllKeyNameFromStringAnyMap(vm, keyName)
|
||||
}
|
||||
vs, ok := value.([]any)
|
||||
if ok {
|
||||
DeleteAllKeyNameFromAnyList(vs, keyName)
|
||||
}
|
||||
if key == keyName {
|
||||
delete(src, key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func DeleteAllKeyNameFromAnyList(src []any, keyName string) {
|
||||
for _, value := range src {
|
||||
vm, ok := value.(map[string]any)
|
||||
if ok {
|
||||
DeleteAllKeyNameFromStringAnyMap(vm, keyName)
|
||||
}
|
||||
vs, ok := value.([]any)
|
||||
if ok {
|
||||
DeleteAllKeyNameFromAnyList(vs, keyName)
|
||||
}
|
||||
err = protojson.UnmarshalOptions{
|
||||
DiscardUnknown: true,
|
||||
}.Unmarshal(data, dst)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ConvBoolToInt64(v bool) int64 {
|
||||
|
||||
@@ -203,7 +203,7 @@ func clientLogic(account string, session *net.Session) {
|
||||
if clientProtoObj == nil {
|
||||
continue
|
||||
}
|
||||
_, err := object.CopyProtoBufSameField(clientProtoObj, combatInvocationsNotify)
|
||||
err := object.CopyProtoBufSameField(clientProtoObj, combatInvocationsNotify)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user