Commit 2e0d2609e38c1a09d7f49eff5466a33e1241f20b

Authored by zhangqijia
1 parent b0e5082c

fix: 英雄升级返回值+protobuf包裹。优化协议名字。req -> rpc.

cmd/gameserver/action/HeroAction.go
@@ -87,5 +87,5 @@ func HeroUpLevelRpc(role *models.RoleModel, msg components.IMessage) (int32, int @@ -87,5 +87,5 @@ func HeroUpLevelRpc(role *models.RoleModel, msg components.IMessage) (int32, int
87 h.SetProperty("exp", exp) 87 h.SetProperty("exp", exp)
88 } 88 }
89 89
90 - return 0, hero.Hero 90 + return 0, &pb.HeroUpLevelRsp{Hero: hero.Hero}
91 } 91 }
cmd/gameserver/action/protocode.go
@@ -8,15 +8,15 @@ import ( @@ -8,15 +8,15 @@ import (
8 func GetActionMap() map[interface{}]interface{} { 8 func GetActionMap() map[interface{}]interface{} {
9 logger.Debug("init protocode...") 9 logger.Debug("init protocode...")
10 am := make(map[interface{}]interface{}) 10 am := make(map[interface{}]interface{})
11 - am[uint32(pb.ProtoCode_HeartReq)] = HeartRpc  
12 - am[uint32(pb.ProtoCode_CreateReq)] = CreateRpc  
13 - am[uint32(pb.ProtoCode_ChangeTeamReq)] = ChangeTeamRpc  
14 - am[uint32(pb.ProtoCode_HeroEquipReferReq)] = HeroEquipReferRpc  
15 - am[uint32(pb.ProtoCode_RoleClearItemsReq)] = RoleClearItemsRpc  
16 - am[uint32(pb.ProtoCode_RoleStartBattleReq)] = RoleStartBattleRpc  
17 - am[uint32(pb.ProtoCode_RoleEndBattleReq)] = RoleEndBattleRpc  
18 - am[uint32(pb.ProtoCode_EquipmentDelReq)] = EquipmentDelRpc  
19 - am[uint32(pb.ProtoCode_HeroUpLevelReq)] = HeroUpLevelRpc 11 + am[uint32(pb.ProtoCode_HeartRpc)] = HeartRpc
  12 + am[uint32(pb.ProtoCode_CreateRpc)] = CreateRpc
  13 + am[uint32(pb.ProtoCode_ChangeTeamRpc)] = ChangeTeamRpc
  14 + am[uint32(pb.ProtoCode_HeroEquipReferRpc)] = HeroEquipReferRpc
  15 + am[uint32(pb.ProtoCode_RoleClearItemsRpc)] = RoleClearItemsRpc
  16 + am[uint32(pb.ProtoCode_RoleStartBattleRpc)] = RoleStartBattleRpc
  17 + am[uint32(pb.ProtoCode_RoleEndBattleRpc)] = RoleEndBattleRpc
  18 + am[uint32(pb.ProtoCode_EquipmentDelRpc)] = EquipmentDelRpc
  19 + am[uint32(pb.ProtoCode_HeroUpLevelRpc)] = HeroUpLevelRpc
20 20
21 return am 21 return am
22 } 22 }
cmd/test/action/protocode.go
@@ -7,22 +7,23 @@ import ( @@ -7,22 +7,23 @@ import (
7 func GetTestActionMap() map[interface{}]interface{} { 7 func GetTestActionMap() map[interface{}]interface{} {
8 am := make(map[interface{}]interface{}) 8 am := make(map[interface{}]interface{})
9 am[uint32(pb.ProtoCode_LoginRsp)] = LoginRsp 9 am[uint32(pb.ProtoCode_LoginRsp)] = LoginRsp
10 - am[uint32(pb.ProtoCode_HeartReq)] = HeartRsp 10 + am[uint32(pb.ProtoCode_HeartRpc)] = HeartRsp
  11 + am[uint32(pb.ProtoCode_CreateRpc)] = CreateRsp
  12 + am[uint32(pb.ProtoCode_ChangeTeamRpc)] = ChangeTeamRsp
  13 + am[uint32(pb.ProtoCode_HeroEquipReferRpc)] = HeroEquipReferRsp
  14 + am[uint32(pb.ProtoCode_RoleClearItemsRpc)] = RoleClearItemsRsp
  15 + am[uint32(pb.ProtoCode_RoleStartBattleRpc)] = RoleStartBattleRsp
  16 + am[uint32(pb.ProtoCode_RoleEndBattleRpc)] = RoleEndBattleRsp
  17 + am[uint32(pb.ProtoCode_EquipmentDelRpc)] = EquipmentDelRsp
  18 + am[uint32(pb.ProtoCode_HeroUpLevelRpc)] = HeroUpLevelRsp
11 am[uint32(pb.ProtoCode_HeartRsp)] = HeartRsp 19 am[uint32(pb.ProtoCode_HeartRsp)] = HeartRsp
12 - am[uint32(pb.ProtoCode_CreateReq)] = CreateRsp  
13 am[uint32(pb.ProtoCode_DisConnectRsp)] = DisConnectRsp 20 am[uint32(pb.ProtoCode_DisConnectRsp)] = DisConnectRsp
14 - am[uint32(pb.ProtoCode_ChangeTeamReq)] = ChangeTeamRsp  
15 - am[uint32(pb.ProtoCode_HeroEquipReferReq)] = HeroEquipReferRsp  
16 am[uint32(pb.ProtoCode_RoleRsp)] = RoleRsp 21 am[uint32(pb.ProtoCode_RoleRsp)] = RoleRsp
17 am[uint32(pb.ProtoCode_RoleUpdatePropertyRsp)] = RoleUpdatePropertyRsp 22 am[uint32(pb.ProtoCode_RoleUpdatePropertyRsp)] = RoleUpdatePropertyRsp
18 am[uint32(pb.ProtoCode_RoleUpdateItemsRsp)] = RoleUpdateItemsRsp 23 am[uint32(pb.ProtoCode_RoleUpdateItemsRsp)] = RoleUpdateItemsRsp
19 - am[uint32(pb.ProtoCode_RoleClearItemsReq)] = RoleClearItemsRsp  
20 - am[uint32(pb.ProtoCode_RoleStartBattleReq)] = RoleStartBattleRsp  
21 - am[uint32(pb.ProtoCode_RoleEndBattleReq)] = RoleEndBattleRsp  
22 am[uint32(pb.ProtoCode_RoleEndBattleRsp)] = RoleEndBattleRsp 24 am[uint32(pb.ProtoCode_RoleEndBattleRsp)] = RoleEndBattleRsp
23 - am[uint32(pb.ProtoCode_EquipmentDelReq)] = EquipmentDelRsp  
24 am[uint32(pb.ProtoCode_EquipmentAddRsp)] = EquipmentAddRsp 25 am[uint32(pb.ProtoCode_EquipmentAddRsp)] = EquipmentAddRsp
25 - am[uint32(pb.ProtoCode_HeroUpLevelReq)] = HeroUpLevelRsp 26 + am[uint32(pb.ProtoCode_HeroUpLevelRsp)] = HeroUpLevelRsp
26 27
27 return am 28 return am
28 } 29 }
@@ -966,6 +966,7 @@ func (x *EquipmentAddRsp) GetEquip() *Equipment { @@ -966,6 +966,7 @@ func (x *EquipmentAddRsp) GetEquip() *Equipment {
966 return nil 966 return nil
967 } 967 }
968 968
  969 +//ResponseCmd HeroUpLevelRsp
969 type HeroUpLevelReq struct { 970 type HeroUpLevelReq struct {
970 state protoimpl.MessageState 971 state protoimpl.MessageState
971 sizeCache protoimpl.SizeCache 972 sizeCache protoimpl.SizeCache
@@ -1021,6 +1022,53 @@ func (x *HeroUpLevelReq) GetItems() string { @@ -1021,6 +1022,53 @@ func (x *HeroUpLevelReq) GetItems() string {
1021 return "" 1022 return ""
1022 } 1023 }
1023 1024
  1025 +type HeroUpLevelRsp struct {
  1026 + state protoimpl.MessageState
  1027 + sizeCache protoimpl.SizeCache
  1028 + unknownFields protoimpl.UnknownFields
  1029 +
  1030 + Hero *Hero `protobuf:"bytes,1,opt,name=hero,proto3" json:"hero,omitempty"`
  1031 +}
  1032 +
  1033 +func (x *HeroUpLevelRsp) Reset() {
  1034 + *x = HeroUpLevelRsp{}
  1035 + if protoimpl.UnsafeEnabled {
  1036 + mi := &file_game_proto_msgTypes[18]
  1037 + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
  1038 + ms.StoreMessageInfo(mi)
  1039 + }
  1040 +}
  1041 +
  1042 +func (x *HeroUpLevelRsp) String() string {
  1043 + return protoimpl.X.MessageStringOf(x)
  1044 +}
  1045 +
  1046 +func (*HeroUpLevelRsp) ProtoMessage() {}
  1047 +
  1048 +func (x *HeroUpLevelRsp) ProtoReflect() protoreflect.Message {
  1049 + mi := &file_game_proto_msgTypes[18]
  1050 + if protoimpl.UnsafeEnabled && x != nil {
  1051 + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
  1052 + if ms.LoadMessageInfo() == nil {
  1053 + ms.StoreMessageInfo(mi)
  1054 + }
  1055 + return ms
  1056 + }
  1057 + return mi.MessageOf(x)
  1058 +}
  1059 +
  1060 +// Deprecated: Use HeroUpLevelRsp.ProtoReflect.Descriptor instead.
  1061 +func (*HeroUpLevelRsp) Descriptor() ([]byte, []int) {
  1062 + return file_game_proto_rawDescGZIP(), []int{18}
  1063 +}
  1064 +
  1065 +func (x *HeroUpLevelRsp) GetHero() *Hero {
  1066 + if x != nil {
  1067 + return x.Hero
  1068 + }
  1069 + return nil
  1070 +}
  1071 +
1024 var File_game_proto protoreflect.FileDescriptor 1072 var File_game_proto protoreflect.FileDescriptor
1025 1073
1026 var file_game_proto_rawDesc = []byte{ 1074 var file_game_proto_rawDesc = []byte{
@@ -1107,8 +1155,12 @@ var file_game_proto_rawDesc = []byte{ @@ -1107,8 +1155,12 @@ var file_game_proto_rawDesc = []byte{
1107 0x48, 0x65, 0x72, 0x6f, 0x55, 0x70, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x16, 1155 0x48, 0x65, 0x72, 0x6f, 0x55, 0x70, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x16,
1108 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 1156 0x0a, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
1109 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 1157 0x68, 0x65, 0x72, 0x6f, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18,
1110 - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x42, 0x0a, 0x5a, 0x08,  
1111 - 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 1158 + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x32, 0x0a, 0x0e,
  1159 + 0x48, 0x65, 0x72, 0x6f, 0x55, 0x70, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x73, 0x70, 0x12, 0x20,
  1160 + 0x0a, 0x04, 0x68, 0x65, 0x72, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x6d,
  1161 + 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2e, 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x68, 0x65, 0x72, 0x6f,
  1162 + 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
  1163 + 0x6f, 0x74, 0x6f, 0x33,
1112 } 1164 }
1113 1165
1114 var ( 1166 var (
@@ -1123,7 +1175,7 @@ func file_game_proto_rawDescGZIP() []byte { @@ -1123,7 +1175,7 @@ func file_game_proto_rawDescGZIP() []byte {
1123 return file_game_proto_rawDescData 1175 return file_game_proto_rawDescData
1124 } 1176 }
1125 1177
1126 -var file_game_proto_msgTypes = make([]protoimpl.MessageInfo, 18) 1178 +var file_game_proto_msgTypes = make([]protoimpl.MessageInfo, 19)
1127 var file_game_proto_goTypes = []interface{}{ 1179 var file_game_proto_goTypes = []interface{}{
1128 (*HeartReq)(nil), // 0: game.HeartReq 1180 (*HeartReq)(nil), // 0: game.HeartReq
1129 (*HeartRsp)(nil), // 1: game.HeartRsp 1181 (*HeartRsp)(nil), // 1: game.HeartRsp
@@ -1143,26 +1195,28 @@ var file_game_proto_goTypes = []interface{}{ @@ -1143,26 +1195,28 @@ var file_game_proto_goTypes = []interface{}{
1143 (*EquipmentDelReq)(nil), // 15: game.EquipmentDelReq 1195 (*EquipmentDelReq)(nil), // 15: game.EquipmentDelReq
1144 (*EquipmentAddRsp)(nil), // 16: game.EquipmentAddRsp 1196 (*EquipmentAddRsp)(nil), // 16: game.EquipmentAddRsp
1145 (*HeroUpLevelReq)(nil), // 17: game.HeroUpLevelReq 1197 (*HeroUpLevelReq)(nil), // 17: game.HeroUpLevelReq
1146 - (*Team)(nil), // 18: models.Team  
1147 - (*Role)(nil), // 19: models.Role  
1148 - (*Hero)(nil), // 20: models.Hero  
1149 - (*Equipment)(nil), // 21: models.Equipment 1198 + (*HeroUpLevelRsp)(nil), // 18: game.HeroUpLevelRsp
  1199 + (*Team)(nil), // 19: models.Team
  1200 + (*Role)(nil), // 20: models.Role
  1201 + (*Hero)(nil), // 21: models.Hero
  1202 + (*Equipment)(nil), // 22: models.Equipment
1150 } 1203 }
1151 var file_game_proto_depIdxs = []int32{ 1204 var file_game_proto_depIdxs = []int32{
1152 - 18, // 0: game.ChangeTeamReq.team:type_name -> models.Team 1205 + 19, // 0: game.ChangeTeamReq.team:type_name -> models.Team
1153 6, // 1: game.HeroEquipReferReq.equipIds:type_name -> game.EquipInfo 1206 6, // 1: game.HeroEquipReferReq.equipIds:type_name -> game.EquipInfo
1154 - 19, // 2: game.RoleRsp.role:type_name -> models.Role  
1155 - 20, // 3: game.RoleRsp.hero:type_name -> models.Hero  
1156 - 18, // 4: game.RoleRsp.team:type_name -> models.Team  
1157 - 21, // 5: game.RoleRsp.equipments:type_name -> models.Equipment  
1158 - 19, // 6: game.RoleUpdatePropertyRsp.role:type_name -> models.Role  
1159 - 20, // 7: game.RoleEndBattleRsp.hero:type_name -> models.Hero  
1160 - 21, // 8: game.EquipmentAddRsp.equip:type_name -> models.Equipment  
1161 - 9, // [9:9] is the sub-list for method output_type  
1162 - 9, // [9:9] is the sub-list for method input_type  
1163 - 9, // [9:9] is the sub-list for extension type_name  
1164 - 9, // [9:9] is the sub-list for extension extendee  
1165 - 0, // [0:9] is the sub-list for field type_name 1207 + 20, // 2: game.RoleRsp.role:type_name -> models.Role
  1208 + 21, // 3: game.RoleRsp.hero:type_name -> models.Hero
  1209 + 19, // 4: game.RoleRsp.team:type_name -> models.Team
  1210 + 22, // 5: game.RoleRsp.equipments:type_name -> models.Equipment
  1211 + 20, // 6: game.RoleUpdatePropertyRsp.role:type_name -> models.Role
  1212 + 21, // 7: game.RoleEndBattleRsp.hero:type_name -> models.Hero
  1213 + 22, // 8: game.EquipmentAddRsp.equip:type_name -> models.Equipment
  1214 + 21, // 9: game.HeroUpLevelRsp.hero:type_name -> models.Hero
  1215 + 10, // [10:10] is the sub-list for method output_type
  1216 + 10, // [10:10] is the sub-list for method input_type
  1217 + 10, // [10:10] is the sub-list for extension type_name
  1218 + 10, // [10:10] is the sub-list for extension extendee
  1219 + 0, // [0:10] is the sub-list for field type_name
1166 } 1220 }
1167 1221
1168 func init() { file_game_proto_init() } 1222 func init() { file_game_proto_init() }
@@ -1388,6 +1442,18 @@ func file_game_proto_init() { @@ -1388,6 +1442,18 @@ func file_game_proto_init() {
1388 return nil 1442 return nil
1389 } 1443 }
1390 } 1444 }
  1445 + file_game_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} {
  1446 + switch v := v.(*HeroUpLevelRsp); i {
  1447 + case 0:
  1448 + return &v.state
  1449 + case 1:
  1450 + return &v.sizeCache
  1451 + case 2:
  1452 + return &v.unknownFields
  1453 + default:
  1454 + return nil
  1455 + }
  1456 + }
1391 } 1457 }
1392 type x struct{} 1458 type x struct{}
1393 out := protoimpl.TypeBuilder{ 1459 out := protoimpl.TypeBuilder{
@@ -1395,7 +1461,7 @@ func file_game_proto_init() { @@ -1395,7 +1461,7 @@ func file_game_proto_init() {
1395 GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 1461 GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
1396 RawDescriptor: file_game_proto_rawDesc, 1462 RawDescriptor: file_game_proto_rawDesc,
1397 NumEnums: 0, 1463 NumEnums: 0,
1398 - NumMessages: 18, 1464 + NumMessages: 19,
1399 NumExtensions: 0, 1465 NumExtensions: 0,
1400 NumServices: 0, 1466 NumServices: 0,
1401 }, 1467 },
pb/protocode.pb.go
@@ -25,23 +25,23 @@ type ProtoCode int32 @@ -25,23 +25,23 @@ type ProtoCode int32
25 const ( 25 const (
26 ProtoCode_UNKNOWN ProtoCode = 0 26 ProtoCode_UNKNOWN ProtoCode = 0
27 ProtoCode_LoginRsp ProtoCode = 1 27 ProtoCode_LoginRsp ProtoCode = 1
28 - ProtoCode_HeartReq ProtoCode = 2  
29 - ProtoCode_HeartRsp ProtoCode = 3  
30 - ProtoCode_LoginReq ProtoCode = 4  
31 - ProtoCode_CreateReq ProtoCode = 5  
32 - ProtoCode_DisConnectRsp ProtoCode = 6  
33 - ProtoCode_ChangeTeamReq ProtoCode = 7  
34 - ProtoCode_HeroEquipReferReq ProtoCode = 8  
35 - ProtoCode_RoleRsp ProtoCode = 9  
36 - ProtoCode_RoleUpdatePropertyRsp ProtoCode = 10  
37 - ProtoCode_RoleUpdateItemsRsp ProtoCode = 11  
38 - ProtoCode_RoleClearItemsReq ProtoCode = 12  
39 - ProtoCode_RoleStartBattleReq ProtoCode = 13  
40 - ProtoCode_RoleEndBattleReq ProtoCode = 14  
41 - ProtoCode_RoleEndBattleRsp ProtoCode = 15  
42 - ProtoCode_EquipmentDelReq ProtoCode = 16 28 + ProtoCode_HeartRpc ProtoCode = 2
  29 + ProtoCode_CreateRpc ProtoCode = 3
  30 + ProtoCode_ChangeTeamRpc ProtoCode = 4
  31 + ProtoCode_HeroEquipReferRpc ProtoCode = 5
  32 + ProtoCode_RoleClearItemsRpc ProtoCode = 6
  33 + ProtoCode_RoleStartBattleRpc ProtoCode = 7
  34 + ProtoCode_RoleEndBattleRpc ProtoCode = 8
  35 + ProtoCode_EquipmentDelRpc ProtoCode = 9
  36 + ProtoCode_HeroUpLevelRpc ProtoCode = 10
  37 + ProtoCode_HeartRsp ProtoCode = 11
  38 + ProtoCode_DisConnectRsp ProtoCode = 12
  39 + ProtoCode_RoleRsp ProtoCode = 13
  40 + ProtoCode_RoleUpdatePropertyRsp ProtoCode = 14
  41 + ProtoCode_RoleUpdateItemsRsp ProtoCode = 15
  42 + ProtoCode_RoleEndBattleRsp ProtoCode = 16
43 ProtoCode_EquipmentAddRsp ProtoCode = 17 43 ProtoCode_EquipmentAddRsp ProtoCode = 17
44 - ProtoCode_HeroUpLevelReq ProtoCode = 18 44 + ProtoCode_HeroUpLevelRsp ProtoCode = 18
45 ) 45 )
46 46
47 // Enum value maps for ProtoCode. 47 // Enum value maps for ProtoCode.
@@ -49,44 +49,44 @@ var ( @@ -49,44 +49,44 @@ var (
49 ProtoCode_name = map[int32]string{ 49 ProtoCode_name = map[int32]string{
50 0: "UNKNOWN", 50 0: "UNKNOWN",
51 1: "LoginRsp", 51 1: "LoginRsp",
52 - 2: "HeartReq",  
53 - 3: "HeartRsp",  
54 - 4: "LoginReq",  
55 - 5: "CreateReq",  
56 - 6: "DisConnectRsp",  
57 - 7: "ChangeTeamReq",  
58 - 8: "HeroEquipReferReq",  
59 - 9: "RoleRsp",  
60 - 10: "RoleUpdatePropertyRsp",  
61 - 11: "RoleUpdateItemsRsp",  
62 - 12: "RoleClearItemsReq",  
63 - 13: "RoleStartBattleReq",  
64 - 14: "RoleEndBattleReq",  
65 - 15: "RoleEndBattleRsp",  
66 - 16: "EquipmentDelReq", 52 + 2: "HeartRpc",
  53 + 3: "CreateRpc",
  54 + 4: "ChangeTeamRpc",
  55 + 5: "HeroEquipReferRpc",
  56 + 6: "RoleClearItemsRpc",
  57 + 7: "RoleStartBattleRpc",
  58 + 8: "RoleEndBattleRpc",
  59 + 9: "EquipmentDelRpc",
  60 + 10: "HeroUpLevelRpc",
  61 + 11: "HeartRsp",
  62 + 12: "DisConnectRsp",
  63 + 13: "RoleRsp",
  64 + 14: "RoleUpdatePropertyRsp",
  65 + 15: "RoleUpdateItemsRsp",
  66 + 16: "RoleEndBattleRsp",
67 17: "EquipmentAddRsp", 67 17: "EquipmentAddRsp",
68 - 18: "HeroUpLevelReq", 68 + 18: "HeroUpLevelRsp",
69 } 69 }
70 ProtoCode_value = map[string]int32{ 70 ProtoCode_value = map[string]int32{
71 "UNKNOWN": 0, 71 "UNKNOWN": 0,
72 "LoginRsp": 1, 72 "LoginRsp": 1,
73 - "HeartReq": 2,  
74 - "HeartRsp": 3,  
75 - "LoginReq": 4,  
76 - "CreateReq": 5,  
77 - "DisConnectRsp": 6,  
78 - "ChangeTeamReq": 7,  
79 - "HeroEquipReferReq": 8,  
80 - "RoleRsp": 9,  
81 - "RoleUpdatePropertyRsp": 10,  
82 - "RoleUpdateItemsRsp": 11,  
83 - "RoleClearItemsReq": 12,  
84 - "RoleStartBattleReq": 13,  
85 - "RoleEndBattleReq": 14,  
86 - "RoleEndBattleRsp": 15,  
87 - "EquipmentDelReq": 16, 73 + "HeartRpc": 2,
  74 + "CreateRpc": 3,
  75 + "ChangeTeamRpc": 4,
  76 + "HeroEquipReferRpc": 5,
  77 + "RoleClearItemsRpc": 6,
  78 + "RoleStartBattleRpc": 7,
  79 + "RoleEndBattleRpc": 8,
  80 + "EquipmentDelRpc": 9,
  81 + "HeroUpLevelRpc": 10,
  82 + "HeartRsp": 11,
  83 + "DisConnectRsp": 12,
  84 + "RoleRsp": 13,
  85 + "RoleUpdatePropertyRsp": 14,
  86 + "RoleUpdateItemsRsp": 15,
  87 + "RoleEndBattleRsp": 16,
88 "EquipmentAddRsp": 17, 88 "EquipmentAddRsp": 17,
89 - "HeroUpLevelReq": 18, 89 + "HeroUpLevelRsp": 18,
90 } 90 }
91 ) 91 )
92 92
@@ -121,32 +121,32 @@ var File_protocode_proto protoreflect.FileDescriptor @@ -121,32 +121,32 @@ var File_protocode_proto protoreflect.FileDescriptor
121 121
122 var file_protocode_proto_rawDesc = []byte{ 122 var file_protocode_proto_rawDesc = []byte{
123 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 123 0x0a, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
124 - 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0xf5, 0x02, 0x0a, 124 + 0x6f, 0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x64, 0x65, 0x2a, 0xfb, 0x02, 0x0a,
125 0x09, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 125 0x09, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e,
126 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 126 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e,
127 - 0x52, 0x73, 0x70, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74, 0x52, 0x65,  
128 - 0x71, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74, 0x52, 0x73, 0x70, 0x10,  
129 - 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x10, 0x04, 0x12,  
130 - 0x0d, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x10, 0x05, 0x12, 0x11,  
131 - 0x0a, 0x0d, 0x44, 0x69, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x73, 0x70, 0x10,  
132 - 0x06, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d, 0x52,  
133 - 0x65, 0x71, 0x10, 0x07, 0x12, 0x15, 0x0a, 0x11, 0x48, 0x65, 0x72, 0x6f, 0x45, 0x71, 0x75, 0x69,  
134 - 0x70, 0x52, 0x65, 0x66, 0x65, 0x72, 0x52, 0x65, 0x71, 0x10, 0x08, 0x12, 0x0b, 0x0a, 0x07, 0x52,  
135 - 0x6f, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x10, 0x09, 0x12, 0x19, 0x0a, 0x15, 0x52, 0x6f, 0x6c, 0x65, 127 + 0x52, 0x73, 0x70, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65, 0x61, 0x72, 0x74, 0x52, 0x70,
  128 + 0x63, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x70, 0x63,
  129 + 0x10, 0x03, 0x12, 0x11, 0x0a, 0x0d, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x54, 0x65, 0x61, 0x6d,
  130 + 0x52, 0x70, 0x63, 0x10, 0x04, 0x12, 0x15, 0x0a, 0x11, 0x48, 0x65, 0x72, 0x6f, 0x45, 0x71, 0x75,
  131 + 0x69, 0x70, 0x52, 0x65, 0x66, 0x65, 0x72, 0x52, 0x70, 0x63, 0x10, 0x05, 0x12, 0x15, 0x0a, 0x11,
  132 + 0x52, 0x6f, 0x6c, 0x65, 0x43, 0x6c, 0x65, 0x61, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x70,
  133 + 0x63, 0x10, 0x06, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x6f, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74,
  134 + 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x70, 0x63, 0x10, 0x07, 0x12, 0x14, 0x0a, 0x10, 0x52,
  135 + 0x6f, 0x6c, 0x65, 0x45, 0x6e, 0x64, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x70, 0x63, 0x10,
  136 + 0x08, 0x12, 0x13, 0x0a, 0x0f, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x65,
  137 + 0x6c, 0x52, 0x70, 0x63, 0x10, 0x09, 0x12, 0x12, 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x55, 0x70,
  138 + 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x70, 0x63, 0x10, 0x0a, 0x12, 0x0c, 0x0a, 0x08, 0x48, 0x65,
  139 + 0x61, 0x72, 0x74, 0x52, 0x73, 0x70, 0x10, 0x0b, 0x12, 0x11, 0x0a, 0x0d, 0x44, 0x69, 0x73, 0x43,
  140 + 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x73, 0x70, 0x10, 0x0c, 0x12, 0x0b, 0x0a, 0x07, 0x52,
  141 + 0x6f, 0x6c, 0x65, 0x52, 0x73, 0x70, 0x10, 0x0d, 0x12, 0x19, 0x0a, 0x15, 0x52, 0x6f, 0x6c, 0x65,
136 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x52, 0x73, 142 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x79, 0x52, 0x73,
137 - 0x70, 0x10, 0x0a, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x6f, 0x6c, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74,  
138 - 0x65, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x73, 0x70, 0x10, 0x0b, 0x12, 0x15, 0x0a, 0x11, 0x52,  
139 - 0x6f, 0x6c, 0x65, 0x43, 0x6c, 0x65, 0x61, 0x72, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x65, 0x71,  
140 - 0x10, 0x0c, 0x12, 0x16, 0x0a, 0x12, 0x52, 0x6f, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x42,  
141 - 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x10, 0x0d, 0x12, 0x14, 0x0a, 0x10, 0x52, 0x6f,  
142 - 0x6c, 0x65, 0x45, 0x6e, 0x64, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x10, 0x0e,  
143 - 0x12, 0x14, 0x0a, 0x10, 0x52, 0x6f, 0x6c, 0x65, 0x45, 0x6e, 0x64, 0x42, 0x61, 0x74, 0x74, 0x6c,  
144 - 0x65, 0x52, 0x73, 0x70, 0x10, 0x0f, 0x12, 0x13, 0x0a, 0x0f, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d,  
145 - 0x65, 0x6e, 0x74, 0x44, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x10, 0x10, 0x12, 0x13, 0x0a, 0x0f, 0x45,  
146 - 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x64, 0x64, 0x52, 0x73, 0x70, 0x10, 0x11,  
147 - 0x12, 0x12, 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x55, 0x70, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52,  
148 - 0x65, 0x71, 0x10, 0x12, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62,  
149 - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 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,
  149 + 0x2f, 0x70, 0x62, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
150 } 150 }
151 151
152 var ( 152 var (
tools/generator.py
@@ -7,18 +7,18 @@ ProtoFileDir = "./protos" @@ -7,18 +7,18 @@ ProtoFileDir = "./protos"
7 7
8 ProtoCodeStr = "syntax = \"proto3\";\noption go_package = \"../pb;pb\";\n\npackage protocode;\n\nenum ProtoCode\n{{\n " \ 8 ProtoCodeStr = "syntax = \"proto3\";\noption go_package = \"../pb;pb\";\n\npackage protocode;\n\nenum ProtoCode\n{{\n " \
9 "UNKNOWN = 0;\n {}\n}} " 9 "UNKNOWN = 0;\n {}\n}} "
10 -ProtoCodeLineReq = "\t{}Req = {};\n" 10 +ProtoCodeLineReq = "\t{}Rpc = {};\n"
11 ProtoCodeLineRsp = "\t{}Rsp = {};\n" 11 ProtoCodeLineRsp = "\t{}Rsp = {};\n"
12 12
13 GoProtoCodeStr = "package action\n\nimport (\n\t\"pro2d/common/logger\"\n\t\"pro2d/pb\"\n)\n\nfunc GetActionMap() " \ 13 GoProtoCodeStr = "package action\n\nimport (\n\t\"pro2d/common/logger\"\n\t\"pro2d/pb\"\n)\n\nfunc GetActionMap() " \
14 "map[interface{{}}]interface{{}} {{\n\tlogger.Debug(\"init protocode...\")\n\tam := make(map[interface{{" \ 14 "map[interface{{}}]interface{{}} {{\n\tlogger.Debug(\"init protocode...\")\n\tam := make(map[interface{{" \
15 "}}]interface{{}})\n{}\n\treturn am\n}}" 15 "}}]interface{{}})\n{}\n\treturn am\n}}"
16 -GoProtoCodeLine = "\tam[uint32(pb.ProtoCode_{}Req)] = {}Rpc\n" 16 +GoProtoCodeLine = "\tam[uint32(pb.ProtoCode_{}Rpc)] = {}Rpc\n"
17 17
18 GoProtoCodeTestStr = "package action\n\nimport (\n\t\"pro2d/pb\"\n)\n\nfunc GetTestActionMap() " \ 18 GoProtoCodeTestStr = "package action\n\nimport (\n\t\"pro2d/pb\"\n)\n\nfunc GetTestActionMap() " \
19 "map[interface{{}}]interface{{}} {{\n\tam := make(map[interface{{" \ 19 "map[interface{{}}]interface{{}} {{\n\tam := make(map[interface{{" \
20 "}}]interface{{}})\n{}\n\treturn am\n}}" 20 "}}]interface{{}})\n{}\n\treturn am\n}}"
21 -GoProtoCodeTestReqLine = "\tam[uint32(pb.ProtoCode_{}Req)] = {}Rsp\n" 21 +GoProtoCodeTestReqLine = "\tam[uint32(pb.ProtoCode_{}Rpc)] = {}Rsp\n"
22 GoProtoCodeTestRspLine = "\tam[uint32(pb.ProtoCode_{}Rsp)] = {}Rsp\n" 22 GoProtoCodeTestRspLine = "\tam[uint32(pb.ProtoCode_{}Rsp)] = {}Rsp\n"
23 23
24 def generatorProto(path): 24 def generatorProto(path):
@@ -40,34 +40,41 @@ def generatorProto(path): @@ -40,34 +40,41 @@ def generatorProto(path):
40 for line in lines: 40 for line in lines:
41 if line.find("message") == -1: 41 if line.find("message") == -1:
42 continue 42 continue
43 -  
44 sline = line.split(' ') 43 sline = line.split(' ')
45 if len(sline) < 2: 44 if len(sline) < 2:
46 continue 45 continue
47 46
48 messageStr = sline[1].replace('\n', '').replace('{', "") 47 messageStr = sline[1].replace('\n', '').replace('{', "")
49 n1 = messageStr.find('Req') 48 n1 = messageStr.find('Req')
50 - n2 = messageStr.find('Rsp')  
51 loginReq = messageStr.find('LoginReq') 49 loginReq = messageStr.find('LoginReq')
52 -  
53 - 50 + if loginReq != -1:
  51 + continue
54 52
55 if n1 != -1: 53 if n1 != -1:
56 code += 1 54 code += 1
57 ProtoCodeData += ProtoCodeLineReq.format(messageStr[:n1], code) 55 ProtoCodeData += ProtoCodeLineReq.format(messageStr[:n1], code)
58 -  
59 - if loginReq != -1:  
60 - continue  
61 -  
62 GoCodeData += GoProtoCodeLine.format(messageStr[:n1], messageStr[:n1]) 56 GoCodeData += GoProtoCodeLine.format(messageStr[:n1], messageStr[:n1])
63 GoCodeTestData += GoProtoCodeTestReqLine.format(messageStr[:n1], messageStr[:n1]) 57 GoCodeTestData += GoProtoCodeTestReqLine.format(messageStr[:n1], messageStr[:n1])
64 - elif n2 != -1:  
65 - code += 1  
66 - ProtoCodeData += ProtoCodeLineRsp.format(messageStr[:n2], code)  
67 58
  59 + ProtoCodeData += "\n"
  60 + for line in lines:
  61 + if line.find("message") == -1:
  62 + continue
  63 + sline = line.split(' ')
  64 + if len(sline) < 2:
  65 + continue
  66 +
  67 + messageStr = sline[1].replace('\n', '').replace('{', "")
  68 + n2 = messageStr.find('Rsp')
  69 + loginReq = messageStr.find('LoginReq')
68 if loginReq != -1: 70 if loginReq != -1:
69 continue 71 continue
70 - GoCodeTestData += GoProtoCodeTestRspLine.format(messageStr[:n2], messageStr[:n2]) 72 +
  73 + if n2 != -1:
  74 + code += 1
  75 + ProtoCodeData += ProtoCodeLineRsp.format(messageStr[:n2], code)
  76 + GoCodeTestData += GoProtoCodeTestRspLine.format(messageStr[:n2], messageStr[:n2])
  77 +
71 78
72 # protocode.go 79 # protocode.go
73 gostr = GoProtoCodeStr.format(GoCodeData) 80 gostr = GoProtoCodeStr.format(GoCodeData)