1 Star 0 Fork 0

TERA Toolbox Mods/fake-marker

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
set_migrator.js 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
海比天蓝 提交于 2022-12-22 11:50 . Initial commit
const DefaultSettings = {
"collection": "clean",
"deadMember": true,
"creature": true,
"logNPC": false,
"h_ID": 0,
"t_ID": 0,
"log": false,
}
module.exports = function MigrateSettings(from_ver, to_ver, settings) {
if (from_ver === undefined) {
// Migrate legacy config file
return Object.assign(Object.assign({}, DefaultSettings), settings)
} else if (from_ver === null) {
// No config file exists, use default settings
return DefaultSettings
} else {
// Migrate from older version (using the new system) to latest one
if (from_ver + 1 < to_ver) { // Recursively upgrade in one-version steps
settings = MigrateSettings(from_ver, from_ver + 1, settings)
return MigrateSettings(from_ver + 1, to_ver, settings)
}
// If we reach this point it's guaranteed that from_ver === to_ver - 1, so we can implement
// a switch for each version step that upgrades to the next version. This enables us to
// upgrade from any version to the latest version without additional effort!
switch (to_ver) {
default:
let oldsettings = settings
settings = Object.assign(DefaultSettings, {})
for (let option in oldsettings) {
if (settings[option]) {
settings[option] = oldsettings[option]
}
}
break
}
return settings
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/tera-toolbox-mods/fake-marker.git
git@gitee.com:tera-toolbox-mods/fake-marker.git
tera-toolbox-mods
fake-marker
fake-marker
master

搜索帮助