Merge branch 'main' of github.com:72wo/blazing
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime/debug"
|
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -45,9 +44,9 @@ func (s *Server) OnClose(c gnet.Conn, _ error) (action gnet.Action) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil { // 恢复 panic,err 为 panic 错误值
|
if err := recover(); err != nil { // 恢复 panic,err 为 panic 错误值
|
||||||
// 1. 打印错误信息
|
// 1. 打印错误信息
|
||||||
log.Printf("捕获到 panic 错误:%v", err)
|
|
||||||
// 2. 打印完整调用堆栈(debug.Stack() 获取堆栈字节流,转为字符串)
|
cool.Loger.Error(context.TODO(), "panic 错误:", err)
|
||||||
log.Printf("panic 详细堆栈:\n%s", debug.Stack())
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -102,9 +101,9 @@ func (s *Server) OnTraffic(c gnet.Conn) (action gnet.Action) {
|
|||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil { // 恢复 panic,err 为 panic 错误值
|
if err := recover(); err != nil { // 恢复 panic,err 为 panic 错误值
|
||||||
// 1. 打印错误信息
|
// 1. 打印错误信息
|
||||||
log.Printf("捕获到 panic 错误:%v", err)
|
|
||||||
// 2. 打印完整调用堆栈(debug.Stack() 获取堆栈字节流,转为字符串)
|
cool.Loger.Error(context.TODO(), "panic 错误:", err)
|
||||||
log.Printf("panic 详细堆栈:\n%s", debug.Stack())
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if s.network != "tcp" {
|
if s.network != "tcp" {
|
||||||
|
|||||||
@@ -514,14 +514,16 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
|
|||||||
// 伤害值
|
// 伤害值
|
||||||
|
|
||||||
// 根据攻击方归属设置当前战斗的主/次攻击方属性
|
// 根据攻击方归属设置当前战斗的主/次攻击方属性
|
||||||
|
if fattack != nil {
|
||||||
|
if fattack.GetPlayerID() == f.ownerID {
|
||||||
|
f.First, f.Second = f.Our, f.Opp // 攻击方为我方时,主攻击方是我方
|
||||||
|
|
||||||
if fattack.GetPlayerID() == f.ownerID {
|
} else {
|
||||||
f.First, f.Second = f.Our, f.Opp // 攻击方为我方时,主攻击方是我方
|
f.First, f.Second = f.Opp, f.Our // 攻击方为对方时,主攻击方是对方
|
||||||
|
|
||||||
} else {
|
|
||||||
f.First, f.Second = f.Opp, f.Our // 攻击方为对方时,主攻击方是对方
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
f.First.InitAttackValue()
|
f.First.InitAttackValue()
|
||||||
f.Second.InitAttackValue()
|
f.Second.InitAttackValue()
|
||||||
|
|
||||||
|
|||||||
@@ -388,8 +388,18 @@ func (p *Player) Save() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if p.FightC != nil {
|
if p.FightC != nil {
|
||||||
|
go func() {
|
||||||
|
|
||||||
go p.FightC.Over(p, info.BattleOverReason.PlayerOffline) //玩家逃跑,但是不能锁线程
|
defer func() {
|
||||||
|
if err := recover(); err != nil { // 恢复 panic,err 为 panic 错误值
|
||||||
|
// 1. 打印错误信息
|
||||||
|
|
||||||
|
cool.Loger.Error(context.TODO(), "panic 错误:", err)
|
||||||
|
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
p.FightC.Over(p, info.BattleOverReason.PlayerOffline) //玩家逃跑,但是不能锁线程
|
||||||
|
}()
|
||||||
|
|
||||||
}
|
}
|
||||||
p.Info.TimeToday = p.Info.TimeToday + uint32(time.Now().Unix()) - uint32(p.Onlinetime) //保存电池时间
|
p.Info.TimeToday = p.Info.TimeToday + uint32(time.Now().Unix()) - uint32(p.Onlinetime) //保存电池时间
|
||||||
|
|||||||
@@ -77,3 +77,9 @@ func (c *BlazingController) GetSession(ctx context.Context, req *SessionReq) (re
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MockReq struct {
|
||||||
|
g.Meta `path:"/mock" method:"GET"`
|
||||||
|
Email string `json:"email" v:"required|email"`
|
||||||
|
Password string `json:"password" v:"required"`
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user