diff --git a/extend/lmake/lmake.lua b/extend/lmake/lmake.lua index c288c75c..9628a6ae 100644 --- a/extend/lmake/lmake.lua +++ b/extend/lmake/lmake.lua @@ -114,14 +114,18 @@ local function init_solution_env(env) env.GROUPS = sgroup end +local function is_cpp_file(ext_name) + return ext_name == ".c" or ext_name == ".cc" or ext_name == ".cpp" or ext_name == ".m" +end + --收集文件 local function collect_files(collect_dir, project_dir, source_dir, args, sub_dir, collects, is_hfile) local dir_files = ldir(collect_dir) for _, file in pairs(dir_files) do if file.type == "directory" then if args.RECURSION then - local sub_dir = path_cut(file.name, project_dir) - collect_files(file.name, project_dir, source_dir, args, sub_dir, collects, is_hfile) + local rec_sub_dir = path_cut(file.name, project_dir) + collect_files(file.name, project_dir, source_dir, args, rec_sub_dir, collects, is_hfile) end goto continue end @@ -135,7 +139,7 @@ local function collect_files(collect_dir, project_dir, source_dir, args, sub_dir end goto continue end - if ext_name == ".c" or ext_name == ".cc" or ext_name == ".cpp" or ext_name == ".m" then + if is_cpp_file(ext_name) then local cmp_name = path_cut(fullname, source_dir) local is_obj = tcontain(args.OBJS, cmp_name) local cmp_name_c = sgsub(cmp_name, '/', '\\') diff --git a/server/business/component/attr_component.lua b/server/business/component/attr_component.lua index b28b8e02..e34e5c37 100644 --- a/server/business/component/attr_component.lua +++ b/server/business/component/attr_component.lua @@ -3,7 +3,6 @@ local qenum = quanta.enum local log_warn = logger.warn local log_debug = logger.debug local tinsert = table.insert -local supper = string.upper local sformat = string.format local qmerge = qtable.merge @@ -12,10 +11,6 @@ local config_mgr = quanta.get("config_mgr") local attr_db = config_mgr:get_table("attribute") -local AttrID = quanta.enum("AttrID") -local INTERNAL = { "_base", "_inc", "_per" } -local INTERNALID = 1000 - local AttrComponent = mixin() local prop = property(AttrComponent) prop:reader("range", {}) --属性集合 @@ -31,7 +26,7 @@ dbprop:store_values("attrs", {}) --属性集合 --委托回调 function AttrComponent:__delegate() - local function delegate_attr(attr) + for _, attr in attr_db:iterator() do AttrComponent["get_" .. attr.nick] = function(this) return this:get_attr(attr.id) end @@ -46,26 +41,6 @@ function AttrComponent:__delegate() return this:cost_attr(attr.id, value) end end - local function delegate_internal_attr(attr_bid, attr) - for idx, name in ipairs(INTERNAL) do - AttrID[attr.enum_key .. supper(name)] = attr_bid + idx - delegate_attr({ id = attr_bid + idx, nick = attr.nick .. name, increase = true}) - end - end - end - for _, attr in attr_db:iterator() do - if attr.complex then - local attr_bid = INTERNALID + attr.id * 3 - delegate_internal_attr(attr_bid, attr) - AttrComponent["get_" .. attr.nick] = function(this) - local base = this:get_attr(attr_bid) - local add_val = this:get_attr(attr_bid + 1) - local per_val = this:get_attr(attr_bid + 2) - return (base + add_val) * (1 + per_val) - end - else - delegate_attr(attr) - end end end @@ -75,22 +50,12 @@ function AttrComponent:init_attrset(type_attr_db, range) for _, attr in type_attr_db:iterator() do local attr_id = qenum("AttrID", attr.key) local attr_type = attr_db:find_value("type", attr_id) - local attr_limit = attr_db:find_value("limit", attr_id) - local attr_complex = attr_db:find_value("complex", attr_id) local attr_def = { save = attr.save, back = attr.back, range = attr.range, type = attr_type } - if attr_limit then - attr_def.limit_id = qenum("AttrID", attr_limit) - end - if attr_complex then - local attr_bid = INTERNALID + attr_id * 3 - for idx, name in ipairs(INTERNAL) do - self.attr_set[attr_bid + idx] = { save = false, back = false, range = 0, type = attr_type } - self.attrs[attr_bid + idx] = attr_type == "int" and 0 or "" - end - else - self.attr_set[attr_id] = attr_def - self.attrs[attr_id] = attr_type == "int" and 0 or "" + if attr.limit then + attr_def.limit_id = qenum("AttrID", attr.limit) end + self.attr_set[attr_id] = attr_def + self.attrs[attr_id] = attr_type == "int" and 0 or "" end end @@ -246,7 +211,7 @@ end function AttrComponent:package_attrs(range) local attrs = {} for attr_id, attr in pairs(self.attr_set) do - if attr.range > 0 and attr.range > range then + if attr.range > 0 and range >= attr.range then tinsert(attrs, self:encode_attr(attr_id, attr)) end end