123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- local skynet = require "skynet"
- require "skynet.manager"
- local sharedata = require "skynet.sharedata"
- local logger = require "logger"
- local cache = require "skynet.codecache"
- cache.mode "OFF" -- turn off codecache, because CMD.new may load data file
- local index = ...
- local SET_FILES
- local path = skynet.getenv "asset"
- local skynet_retpack = skynet.retpack
- local FILES = {
- -- TODO: 在下面定义需要引入的配置文件
- DataConfig_proto = "DataConfig_proto", -- 离散表
- GoodsConfig_proto = "GoodsConfig_proto", -- 货币表
- StageConfig_proto = "StageConfig_proto", -- 关卡表
- StageInfoConfig_proto = "StageInfoConfig_proto", -- 关卡信息表
- RoleConfig_proto = "RoleConfig_proto", -- 角色表
- RoleLevelConfig_proto = "RoleLevelConfig_proto", -- 角色升级表
- RanksLevelConfig_proto = "RanksLevelConfig_proto", -- 队伍升级表
- ArmorConfig_proto = "ArmorConfig_proto", -- 装备表
- EquipmentQualityConfig_proto = "EquipmentQualityConfig_proto", -- 装备升阶表
- EquipmentLevelConfig_proto = "EquipmentLevelConfig_proto", -- 装备升级表
- AwardConfig_proto = "AwardConfig_proto", -- 奖励库id
- TalentConfig_proto = "TalentConfig_proto", -- 天赋配置表
- SigninConfig_proto = "SigninConfig_proto", -- 签到配置
- GiftConfig_proto = "GiftConfig_proto", -- 计费点礼包配置
- RechargeConfig_proto = "RechargeConfig_proto", -- 充值计费点
- MonsterConfig_proto = "MonsterConfig_proto", -- 怪物表
- NewawardConfig_proto = "NewawardConfig_proto", -- 奖励库活动
- EntryConfig_proto = "EntryConfig_proto", -- 词条表
- BoxConfig_proto = "BoxConfig_proto", -- 宝箱配置
- }
- -- TODO: 集群使用的配置表
- local SPAN_FILES = {
-
- }
- local function encode(filename)
- return string.format("@%s%s.lua", path, filename)
- end
- local function reload(k, filename)
- local ok = pcall(sharedata.update, k, encode(filename))
- if ok then
- logger.warn("hotfix: '%s.lua'", k)
- else
- return filename
- end
- end
- local function hotfix(...)
- local args = { ... }
- if #args == 0 then
- for k, v in pairs(SET_FILES) do
- local error = reload(k, v)
- if error then
- return error
- end
- end
- else
- for _, k in ipairs(args) do
- local v = SET_FILES[k]
- if v then
- local error = reload(k, v)
- if error then
- return error
- end
- end
- end
- end
- end
- local CMD = {}
- function CMD.start()
- logger.info("start")
- if index == "master" then
- SET_FILES = SPAN_FILES
- else
- SET_FILES = FILES
- end
- for k, filename in pairs(SET_FILES) do
- sharedata.new(k, encode(filename))
- end
- end
- function CMD.hotfix(...)
- local error = hotfix(...)
- collectgarbage "collect"
- return error
- end
- skynet.memlimit(128 * 1024 * 1024)
- skynet.init(function() skynet.register(".assetcenter") end)
- skynet.start(function()
- logger.label("<Assetcenter>")
- skynet.dispatch("lua", function(session, _, cmd, ...)
- local f = assert(CMD[cmd])
- if session == 0 then
- f(...)
- else
- skynet_retpack(f(...))
- end
- end)
- end)
|