From a75664632cf6508823d5f9712d5c493e0b7a1038 Mon Sep 17 00:00:00 2001 From: zqj <582132116@qq.com> Date: Wed, 8 Jun 2022 16:09:53 +0800 Subject: [PATCH] fix: update protocode --- cmd/gameserver/plugin/plugin.go | 2 +- cmd/gameserver/service/agent.go | 6 +++--- cmd/test/action/protocode.go | 1 - cmd/test/main.go | 2 +- pb/protocode.pb.go | 16 ++++++++-------- tools/generator.py | 11 +++++++---- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/cmd/gameserver/plugin/plugin.go b/cmd/gameserver/plugin/plugin.go index e69d284..50adb9f 100644 --- a/cmd/gameserver/plugin/plugin.go +++ b/cmd/gameserver/plugin/plugin.go @@ -16,7 +16,7 @@ func init() { func GetActionMap() map[interface{}]interface{} { logger.Debug("init protocode...") am := make(map[interface{}]interface{}) - am[uint32(pb.ProtoCode_LoginReq)] = LoginRpc + am[uint32(pb.ProtoCode_LoginRsp)] = LoginRpc return am } diff --git a/cmd/gameserver/service/agent.go b/cmd/gameserver/service/agent.go index 4b4d732..147d08a 100644 --- a/cmd/gameserver/service/agent.go +++ b/cmd/gameserver/service/agent.go @@ -112,12 +112,12 @@ func (c *Agent) OnMessage(msg components.IMessage) error { atomic.StoreInt64(&c.lastHeartCheckTime, common.Timex()) logger.Debug("req protocolID: %d, %s", msg.GetHeader().GetMsgID(), msg.GetData()) //heart - if msg.GetHeader().GetMsgID() == uint32(pb.ProtoCode_HeartReq) { + if msg.GetHeader().GetMsgID() == uint32(pb.ProtoCode_HeartRpc) { return nil } //login - if msg.GetHeader().GetMsgID() == uint32(pb.ProtoCode_LoginReq) { + if msg.GetHeader().GetMsgID() == uint32(pb.ProtoCode_LoginRpc) { code, protoMsg := c.OnLoginQuery(msg) return c.SendMsg(code, msg.GetHeader().GetMsgID(), protoMsg) } @@ -128,7 +128,7 @@ func (c *Agent) OnMessage(msg components.IMessage) error { return fmt.Errorf("cmd: %d, handler is nil", msg.GetHeader().GetMsgID()) } - if msg.GetHeader().GetMsgID() != uint32(pb.ProtoCode_CreateReq) && c.Role == nil { + if msg.GetHeader().GetMsgID() != uint32(pb.ProtoCode_CreateRpc) && c.Role == nil { return c.Send(-101, msg.GetHeader().GetMsgID(), nil) } diff --git a/cmd/test/action/protocode.go b/cmd/test/action/protocode.go index b486f0a..5d02630 100644 --- a/cmd/test/action/protocode.go +++ b/cmd/test/action/protocode.go @@ -6,7 +6,6 @@ import ( func GetTestActionMap() map[interface{}]interface{} { am := make(map[interface{}]interface{}) - am[uint32(pb.ProtoCode_LoginRsp)] = LoginRsp am[uint32(pb.ProtoCode_HeartRpc)] = HeartRsp am[uint32(pb.ProtoCode_CreateRpc)] = CreateRsp am[uint32(pb.ProtoCode_ChangeTeamRpc)] = ChangeTeamRsp diff --git a/cmd/test/main.go b/cmd/test/main.go index c34bcad..4cee58f 100644 --- a/cmd/test/main.go +++ b/cmd/test/main.go @@ -26,7 +26,7 @@ func main() { time.Sleep(2 * time.Second) for { //tc.SendPB(pb.ProtoCode_HeartReq, nil) - tc.SendPB(pb.ProtoCode_HeroUpLevelReq, pp) + tc.SendPB(pb.ProtoCode_HeroUpLevelRpc, pp) time.Sleep(5 * time.Second) } diff --git a/pb/protocode.pb.go b/pb/protocode.pb.go index 5f634e3..1b1b307 100644 --- a/pb/protocode.pb.go +++ b/pb/protocode.pb.go @@ -24,8 +24,8 @@ type ProtoCode int32 const ( ProtoCode_UNKNOWN ProtoCode = 0 - ProtoCode_LoginRsp ProtoCode = 1 - ProtoCode_HeartRpc ProtoCode = 2 + ProtoCode_HeartRpc ProtoCode = 1 + ProtoCode_LoginRpc ProtoCode = 2 ProtoCode_CreateRpc ProtoCode = 3 ProtoCode_ChangeTeamRpc ProtoCode = 4 ProtoCode_HeroEquipReferRpc ProtoCode = 5 @@ -48,8 +48,8 @@ const ( var ( ProtoCode_name = map[int32]string{ 0: "UNKNOWN", - 1: "LoginRsp", - 2: "HeartRpc", + 1: "HeartRpc", + 2: "LoginRpc", 3: "CreateRpc", 4: "ChangeTeamRpc", 5: "HeroEquipReferRpc", @@ -69,8 +69,8 @@ var ( } ProtoCode_value = map[string]int32{ "UNKNOWN": 0, - "LoginRsp": 1, - "HeartRpc": 2, + "HeartRpc": 1, + "LoginRpc": 2, "CreateRpc": 3, "ChangeTeamRpc": 4, "HeroEquipReferRpc": 5, @@ -123,8 +123,8 @@ var file_protocode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0xfb, 0x02, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, - 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, - 0x52, 0x73, 0x70, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74, 0x52, 0x70, + 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74, + 0x52, 0x70, 0x63, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x70, 0x63, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x70, 0x63, 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x70, 0x63, 0x10, 0x04, 0x12, 0x15, 0x0a, 0x11, 0x48, 0x65, 0x72, 0x6f, 0x45, 0x71, 0x75, diff --git a/tools/generator.py b/tools/generator.py index 0bf1840..31f6cab 100644 --- a/tools/generator.py +++ b/tools/generator.py @@ -28,6 +28,9 @@ def generatorProto(path): GoCodeData = "" GoCodeTestData = "" for file in files: + if file.find("account.proto") != -1: + continue + if os.path.isdir(file): continue @@ -47,12 +50,12 @@ def generatorProto(path): messageStr = sline[1].replace('\n', '').replace('{', "") n1 = messageStr.find('Req') loginReq = messageStr.find('LoginReq') - if loginReq != -1: - continue if n1 != -1: code += 1 ProtoCodeData += ProtoCodeLineReq.format(messageStr[:n1], code) + if loginReq != -1: + continue GoCodeData += GoProtoCodeLine.format(messageStr[:n1], messageStr[:n1]) GoCodeTestData += GoProtoCodeTestReqLine.format(messageStr[:n1], messageStr[:n1]) @@ -67,12 +70,12 @@ def generatorProto(path): messageStr = sline[1].replace('\n', '').replace('{', "") n2 = messageStr.find('Rsp') loginReq = messageStr.find('LoginReq') - if loginReq != -1: - continue if n2 != -1: code += 1 ProtoCodeData += ProtoCodeLineRsp.format(messageStr[:n2], code) + if loginReq != -1: + continue GoCodeTestData += GoProtoCodeTestRspLine.format(messageStr[:n2], messageStr[:n2]) -- libgit2 0.21.2