1
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
昔念
2026-02-03 23:08:06 +08:00
parent 55fbcd6fc3
commit 4b83346f36
4 changed files with 22 additions and 11 deletions

View File

@@ -44,7 +44,7 @@ func (s *Server) QuitSelf(a int) error {
s.quit = true
if a != 0 {
player.Mainplayer.Range(func(key uint32, value *player.Player) bool {
value.Kick(1)
value.KickMessage()
return false
})
} else {
@@ -60,7 +60,7 @@ func (s *Server) QuitSelf(a int) error {
<-time.After(10 * time.Minute)
player.Mainplayer.Range(func(key uint32, value *player.Player) bool {
value.Kick(1)
value.Kick()
return false
})
}()

View File

@@ -38,7 +38,7 @@ func cleanup() {
log.Println("执行优雅清理资源...")
player.Mainplayer.Range(func(key uint32, value *player.Player) bool {
value.Kick(1)
value.Kick()
return false
})

View File

@@ -223,22 +223,17 @@ func (p *Player) ItemAdd(ItemId, ItemCnt uint32) (result bool) {
return false
}
func (player1 *Player) Kick(qtype int) {
func (player1 *Player) Kick() {
if player1.Info == nil {
return
}
// 取成功,否则创建
// player1.Save() //先保存数据再返回
head := common.NewTomeeHeader(1001, player1.Info.UserID)
head.Result = uint32(errorcode.ErrorCodes.ErrXinPlanSleepMode)
// 实际上这里有个问题,会造成重复保存问题
player1.SendPack(head.Pack(nil))
if qtype == 1 {
return
}
CloseChan := make(chan struct{})
@@ -260,6 +255,22 @@ func (player1 *Player) Kick(qtype int) {
}
}
// 1是延迟踢人,0是强制踢人
func (player1 *Player) KickMessage() {
if player1.Info == nil {
return
}
// 取成功,否则创建
// player1.Save() //先保存数据再返回
head := common.NewTomeeHeader(1001, player1.Info.UserID)
head.Result = uint32(errorcode.ErrorCodes.ErrXinPlanSleepMode)
// 实际上这里有个问题,会造成重复保存问题
player1.SendPack(head.Pack(nil))
}
func (p *Player) Cheak(b error) {
if b != nil {
g.Log().Error(context.Background(), "出现错误", p.Info.UserID, b.Error())

View File

@@ -34,7 +34,7 @@ func KickPlayer(userid uint32) error { //踢出玩家
//TODO 返回错误码
//var player *entity.Player
if player1, ok := Mainplayer.Load(userid); ok {
player1.Kick(0)
player1.Kick()
}