feat(space): 替换并发安全map实现以提升性能

将原来基于`utils.ConcurrentMap`的玩家存储结构替换为
`github.com/mhmtszr/concurrent-swiss-map`提供的`CsMap`,
以获得更高效的并发读写能力。

同时修改了相关API调用方式:
- `Set` 改为 `Store`
- `Remove` 改为 `Delete`
- `IterCb` 改为 `Range`,并支持提前终止迭代
- `Items()` 不再使用

此外,调整了部分业务逻辑中对玩家列表遍历的方式,
确保在发送网络包后及时跳出循环,避免不必要的操作。

新增战斗类型处理函数`PET_King`用于处理宠物王相关的
战斗请求,并修复了`PET_MELEE`方法中的逻辑问题。

更新了go.mod和go.sum引入新的依赖库。
```
This commit is contained in:
2025-11-15 15:22:58 +08:00
parent f919047ff6
commit 6979b7018d
19 changed files with 117 additions and 48 deletions

View File

@@ -281,7 +281,7 @@ func (m ConcurrentMap[K, V]) Items() map[K]V {
// maps. RLock is held for all calls for a given shard
// therefore callback sess consistent view of a shard,
// but not across the shards
type IterCb[K comparable, V any] func(key K, v V)
type IterCb[K comparable, V any] func(key K, v V) bool
// Callback based iterator, cheapest way to read
// all elements in a map.
@@ -290,7 +290,10 @@ func (m ConcurrentMap[K, V]) IterCb(fn IterCb[K, V]) {
shard := (m.shards)[idx]
shard.RLock()
for key, value := range shard.items {
fn(key, value)
if !fn(key, value) {
break
}
}
shard.RUnlock()
}