refactor: 移除 syncBackupPetList 调用和定义
This commit is contained in:
@@ -12,7 +12,6 @@ func (h Controller) SavePetBagOrder(
|
||||
data *pet.SavePetBagOrderInboundInfo,
|
||||
player *player.Player) (result *fight.NullOutboundInfo,
|
||||
err errorcode.ErrorCode) {
|
||||
syncBackupPetList(player)
|
||||
|
||||
if len(data.PetList) > 6 || len(data.BackupPetList) > 6 {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
|
||||
@@ -58,18 +57,14 @@ func (h Controller) PetRetrieveFromWarehouse(
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
syncBackupPetList(player)
|
||||
changed := false
|
||||
if len(player.Info.PetList) < 6 {
|
||||
player.Info.PetList = append(player.Info.PetList, petInfo.Data)
|
||||
changed = true
|
||||
|
||||
} else if len(player.Info.BackupPetList) < 6 {
|
||||
player.Info.BackupPetList = append(player.Info.BackupPetList, petInfo.Data)
|
||||
changed = true
|
||||
}
|
||||
if changed {
|
||||
player.Service.Info.Save(*player.Info)
|
||||
|
||||
}
|
||||
|
||||
return nil, 0
|
||||
}
|
||||
|
||||
@@ -85,8 +80,6 @@ func (h Controller) TogglePetBagWarehouse(
|
||||
return result, errorcode.ErrorCodes.ErrChampionCannotSwitch
|
||||
}
|
||||
|
||||
syncBackupPetList(player)
|
||||
|
||||
switch data.Flag {
|
||||
case 0:
|
||||
slot, ok := findPetListSlot(player, data.CatchTime)
|
||||
|
||||
@@ -48,7 +48,7 @@ func (h Controller) GetPetReleaseList(
|
||||
data *pet.GetPetListFreeInboundEmpty,
|
||||
player *player.Player) (result *pet.GetPetListOutboundInfo,
|
||||
err errorcode.ErrorCode) {
|
||||
syncBackupPetList(player)
|
||||
|
||||
return buildPetListOutboundInfo(buildWarehousePetList(player)), 0
|
||||
}
|
||||
|
||||
|
||||
@@ -137,40 +137,7 @@ func findPetListSlot(player *player.Player, catchTime uint32) (petListSlot, bool
|
||||
return petListSlot{}, false
|
||||
}
|
||||
|
||||
func syncBackupPetList(player *player.Player) {
|
||||
if player.Info.BackupPetList == nil {
|
||||
player.Info.BackupPetList = make([]model.PetInfo, 0)
|
||||
return
|
||||
}
|
||||
|
||||
bagPets := player.Service.Pet.PetInfo(0)
|
||||
if len(bagPets) == 0 {
|
||||
player.Info.BackupPetList = make([]model.PetInfo, 0)
|
||||
return
|
||||
}
|
||||
|
||||
bagCatchTimes := make(map[uint32]struct{}, len(bagPets))
|
||||
for i := range bagPets {
|
||||
bagCatchTimes[bagPets[i].Data.CatchTime] = struct{}{}
|
||||
}
|
||||
|
||||
mainPetCatchTimes := buildCatchTimeSet(player.Info.PetList)
|
||||
nextBackupList := make([]model.PetInfo, 0, len(player.Info.BackupPetList))
|
||||
for _, petInfo := range player.Info.BackupPetList {
|
||||
if _, inBag := bagCatchTimes[petInfo.CatchTime]; !inBag {
|
||||
continue
|
||||
}
|
||||
if _, inMain := mainPetCatchTimes[petInfo.CatchTime]; inMain {
|
||||
continue
|
||||
}
|
||||
nextBackupList = append(nextBackupList, petInfo)
|
||||
}
|
||||
|
||||
player.Info.BackupPetList = nextBackupList
|
||||
}
|
||||
|
||||
func buildUserBagPetInfo(player *player.Player) *pet.GetUserBagPetInfoOutboundInfo {
|
||||
syncBackupPetList(player)
|
||||
|
||||
result := &pet.GetUserBagPetInfoOutboundInfo{
|
||||
PetList: make([]model.PetInfo, len(player.Info.PetList)),
|
||||
|
||||
@@ -241,7 +241,7 @@ func (m *manager) queueHeartbeatLoop(p *player.Player, ticket *localQueueTicket)
|
||||
CatchTimes: filterAvailableCatchTimes(p.GetPetInfo(0)),
|
||||
},
|
||||
}
|
||||
if err := publishServerMessage(pvpwire.CoordinatorTopicPrefix, pvpwire.MessageTypeQueueJoin, payload); err != nil {
|
||||
if err := publishServerMessage(pvpwire.CoordinatorTopicPrefix, pvpwire.MessageTypeQueueJoin, payload); err != 0 {
|
||||
cool.Logger.Warning(context.Background(), "peak queue publish failed", err)
|
||||
}
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user