This commit is contained in:
1
2026-01-27 06:40:49 +00:00
parent 4078511183
commit 445aab3c22
3 changed files with 89 additions and 81 deletions

View File

@@ -5,7 +5,6 @@ import (
"blazing/cool"
"fmt"
"blazing/logic/service/fight/info"
"blazing/logic/service/space"
"context"
"time"
@@ -23,30 +22,30 @@ func (p *Player) Save() {
return
}
if p.FightC != nil {
// if p.FightC != nil {
//ov := make(chan struct{})
go func() {
// //ov := make(chan struct{})
// go func() {
defer func() {
if err := recover(); err != nil { // 恢复 panicerr 为 panic 错误值
// 1. 打印错误信息
// defer func() {
// if err := recover(); err != nil { // 恢复 panicerr 为 panic 错误值
// // 1. 打印错误信息
cool.Logger.Error(context.TODO(), "panic 错误:", err)
// cool.Logger.Error(context.TODO(), "panic 错误:", err)
}
}()
p.FightC.Over(p, info.BattleOverReason.PlayerOffline) //玩家逃跑,但是不能锁线程
}()
//<-ov
select {
case <-p.FightC.GetOverChan(): //等待结束
case <-time.After(time.Second * 5): //等待5秒
cool.Logger.Error(context.TODO(), "战斗崩溃", p.Info.UserID)
// }
// }()
// p.FightC.Over(p, info.BattleOverReason.PlayerOffline) //玩家逃跑,但是不能锁线程
// }()
// //<-ov
// select {
// case <-p.FightC.GetOverChan(): //等待结束
// case <-time.After(time.Second * 5): //等待5秒
// cool.Logger.Error(context.TODO(), "战斗崩溃", p.Info.UserID)
}
// }
}
// }
newtime := uint32(time.Now().Unix())
p.Info.TimeToday = p.Info.TimeToday + newtime - uint32(p.Logintime) //保存电池时间