refactor(socket): 重构 ClientData 结构体并优化相关逻辑

- 简化 ClientData 结构体,移除不必要的方法
- 优化 Player 结构体,调整 Conn 类型
- 更新 wscodec.go 中的 Conn 结构体
- 删除未使用的 XML 相关文件和代码
- 调整 ServerEvent 和 controller 中的相关逻辑
This commit is contained in:
2025-08-30 00:36:08 +08:00
parent 1f835c1197
commit 7b5ec208fc
31 changed files with 472 additions and 602 deletions

View File

@@ -1,7 +1,7 @@
package space
import (
xml "blazing/common/data/xml/map"
"blazing/common/data/xmlres"
"golang.org/x/sync/singleflight"
)
@@ -19,7 +19,7 @@ func GetMapHot() []MapHotInfo {
tt := make(map[uint32]uint32)
for _, v := range xml.MapConfig.Maps {
for _, v := range xmlres.MapConfig.Maps {
t1, ok := tt[uint32(v.Super)]
if ok {
@@ -41,5 +41,5 @@ func GetMapHot() []MapHotInfo {
}
return result, nil
})
return result1.([]MapHotInfo)
return result1.([]MapHotInfo)
}

View File

@@ -2,7 +2,7 @@ package space
import (
"blazing/common/data/socket"
xml "blazing/common/data/xml/map"
"blazing/common/data/xmlres"
"blazing/common/utils"
"blazing/modules/blazing/model"
"sync"
@@ -37,7 +37,7 @@ func (m *Space) Get(playerID uint32) (*socket.Player, bool) {
// Set 存储玩家实例按ID
// 写操作使用Lock独占锁保证数据一致性
func (m *Space) Set(playerID uint32, player *socket.Player)*Space {
func (m *Space) Set(playerID uint32, player *socket.Player) *Space {
m.mu.Lock()
defer m.mu.Unlock()
m.data[playerID] = player
@@ -90,7 +90,7 @@ func GetSpace(id uint32) *Space {
}
//如果不ok,说明星球未创建,那就新建星球
for _, v := range xml.MapConfig.Maps {
for _, v := range xmlres.MapConfig.Maps {
if v.ID == int(id) { //找到这个地图
t := NewSpace()
t.DefaultPos = model.Pos{X: uint32(v.X), Y: uint32(v.Y)}