```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

feat(pet): 宠物系统重构和功能增强

- 修复战斗boss中effect ID索引错误问题
- 实现宠物仓库和背包管理功能
- 添加宠物列表排序保存功能
- 重构宠物备份列表同步逻辑
- 优化宠物释放和获取逻辑
- 添加宠物背包仓库切换功能
- 修复地图模型广播信息结构问题
- 调整宠物特效数据库查询逻辑
```
This commit is contained in:
昔念
2026-04-02 07:49:49 +08:00
parent 3a13bcc99c
commit f810a2ae86
13 changed files with 280 additions and 43 deletions

View File

@@ -160,7 +160,7 @@ func appendPetEffects(monster *model.PetInfo, effectIDs []uint32) {
effects := service.NewEffectService().Args(effectIDs) effects := service.NewEffectService().Args(effectIDs)
for _, effect := range effects { for _, effect := range effects {
monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{ monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{
Idx: uint16(effect.SeIdx), Idx: uint16(effect.ID),
EID: gconv.Uint16(effect.Eid), EID: gconv.Uint16(effect.Eid),
Args: gconv.Ints(effect.Args), Args: gconv.Ints(effect.Args),
}) })

View File

@@ -224,7 +224,7 @@ func buildTowerMonsterInfo(towerBoss configmodel.BaseTowerConfig) (*model.Player
effects := service.NewEffectService().Args(boss.Effect) effects := service.NewEffectService().Args(boss.Effect)
for _, effect := range effects { for _, effect := range effects {
monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{ monster.EffectInfo = append(monster.EffectInfo, model.PetEffectInfo{
Idx: uint16(effect.SeIdx), Idx: uint16(effect.ID),
EID: gconv.Uint16(effect.Eid), EID: gconv.Uint16(effect.Eid),
Args: gconv.Ints(effect.Args), Args: gconv.Ints(effect.Args),
}) })

View File

@@ -39,21 +39,73 @@ func removePetByCatchTime(petList []model.PetInfo, catchTime uint32) []model.Pet
return petList return petList
} }
func syncBackupPetList(player *player.Player) { func buildWarehousePetList(player *player.Player) []model.PetInfo {
if len(player.Info.BackupPetList) > 0 { allPets := player.Service.Pet.PetInfo(0)
return if len(allPets) == 0 {
return make([]model.PetInfo, 0)
} }
storagePets := player.Service.Pet.PetInfo(1) usedCatchTimes := make(map[uint32]struct{}, len(player.Info.PetList)+len(player.Info.BackupPetList))
if len(storagePets) == 0 { for _, petInfo := range player.Info.PetList {
usedCatchTimes[petInfo.CatchTime] = struct{}{}
}
for _, petInfo := range player.Info.BackupPetList {
usedCatchTimes[petInfo.CatchTime] = struct{}{}
}
result := make([]model.PetInfo, 0, len(allPets))
for i := range allPets {
catchTime := allPets[i].Data.CatchTime
if _, exists := usedCatchTimes[catchTime]; exists {
continue
}
result = append(result, allPets[i].Data)
}
return result
}
func findBackupPet(player *player.Player, catchTime uint32) (int, *model.PetInfo, bool) {
for i := range player.Info.BackupPetList {
if player.Info.BackupPetList[i].CatchTime == catchTime {
return i, &player.Info.BackupPetList[i], true
}
}
return -1, nil, false
}
func syncBackupPetList(player *player.Player) {
if player.Info.BackupPetList == nil {
player.Info.BackupPetList = make([]model.PetInfo, 0) player.Info.BackupPetList = make([]model.PetInfo, 0)
return return
} }
player.Info.BackupPetList = make([]model.PetInfo, len(storagePets)) bagPets := player.Service.Pet.PetInfo(0)
for i := range storagePets { if len(bagPets) == 0 {
player.Info.BackupPetList[i] = storagePets[i].Data 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 := make(map[uint32]struct{}, len(player.Info.PetList))
for _, petInfo := range player.Info.PetList {
mainPetCatchTimes[petInfo.CatchTime] = struct{}{}
}
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 { func buildUserBagPetInfo(player *player.Player) *pet.GetUserBagPetInfoOutboundInfo {
@@ -68,6 +120,31 @@ func buildUserBagPetInfo(player *player.Player) *pet.GetUserBagPetInfoOutboundIn
return result return result
} }
func buildOrderedPetList(
catchTimes []uint32,
petMap map[uint32]model.PetInfo,
used map[uint32]struct{},
) ([]model.PetInfo, bool) {
result := make([]model.PetInfo, 0, len(catchTimes))
for _, catchTime := range catchTimes {
if catchTime == 0 {
return nil, false
}
if _, exists := used[catchTime]; exists {
return nil, false
}
petInfo, exists := petMap[catchTime]
if !exists {
return nil, false
}
used[catchTime] = struct{}{}
result = append(result, petInfo)
}
return result, true
}
func buildPetShowOutboundInfo(userID, flag uint32, info *model.PetInfo) *pet.PetShowOutboundInfo { func buildPetShowOutboundInfo(userID, flag uint32, info *model.PetInfo) *pet.PetShowOutboundInfo {
return &pet.PetShowOutboundInfo{ return &pet.PetShowOutboundInfo{
UserID: userID, UserID: userID,
@@ -115,6 +192,52 @@ func (h Controller) GetUserBagPetInfo(
// data: 空输入结构 // data: 空输入结构
// player: 当前玩家对象 // player: 当前玩家对象
// 返回: 精灵列表和错误码 // 返回: 精灵列表和错误码
// SavePetBagOrder 保存当前主背包和备用背包顺序
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
}
totalPetCount := len(player.Info.PetList) + len(player.Info.BackupPetList)
if len(data.PetList)+len(data.BackupPetList) != totalPetCount {
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
}
petMap := make(map[uint32]model.PetInfo, totalPetCount)
for _, petInfo := range player.Info.PetList {
petMap[petInfo.CatchTime] = petInfo
}
for _, petInfo := range player.Info.BackupPetList {
petMap[petInfo.CatchTime] = petInfo
}
used := make(map[uint32]struct{}, totalPetCount)
battleList, ok := buildOrderedPetList(data.PetList, petMap, used)
if !ok {
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
}
backupList, ok := buildOrderedPetList(data.BackupPetList, petMap, used)
if !ok {
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
}
if len(used) != totalPetCount {
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
}
player.Info.PetList = battleList
player.Info.BackupPetList = backupList
player.Service.Info.Save(*player.Info)
return nil, 0
}
func (h Controller) GetPetList( func (h Controller) GetPetList(
data *pet.GetPetListInboundEmpty, data *pet.GetPetListInboundEmpty,
player *player.Player) (result *pet.GetPetListOutboundInfo, player *player.Player) (result *pet.GetPetListOutboundInfo,
@@ -131,7 +254,7 @@ func (h Controller) GetPetReleaseList(
player *player.Player) (result *pet.GetPetListOutboundInfo, player *player.Player) (result *pet.GetPetListOutboundInfo,
err errorcode.ErrorCode) { err errorcode.ErrorCode) {
syncBackupPetList(player) syncBackupPetList(player)
return buildPetListOutboundInfo(player.Info.BackupPetList), 0 return buildPetListOutboundInfo(buildWarehousePetList(player)), 0
} }
// PetReleaseToWarehouse 将精灵从仓库包中放生 // PetReleaseToWarehouse 将精灵从仓库包中放生
@@ -141,9 +264,10 @@ func (h Controller) GetPetReleaseList(
func (h Controller) PetReleaseToWarehouse( func (h Controller) PetReleaseToWarehouse(
data *pet.PET_ROWEI, player *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { data *pet.PET_ROWEI, player *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
_, _, inBag := player.FindPet(data.CatchTime) _, _, inBag := player.FindPet(data.CatchTime)
_, _, inBackup := findBackupPet(player, data.CatchTime)
freeForbidden := xmlres.PetMAP[int(data.ID)].FreeForbidden freeForbidden := xmlres.PetMAP[int(data.ID)].FreeForbidden
// 如果背包没找到,再放入背包 // 如果背包没找到,再放入背包
if inBag || freeForbidden == 1 { if inBag || inBackup || freeForbidden == 1 {
return nil, errorcode.ErrorCodes.ErrCannotReleaseNonWarehouse return nil, errorcode.ErrorCodes.ErrCannotReleaseNonWarehouse
} }
@@ -160,10 +284,15 @@ func (h Controller) PetRetrieveFromWarehouse(
//如果背包没找到,再放入背包 //如果背包没找到,再放入背包
if _, _, ok := player.FindPet(data.CatchTime); !ok { if _, _, ok := player.FindPet(data.CatchTime); !ok {
if !player.Service.Pet.UpdateFree(data.CatchTime, 0) { if petInfo := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime); petInfo != nil {
return nil, errorcode.ErrorCodes.ErrSystemError syncBackupPetList(player)
if len(player.Info.PetList) < 6 {
player.Info.PetList = append(player.Info.PetList, petInfo.Data)
} else if len(player.Info.BackupPetList) < 6 {
player.Info.BackupPetList = append(player.Info.BackupPetList, petInfo.Data)
}
player.Service.Info.Save(*player.Info)
} }
} }
return nil, 0 return nil, 0
@@ -173,6 +302,76 @@ func (h Controller) PetRetrieveFromWarehouse(
// TogglePetBagWarehouse 精灵背包仓库切换 // TogglePetBagWarehouse 精灵背包仓库切换
func (h Controller) TogglePetBagWarehouse( func (h Controller) TogglePetBagWarehouse(
data *pet.PetReleaseInboundInfo, data *pet.PetReleaseInboundInfo,
player *player.Player) (result *pet.PetReleaseOutboundInfo, err errorcode.ErrorCode) {
result = &pet.PetReleaseOutboundInfo{}
result.Flag = uint32(data.Flag)
if player.GetSpace().Owner.UserID == player.Info.UserID {
return result, errorcode.ErrorCodes.ErrChampionCannotSwitch
}
syncBackupPetList(player)
switch data.Flag {
case 0:
if index, currentPet, ok := player.FindPet(data.CatchTime); ok {
if index < 0 || index >= len(player.Info.PetList) {
return result, errorcode.ErrorCodes.ErrPokemonIDMismatch
}
if !player.Service.Pet.Update(*currentPet) {
return result, errorcode.ErrorCodes.ErrSystemError
}
player.Info.PetList = append(player.Info.PetList[:index], player.Info.PetList[index+1:]...)
player.Service.Info.Save(*player.Info)
break
}
index, currentPet, ok := findBackupPet(player, data.CatchTime)
if !ok {
return result, errorcode.ErrorCodes.ErrPokemonNotExists
}
if index < 0 || index >= len(player.Info.BackupPetList) {
return result, errorcode.ErrorCodes.ErrPokemonIDMismatch
}
if !player.Service.Pet.Update(*currentPet) {
return result, errorcode.ErrorCodes.ErrSystemError
}
player.Info.BackupPetList = append(player.Info.BackupPetList[:index], player.Info.BackupPetList[index+1:]...)
player.Service.Info.Save(*player.Info)
case 1:
if len(player.Info.PetList) >= 6 && len(player.Info.BackupPetList) >= 6 {
return result, errorcode.ErrorCodes.ErrPokemonIDMismatch
}
if _, _, ok := player.FindPet(data.CatchTime); ok {
return result, 0
}
if _, _, ok := findBackupPet(player, data.CatchTime); ok {
return result, 0
}
petInfo := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
if petInfo == nil {
return result, errorcode.ErrorCodes.ErrPokemonNotExists
}
if len(player.Info.PetList) < 6 {
player.Info.PetList = append(player.Info.PetList, petInfo.Data)
} else {
player.Info.BackupPetList = append(player.Info.BackupPetList, petInfo.Data)
}
result.PetInfo = petInfo.Data
player.Service.Info.Save(*player.Info)
}
if len(player.Info.PetList) > 0 {
result.FirstPetTime = player.Info.PetList[0].CatchTime
}
return nil, 0
}
func (h Controller) TogglePetBagWarehouseLegacy(
data *pet.PetReleaseLegacyInboundInfo,
player *player.Player) ( player *player.Player) (
result *pet.PetReleaseOutboundInfo, result *pet.PetReleaseOutboundInfo,
err errorcode.ErrorCode) { //这个时候player应该是空的 err errorcode.ErrorCode) { //这个时候player应该是空的

View File

@@ -15,3 +15,12 @@ type GetUserBagPetInfoOutboundInfo struct {
BackupPetListLen uint32 `struc:"int32,sizeof=BackupPetList"` BackupPetListLen uint32 `struc:"int32,sizeof=BackupPetList"`
BackupPetList []model.PetInfo BackupPetList []model.PetInfo
} }
type SavePetBagOrderInboundInfo struct {
Head common.TomeeHeader `cmd:"4484" struc:"skip"`
PetListLen uint32 `struc:"int32,sizeof=PetList"`
PetList []uint32
BackupPetListLen uint32 `struc:"int32,sizeof=BackupPetList"`
BackupPetList []uint32
}

View File

@@ -27,6 +27,12 @@ type PetReleaseInboundInfo struct {
Flag uint32 `json:"flag" fieldDescription:"0为放入仓库1为放入背包" autoCodec:"true" uint:"true"` Flag uint32 `json:"flag" fieldDescription:"0为放入仓库1为放入背包" autoCodec:"true" uint:"true"`
} }
type PetReleaseLegacyInboundInfo struct {
Head common.TomeeHeader `cmd:"52304" struc:"skip"`
CatchTime uint32
Flag uint32 `json:"flag" fieldDescription:"0为放入仓库1为放入背包" autoCodec:"true" uint:"true"`
}
type PetShowInboundInfo struct { type PetShowInboundInfo struct {
Head common.TomeeHeader `cmd:"2305" struc:"skip"` Head common.TomeeHeader `cmd:"2305" struc:"skip"`

View File

@@ -0,0 +1,24 @@
package info
import (
configm "blazing/modules/config/model"
"blazing/modules/player/model"
)
type MapModelBroadcastInfo struct {
Wer int32 `struc:"uint32"`
InfoLen uint32 `struc:"sizeof=INFO" json:"info_len"`
INFO []MapModelBroadcastEntry
}
type MapModelBroadcastEntry struct {
ModelID uint32 `json:"model_id" protobuf:"1,req,name=model_id"`
Region uint32 `json:"region" protobuf:"2,req,name=region"`
Hp int32 `struc:"uint32" json:"hp" protobuf:"3,req,name=hp"`
PosIndex uint32 `struc:"uint32" json:"pos_index" protobuf:"4,req,name=pos_index"`
IsShow int32 `struc:"uint32" json:"is_show"`
PosInfo []model.Pos `struc:"skip"`
Config configm.MapNode `struc:"skip"`
Model configm.MapModel `struc:"skip"`
}

View File

@@ -34,10 +34,10 @@ type Space struct {
CanRefresh bool CanRefresh bool
Super uint32 Super uint32
ID uint32 ID uint32
Name string Name string
Owner ARENA Owner ARENA
info.MapBossSInfo MapBossSInfo info.MapModelBroadcastInfo
WeatherType []uint32 WeatherType []uint32
TimeBoss info.S2C_2022 TimeBoss info.S2C_2022
@@ -183,8 +183,8 @@ func (ret *Space) init() {
if r.IsTimeSpace != 0 { if r.IsTimeSpace != 0 {
ret.IsTime = true ret.IsTime = true
} }
ret.MapBossSInfo = info.MapBossSInfo{} ret.MapBossSInfo = info.MapModelBroadcastInfo{}
ret.MapBossSInfo.INFO = make([]info.MapBossInfo, 0) ret.MapBossSInfo.INFO = make([]info.MapModelBroadcastEntry, 0)
if len(r.WeatherType) > 1 { if len(r.WeatherType) > 1 {
ret.WeatherType = r.WeatherType ret.WeatherType = r.WeatherType
@@ -196,8 +196,8 @@ func (ret *Space) init() {
if r == nil { if r == nil {
continue continue
} }
info := info.MapBossInfo{ info := info.MapModelBroadcastEntry{
Id: uint32(r.ID), ModelID: uint32(r.ID),
Region: v.NodeID, Region: v.NodeID,
Hp: r.HP, Hp: r.HP,
PosInfo: ParseCoordinateString(r.Pos), PosInfo: ParseCoordinateString(r.Pos),
@@ -239,9 +239,9 @@ func (p *Space) IsMatch(t model.Event) bool {
return true return true
} }
func (ret *Space) GenBoss(isfrist bool) *info.MapBossSInfo { func (ret *Space) GenBoss(isfrist bool) *info.MapModelBroadcastInfo {
var res info.MapBossSInfo var res info.MapModelBroadcastInfo
res.Wer = ret.Wer res.Wer = ret.MapBossSInfo.Wer
for i := 0; i < len(ret.MapBossSInfo.INFO); i++ { for i := 0; i < len(ret.MapBossSInfo.INFO); i++ {
if !ret.IsMatch(*ret.MapBossSInfo.INFO[i].Config.Event) { if !ret.IsMatch(*ret.MapBossSInfo.INFO[i].Config.Event) {
@@ -254,7 +254,7 @@ func (ret *Space) GenBoss(isfrist bool) *info.MapBossSInfo {
} }
s := len(ret.MapBossSInfo.INFO[i].PosInfo) s := len(ret.MapBossSInfo.INFO[i].PosInfo)
if s != 0 { if s != 0 {
ret.MapBossSInfo.INFO[i].Pos = ret.MapBossSInfo.INFO[i].PosInfo[(grand.Intn(s-1)+1+int(ret.MapBossSInfo.INFO[i].PosIndex))%s] ret.MapBossSInfo.INFO[i].PosIndex = uint32(grand.Intn(s))
} }
ret.MapBossSInfo.INFO[i].IsShow = 1 ret.MapBossSInfo.INFO[i].IsShow = 1

View File

@@ -12,8 +12,6 @@ const TableNamePlayerPetSpecialEffect = "config_boss_effect"
type PlayerPetSpecialEffect struct { type PlayerPetSpecialEffect struct {
*cool.Model // 嵌入基础Model包含主键、创建/更新时间等通用字段) *cool.Model // 嵌入基础Model包含主键、创建/更新时间等通用字段)
// 严格对应XML的4个核心字段
SeIdx uint32 `gorm:"not null;uniqueIndex:idx_se_idx;comment:'精灵特效索引XML中的Idx'" json:"se_idx"`
//Stat uint32 `gorm:"not null;default:0;comment:'精灵特效状态XML中的Stat'" json:"stat"` //Stat uint32 `gorm:"not null;default:0;comment:'精灵特效状态XML中的Stat'" json:"stat"`
Eid uint32 `gorm:"not null;index:idx_eid;comment:'精灵特效EidXML中的Eid'" json:"eid"` Eid uint32 `gorm:"not null;index:idx_eid;comment:'精灵特效EidXML中的Eid'" json:"eid"`
Args []int `gorm:"type:jsonb;comment:'精灵特效参数XML中的Args'" json:"args"` Args []int `gorm:"type:jsonb;comment:'精灵特效参数XML中的Args'" json:"args"`

View File

@@ -1,4 +1,4 @@
package model package model
import ( import (
"blazing/cool" "blazing/cool"
@@ -6,7 +6,7 @@ import (
// 表名统一改为 map_model // 表名统一改为 map_model
const ( const (
TableNameMapModel = "map_model" TableNameMapModel = "config_map_model"
) )
// 模型类型常量 (0:精灵, 1:NPC) // 模型类型常量 (0:精灵, 1:NPC)
@@ -26,7 +26,7 @@ const (
MapModelDirectionRightUp MapModelDirectionRightUp
) )
// MapModel 地图模型配置表(NPC/宠物) // MapModel 地图模型配置表 (NPC/宠物)
type MapModel struct { type MapModel struct {
*cool.Model // 保留通用ModelID/创建时间/更新时间等) *cool.Model // 保留通用ModelID/创建时间/更新时间等)
@@ -41,6 +41,7 @@ type MapModel struct {
HeadTalk string `gorm:"type:varchar(255);default:'';comment:'头顶对话框内容'" json:"head_talk" description:"头顶对话框内容"` HeadTalk string `gorm:"type:varchar(255);default:'';comment:'头顶对话框内容'" json:"head_talk" description:"头顶对话框内容"`
Pos string `gorm:"type:varchar(255);default:'';comment:'位置'" json:"pos" description:"位置"` Pos string `gorm:"type:varchar(255);default:'';comment:'位置'" json:"pos" description:"位置"`
HP int32 `gorm:"type:int;default:0;comment:'血量'" json:"hp" description:"血量"` HP int32 `gorm:"type:int;default:0;comment:'血量'" json:"hp" description:"血量"`
Scale float64 `gorm:"type:decimal(6,2);default:1.00;comment:'缩放倍数'" json:"scale" description:"缩放倍数"`
Direction int32 `gorm:"type:int;default:2;comment:'方向(0-7)'" json:"direction" description:"BOSS方向"` Direction int32 `gorm:"type:int;default:2;comment:'方向(0-7)'" json:"direction" description:"BOSS方向"`
TriggerPlotID uint32 `gorm:"default:0;comment:'触发剧情ID0表示无剧情'" json:"trigger_plot_id" description:"触发剧情ID"` TriggerPlotID uint32 `gorm:"default:0;comment:'触发剧情ID0表示无剧情'" json:"trigger_plot_id" description:"触发剧情ID"`
Cloths []uint32 `gorm:"type:varchar(255);default:'';comment:'服装'" json:"cloths" description:"服装"` Cloths []uint32 `gorm:"type:varchar(255);default:'';comment:'服装'" json:"cloths" description:"服装"`

View File

@@ -10,7 +10,7 @@ type EffectService struct {
} }
func (s *EffectService) Args(id []uint32) []model.PlayerPetSpecialEffect { func (s *EffectService) Args(id []uint32) []model.PlayerPetSpecialEffect {
m := dbm_notenable(s.Model).WhereIn("se_idx", id) m := dbm_notenable(s.Model).WhereIn("id", id)
var tt []model.PlayerPetSpecialEffect var tt []model.PlayerPetSpecialEffect
m.Scan(&tt) m.Scan(&tt)
@@ -21,8 +21,8 @@ func NewEffectService() *EffectService {
return &EffectService{ return &EffectService{
&cool.Service{ &cool.Service{
Model: model.NewPlayerPetSpecialEffect(), Model: model.NewPlayerPetSpecialEffect(),
UniqueKey: map[string]string{"idx_se_idx": "索引不能重复"},
PageQueryOp: &cool.QueryOp{ PageQueryOp: &cool.QueryOp{
KeyWordField: []string{"desc"}, KeyWordField: []string{"desc"},
}, },

View File

@@ -21,6 +21,10 @@ func NewMapmodelService() *MapmodelService {
KeyWordField: []string{"remake"}, KeyWordField: []string{"remake"},
FieldEQ: []string{"map_id"}, FieldEQ: []string{"map_id"},
}, },
ListQueryOp: &cool.QueryOp{
KeyWordField: []string{"remake"},
FieldEQ: []string{"map_id"},
},
}, },
} }
} }

View File

@@ -205,8 +205,8 @@ type PlayerInfo struct {
Badge uint32 `struc:"uint32" default:"0" json:"badge"` // 默认0 Badge uint32 `struc:"uint32" default:"0" json:"badge"` // 默认0
Reserved1 [27]byte `struc:"[27]byte" default:"3" json:"reserved1"` // 27字节默认3 Reserved1 [27]byte `struc:"[27]byte" default:"3" json:"reserved1"` // 27字节默认3
TaskList [1000]byte `struc:"[1000]byte" default:"0" json:"task_list"` // 任务状态数组500字节默认3 TaskList [1000]byte `struc:"[1000]byte" default:"0" json:"task_list"` // 任务状态数组500字节默认3
PetListCount uint32 `struc:"sizeof=PetList" json:"pet_list_count"` // 精灵列表长度 PetListCount uint32 `struc:"skip" json:"pet_list_count"` // 旧登录协议精灵列表长度(已跳过)
PetList []PetInfo ` json:"pet_list"` // 精灵背包内信息 PetList []PetInfo `struc:"skip" json:"pet_list"` // 精灵背包内信息(不再走旧登录包体)
BackupPetList []PetInfo `struc:"skip" json:"backup_pet_list"` // 精灵并列备用列表 BackupPetList []PetInfo `struc:"skip" json:"backup_pet_list"` // 精灵并列备用列表
ClothesCount uint32 `struc:"sizeof=Clothes" json:"clothes_count"` // 穿戴装备数量 ClothesCount uint32 `struc:"sizeof=Clothes" json:"clothes_count"` // 穿戴装备数量
Clothes []PeopleItemInfo ` json:"clothes"` // 穿戴装备 Clothes []PeopleItemInfo ` json:"clothes"` // 穿戴装备

View File

@@ -65,12 +65,8 @@ func (s *InfoService) GetLogin() *model.PlayerInfo {
return nil return nil
} }
tt.Data.AllPetNumber = uint32(NewPetService(s.userid).PetCount(0)) tt.Data.AllPetNumber = uint32(NewPetService(s.userid).PetCount(0))
if len(tt.Data.BackupPetList) == 0 { if tt.Data.BackupPetList == nil {
storagePets := NewPetService(s.userid).PetInfo(1) tt.Data.BackupPetList = make([]model.PetInfo, 0)
tt.Data.BackupPetList = make([]model.PetInfo, len(storagePets))
for i := range storagePets {
tt.Data.BackupPetList[i] = storagePets[i].Data
}
} }
if tt.Data.MapID > 300 || tt.Data.MapID == 0 { //如果位于基地,就重置到传送仓 if tt.Data.MapID > 300 || tt.Data.MapID == 0 { //如果位于基地,就重置到传送仓