Commit 2ea166846340d33b61e6efae51d50bb2a614e1d0

Authored by zhangqijia
1 parent 495e9142

fix: update

cmd/gameserver/action/RoleAction.go
... ... @@ -235,6 +235,7 @@ func RoleEndBattleRpc(role *models.RoleModel, msg components.IMessage) (int32, i
235 235 amount = carbonInfo.CarbonFailExp
236 236 }
237 237 level, exp := role.UpLevel(amount)
  238 + role.UpdateProperties(map[string]interface{}{"level": level, "exp": exp}, true)
238 239  
239 240 rsp := &pb.RoleEndBattleRsp{
240 241 RoleLevel: level,
... ...
cmd/gameserver/service/agent.go
... ... @@ -75,7 +75,6 @@ func (c *Agent) OnLoginQuery(msg components.IMessage) (int32, proto.Message) {
75 75  
76 76 // 判断是否已经登录 ,挤掉,断开连接
77 77 conn := c.Server.GetConnManage().GetConnByUID(uid)
78   - logger.Debug(conn)
79 78 if conn != nil {
80 79 logger.Debug("挤掉。。。。。。。。")
81 80 conn.SendSuccess(uint32(pb.ProtoCode_DisConnectRsp), nil)
... ...
cmd/test/action/TestAction.go
... ... @@ -8,26 +8,48 @@ import (
8 8 "pro2d/pb"
9 9 )
10 10  
11   -func HeartReq(role *models.RoleTestModel, msg components.IMessage) {
  11 +func HeartRsp(role *models.RoleTestModel, msg components.IMessage) {
12 12 }
13 13  
14   -func CreateReq(role *models.RoleTestModel, msg components.IMessage) {
  14 +func LoginRsp(role *models.RoleTestModel, msg components.IMessage) {
15 15 }
16   -func ChangeTeamReq(role *models.RoleTestModel, msg components.IMessage) {
  16 +
  17 +func CreateRsp(role *models.RoleTestModel, msg components.IMessage) {
17 18 }
18   -func HeroEquipReferReq(role *models.RoleTestModel, msg components.IMessage) {
  19 +
  20 +func DisConnectRsp(role *models.RoleTestModel, msg components.IMessage) {
19 21 }
20   -func RoleClearItemsReq(role *models.RoleTestModel, msg components.IMessage) {
  22 +
  23 +func ChangeTeamRsp(role *models.RoleTestModel, msg components.IMessage) {
21 24 }
22   -func RoleStartBattleReq(role *models.RoleTestModel, msg components.IMessage) {
  25 +func HeroEquipReferRsp(role *models.RoleTestModel, msg components.IMessage) {
  26 +}
  27 +
  28 +func RoleRsp(role *models.RoleTestModel, msg components.IMessage) {
  29 +}
  30 +
  31 +func RoleUpdatePropertyRsp(role *models.RoleTestModel, msg components.IMessage) {
  32 +}
  33 +
  34 +func RoleUpdateItemsRsp(role *models.RoleTestModel, msg components.IMessage) {
23 35 }
24   -func RoleEndBattleReq(role *models.RoleTestModel, msg components.IMessage) {
  36 +
  37 +func RoleClearItemsRsp(role *models.RoleTestModel, msg components.IMessage) {
  38 +}
  39 +
  40 +func RoleStartBattleRsp(role *models.RoleTestModel, msg components.IMessage) {
  41 +}
  42 +
  43 +func RoleEndBattleRsp(role *models.RoleTestModel, msg components.IMessage) {
25 44 rsp := pb.RoleEndBattleRsp{}
26 45 if err := proto.Unmarshal(msg.GetData(), &rsp); err != nil {
27 46 logger.Error("rsp err: %v", err)
28 47 return
29 48 }
30   - logger.Debug(rsp)
31 49 }
32   -func EquipmentDelReq(role *models.RoleTestModel, msg components.IMessage) {
  50 +
  51 +func EquipmentDelRsp(role *models.RoleTestModel, msg components.IMessage) {
  52 +}
  53 +
  54 +func EquipmentAddRsp(role *models.RoleTestModel, msg components.IMessage) {
33 55 }
... ...
cmd/test/action/protocode.go
... ... @@ -6,14 +6,22 @@ import (
6 6  
7 7 func GetTestActionMap() map[interface{}]interface{} {
8 8 am := make(map[interface{}]interface{})
9   - am[uint32(pb.ProtoCode_HeartReq)] = HeartReq
10   - am[uint32(pb.ProtoCode_CreateReq)] = CreateReq
11   - am[uint32(pb.ProtoCode_ChangeTeamReq)] = ChangeTeamReq
12   - am[uint32(pb.ProtoCode_HeroEquipReferReq)] = HeroEquipReferReq
13   - am[uint32(pb.ProtoCode_RoleClearItemsReq)] = RoleClearItemsReq
14   - am[uint32(pb.ProtoCode_RoleStartBattleReq)] = RoleStartBattleReq
15   - am[uint32(pb.ProtoCode_RoleEndBattleReq)] = RoleEndBattleReq
16   - am[uint32(pb.ProtoCode_EquipmentDelReq)] = EquipmentDelReq
  9 + am[uint32(pb.ProtoCode_LoginRsp)] = LoginRsp
  10 + am[uint32(pb.ProtoCode_HeartReq)] = HeartRsp
  11 + am[uint32(pb.ProtoCode_HeartRsp)] = HeartRsp
  12 + am[uint32(pb.ProtoCode_CreateReq)] = CreateRsp
  13 + 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
  17 + am[uint32(pb.ProtoCode_RoleUpdatePropertyRsp)] = RoleUpdatePropertyRsp
  18 + 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
  23 + am[uint32(pb.ProtoCode_EquipmentDelReq)] = EquipmentDelRsp
  24 + am[uint32(pb.ProtoCode_EquipmentAddRsp)] = EquipmentAddRsp
17 25  
18 26 return am
19 27 }
... ...
cmd/test/service/TestClient.go
... ... @@ -98,6 +98,7 @@ func (t *TestClient) OnMessage(msg components.IMessage) {
98 98 }
99 99  
100 100 func (t *TestClient) OnClose(conn components.IConnection) {
  101 + conn.Stop()
101 102 }
102 103 func (t *TestClient) OnTimer(conn components.IConnection) {
103 104 }
... ...
tools/generator.py
1 1 import os
2 2  
3 3 ProtoCodeGO = './cmd/gameserver/action/protocode.go'
  4 +ProtoCodeGOTest = './cmd/test/action/protocode.go'
4 5 ProtoCodeFile = './protos/protocode.proto'
5 6 ProtoFileDir = "./protos"
6 7  
... ... @@ -14,12 +15,18 @@ GoProtoCodeStr = "package action\n\nimport (\n\t\"pro2d/common/logger\"\n\t\"pro
14 15 "}}]interface{{}})\n{}\n\treturn am\n}}"
15 16 GoProtoCodeLine = "\tam[uint32(pb.ProtoCode_{}Req)] = {}Rpc\n"
16 17  
  18 +GoProtoCodeTestStr = "package action\n\nimport (\n\t\"pro2d/pb\"\n)\n\nfunc GetTestActionMap() " \
  19 + "map[interface{{}}]interface{{}} {{\n\tam := make(map[interface{{" \
  20 + "}}]interface{{}})\n{}\n\treturn am\n}}"
  21 +GoProtoCodeTestReqLine = "\tam[uint32(pb.ProtoCode_{}Req)] = {}Rsp\n"
  22 +GoProtoCodeTestRspLine = "\tam[uint32(pb.ProtoCode_{}Rsp)] = {}Rsp\n"
17 23  
18 24 def generatorProto(path):
19 25 files = os.listdir(path)
20 26 code = 0
21 27 ProtoCodeData = ""
22 28 GoCodeData = ""
  29 + GoCodeTestData = ""
23 30 for file in files:
24 31 if os.path.isdir(file):
25 32 continue
... ... @@ -53,16 +60,27 @@ def generatorProto(path):
53 60 continue
54 61  
55 62 GoCodeData += GoProtoCodeLine.format(messageStr[:n1], messageStr[:n1])
  63 + GoCodeTestData += GoProtoCodeTestReqLine.format(messageStr[:n1], messageStr[:n1])
56 64 elif n2 != -1:
57 65 code += 1
58 66 ProtoCodeData += ProtoCodeLineRsp.format(messageStr[:n2], code)
59 67  
  68 + if loginReq != -1:
  69 + continue
  70 + GoCodeTestData += GoProtoCodeTestRspLine.format(messageStr[:n2], messageStr[:n2])
  71 +
60 72 # protocode.go
61 73 gostr = GoProtoCodeStr.format(GoCodeData)
62 74 fo = open(ProtoCodeGO, "w")
63 75 fo.write(gostr)
64 76 fo.close()
65 77  
  78 + # protocode.go
  79 + gostr = GoProtoCodeTestStr.format(GoCodeTestData)
  80 + fo = open(ProtoCodeGOTest, "w")
  81 + fo.write(gostr)
  82 + fo.close()
  83 +
66 84 #protocode.proto
67 85 protostr = ProtoCodeStr.format(ProtoCodeData)
68 86 fo = open(ProtoCodeFile, "w")
... ...