fix: 修复空提交问题

This commit is contained in:
1
2025-11-18 23:41:31 +00:00
parent 6831861e0d
commit 24f2a6d7c8
14 changed files with 71 additions and 55 deletions

View File

@@ -30,9 +30,9 @@ func (h Controller) Escape(data *fight.EscapeFightInboundInfo, c *player.Player)
return nil, 0
}
if !c.FightC.CanEscape() {
if !c.FightC.CanEscape() { //用户对战不能逃跑
return nil, 0
return nil, errorcode.ErrorCodes.ErrCannotFleePlayerBattle
}
c.FightC.Over(c, info.BattleOverReason.PlayerEscape)
return nil, 0

View File

@@ -55,7 +55,7 @@ func (h Controller) ARENA_FIGHT_OWENR(data *fight.ARENA_FIGHT_OWENR, c *player.P
// 获取星际擂台信息的包 进入空间站地图前端会发送请求包 或者 有人站到星际擂台上后 广播回包
// 前端到后端无数据内容
// 后端到前端
func (h Controller) ARENA_GET_INFO(data *fight.ARENA_GET_INFO, c *player.Player) (result *info.S2C_ARENA_GET_INFO, err errorcode.ErrorCode) {
func (h Controller) ARENA_GET_INFO(data *fight.ARENA_GET_INFO, c *player.Player) (result *space.S2C_ARENA_GET_INFO, err errorcode.ErrorCode) {
result = &space.GetSpace(c.Info.MapID).ARENA
return

View File

@@ -3,7 +3,6 @@ package controller
import (
"blazing/common/socket/errorcode"
"sync/atomic"
"unsafe"
"blazing/logic/service/fight"
"blazing/logic/service/fight/info"
@@ -13,8 +12,12 @@ import (
// 接收战斗或者取消战斗的包
func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
if !c.CanFight() {
return nil, errorcode.ErrorCodes.ErrPokemonNotEligible
// if !c.CanFight() {
// return nil, errorcode.ErrorCodes.ErrPokemonNotEligible
// }
if !atomic.CompareAndSwapUint32(&c.Fightinfo.Status, 0, 1) { //邀请前提是自己没在战斗
return nil, errorcode.ErrorCodes.ErrInBattle
}
if ok, p1 := c.AgreeBattle(data.UserID, data.Flag, data.Mode); ok {
@@ -27,24 +30,27 @@ func (h Controller) OnPlayerHandleFightInvite(data *fight.HandleFightInviteInbou
// 邀请其他人进行战斗
func (h Controller) OnPlayerInviteOtherFight(data *fight.InviteToFightInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
if !c.CanFight() {
return nil, errorcode.ErrorCodes.ErrPokemonNotEligible
}
//进入邀请,以及确认对战模式
c.Fightinfo = &info.Fightinfo{PlayerID: data.UserID,
Mode: data.Mode,
Status: info.BattleStatus.FIGHT_WITH_PLAYER}
if !atomic.CompareAndSwapUint32(&c.Fightinfo.PlayerID, 0, data.UserID) { //邀请前提是自己没邀请别人
return nil, errorcode.ErrorCodes.ErrCannotPerformAction
}
c.Fightinfo.Mode = data.Mode
c.InvitePlayerToBattle()
return nil, 0
}
// 取消和他人战斗
// 取消队列
func (h Controller) OnPlayerCanceledOtherInviteFight(data *fight.InviteFightCancelInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
atomic.StorePointer(unsafe.Pointer(c.Fightinfo), nil)
return nil, 0
if atomic.LoadUint32(&c.Fightinfo.Status) != 0 { //如果没有战斗状态,则不做任何处理
atomic.StoreUint32(&c.Fightinfo.Status, 0) //设置状态为0
}
//否则报错
return nil, errorcode.ErrorCodes.ErrCannotCancelBattle
}