refactor(space): 重构空间初始化逻辑并修复变量作用域问题 - 将tips和pits的初始化移到循环外部,避免重复创建 - 修复Name赋值位置,确保在正确时机设置空间名称 - 添加条件判断ret.Super != 0,优化性能 - 调整代码结构,提高可读性和维护性 - 移除注释掉的无用代码 ```
This commit is contained in:
@@ -146,36 +146,6 @@ func (ret *Space) init() {
|
||||
maphot[ret.Super].TipInfoS = make(map[uint32]*TipInfo, 0)
|
||||
}
|
||||
|
||||
tips := &TipInfo{}
|
||||
r := service.NewMapService().GetData(ret.ID)
|
||||
if r != nil {
|
||||
tips.Diao = service.NewMapService().GetData(ret.ID).DropItemIds
|
||||
}
|
||||
|
||||
pits := service.NewMapPitService().GetDataALL(ret.ID)
|
||||
ret.PitS = csmap.New[int, []model.MapPit]()
|
||||
|
||||
for _, v := range pits {
|
||||
|
||||
tips.Pet = append(tips.Pet, v.RefreshID...)
|
||||
for _, vp := range v.Pos {
|
||||
t, ok := ret.PitS.Load(vp)
|
||||
if ok {
|
||||
t = append(t, v)
|
||||
ret.PitS.Store(vp, t)
|
||||
} else {
|
||||
ret.PitS.Store(vp, []model.MapPit{v})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tips.Pet = lo.Union(tips.Pet)
|
||||
tips.Talk = service.NewTalkConfigService().GetTip(ret.ID)
|
||||
tips.Boss = service.NewMapNodeService().GetTip(ret.ID)
|
||||
maphot[ret.Super].TipInfoS[ret.ID] = tips
|
||||
|
||||
ret.Name = v.Name
|
||||
|
||||
//ogreconfig := service.NewMapPitService().GetData(ret.ID, uint32(i))
|
||||
@@ -183,6 +153,38 @@ func (ret *Space) init() {
|
||||
}
|
||||
|
||||
}
|
||||
tips := &TipInfo{}
|
||||
r := service.NewMapService().GetData(ret.ID)
|
||||
if r != nil {
|
||||
tips.Diao = service.NewMapService().GetData(ret.ID).DropItemIds
|
||||
}
|
||||
|
||||
pits := service.NewMapPitService().GetDataALL(ret.ID)
|
||||
ret.PitS = csmap.New[int, []model.MapPit]()
|
||||
|
||||
for _, v := range pits {
|
||||
|
||||
tips.Pet = append(tips.Pet, v.RefreshID...)
|
||||
for _, vp := range v.Pos {
|
||||
t, ok := ret.PitS.Load(vp)
|
||||
if ok {
|
||||
t = append(t, v)
|
||||
ret.PitS.Store(vp, t)
|
||||
} else {
|
||||
ret.PitS.Store(vp, []model.MapPit{v})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ret.Super != 0 {
|
||||
tips.Pet = lo.Union(tips.Pet)
|
||||
tips.Talk = service.NewTalkConfigService().GetTip(ret.ID)
|
||||
tips.Boss = service.NewMapNodeService().GetTip(ret.ID)
|
||||
maphot[ret.Super].TipInfoS[ret.ID] = tips
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
r := service.NewMapService().GetData(ret.ID)
|
||||
|
||||
Reference in New Issue
Block a user