Browse Source

代码规范

huangyuhao 1 year ago
parent
commit
8226c1d1f4

+ 2 - 2
common/utils/nodeUtil.lua

@@ -77,7 +77,7 @@ end
77
 -- 分配游戏服节点/agent
77
 -- 分配游戏服节点/agent
78
 function root:user_dispatch_game_node_and_agent(uid)
78
 function root:user_dispatch_game_node_and_agent(uid)
79
 	local nodeInfo = self:call_to_node("master", ".srvNodeMgr", "user_dispatch_cluster_node", uid, "game")
79
 	local nodeInfo = self:call_to_node("master", ".srvNodeMgr", "user_dispatch_cluster_node", uid, "game")
80
-	if is_empty(nodeInfo) or is_empty(nodeInfo.nodeName) then
80
+	if nodeInfo == nil or is_empty(nodeInfo.nodeName) then
81
 		return
81
 		return
82
 	end
82
 	end
83
 	local gameNode = nodeInfo.nodeName
83
 	local gameNode = nodeInfo.nodeName
@@ -95,7 +95,7 @@ end
95
 -- 分配网关节点/agent
95
 -- 分配网关节点/agent
96
 function root:user_dispatch_gate_node_and_agent(uid)
96
 function root:user_dispatch_gate_node_and_agent(uid)
97
 	local nodeInfo = self:call_to_node("master", ".srvNodeMgr", "user_dispatch_cluster_node", uid, "gate")
97
 	local nodeInfo = self:call_to_node("master", ".srvNodeMgr", "user_dispatch_cluster_node", uid, "gate")
98
-	if is_empty(nodeInfo) or is_empty(nodeInfo.nodeName) then
98
+	if nodeInfo == nil or is_empty(nodeInfo.nodeName) then
99
 		return
99
 		return
100
 	end
100
 	end
101
 	local gameNode = nodeInfo.nodeName
101
 	local gameNode = nodeInfo.nodeName

+ 2 - 1
nodes/game/interface/box.lua

@@ -12,6 +12,7 @@ local gameConst = require("const.gameConst")
12
 local itemUtil = require("utils.itemUtil")
12
 local itemUtil = require("utils.itemUtil")
13
 
13
 
14
 local boxAdapt = require("adapt.boxAdapt")
14
 local boxAdapt = require("adapt.boxAdapt")
15
+local resAdapt = require("adapt.resAdapt")
15
 
16
 
16
 local bagData = require("data.bag")
17
 local bagData = require("data.bag")
17
 
18
 
@@ -95,7 +96,7 @@ function root:box_dream_open(role, msg)
95
     bagData:consume_items(uid, _costItems, keyEvent)
96
     bagData:consume_items(uid, _costItems, keyEvent)
96
     -- 随机道具
97
     -- 随机道具
97
     local awardList = {
98
     local awardList = {
98
-        {id = itemId, count = 1, weight = adds},
99
+        {id = itemId, count = 1, weight = odds},
99
         {id = gameConst.ITEM_ID.N1, count = 1, weight = 100 - odds}
100
         {id = gameConst.ITEM_ID.N1, count = 1, weight = 100 - odds}
100
     }
101
     }
101
     local index = random_list_by_weight(awardList)
102
     local index = random_list_by_weight(awardList)

+ 2 - 1
nodes/game/interface/room.lua

@@ -10,6 +10,7 @@ local code = require("code")
10
 local util_match = require("utils.util_match")
10
 local util_match = require("utils.util_match")
11
 local gameConst = require("const.gameConst")
11
 local gameConst = require("const.gameConst")
12
 local nodeMgr = require("nodeMgr")
12
 local nodeMgr = require("nodeMgr")
13
+local nodeUtil = require("utils.nodeUtil")
13
 
14
 
14
 local boxAdapt = require("adapt.boxAdapt")
15
 local boxAdapt = require("adapt.boxAdapt")
15
 local bagData = require("data.bag")
16
 local bagData = require("data.bag")
@@ -28,7 +29,7 @@ end
28
 
29
 
29
 -- 创建房间
30
 -- 创建房间
30
 function root:room_create_room(role, msg)
31
 function root:room_create_room(role, msg)
31
-    local msg = msg.playCount
32
+    local playCount = msg.playCount
32
     local battleBoxList = msg.battleBoxList
33
     local battleBoxList = msg.battleBoxList
33
     local uid = role.uid
34
     local uid = role.uid
34
 
35
 

+ 1 - 1
nodes/game/interface/shop.lua

@@ -49,7 +49,7 @@ function root.on_pay(role, msg)
49
         util_user:log_event(uid, "OrderError", extraParams)
49
         util_user:log_event(uid, "OrderError", extraParams)
50
     end
50
     end
51
     local gid = msg.goodsId
51
     local gid = msg.goodsId
52
-    local conf = goodsId and shopAdapt:goods_get_info(gid)
52
+    local conf = gid and shopAdapt:goods_get_info(gid)
53
     if is_empty(conf) then
53
     if is_empty(conf) then
54
         log.error("商城充值回调 gid =%s", gid)
54
         log.error("商城充值回调 gid =%s", gid)
55
         logEvent(1)
55
         logEvent(1)

+ 0 - 6
nodes/game/interface/test.lua

@@ -1,12 +1,6 @@
1
 -- 测试工具
1
 -- 测试工具
2
 local code = require "code"
2
 local code = require "code"
3
-local gameConst = require("const.gameConst")
4
 local timeUtil = require "utils.timeUtil"
3
 local timeUtil = require "utils.timeUtil"
5
-local honorAdapt = require("adapt.honorAdapt")
6
-local redisUtil = require "utils.redisUtil"
7
-local whiteAdapt = require "adapt.whiteAdapt"
8
-local nodeMgr = require "nodeMgr"
9
-local util_user = require("utils.util_user")
10
 local util_order = require("utils.util_order")
4
 local util_order = require("utils.util_order")
11
 
5
 
12
 local moduleData = require("data.module")
6
 local moduleData = require("data.module")

+ 4 - 1
nodes/gate/service/srvSprotoAgent.lua

@@ -202,7 +202,7 @@ function CMD.recycle()
202
 end
202
 end
203
 
203
 
204
 function CMD.update_proto()
204
 function CMD.update_proto()
205
-    protoUtil.update()
205
+    protoUtil:update()
206
 end
206
 end
207
 
207
 
208
 skynet.start(
208
 skynet.start(
@@ -211,6 +211,9 @@ skynet.start(
211
             "lua",
211
             "lua",
212
             function(session, address, command, ...)
212
             function(session, address, command, ...)
213
                 local f = CMD[command]
213
                 local f = CMD[command]
214
+                if f == nil then
215
+                    log.error("agent command[%s] not found", tostring(command))
216
+                end
214
                 if session > 0 then
217
                 if session > 0 then
215
                     skynet.ret(skynet.pack(f(...)))
218
                     skynet.ret(skynet.pack(f(...)))
216
                 else
219
                 else

+ 1 - 4
nodes/master/service/srvNodeMgr.lua

@@ -69,10 +69,7 @@ function root.user_dispatch_cluster_node(uid, clusterName)
69
 	if is_empty(clusterName) then
69
 	if is_empty(clusterName) then
70
 		return
70
 		return
71
 	end
71
 	end
72
-	if root.mapCluster == nil then
73
-		return
74
-	end
75
-	if root.mapCluster[clusterName] == nil then
72
+	if root.mapCluster == nil or root.mapCluster[clusterName] == nil then
76
 		return
73
 		return
77
 	end
74
 	end
78
 	-- 已分配
75
 	-- 已分配