Commit 30e6d227a76d734d9a8cdc71480ec48d19bfcf4b

Authored by zhangqijia
1 parent 4e984646

fix: add nty

cmd/test/action/TestAction.go
... ... @@ -31,7 +31,7 @@ func RoleRsp(role *models.RoleTestModel, msg components.IMessage) {
31 31 func RoleUpdatePropertyRsp(role *models.RoleTestModel, msg components.IMessage) {
32 32 }
33 33  
34   -func RoleUpdateItemsRsp(role *models.RoleTestModel, msg components.IMessage) {
  34 +func RoleUpdateItemsNty(role *models.RoleTestModel, msg components.IMessage) {
35 35 }
36 36  
37 37 func RoleUpdateChangeRsp(role *models.RoleTestModel, msg components.IMessage) {
... ...
cmd/test/action/protocode.go
... ... @@ -19,10 +19,10 @@ func GetTestActionMap() map[interface{}]interface{} {
19 19 am[uint32(pb.ProtoCode_DisConnectRsp)] = DisConnectRsp
20 20 am[uint32(pb.ProtoCode_RoleRsp)] = RoleRsp
21 21 am[uint32(pb.ProtoCode_RoleUpdatePropertyRsp)] = RoleUpdatePropertyRsp
22   - am[uint32(pb.ProtoCode_RoleUpdateItemsRsp)] = RoleUpdateItemsRsp
23 22 am[uint32(pb.ProtoCode_RoleEndBattleRsp)] = RoleEndBattleRsp
24 23 am[uint32(pb.ProtoCode_EquipmentAddRsp)] = EquipmentAddRsp
25 24 am[uint32(pb.ProtoCode_HeroUpLevelRsp)] = HeroUpLevelRsp
  25 + am[uint32(pb.ProtoCode_RoleUpdateItemsNty)] = RoleUpdateItemsNty
26 26  
27 27 return am
28 28 }
... ...
models/rolePlugin.go
... ... @@ -48,14 +48,14 @@ func (m *RoleModel) AddItem(key string, count int32) bool {
48 48 }
49 49 m.SetProperty("items", common.MapNumToString(m.Items))
50 50  
51   - rsp, err := proto.Marshal(&pb.RoleUpdateItemsRsp{Items: fmt.Sprintf("%s=%d", key, num)})
  51 + rsp, err := proto.Marshal(&pb.RoleUpdateItemsNty{Items: fmt.Sprintf("%s=%d", key, num)})
52 52 if err != nil {
53 53 logger.Error(err.Error())
54 54 return true
55 55 }
56 56  
57 57 if m.GetConn() != nil {
58   - m.GetConn().Send(0, uint32(pb.ProtoCode_RoleUpdateItemsRsp), rsp)
  58 + m.GetConn().Send(0, uint32(pb.ProtoCode_RoleUpdateItemsNty), rsp)
59 59 }
60 60 return true
61 61 }
... ... @@ -77,14 +77,14 @@ func (m *RoleModel) AddItems(params common.IMapStringNum) bool {
77 77  
78 78 m.SetProperty("items", common.MapNumToString(m.Items))
79 79  
80   - rsp, err := proto.Marshal(&pb.RoleUpdateItemsRsp{Items: common.MapToString(tmp)})
  80 + rsp, err := proto.Marshal(&pb.RoleUpdateItemsNty{Items: common.MapToString(tmp)})
81 81 if err != nil {
82 82 logger.Error(err.Error())
83 83 return true
84 84 }
85 85  
86 86 if m.GetConn() != nil {
87   - m.GetConn().Send(0, uint32(pb.ProtoCode_RoleUpdateItemsRsp), rsp)
  87 + m.GetConn().Send(0, uint32(pb.ProtoCode_RoleUpdateItemsNty), rsp)
88 88 }
89 89  
90 90 return true
... ...
pb/game.pb.go
... ... @@ -559,8 +559,8 @@ func (x *RoleUpdatePropertyRsp) GetRole() *Role {
559 559 return nil
560 560 }
561 561  
562   -//ResponseCmd RoleUpdateItemsRsp
563   -type RoleUpdateItemsRsp struct {
  562 +//ResponseCmd RoleUpdateItemsNty
  563 +type RoleUpdateItemsNty struct {
564 564 state protoimpl.MessageState
565 565 sizeCache protoimpl.SizeCache
566 566 unknownFields protoimpl.UnknownFields
... ... @@ -568,8 +568,8 @@ type RoleUpdateItemsRsp struct {
568 568 Items string `protobuf:"bytes,1,opt,name=items,proto3" json:"items,omitempty"`
569 569 }
570 570  
571   -func (x *RoleUpdateItemsRsp) Reset() {
572   - *x = RoleUpdateItemsRsp{}
  571 +func (x *RoleUpdateItemsNty) Reset() {
  572 + *x = RoleUpdateItemsNty{}
573 573 if protoimpl.UnsafeEnabled {
574 574 mi := &file_game_proto_msgTypes[10]
575 575 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
... ... @@ -577,13 +577,13 @@ func (x *RoleUpdateItemsRsp) Reset() {
577 577 }
578 578 }
579 579  
580   -func (x *RoleUpdateItemsRsp) String() string {
  580 +func (x *RoleUpdateItemsNty) String() string {
581 581 return protoimpl.X.MessageStringOf(x)
582 582 }
583 583  
584   -func (*RoleUpdateItemsRsp) ProtoMessage() {}
  584 +func (*RoleUpdateItemsNty) ProtoMessage() {}
585 585  
586   -func (x *RoleUpdateItemsRsp) ProtoReflect() protoreflect.Message {
  586 +func (x *RoleUpdateItemsNty) ProtoReflect() protoreflect.Message {
587 587 mi := &file_game_proto_msgTypes[10]
588 588 if protoimpl.UnsafeEnabled && x != nil {
589 589 ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
... ... @@ -595,12 +595,12 @@ func (x *RoleUpdateItemsRsp) ProtoReflect() protoreflect.Message {
595 595 return mi.MessageOf(x)
596 596 }
597 597  
598   -// Deprecated: Use RoleUpdateItemsRsp.ProtoReflect.Descriptor instead.
599   -func (*RoleUpdateItemsRsp) Descriptor() ([]byte, []int) {
  598 +// Deprecated: Use RoleUpdateItemsNty.ProtoReflect.Descriptor instead.
  599 +func (*RoleUpdateItemsNty) Descriptor() ([]byte, []int) {
600 600 return file_game_proto_rawDescGZIP(), []int{10}
601 601 }
602 602  
603   -func (x *RoleUpdateItemsRsp) GetItems() string {
  603 +func (x *RoleUpdateItemsNty) GetItems() string {
604 604 if x != nil {
605 605 return x.Items
606 606 }
... ... @@ -1116,7 +1116,7 @@ var file_game_proto_rawDesc = []byte{
1116 1116 0x64, 0x12, 0x20, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32,
1117 1117 0x0c, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72,
1118 1118 0x6f, 0x6c, 0x65, 0x22, 0x2a, 0x0a, 0x12, 0x52, 0x6f, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74,
1119   - 0x65, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65,
  1119 + 0x65, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x4e, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65,
1120 1120 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22,
1121 1121 0x29, 0x0a, 0x11, 0x52, 0x6f, 0x6c, 0x65, 0x43, 0x6c, 0x65, 0x61, 0x72, 0x49, 0x74, 0x65, 0x6d,
1122 1122 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{}{
1187 1187 (*HeroEquipReferReq)(nil), // 7: game.HeroEquipReferReq
1188 1188 (*RoleRsp)(nil), // 8: game.RoleRsp
1189 1189 (*RoleUpdatePropertyRsp)(nil), // 9: game.RoleUpdatePropertyRsp
1190   - (*RoleUpdateItemsRsp)(nil), // 10: game.RoleUpdateItemsRsp
  1190 + (*RoleUpdateItemsNty)(nil), // 10: game.RoleUpdateItemsNty
1191 1191 (*RoleClearItemsReq)(nil), // 11: game.RoleClearItemsReq
1192 1192 (*RoleStartBattleReq)(nil), // 12: game.RoleStartBattleReq
1193 1193 (*RoleEndBattleReq)(nil), // 13: game.RoleEndBattleReq
... ... @@ -1347,7 +1347,7 @@ func file_game_proto_init() {
1347 1347 }
1348 1348 }
1349 1349 file_game_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
1350   - switch v := v.(*RoleUpdateItemsRsp); i {
  1350 + switch v := v.(*RoleUpdateItemsNty); i {
1351 1351 case 0:
1352 1352 return &v.state
1353 1353 case 1:
... ...
pb/protocode.pb.go
... ... @@ -38,10 +38,10 @@ const (
38 38 ProtoCode_DisConnectRsp ProtoCode = 12
39 39 ProtoCode_RoleRsp ProtoCode = 13
40 40 ProtoCode_RoleUpdatePropertyRsp ProtoCode = 14
41   - ProtoCode_RoleUpdateItemsRsp ProtoCode = 15
42   - ProtoCode_RoleEndBattleRsp ProtoCode = 16
43   - ProtoCode_EquipmentAddRsp ProtoCode = 17
44   - ProtoCode_HeroUpLevelRsp ProtoCode = 18
  41 + ProtoCode_RoleEndBattleRsp ProtoCode = 15
  42 + ProtoCode_EquipmentAddRsp ProtoCode = 16
  43 + ProtoCode_HeroUpLevelRsp ProtoCode = 17
  44 + ProtoCode_RoleUpdateItemsNty ProtoCode = 18
45 45 )
46 46  
47 47 // Enum value maps for ProtoCode.
... ... @@ -62,10 +62,10 @@ var (
62 62 12: "DisConnectRsp",
63 63 13: "RoleRsp",
64 64 14: "RoleUpdatePropertyRsp",
65   - 15: "RoleUpdateItemsRsp",
66   - 16: "RoleEndBattleRsp",
67   - 17: "EquipmentAddRsp",
68   - 18: "HeroUpLevelRsp",
  65 + 15: "RoleEndBattleRsp",
  66 + 16: "EquipmentAddRsp",
  67 + 17: "HeroUpLevelRsp",
  68 + 18: "RoleUpdateItemsNty",
69 69 }
70 70 ProtoCode_value = map[string]int32{
71 71 "UNKNOWN": 0,
... ... @@ -83,10 +83,10 @@ var (
83 83 "DisConnectRsp": 12,
84 84 "RoleRsp": 13,
85 85 "RoleUpdatePropertyRsp": 14,
86   - "RoleUpdateItemsRsp": 15,
87   - "RoleEndBattleRsp": 16,
88   - "EquipmentAddRsp": 17,
89   - "HeroUpLevelRsp": 18,
  86 + "RoleEndBattleRsp": 15,
  87 + "EquipmentAddRsp": 16,
  88 + "HeroUpLevelRsp": 17,
  89 + "RoleUpdateItemsNty": 18,
90 90 }
91 91 )
92 92  
... ... @@ -140,12 +140,12 @@ var file_protocode_proto_rawDesc = []byte{
140 140 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x73, 0x70, 0x10, 0x0c, 0x12, 0x0b, 0x0a, 0x07, 0x52,
141 141 0x6f, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x10, 0x0d, 0x12, 0x19, 0x0a, 0x15, 0x52, 0x6f, 0x6c, 0x65,
142 142 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x52, 0x73,
143   - 0x70, 0x10, 0x0e, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x6f, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74,
144   - 0x65, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x73, 0x70, 0x10, 0x0f, 0x12, 0x14, 0x0a, 0x10, 0x52,
145   - 0x6f, 0x6c, 0x65, 0x45, 0x6e, 0x64, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x10,
146   - 0x10, 0x12, 0x13, 0x0a, 0x0f, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x64,
147   - 0x64, 0x52, 0x73, 0x70, 0x10, 0x11, 0x12, 0x12, 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x55, 0x70,
148   - 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x73, 0x70, 0x10, 0x12, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e,
  143 + 0x70, 0x10, 0x0e, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x6f, 0x6c, 0x65, 0x45, 0x6e, 0x64, 0x42, 0x61,
  144 + 0x74, 0x74, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x10, 0x0f, 0x12, 0x13, 0x0a, 0x0f, 0x45, 0x71, 0x75,
  145 + 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x52, 0x73, 0x70, 0x10, 0x10, 0x12, 0x12,
  146 + 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x55, 0x70, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x73, 0x70,
  147 + 0x10, 0x11, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x6f, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
  148 + 0x49, 0x74, 0x65, 0x6d, 0x73, 0x4e, 0x74, 0x79, 0x10, 0x12, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e,
149 149 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
150 150 }
151 151  
... ...
1   -Subproject commit d368d9b3f0ceb90f11f2da4f1bce0b0236e828aa
  1 +Subproject commit c1963893851348082d49e07a02b762bde8aac6f5
... ...
tools/generator.py
... ... @@ -9,6 +9,7 @@ ProtoCodeStr = "syntax = \"proto3\";\noption go_package = \"../pb;pb\";\n\npacka
9 9 "UNKNOWN = 0;\n {}\n}} "
10 10 ProtoCodeLineReq = "\t{}Rpc = {};\n"
11 11 ProtoCodeLineRsp = "\t{}Rsp = {};\n"
  12 +ProtoCodeLineNty = "\t{}Nty= {};\n"
12 13  
13 14 GoProtoCodeStr = "package action\n\nimport (\n\t\"pro2d/common/logger\"\n\t\"pro2d/pb\"\n)\n\nfunc GetActionMap() " \
14 15 "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
20 21 "}}]interface{{}})\n{}\n\treturn am\n}}"
21 22 GoProtoCodeTestReqLine = "\tam[uint32(pb.ProtoCode_{}Rpc)] = {}Rsp\n"
22 23 GoProtoCodeTestRspLine = "\tam[uint32(pb.ProtoCode_{}Rsp)] = {}Rsp\n"
  24 +GoProtoCodeTestNtyLine = "\tam[uint32(pb.ProtoCode_{}Nty)] = {}Nty\n"
23 25  
24 26 def generatorProto(path):
25 27 files = os.listdir(path)
... ... @@ -40,6 +42,7 @@ def generatorProto(path):
40 42 if firstline.find("proto3") == -1:
41 43 continue
42 44  
  45 + # req
43 46 for line in lines:
44 47 if line.find("message") == -1:
45 48 continue
... ... @@ -59,7 +62,7 @@ def generatorProto(path):
59 62 GoCodeData += GoProtoCodeLine.format(messageStr[:n1], messageStr[:n1])
60 63 GoCodeTestData += GoProtoCodeTestReqLine.format(messageStr[:n1], messageStr[:n1])
61 64  
62   - ProtoCodeData += "\n"
  65 + # rsp
63 66 for line in lines:
64 67 if line.find("message") == -1:
65 68 continue
... ... @@ -78,6 +81,25 @@ def generatorProto(path):
78 81 continue
79 82 GoCodeTestData += GoProtoCodeTestRspLine.format(messageStr[:n2], messageStr[:n2])
80 83  
  84 + # nty
  85 + for line in lines:
  86 + if line.find("message") == -1:
  87 + continue
  88 + sline = line.split(' ')
  89 + if len(sline) < 2:
  90 + continue
  91 +
  92 + messageStr = sline[1].replace('\n', '').replace('{', "")
  93 + n3 = messageStr.find('Nty')
  94 + loginReq = messageStr.find('LoginReq')
  95 +
  96 + if n3 != -1:
  97 + code += 1
  98 + ProtoCodeData += ProtoCodeLineNty.format(messageStr[:n3], code)
  99 + if loginReq != -1:
  100 + continue
  101 + GoCodeTestData += GoProtoCodeTestNtyLine.format(messageStr[:n3], messageStr[:n3])
  102 +
81 103  
82 104 # protocode.go
83 105 gostr = GoProtoCodeStr.format(GoCodeData)
... ...