diff --git a/common/socket/codec/SocketCodec_Tomee.go b/common/socket/codec/SocketCodec_Tomee.go index bd138e21..716690a3 100644 --- a/common/socket/codec/SocketCodec_Tomee.go +++ b/common/socket/codec/SocketCodec_Tomee.go @@ -1,8 +1,6 @@ package codec import ( - "blazing/cool" - "context" "encoding/binary" "errors" "io" @@ -60,7 +58,7 @@ func (codec TomeeSocketCodec) Decode(c gnet.Conn) ([]byte, error) { } bodyLen := binary.BigEndian.Uint32(lenBuf) - cool.Loger.Print(context.TODO(), "lenBuf", bodyLen) + if bodyLen > maxBodyLen { return nil, errors.New("packet body exceeds max length") } diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index 0d9353a7..d0604224 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -94,8 +94,11 @@ func (f *FightC) LoadPercent(c common.PlayerI, percent int32) { }) } -func (f *FightC) initplayer(c common.PlayerI, opp bool) { +func (f *FightC) initplayer(c common.PlayerI, opp bool) bool { + if len(c.GetInfo().PetList) == 0 { + return false + } temp := input.NewInput(f, c) temp.AllPet = make([]*info.BattlePetEntity, 0) @@ -153,7 +156,7 @@ func (f *FightC) initplayer(c common.PlayerI, opp bool) { } temp.CurrentPet = temp.AllPet[0] - + return true } // 创建新战斗,邀请方和被邀请方,或者玩家和野怪方 @@ -174,9 +177,15 @@ func NewFight(mode, status info.EnumBattleMode, p1 common.PlayerI, p2 common.Pla Status: status, } - f.initplayer(p1, false) + ok := f.initplayer(p1, false) + if !ok { + return nil + } - f.initplayer(p2, true) + ok = f.initplayer(p2, true) + if !ok { + return nil + } defer func() { rr := Fightpool.Submit(f.battleLoop)