fix(socket): 优化 TCP 连接处理和玩家昵称处理

- 在 ServerEvent.go 中增加 TCP 连接的特殊处理逻辑,防止缓冲区溢出
- 修改 CreatePlayer.go 中的昵称处理,去除多余的空格
- 优化 mapout.go 中的玩家离开地图通知逻辑
- 在 wscodec.go 中增加对 TCP 连接的识别和处理
This commit is contained in:
2025-09-13 00:42:39 +08:00
parent c70e9621e0
commit 910e866456
4 changed files with 21 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ import (
"blazing/logic/service/login"
"blazing/logic/service/space"
blservice "blazing/modules/blazing/service"
"strings"
)
// 处理命令: 1001
@@ -17,18 +18,17 @@ func (h *Controller) CreatePlayer(data *login.CreatePlayerInboundInfo, c *servic
}
func (h *Controller) ChangePlayerName(data *login.ChangePlayerNameInboundInfo, c *service.Player) (result *login.ChangePlayerNameOutboundInfo, err errorcode.ErrorCode) {
newnice := cool.Filter.Replace(data.Nickname, '*')
newnice := cool.Filter.Replace(strings.Trim(data.Nickname, "\x00"), '*')
tt := login.ChangePlayerNameOutboundInfo{
c.Info.Nick = newnice
result = &login.ChangePlayerNameOutboundInfo{
Nickname: newnice,
UserID: c.ID(),
}
c.Info.Nick = newnice
space.GetSpace(c.MapID()).Range(func(playerID uint32, player service.PlayerI) bool {
defer space.GetSpace(c.MapID()).Range(func(playerID uint32, player service.PlayerI) bool {
player.SendPack(data.Head.Pack(&tt))
player.SendPack(data.Head.Pack(&result))
return true
})
return result, -1
return result, 0
}