From 30e6d227a76d734d9a8cdc71480ec48d19bfcf4b Mon Sep 17 00:00:00 2001 From: zqj <582132116@qq.com> Date: Wed, 8 Jun 2022 17:02:30 +0800 Subject: [PATCH] fix: add nty --- cmd/test/action/TestAction.go | 2 +- cmd/test/action/protocode.go | 2 +- models/rolePlugin.go | 8 ++++---- pb/game.pb.go | 26 +++++++++++++------------- pb/protocode.pb.go | 36 ++++++++++++++++++------------------ protos | 2 +- tools/generator.py | 24 +++++++++++++++++++++++- 7 files changed, 61 insertions(+), 39 deletions(-) diff --git a/cmd/test/action/TestAction.go b/cmd/test/action/TestAction.go index f552f16..ede1409 100644 --- a/cmd/test/action/TestAction.go +++ b/cmd/test/action/TestAction.go @@ -31,7 +31,7 @@ func RoleRsp(role *models.RoleTestModel, msg components.IMessage) { func RoleUpdatePropertyRsp(role *models.RoleTestModel, msg components.IMessage) { } -func RoleUpdateItemsRsp(role *models.RoleTestModel, msg components.IMessage) { +func RoleUpdateItemsNty(role *models.RoleTestModel, msg components.IMessage) { } func RoleUpdateChangeRsp(role *models.RoleTestModel, msg components.IMessage) { diff --git a/cmd/test/action/protocode.go b/cmd/test/action/protocode.go index 5d02630..3a5f6b6 100644 --- a/cmd/test/action/protocode.go +++ b/cmd/test/action/protocode.go @@ -19,10 +19,10 @@ func GetTestActionMap() map[interface{}]interface{} { am[uint32(pb.ProtoCode_DisConnectRsp)] = DisConnectRsp am[uint32(pb.ProtoCode_RoleRsp)] = RoleRsp am[uint32(pb.ProtoCode_RoleUpdatePropertyRsp)] = RoleUpdatePropertyRsp - am[uint32(pb.ProtoCode_RoleUpdateItemsRsp)] = RoleUpdateItemsRsp am[uint32(pb.ProtoCode_RoleEndBattleRsp)] = RoleEndBattleRsp am[uint32(pb.ProtoCode_EquipmentAddRsp)] = EquipmentAddRsp am[uint32(pb.ProtoCode_HeroUpLevelRsp)] = HeroUpLevelRsp + am[uint32(pb.ProtoCode_RoleUpdateItemsNty)] = RoleUpdateItemsNty return am } diff --git a/models/rolePlugin.go b/models/rolePlugin.go index 4dbc738..080c7c4 100644 --- a/models/rolePlugin.go +++ b/models/rolePlugin.go @@ -48,14 +48,14 @@ func (m *RoleModel) AddItem(key string, count int32) bool { } m.SetProperty("items", common.MapNumToString(m.Items)) - rsp, err := proto.Marshal(&pb.RoleUpdateItemsRsp{Items: fmt.Sprintf("%s=%d", key, num)}) + rsp, err := proto.Marshal(&pb.RoleUpdateItemsNty{Items: fmt.Sprintf("%s=%d", key, num)}) if err != nil { logger.Error(err.Error()) return true } if m.GetConn() != nil { - m.GetConn().Send(0, uint32(pb.ProtoCode_RoleUpdateItemsRsp), rsp) + m.GetConn().Send(0, uint32(pb.ProtoCode_RoleUpdateItemsNty), rsp) } return true } @@ -77,14 +77,14 @@ func (m *RoleModel) AddItems(params common.IMapStringNum) bool { m.SetProperty("items", common.MapNumToString(m.Items)) - rsp, err := proto.Marshal(&pb.RoleUpdateItemsRsp{Items: common.MapToString(tmp)}) + rsp, err := proto.Marshal(&pb.RoleUpdateItemsNty{Items: common.MapToString(tmp)}) if err != nil { logger.Error(err.Error()) return true } if m.GetConn() != nil { - m.GetConn().Send(0, uint32(pb.ProtoCode_RoleUpdateItemsRsp), rsp) + m.GetConn().Send(0, uint32(pb.ProtoCode_RoleUpdateItemsNty), rsp) } return true diff --git a/pb/game.pb.go b/pb/game.pb.go index b2615ca..17228e0 100644 --- a/pb/game.pb.go +++ b/pb/game.pb.go @@ -559,8 +559,8 @@ func (x *RoleUpdatePropertyRsp) GetRole() *Role { return nil } -//ResponseCmd RoleUpdateItemsRsp -type RoleUpdateItemsRsp struct { +//ResponseCmd RoleUpdateItemsNty +type RoleUpdateItemsNty struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -568,8 +568,8 @@ type RoleUpdateItemsRsp struct { Items string `protobuf:"bytes,1,opt,name=items,proto3" json:"items,omitempty"` } -func (x *RoleUpdateItemsRsp) Reset() { - *x = RoleUpdateItemsRsp{} +func (x *RoleUpdateItemsNty) Reset() { + *x = RoleUpdateItemsNty{} if protoimpl.UnsafeEnabled { mi := &file_game_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -577,13 +577,13 @@ func (x *RoleUpdateItemsRsp) Reset() { } } -func (x *RoleUpdateItemsRsp) String() string { +func (x *RoleUpdateItemsNty) String() string { return protoimpl.X.MessageStringOf(x) } -func (*RoleUpdateItemsRsp) ProtoMessage() {} +func (*RoleUpdateItemsNty) ProtoMessage() {} -func (x *RoleUpdateItemsRsp) ProtoReflect() protoreflect.Message { +func (x *RoleUpdateItemsNty) ProtoReflect() protoreflect.Message { mi := &file_game_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -595,12 +595,12 @@ func (x *RoleUpdateItemsRsp) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use RoleUpdateItemsRsp.ProtoReflect.Descriptor instead. -func (*RoleUpdateItemsRsp) Descriptor() ([]byte, []int) { +// Deprecated: Use RoleUpdateItemsNty.ProtoReflect.Descriptor instead. +func (*RoleUpdateItemsNty) Descriptor() ([]byte, []int) { return file_game_proto_rawDescGZIP(), []int{10} } -func (x *RoleUpdateItemsRsp) GetItems() string { +func (x *RoleUpdateItemsNty) GetItems() string { if x != nil { return x.Items } @@ -1116,7 +1116,7 @@ var file_game_proto_rawDesc = []byte{ 0x64, 0x12, 0x20, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x2a, 0x0a, 0x12, 0x52, 0x6f, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65, + 0x65, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x4e, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x29, 0x0a, 0x11, 0x52, 0x6f, 0x6c, 0x65, 0x43, 0x6c, 0x65, 0x61, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, @@ -1187,7 +1187,7 @@ var file_game_proto_goTypes = []interface{}{ (*HeroEquipReferReq)(nil), // 7: game.HeroEquipReferReq (*RoleRsp)(nil), // 8: game.RoleRsp (*RoleUpdatePropertyRsp)(nil), // 9: game.RoleUpdatePropertyRsp - (*RoleUpdateItemsRsp)(nil), // 10: game.RoleUpdateItemsRsp + (*RoleUpdateItemsNty)(nil), // 10: game.RoleUpdateItemsNty (*RoleClearItemsReq)(nil), // 11: game.RoleClearItemsReq (*RoleStartBattleReq)(nil), // 12: game.RoleStartBattleReq (*RoleEndBattleReq)(nil), // 13: game.RoleEndBattleReq @@ -1347,7 +1347,7 @@ func file_game_proto_init() { } } file_game_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RoleUpdateItemsRsp); i { + switch v := v.(*RoleUpdateItemsNty); i { case 0: return &v.state case 1: diff --git a/pb/protocode.pb.go b/pb/protocode.pb.go index 1b1b307..fc01ced 100644 --- a/pb/protocode.pb.go +++ b/pb/protocode.pb.go @@ -38,10 +38,10 @@ const ( ProtoCode_DisConnectRsp ProtoCode = 12 ProtoCode_RoleRsp ProtoCode = 13 ProtoCode_RoleUpdatePropertyRsp ProtoCode = 14 - ProtoCode_RoleUpdateItemsRsp ProtoCode = 15 - ProtoCode_RoleEndBattleRsp ProtoCode = 16 - ProtoCode_EquipmentAddRsp ProtoCode = 17 - ProtoCode_HeroUpLevelRsp ProtoCode = 18 + ProtoCode_RoleEndBattleRsp ProtoCode = 15 + ProtoCode_EquipmentAddRsp ProtoCode = 16 + ProtoCode_HeroUpLevelRsp ProtoCode = 17 + ProtoCode_RoleUpdateItemsNty ProtoCode = 18 ) // Enum value maps for ProtoCode. @@ -62,10 +62,10 @@ var ( 12: "DisConnectRsp", 13: "RoleRsp", 14: "RoleUpdatePropertyRsp", - 15: "RoleUpdateItemsRsp", - 16: "RoleEndBattleRsp", - 17: "EquipmentAddRsp", - 18: "HeroUpLevelRsp", + 15: "RoleEndBattleRsp", + 16: "EquipmentAddRsp", + 17: "HeroUpLevelRsp", + 18: "RoleUpdateItemsNty", } ProtoCode_value = map[string]int32{ "UNKNOWN": 0, @@ -83,10 +83,10 @@ var ( "DisConnectRsp": 12, "RoleRsp": 13, "RoleUpdatePropertyRsp": 14, - "RoleUpdateItemsRsp": 15, - "RoleEndBattleRsp": 16, - "EquipmentAddRsp": 17, - "HeroUpLevelRsp": 18, + "RoleEndBattleRsp": 15, + "EquipmentAddRsp": 16, + "HeroUpLevelRsp": 17, + "RoleUpdateItemsNty": 18, } ) @@ -140,12 +140,12 @@ var file_protocode_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x73, 0x70, 0x10, 0x0c, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x10, 0x0d, 0x12, 0x19, 0x0a, 0x15, 0x52, 0x6f, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x52, 0x73, - 0x70, 0x10, 0x0e, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x6f, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x73, 0x70, 0x10, 0x0f, 0x12, 0x14, 0x0a, 0x10, 0x52, - 0x6f, 0x6c, 0x65, 0x45, 0x6e, 0x64, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x10, - 0x10, 0x12, 0x13, 0x0a, 0x0f, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x64, - 0x64, 0x52, 0x73, 0x70, 0x10, 0x11, 0x12, 0x12, 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x55, 0x70, - 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x73, 0x70, 0x10, 0x12, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, + 0x70, 0x10, 0x0e, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x6f, 0x6c, 0x65, 0x45, 0x6e, 0x64, 0x42, 0x61, + 0x74, 0x74, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x10, 0x0f, 0x12, 0x13, 0x0a, 0x0f, 0x45, 0x71, 0x75, + 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x52, 0x73, 0x70, 0x10, 0x10, 0x12, 0x12, + 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x55, 0x70, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x73, 0x70, + 0x10, 0x11, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x6f, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x49, 0x74, 0x65, 0x6d, 0x73, 0x4e, 0x74, 0x79, 0x10, 0x12, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } diff --git a/protos b/protos index d368d9b..c196389 160000 --- a/protos +++ b/protos @@ -1 +1 @@ -Subproject commit d368d9b3f0ceb90f11f2da4f1bce0b0236e828aa +Subproject commit c1963893851348082d49e07a02b762bde8aac6f5 diff --git a/tools/generator.py b/tools/generator.py index 31f6cab..e4065ee 100644 --- a/tools/generator.py +++ b/tools/generator.py @@ -9,6 +9,7 @@ ProtoCodeStr = "syntax = \"proto3\";\noption go_package = \"../pb;pb\";\n\npacka "UNKNOWN = 0;\n {}\n}} " ProtoCodeLineReq = "\t{}Rpc = {};\n" ProtoCodeLineRsp = "\t{}Rsp = {};\n" +ProtoCodeLineNty = "\t{}Nty= {};\n" GoProtoCodeStr = "package action\n\nimport (\n\t\"pro2d/common/logger\"\n\t\"pro2d/pb\"\n)\n\nfunc GetActionMap() " \ "map[interface{{}}]interface{{}} {{\n\tlogger.Debug(\"init protocode...\")\n\tam := make(map[interface{{" \ @@ -20,6 +21,7 @@ GoProtoCodeTestStr = "package action\n\nimport (\n\t\"pro2d/pb\"\n)\n\nfunc GetT "}}]interface{{}})\n{}\n\treturn am\n}}" GoProtoCodeTestReqLine = "\tam[uint32(pb.ProtoCode_{}Rpc)] = {}Rsp\n" GoProtoCodeTestRspLine = "\tam[uint32(pb.ProtoCode_{}Rsp)] = {}Rsp\n" +GoProtoCodeTestNtyLine = "\tam[uint32(pb.ProtoCode_{}Nty)] = {}Nty\n" def generatorProto(path): files = os.listdir(path) @@ -40,6 +42,7 @@ def generatorProto(path): if firstline.find("proto3") == -1: continue + # req for line in lines: if line.find("message") == -1: continue @@ -59,7 +62,7 @@ def generatorProto(path): GoCodeData += GoProtoCodeLine.format(messageStr[:n1], messageStr[:n1]) GoCodeTestData += GoProtoCodeTestReqLine.format(messageStr[:n1], messageStr[:n1]) - ProtoCodeData += "\n" + # rsp for line in lines: if line.find("message") == -1: continue @@ -78,6 +81,25 @@ def generatorProto(path): continue GoCodeTestData += GoProtoCodeTestRspLine.format(messageStr[:n2], messageStr[:n2]) + # nty + for line in lines: + if line.find("message") == -1: + continue + sline = line.split(' ') + if len(sline) < 2: + continue + + messageStr = sline[1].replace('\n', '').replace('{', "") + n3 = messageStr.find('Nty') + loginReq = messageStr.find('LoginReq') + + if n3 != -1: + code += 1 + ProtoCodeData += ProtoCodeLineNty.format(messageStr[:n3], code) + if loginReq != -1: + continue + GoCodeTestData += GoProtoCodeTestNtyLine.format(messageStr[:n3], messageStr[:n3]) + # protocode.go gostr = GoProtoCodeStr.format(GoCodeData) -- libgit2 0.21.2