feat(xmlres): 优化配置加载与字段指针处理
- 将部分全局配置变量调整为局部加载,减少内存占用 - 修改 Item 结构体中 Nature 和 NatureSet 字段为指针类型,支持空值判断 - 更新使用点逻辑以适配指针字段,避免解析错误 - 移除未使用的配置引用及旧控制器文件
This commit is contained in:
@@ -36,11 +36,11 @@ func getJson[T any](path string) T {
|
||||
}
|
||||
|
||||
var (
|
||||
MapConfig Maps //地图配置
|
||||
ItemsConfig Items //物品配置
|
||||
EffectArgsConfig EffectArg //arg参数
|
||||
TalkConfig TalkRoot //任务配置
|
||||
//Monster MonsterRoot //野怪配置
|
||||
MapConfig Maps //地图配置
|
||||
// ItemsConfig Items //物品配置
|
||||
// EffectArgsConfig EffectArg //arg参数
|
||||
TalkConfig TalkRoot //任务配置
|
||||
// //Monster MonsterRoot //野怪配置
|
||||
MonsterMap map[int]TMapConfig
|
||||
//Skill MovesTbl //技能配置
|
||||
SkillMap map[int]Move
|
||||
@@ -60,14 +60,13 @@ func Initfile() {
|
||||
path1, _ := os.Getwd()
|
||||
path = path1 + "/public/config/"
|
||||
MapConfig = getXml[Maps](path + "210.xml")
|
||||
ItemsConfig = getXml[Items](path + "43.xml")
|
||||
EffectArgsConfig = getJson[EffectArg](path + "side_effect.json")
|
||||
|
||||
EffectArgs = make(map[int]int)
|
||||
for _, t := range EffectArgsConfig.SideEffects.SideEffect {
|
||||
for _, t := range getJson[EffectArg](path + "side_effect.json").SideEffects.SideEffect {
|
||||
EffectArgs[t.ID] = t.SideEffectArgcount
|
||||
|
||||
}
|
||||
ItemsMAP = utils.ToMap[Item, int](ItemsConfig.Items, func(m Item) int {
|
||||
ItemsMAP = utils.ToMap[Item, int](getXml[Items](path+"43.xml").Items, func(m Item) int {
|
||||
return m.ID
|
||||
|
||||
})
|
||||
|
||||
@@ -46,11 +46,11 @@ type Item struct {
|
||||
DualEvTimes int `xml:"DualEvTimes,attr,omitempty"` // 双倍学习力次数(学习力双倍仪)
|
||||
YuanshenDegrade int `xml:"YuanshenDegrade,attr,omitempty"` // 融合精灵还原标识(融合精灵还原药剂)
|
||||
EvRemove int `xml:"EvRemove,attr,omitempty"` // 学习力遗忘类型(各类学习力遗忘剂)
|
||||
bShowPetBag int `xml:"bShowPetBag,attr,omitempty"` // 宠物背包显示标识(副融合精灵保留药剂等)
|
||||
Nature int `xml:"Nature,attr,omitempty"`
|
||||
NatureSet string `xml:"NatureSet,attr,omitempty"`
|
||||
Pet *Pet `xml:"pet,omitempty"` // 精灵属性子节点
|
||||
TeamPK *TeamPK `xml:"teamPK,omitempty"` // 要塞保卫战子节点
|
||||
//bShowPetBag int `xml:"bShowPetBag,attr,omitempty"` // 宠物背包显示标识(副融合精灵保留药剂等)
|
||||
Nature *string `xml:"Nature,attr"` // 指向int的指针,无值时为nil
|
||||
NatureSet *string `xml:"NatureSet,attr"` // 指向string的指针,无值时为nil
|
||||
Pet *Pet `xml:"pet,omitempty"` // 精灵属性子节点
|
||||
TeamPK *TeamPK `xml:"teamPK,omitempty"` // 要塞保卫战子节点
|
||||
}
|
||||
|
||||
// Pet 精灵属性子节点,对应<pet>标签
|
||||
|
||||
Reference in New Issue
Block a user