fix: restore battle entry and character profile initialization
This commit is contained in:
1 parent
cfbbc7b970
commit
5c4d0d4149
16 files changed
+888
-228
No files matched your search
@@ -37,6 +37,25 @@ func (sm *syncMap) Delete(k uint32) { muBattle.Lock(); sm.init(); delete(sm.m, k
|
||||
|
||||
func randUint32() uint32 { return rand.Uint32() }
|
||||
|
||||
func playerArchive(s *Session) *goproto.ArchiveData {
|
||||
archive := &goproto.ArchiveData{}
|
||||
if player := s.JSON(); player != nil {
|
||||
for id := range player.Avatars {
|
||||
archive.ArchiveAvatarIdList = append(archive.ArchiveAvatarIdList, id)
|
||||
}
|
||||
sortU32Slice(archive.ArchiveAvatarIdList)
|
||||
seen := map[uint32]bool{}
|
||||
for _, equipment := range player.Lightcones {
|
||||
if !seen[equipment.ItemID] {
|
||||
seen[equipment.ItemID] = true
|
||||
archive.ArchiveEquipmentIdList = append(archive.ArchiveEquipmentIdList, equipment.ItemID)
|
||||
}
|
||||
}
|
||||
sortU32Slice(archive.ArchiveEquipmentIdList)
|
||||
}
|
||||
return archive
|
||||
}
|
||||
|
||||
func init() {
|
||||
handle("GetBag", func(s *Session, req *goproto.GetBagCsReq, rsp *goproto.GetBagScRsp) error {
|
||||
player := s.JSON()
|
||||
@@ -55,17 +74,18 @@ func init() {
|
||||
{Tid: 101, Num: 999999}, // Normal Pass
|
||||
{Tid: 102, Num: 999999}, // Special Pass
|
||||
}
|
||||
for _, aid := range BaseAvatarIDs {
|
||||
rsp.MaterialList = append(rsp.MaterialList, &goproto.Material{
|
||||
Tid: 130000 + aid,
|
||||
Num: 10,
|
||||
})
|
||||
}
|
||||
// Avatar IDs do not imply item IDs. The old 130000+avatar formula
|
||||
// produced nonexistent materials and broke the client's inventory init.
|
||||
return nil
|
||||
})
|
||||
|
||||
handle("GetArchiveData", func(s *Session, req *goproto.GetArchiveDataCsReq, rsp *goproto.GetArchiveDataScRsp) error {
|
||||
rsp.Retcode = 0
|
||||
rsp.ArchiveData = playerArchive(s)
|
||||
return nil
|
||||
})
|
||||
handle("GetUpdatedArchiveData", func(s *Session, req *goproto.GetUpdatedArchiveDataCsReq, rsp *goproto.GetUpdatedArchiveDataScRsp) error {
|
||||
rsp.ArchiveData = playerArchive(s)
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user