feat(fight): 使用专用函数构建战斗结束数据包 为战斗结束消息创建专用的构建函数, 统一处理战斗结束信息的数据包构建逻辑, 提高代码的一致性和可维护性。 fix(config): 优化数据库查询语句以提高性能 将数组包含操作(@>)替换为 ANY 操作符, 在 Egg、MapPit、PetFusion 等服务中使用更高效 的查询方式
This commit is contained in:
31
logic/service/fight/fight_over_payload.go
Normal file
31
logic/service/fight/fight_over_payload.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package fight
|
||||
|
||||
import "blazing/modules/player/model"
|
||||
|
||||
// buildFightOverPayload builds the legacy 2506 payload expected by the flash client.
|
||||
// Regular fight-over packets use a different reason mapping than group fight 7560:
|
||||
// 0=normal end 1=player lost/offline 2=overtime 3=draw 4=system error 5=npc escape.
|
||||
func buildFightOverPayload(over model.FightOverInfo) *model.FightOverInfo {
|
||||
payload := over
|
||||
payload.Reason = mapFightOverReasonFor2506(over.Reason)
|
||||
return &payload
|
||||
}
|
||||
|
||||
func mapFightOverReasonFor2506(reason model.EnumBattleOverReason) model.EnumBattleOverReason {
|
||||
switch reason {
|
||||
case model.BattleOverReason.PlayerOffline:
|
||||
return 1
|
||||
case model.BattleOverReason.PlayerOVerTime:
|
||||
return 2
|
||||
case model.BattleOverReason.NOTwind:
|
||||
return 3
|
||||
case model.BattleOverReason.PlayerEscape:
|
||||
// Player-initiated escape is handled by 2410 on the flash side; 2506 should
|
||||
// still land in a non-error bucket instead of "system error".
|
||||
return 1
|
||||
case model.BattleOverReason.Cacthok, model.BattleOverReason.DefaultEnd:
|
||||
return 0
|
||||
default:
|
||||
return 4
|
||||
}
|
||||
}
|
||||
@@ -177,7 +177,7 @@ func (f *FightC) battleLoop() {
|
||||
if f.LegacyGroupProtocol {
|
||||
f.sendLegacyGroupOver(p, &f.FightOverInfo)
|
||||
} else {
|
||||
f.sendFightPacket(p, fightPacketOver, &f.FightOverInfo)
|
||||
f.sendFightPacket(p, fightPacketOver, buildFightOverPayload(f.FightOverInfo))
|
||||
}
|
||||
|
||||
p.QuitFight()
|
||||
|
||||
@@ -342,7 +342,7 @@ func buildFight(opts *fightBuildOptions) (*FightC, errorcode.ErrorCode) {
|
||||
if f.LegacyGroupProtocol {
|
||||
f.sendLegacyGroupOver(p, &f.FightOverInfo)
|
||||
} else {
|
||||
f.sendFightPacket(p, fightPacketOver, &f.FightOverInfo)
|
||||
f.sendFightPacket(p, fightPacketOver, buildFightOverPayload(f.FightOverInfo))
|
||||
}
|
||||
p.QuitFight()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user