feat(player): 实现玩家主动退出并优化踢出逻辑

将原有的踢出玩家逻辑提取到 Player 结构体的 Kick 方法中,统一处理登录状态判断、
发送错误码、关闭连接等操作。同时在 QuitSelf 方法中调用该逻辑,确保所有玩家被正确踢出。
移除了 server.go 中重复的踢出实现,并调整了相关包导入路径。
```
This commit is contained in:
2025-10-26 14:56:29 +08:00
parent 4306e2db53
commit 03aea8ae6c
3 changed files with 25 additions and 18 deletions

View File

@@ -15,6 +15,12 @@ func (h *Server) KickPerson(a int) error {
func (h *Server) QuitSelf(a int) error {
//TODO 这里待退出
fmt.Println("检测到退出请求")
h.quit = true
player.Mainplayer.Range(func(key uint32, value *player.Player) bool {
value.Kick()
return true
})
return nil
}