Skip to content

Commit

Permalink
sharedata 考虑纵表情况
Browse files Browse the repository at this point in the history
  • Loading branch information
huahua132 committed Sep 30, 2024
1 parent 80fdf04 commit 71b2e93
Showing 1 changed file with 54 additions and 42 deletions.
96 changes: 54 additions & 42 deletions lualib/skynet-fly/sharedata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ local setmetatable = setmetatable
local pairs = pairs
local table = table
local ipairs = ipairs
local type = type

local g_mode_map = {}
local g_data_map = {}
Expand Down Expand Up @@ -197,58 +198,69 @@ function M:builder()
local data_table = self.data_table

for index, oneCfg in pairs(data_table) do
for k,v in pairs(oneCfg) do
local kfunc = check_func_map[k]
if kfunc then
local isok,err = kfunc(v)
if not isok then
log.warn_fmt("check field err filepath[%s] idx[%s] fieldname[%s] errinfo[%s]", file_path, index, k, err)
if type(oneCfg) == 'table' then
for k,v in pairs(oneCfg) do
local kfunc = check_func_map[k]
if kfunc then
local isok,err = kfunc(v)
if not isok then
log.warn_fmt("check field err filepath[%s] idx[%s] fieldname[%s] errinfo[%s]", file_path, index, k, err)
end
end
end
end
if check_line_func then
local isok,err = check_line_func(oneCfg)
if not isok then
log.warn_fmt("check line err filepath[%s] idx[%s] errinfo[%s]", file_path, index, err)
end
end

for name,field_list in pairs(map_list_map_fields) do
local map = map_list_map[name]
for _,fieldname in ipairs(field_list) do
local v = oneCfg[fieldname]
if not v then
log.warn_fmt("set maplist err field not exists name[%s] filepath[%s] idx[%s] fieldname[%s]", name, file_path, index, fieldname)
break
end
if not map[v] then
map[v] = {}
if check_line_func then
local isok,err = check_line_func(oneCfg)
if not isok then
log.warn_fmt("check line err filepath[%s] idx[%s] errinfo[%s]", file_path, index, err)
end
map = map[v]
end
table.insert(map, oneCfg)
end

for name,field_list in pairs(map_map_fields) do
local map = map_map[name]
local len = #field_list
for i = 1, len do
local fieldname = field_list[i]
local v = oneCfg[fieldname]
if not v then
log.warn_fmt("set map err field not exists name[%s] filepath[%s] idx[%s] fieldname[%s]", name, file_path, index, fieldname)
break
end
if i < len then
for name,field_list in pairs(map_list_map_fields) do
local map = map_list_map[name]
for _,fieldname in ipairs(field_list) do
local v = oneCfg[fieldname]
if not v then
log.warn_fmt("set maplist err field not exists name[%s] filepath[%s] idx[%s] fieldname[%s]", name, file_path, index, fieldname)
break
end
if not map[v] then
map[v] = {}
end
map = map[v]
else
if map[v] then
log.warn_fmt("set map repeat err field not exists name[%s] filepath[%s] idx[%s] fieldname[%s]", name, file_path, index, fieldname)
end
table.insert(map, oneCfg)
end

for name,field_list in pairs(map_map_fields) do
local map = map_map[name]
local len = #field_list
for i = 1, len do
local fieldname = field_list[i]
local v = oneCfg[fieldname]
if not v then
log.warn_fmt("set map err field not exists name[%s] filepath[%s] idx[%s] fieldname[%s]", name, file_path, index, fieldname)
break
end
map[v] = oneCfg
if i < len then
if not map[v] then
map[v] = {}
end
map = map[v]
else
if map[v] then
log.warn_fmt("set map repeat err field not exists name[%s] filepath[%s] idx[%s] fieldname[%s]", name, file_path, index, fieldname)
end
map[v] = oneCfg
end
end
end
else
--one 参数表
local kfunc = check_func_map[index]
if kfunc then
local isok,err = kfunc(oneCfg)
if not isok then
log.warn_fmt("check field err filepath[%s] idx[%s] fieldname[%s] errinfo[%s]", file_path, index, oneCfg, err)
end
end
end
Expand Down

0 comments on commit 71b2e93

Please sign in to comment.