From 6520a6c2fd0c1f0fbe15bab87ecd7d63c7aa8235 Mon Sep 17 00:00:00 2001 From: huahua132 <958677003@qq.com> Date: Mon, 13 Jan 2025 20:39:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E9=99=A4lua-language=20server=20code?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=E6=A3=80=E6=9F=A5=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/frpc_server/module/test_m.lua | 1 + lualib/skynet-fly/client/contriner_client.lua | 3 ++- lualib/skynet-fly/client/frpc_client.lua | 2 ++ lualib/skynet-fly/db/orm/ormtable.lua | 5 +++-- lualib/skynet-fly/logrotate.lua | 2 +- lualib/skynet-fly/utils/skynet_util.lua | 2 +- lualib/skynet-fly/utils/string_util.lua | 3 ++- lualib/skynet-fly/watch/watch_syn.lua | 1 + module/frpc_client_m.lua | 1 + module/mysql_m.lua | 3 ++- module/orm_table_m.lua | 1 + module/room_game_alloc_m.lua | 2 ++ service/hot_container.lua | 1 + service/room_game_login.lua | 1 + service/sharedata_service.lua | 1 + 15 files changed, 22 insertions(+), 7 deletions(-) diff --git a/examples/frpc_server/module/test_m.lua b/examples/frpc_server/module/test_m.lua index 065bd5637..44d999dc4 100644 --- a/examples/frpc_server/module/test_m.lua +++ b/examples/frpc_server/module/test_m.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: undefined-field, need-check-nil local log = require "skynet-fly.log" local skynet = require "skynet.manager" local contriner_client = require "skynet-fly.client.contriner_client" diff --git a/lualib/skynet-fly/client/contriner_client.lua b/lualib/skynet-fly/client/contriner_client.lua index bc2a697cd..874cb0b79 100644 --- a/lualib/skynet-fly/client/contriner_client.lua +++ b/lualib/skynet-fly/client/contriner_client.lua @@ -148,7 +148,7 @@ g_mod_svr_ids_map = setmetatable({},{__index = function(t,key) g_querycbed_map[key] = true skynet.fork(call_back_queryed, queryed) end - return t[key],g_mod_svr_version_map[key] + return t[key] end}) local function monitor_all() @@ -166,6 +166,7 @@ local function monitor_all() end) end +---@diagnostic disable-next-line: duplicate-set-field skynet.exit = function() IS_CLOSE = true for mod_name in pairs(g_mod_svr_ids_map) do diff --git a/lualib/skynet-fly/client/frpc_client.lua b/lualib/skynet-fly/client/frpc_client.lua index 3934bacab..b2cf9b470 100644 --- a/lualib/skynet-fly/client/frpc_client.lua +++ b/lualib/skynet-fly/client/frpc_client.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: undefined-field, need-check-nil local skynet = require "skynet" local contriner_client = require "skynet-fly.client.contriner_client" @@ -187,6 +188,7 @@ end local function unpack_broadcast(rsp, secret) local ret_map = unpack_rsp(rsp, secret) +---@diagnostic disable-next-line: param-type-mismatch for sid, luastr in pairs(ret_map) do ret_map[sid] = {skynet.unpack(luastr)} end diff --git a/lualib/skynet-fly/db/orm/ormtable.lua b/lualib/skynet-fly/db/orm/ormtable.lua index 57f4bff09..3dc3afee1 100644 --- a/lualib/skynet-fly/db/orm/ormtable.lua +++ b/lualib/skynet-fly/db/orm/ormtable.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: need-check-nil, assign-type-mismatch, param-type-mismatch local ormentry = require "skynet-fly.db.orm.ormentry" local table_util = require "skynet-fly.utils.table_util" local math_util = require "skynet-fly.utils.math_util" @@ -714,7 +715,7 @@ local function get_one_entry(t, key_values) add_key_select(t, invalid_entry) return nil, false else - entry = ormentry:new(t, init_entry_data(t, entry_data), true) + entry = ormentry:new(t, init_entry_data(t, entry_data, true)) return add_key_select(t, entry) end end @@ -839,7 +840,7 @@ local function get_entry_by_limit(t, cursor, limit, sort, key_values) local cursor, entry_data_list, count = t._adapterinterface:get_entry_by_limit(cursor, limit, sort, key_values) for i = 1, #entry_data_list do local entry_data = entry_data_list[i] - local entry = ormentry:new(t, init_entry_data(t, entry_data), true) + local entry = ormentry:new(t, init_entry_data(t, entry_data, true)) entry_data_list[i] = entry end diff --git a/lualib/skynet-fly/logrotate.lua b/lualib/skynet-fly/logrotate.lua index d4e6ed748..b8a68de97 100644 --- a/lualib/skynet-fly/logrotate.lua +++ b/lualib/skynet-fly/logrotate.lua @@ -45,7 +45,7 @@ end local M = {} local mt = {__index = M} ---#desc 新建对象 ----@param filename string 文件名 +---@param filename string? 文件名 ---@return table 对象 function M:new(filename) local t = { diff --git a/lualib/skynet-fly/utils/skynet_util.lua b/lualib/skynet-fly/utils/skynet_util.lua index 675488dd1..dd877886e 100644 --- a/lualib/skynet-fly/utils/skynet_util.lua +++ b/lualib/skynet-fly/utils/skynet_util.lua @@ -149,7 +149,7 @@ local g_shutdown_func_map = {} ---#desc 注册关服处理函数 ---@param func function 函数 ----@param sort_weight number 排序权重 +---@param sort_weight number? 排序权重 function M.reg_shutdown_func(func, sort_weight) sort_weight = sort_weight or 0 assert(type(func) == 'function', "not function") diff --git a/lualib/skynet-fly/utils/string_util.lua b/lualib/skynet-fly/utils/string_util.lua index 7671165b0..bf1ad5fef 100644 --- a/lualib/skynet-fly/utils/string_util.lua +++ b/lualib/skynet-fly/utils/string_util.lua @@ -21,12 +21,13 @@ local sfind = string.find ---#desc 字符串分割,可以嵌套分割 例如:split('1:2_3:4','_',':') res = {{1,2},{3,4}} ---@param inputstr string 被分割字符串 ---@param ... string 分隔符列表 ----@return table|string 分割结果 +---@return table 分割结果 function M.split(inputstr, ...) local seps = {...} local sep = tremove(seps,1) if sep == nil then +---@diagnostic disable-next-line: return-type-mismatch return inputstr end local result={} diff --git a/lualib/skynet-fly/watch/watch_syn.lua b/lualib/skynet-fly/watch/watch_syn.lua index 9948a974f..773d7a670 100644 --- a/lualib/skynet-fly/watch/watch_syn.lua +++ b/lualib/skynet-fly/watch/watch_syn.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field local skynet = require "skynet" local skynet_util = require "skynet-fly.utils.skynet_util" local log = require "skynet-fly.log" diff --git a/module/frpc_client_m.lua b/module/frpc_client_m.lua index 59ddd6584..6297ff110 100644 --- a/module/frpc_client_m.lua +++ b/module/frpc_client_m.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: need-check-nil, undefined-field local skynet = require "skynet" local timer = require "skynet-fly.timer" local log = require "skynet-fly.log" diff --git a/module/mysql_m.lua b/module/mysql_m.lua index 02cfc5042..6da2a2ee8 100644 --- a/module/mysql_m.lua +++ b/module/mysql_m.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: undefined-field, need-check-nil local skynet = require "skynet" local timer = require "skynet-fly.timer" local log = require "skynet-fly.log" @@ -70,7 +71,7 @@ function CMD.query(sql_str) end function CMD.max_packet_size() - return g_db_conf.max_packet_size or 1024 * 1024 + return g_db_conf.max_packet_size or (1024 * 1024) end function CMD.check_exit() diff --git a/module/orm_table_m.lua b/module/orm_table_m.lua index 61923ff43..f900d8a3b 100644 --- a/module/orm_table_m.lua +++ b/module/orm_table_m.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: undefined-field, need-check-nil local skynet = require "skynet" local log = require "skynet-fly.log" local skynet_util = require "skynet-fly.utils.skynet_util" diff --git a/module/room_game_alloc_m.lua b/module/room_game_alloc_m.lua index 255fe6f0c..5a6be73c3 100644 --- a/module/room_game_alloc_m.lua +++ b/module/room_game_alloc_m.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: undefined-field, need-check-nil --桌子分配 local log = require "skynet-fly.log" local contriner_client = require "skynet-fly.client.contriner_client" @@ -6,6 +7,7 @@ local queue = require "skynet.queue"() local timer = require "skynet-fly.timer" local time_util = require "skynet-fly.utils.time_util" local skynet_util = require "skynet-fly.utils.skynet_util" +local table_util = require "skynet-fly.utils.table_util" contriner_client:register("room_game_table_m") diff --git a/service/hot_container.lua b/service/hot_container.lua index 385aac909..6c89bac78 100755 --- a/service/hot_container.lua +++ b/service/hot_container.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: duplicate-set-field, undefined-field, need-check-nil local skynet = require "skynet" local assert = assert local tonumber = tonumber diff --git a/service/room_game_login.lua b/service/room_game_login.lua index e0e47a5eb..8f51aafed 100644 --- a/service/room_game_login.lua +++ b/service/room_game_login.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: need-check-nil, undefined-field local skynet = require "skynet.manager" local timer = require "skynet-fly.timer" local log = require "skynet-fly.log" diff --git a/service/sharedata_service.lua b/service/sharedata_service.lua index c03f6d52e..4de3fba42 100644 --- a/service/sharedata_service.lua +++ b/service/sharedata_service.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: need-check-nil, undefined-field local skynet = require "skynet.manager" local sharedata = require "skynet.sharedata" local sharetable = require "skynet.sharetable"