mirror of
https://github.com/PretendoNetwork/super-mario-maker.git
synced 2026-08-27 19:24:39 -05:00
Cleaned up a lot of duplicate code for metadata
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
)
|
||||
@@ -16,97 +14,8 @@ func ctrPickUpCourseSearchObject(err error, client *nex.Client, callID uint32, d
|
||||
|
||||
courseMetadatas := getCourseMetadatasByLimit(100) // In PCAPs param.minimalRatingFrequency is 100 but is 0 here?
|
||||
|
||||
for i := 0; i < len(courseMetadatas); i++ {
|
||||
now := uint64(time.Now().Unix())
|
||||
courseMetadata := courseMetadatas[i]
|
||||
|
||||
rankingResult := nexproto.NewDataStoreCustomRankingResult()
|
||||
|
||||
rankingResult.Order = 0 // unknown
|
||||
rankingResult.Score = courseMetadata.Stars
|
||||
rankingResult.MetaInfo = nexproto.NewDataStoreMetaInfo()
|
||||
rankingResult.MetaInfo.DataID = courseMetadata.DataID
|
||||
rankingResult.MetaInfo.OwnerID = courseMetadata.OwnerPID
|
||||
rankingResult.MetaInfo.Size = courseMetadata.Size
|
||||
rankingResult.MetaInfo.Name = courseMetadata.Name
|
||||
rankingResult.MetaInfo.DataType = courseMetadata.DataType
|
||||
rankingResult.MetaInfo.MetaBinary = courseMetadata.MetaBinary
|
||||
rankingResult.MetaInfo.Permission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.Permission.Permission = 0 // unknown
|
||||
rankingResult.MetaInfo.Permission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.DelPermission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.DelPermission.Permission = 3 // unknown
|
||||
rankingResult.MetaInfo.DelPermission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.CreatedTime = courseMetadata.CreatedTime
|
||||
rankingResult.MetaInfo.UpdatedTime = courseMetadata.UpdatedTime
|
||||
rankingResult.MetaInfo.Period = courseMetadata.Period
|
||||
rankingResult.MetaInfo.Status = 0 // unknown
|
||||
rankingResult.MetaInfo.ReferredCnt = 0 // unknown
|
||||
rankingResult.MetaInfo.ReferDataID = 0 // unknown
|
||||
rankingResult.MetaInfo.Flag = courseMetadata.Flag
|
||||
rankingResult.MetaInfo.ReferredTime = nex.NewDateTime(now)
|
||||
rankingResult.MetaInfo.ExpireTime = nex.NewDateTime(now)
|
||||
rankingResult.MetaInfo.Tags = []string{""} // unknown
|
||||
rankingResult.MetaInfo.Ratings = []*nexproto.DataStoreRatingInfoWithSlot{
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // attempts
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // completions
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // failures
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
}
|
||||
|
||||
// attempts
|
||||
rankingResult.MetaInfo.Ratings[0].Slot = 0
|
||||
rankingResult.MetaInfo.Ratings[0].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.TotalValue = int64(courseMetadata.Attempts)
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.Count = courseMetadata.Attempts
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.InitialValue = int64(courseMetadata.Attempts)
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[1].Slot = 1
|
||||
rankingResult.MetaInfo.Ratings[1].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.TotalValue = 0
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.Count = 0
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.InitialValue = 0
|
||||
|
||||
// completions
|
||||
rankingResult.MetaInfo.Ratings[2].Slot = 2
|
||||
rankingResult.MetaInfo.Ratings[2].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.TotalValue = int64(courseMetadata.Completions)
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.Count = courseMetadata.Completions
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.InitialValue = int64(courseMetadata.Completions)
|
||||
|
||||
// failures
|
||||
rankingResult.MetaInfo.Ratings[3].Slot = 3
|
||||
rankingResult.MetaInfo.Ratings[3].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.TotalValue = int64(courseMetadata.Failures)
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.Count = courseMetadata.Failures
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.InitialValue = int64(courseMetadata.Failures)
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[4].Slot = 4
|
||||
rankingResult.MetaInfo.Ratings[4].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.TotalValue = 5
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.Count = 5
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.InitialValue = 5
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[5].Slot = 5
|
||||
rankingResult.MetaInfo.Ratings[5].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.TotalValue = 6
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.Count = 6
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.InitialValue = 6
|
||||
|
||||
// Number of new Miiverse comments
|
||||
rankingResult.MetaInfo.Ratings[6].Slot = 6
|
||||
rankingResult.MetaInfo.Ratings[6].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.TotalValue = 7
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.Count = 7
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.InitialValue = 7
|
||||
|
||||
pRankingResults = append(pRankingResults, rankingResult)
|
||||
for _, courseMetadata := range courseMetadatas {
|
||||
pRankingResults = append(pRankingResults, courseMetadataToDataStoreCustomRankingResult(courseMetadata))
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(nexServer)
|
||||
|
||||
@@ -12,93 +12,7 @@ func followingsLatestCourseSearchObject(err error, client *nex.Client, callID ui
|
||||
courseMetadatas := getCourseMetadatasByPID(pid)
|
||||
|
||||
for _, courseMetadata := range courseMetadatas {
|
||||
rankingResult := nexproto.NewDataStoreCustomRankingResult()
|
||||
|
||||
rankingResult.Order = 0 // unknown
|
||||
rankingResult.Score = courseMetadata.Stars
|
||||
rankingResult.MetaInfo = nexproto.NewDataStoreMetaInfo()
|
||||
rankingResult.MetaInfo.DataID = courseMetadata.DataID
|
||||
rankingResult.MetaInfo.OwnerID = courseMetadata.OwnerPID
|
||||
rankingResult.MetaInfo.Size = courseMetadata.Size
|
||||
rankingResult.MetaInfo.Name = courseMetadata.Name
|
||||
rankingResult.MetaInfo.DataType = courseMetadata.DataType
|
||||
rankingResult.MetaInfo.MetaBinary = courseMetadata.MetaBinary
|
||||
rankingResult.MetaInfo.Permission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.Permission.Permission = 0 // unknown
|
||||
rankingResult.MetaInfo.Permission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.DelPermission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.DelPermission.Permission = 3 // unknown
|
||||
rankingResult.MetaInfo.DelPermission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.CreatedTime = courseMetadata.CreatedTime
|
||||
rankingResult.MetaInfo.UpdatedTime = courseMetadata.UpdatedTime
|
||||
rankingResult.MetaInfo.Period = courseMetadata.Period
|
||||
rankingResult.MetaInfo.Status = 0 // unknown
|
||||
rankingResult.MetaInfo.ReferredCnt = 0 // unknown
|
||||
rankingResult.MetaInfo.ReferDataID = 0 // unknown
|
||||
rankingResult.MetaInfo.Flag = courseMetadata.Flag
|
||||
rankingResult.MetaInfo.ReferredTime = courseMetadata.CreatedTime
|
||||
rankingResult.MetaInfo.ExpireTime = nex.NewDateTime(671075926016) // December 31st, year 9999
|
||||
rankingResult.MetaInfo.Tags = []string{""} // unknown
|
||||
rankingResult.MetaInfo.Ratings = []*nexproto.DataStoreRatingInfoWithSlot{
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // attempts
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // completions
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // failures
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
}
|
||||
|
||||
// attempts
|
||||
rankingResult.MetaInfo.Ratings[0].Slot = 0
|
||||
rankingResult.MetaInfo.Ratings[0].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.TotalValue = int64(courseMetadata.Attempts)
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.Count = courseMetadata.Attempts
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.InitialValue = 0
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[1].Slot = 1
|
||||
rankingResult.MetaInfo.Ratings[1].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.TotalValue = 2
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.Count = 2
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.InitialValue = 0
|
||||
|
||||
// completions
|
||||
rankingResult.MetaInfo.Ratings[2].Slot = 2
|
||||
rankingResult.MetaInfo.Ratings[2].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.TotalValue = int64(courseMetadata.Completions)
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.Count = courseMetadata.Completions
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.InitialValue = 0
|
||||
|
||||
// failures
|
||||
rankingResult.MetaInfo.Ratings[3].Slot = 3
|
||||
rankingResult.MetaInfo.Ratings[3].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.TotalValue = int64(courseMetadata.Failures)
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.Count = courseMetadata.Failures
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.InitialValue = 0
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[4].Slot = 4
|
||||
rankingResult.MetaInfo.Ratings[4].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.TotalValue = 5
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.Count = 5
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.InitialValue = 0
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[5].Slot = 5
|
||||
rankingResult.MetaInfo.Ratings[5].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.TotalValue = 6
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.Count = 6
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.InitialValue = 0
|
||||
|
||||
// Number of new Miiverse comments
|
||||
rankingResult.MetaInfo.Ratings[6].Slot = 6
|
||||
rankingResult.MetaInfo.Ratings[6].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.TotalValue = 0
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.Count = 0
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.InitialValue = 0
|
||||
|
||||
pRankingResults = append(pRankingResults, rankingResult)
|
||||
pRankingResults = append(pRankingResults, courseMetadataToDataStoreCustomRankingResult(courseMetadata))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"time"
|
||||
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
)
|
||||
@@ -58,93 +55,7 @@ func getCustomRankingByDataIdStarredCourses(pid uint32) ([]*nexproto.DataStoreCu
|
||||
pResults := make([]uint32, 0)
|
||||
|
||||
for _, courseMetadata := range courseMetadatas {
|
||||
rankingResult := nexproto.NewDataStoreCustomRankingResult()
|
||||
|
||||
rankingResult.Order = 0 // unknown
|
||||
rankingResult.Score = courseMetadata.Stars
|
||||
rankingResult.MetaInfo = nexproto.NewDataStoreMetaInfo()
|
||||
rankingResult.MetaInfo.DataID = courseMetadata.DataID
|
||||
rankingResult.MetaInfo.OwnerID = courseMetadata.OwnerPID
|
||||
rankingResult.MetaInfo.Size = courseMetadata.Size
|
||||
rankingResult.MetaInfo.Name = courseMetadata.Name
|
||||
rankingResult.MetaInfo.DataType = courseMetadata.DataType
|
||||
rankingResult.MetaInfo.MetaBinary = courseMetadata.MetaBinary
|
||||
rankingResult.MetaInfo.Permission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.Permission.Permission = 0 // unknown
|
||||
rankingResult.MetaInfo.Permission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.DelPermission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.DelPermission.Permission = 3 // unknown
|
||||
rankingResult.MetaInfo.DelPermission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.CreatedTime = courseMetadata.CreatedTime
|
||||
rankingResult.MetaInfo.UpdatedTime = courseMetadata.UpdatedTime
|
||||
rankingResult.MetaInfo.Period = courseMetadata.Period
|
||||
rankingResult.MetaInfo.Status = 0 // unknown
|
||||
rankingResult.MetaInfo.ReferredCnt = 0 // unknown
|
||||
rankingResult.MetaInfo.ReferDataID = 0 // unknown
|
||||
rankingResult.MetaInfo.Flag = courseMetadata.Flag
|
||||
rankingResult.MetaInfo.ReferredTime = courseMetadata.CreatedTime
|
||||
rankingResult.MetaInfo.ExpireTime = nex.NewDateTime(671075926016) // December 31st, year 9999
|
||||
rankingResult.MetaInfo.Tags = []string{""} // unknown
|
||||
rankingResult.MetaInfo.Ratings = []*nexproto.DataStoreRatingInfoWithSlot{
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // attempts
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // completions
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // failures
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
}
|
||||
|
||||
// attempts
|
||||
rankingResult.MetaInfo.Ratings[0].Slot = 0
|
||||
rankingResult.MetaInfo.Ratings[0].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.TotalValue = int64(courseMetadata.Attempts)
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.Count = courseMetadata.Attempts
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.InitialValue = 0
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[1].Slot = 1
|
||||
rankingResult.MetaInfo.Ratings[1].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.TotalValue = 2
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.Count = 2
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.InitialValue = 0
|
||||
|
||||
// completions
|
||||
rankingResult.MetaInfo.Ratings[2].Slot = 2
|
||||
rankingResult.MetaInfo.Ratings[2].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.TotalValue = int64(courseMetadata.Completions)
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.Count = courseMetadata.Completions
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.InitialValue = 0
|
||||
|
||||
// failures
|
||||
rankingResult.MetaInfo.Ratings[3].Slot = 3
|
||||
rankingResult.MetaInfo.Ratings[3].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.TotalValue = int64(courseMetadata.Failures)
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.Count = courseMetadata.Failures
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.InitialValue = 0
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[4].Slot = 4
|
||||
rankingResult.MetaInfo.Ratings[4].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.TotalValue = 5
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.Count = 5
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.InitialValue = 0
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[5].Slot = 5
|
||||
rankingResult.MetaInfo.Ratings[5].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.TotalValue = 6
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.Count = 6
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.InitialValue = 0
|
||||
|
||||
// Number of new Miiverse comments
|
||||
rankingResult.MetaInfo.Ratings[6].Slot = 6
|
||||
rankingResult.MetaInfo.Ratings[6].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.TotalValue = 0
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.Count = 0
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.InitialValue = 0
|
||||
|
||||
pRankingResult = append(pRankingResult, rankingResult)
|
||||
pRankingResult = append(pRankingResult, courseMetadataToDataStoreCustomRankingResult(courseMetadata))
|
||||
pResults = append(pResults, 0x690001)
|
||||
}
|
||||
|
||||
@@ -160,60 +71,7 @@ func getCustomRankingByDataIdMiiData(param *nexproto.DataStoreGetCustomRankingBy
|
||||
miiInfo := getUserMiiInfoByPID(ownerID)
|
||||
|
||||
if miiInfo != nil {
|
||||
encodedMiiData := miiInfo["data"].(string)
|
||||
decodedMiiData, _ := base64.StdEncoding.DecodeString(encodedMiiData)
|
||||
|
||||
metaBinaryStream := nex.NewStreamOut(nexServer)
|
||||
metaBinaryStream.Grow(140)
|
||||
metaBinaryStream.WriteBytesNext([]byte{
|
||||
0x42, 0x50, 0x46, 0x43, // BPFC magic
|
||||
0x00, 0x00, 0x00, 0x01, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x01, 0x00, 0x00, // Unknown
|
||||
})
|
||||
metaBinaryStream.WriteBytesNext(decodedMiiData) // Actual Mii data
|
||||
metaBinaryStream.WriteBytesNext([]byte{
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x01, // Unknown
|
||||
})
|
||||
|
||||
now := uint64(time.Now().Unix())
|
||||
|
||||
rankingResult := nexproto.NewDataStoreCustomRankingResult()
|
||||
|
||||
rankingResult.Order = 0
|
||||
rankingResult.Score = 0
|
||||
rankingResult.MetaInfo = nexproto.NewDataStoreMetaInfo()
|
||||
rankingResult.MetaInfo.DataID = uint64(ownerID) // idk what this is, but it gets used elsewhere for request Mii data again. Setting it as a PID makes that easier for me
|
||||
rankingResult.MetaInfo.OwnerID = ownerID
|
||||
rankingResult.MetaInfo.Size = 0
|
||||
rankingResult.MetaInfo.Name = miiInfo["name"].(string)
|
||||
rankingResult.MetaInfo.DataType = 1 // Mii data type?
|
||||
rankingResult.MetaInfo.MetaBinary = metaBinaryStream.Bytes()
|
||||
rankingResult.MetaInfo.Permission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.Permission.Permission = 0 // idk?
|
||||
rankingResult.MetaInfo.Permission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.DelPermission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.DelPermission.Permission = 3 // idk?
|
||||
rankingResult.MetaInfo.DelPermission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.CreatedTime = nex.NewDateTime(now)
|
||||
rankingResult.MetaInfo.UpdatedTime = nex.NewDateTime(now)
|
||||
rankingResult.MetaInfo.Period = 90 // idk?
|
||||
rankingResult.MetaInfo.Status = 0
|
||||
rankingResult.MetaInfo.ReferredCnt = 0
|
||||
rankingResult.MetaInfo.ReferDataID = 0
|
||||
rankingResult.MetaInfo.Flag = 256 // idk?
|
||||
rankingResult.MetaInfo.ReferredTime = nex.NewDateTime(now)
|
||||
rankingResult.MetaInfo.ExpireTime = nex.NewDateTime(now)
|
||||
rankingResult.MetaInfo.Tags = []string{"49"} // idk?
|
||||
rankingResult.MetaInfo.Ratings = []*nexproto.DataStoreRatingInfoWithSlot{}
|
||||
|
||||
pRankingResult = append(pRankingResult, rankingResult)
|
||||
pRankingResult = append(pRankingResult, userMiiDataToDataStoreCustomRankingResult(ownerID, miiInfo))
|
||||
pResults = append(pResults, 0x690001)
|
||||
}
|
||||
}
|
||||
@@ -228,93 +86,7 @@ func getCustomRankingByDataIdCourseMetadata(param *nexproto.DataStoreGetCustomRa
|
||||
pResults := make([]uint32, 0)
|
||||
|
||||
for _, courseMetadata := range courseMetadatas {
|
||||
rankingResult := nexproto.NewDataStoreCustomRankingResult()
|
||||
|
||||
rankingResult.Order = 0 // unknown
|
||||
rankingResult.Score = courseMetadata.Stars
|
||||
rankingResult.MetaInfo = nexproto.NewDataStoreMetaInfo()
|
||||
rankingResult.MetaInfo.DataID = courseMetadata.DataID
|
||||
rankingResult.MetaInfo.OwnerID = courseMetadata.OwnerPID
|
||||
rankingResult.MetaInfo.Size = courseMetadata.Size
|
||||
rankingResult.MetaInfo.Name = courseMetadata.Name
|
||||
rankingResult.MetaInfo.DataType = courseMetadata.DataType
|
||||
rankingResult.MetaInfo.MetaBinary = courseMetadata.MetaBinary
|
||||
rankingResult.MetaInfo.Permission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.Permission.Permission = 0 // unknown
|
||||
rankingResult.MetaInfo.Permission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.DelPermission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.DelPermission.Permission = 3 // unknown
|
||||
rankingResult.MetaInfo.DelPermission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.CreatedTime = courseMetadata.CreatedTime
|
||||
rankingResult.MetaInfo.UpdatedTime = courseMetadata.UpdatedTime
|
||||
rankingResult.MetaInfo.Period = courseMetadata.Period
|
||||
rankingResult.MetaInfo.Status = 0 // unknown
|
||||
rankingResult.MetaInfo.ReferredCnt = 0 // unknown
|
||||
rankingResult.MetaInfo.ReferDataID = 0 // unknown
|
||||
rankingResult.MetaInfo.Flag = courseMetadata.Flag
|
||||
rankingResult.MetaInfo.ReferredTime = courseMetadata.CreatedTime
|
||||
rankingResult.MetaInfo.ExpireTime = nex.NewDateTime(671075926016) // December 31st, year 9999
|
||||
rankingResult.MetaInfo.Tags = []string{""} // unknown
|
||||
rankingResult.MetaInfo.Ratings = []*nexproto.DataStoreRatingInfoWithSlot{
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // attempts
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // completions
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // failures
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
}
|
||||
|
||||
// attempts
|
||||
rankingResult.MetaInfo.Ratings[0].Slot = 0
|
||||
rankingResult.MetaInfo.Ratings[0].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.TotalValue = int64(courseMetadata.Attempts)
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.Count = courseMetadata.Attempts
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.InitialValue = 0
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[1].Slot = 1
|
||||
rankingResult.MetaInfo.Ratings[1].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.TotalValue = 2
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.Count = 2
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.InitialValue = 0
|
||||
|
||||
// completions
|
||||
rankingResult.MetaInfo.Ratings[2].Slot = 2
|
||||
rankingResult.MetaInfo.Ratings[2].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.TotalValue = int64(courseMetadata.Completions)
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.Count = courseMetadata.Completions
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.InitialValue = 0
|
||||
|
||||
// failures
|
||||
rankingResult.MetaInfo.Ratings[3].Slot = 3
|
||||
rankingResult.MetaInfo.Ratings[3].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.TotalValue = int64(courseMetadata.Failures)
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.Count = courseMetadata.Failures
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.InitialValue = 0
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[4].Slot = 4
|
||||
rankingResult.MetaInfo.Ratings[4].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.TotalValue = 5
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.Count = 5
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.InitialValue = 0
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[5].Slot = 5
|
||||
rankingResult.MetaInfo.Ratings[5].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.TotalValue = 6
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.Count = 6
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.InitialValue = 0
|
||||
|
||||
// Number of new Miiverse comments
|
||||
rankingResult.MetaInfo.Ratings[6].Slot = 6
|
||||
rankingResult.MetaInfo.Ratings[6].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.TotalValue = 0
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.Count = 0
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.InitialValue = 0
|
||||
|
||||
pRankingResult = append(pRankingResult, rankingResult)
|
||||
pRankingResult = append(pRankingResult, courseMetadataToDataStoreCustomRankingResult(courseMetadata))
|
||||
pResults = append(pResults, 0x690001)
|
||||
}
|
||||
|
||||
|
||||
52
get_meta.go
52
get_meta.go
@@ -1,10 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
@@ -24,55 +22,7 @@ func getMeta(err error, client *nex.Client, callID uint32, param *nexproto.DataS
|
||||
func getMetaMiiData(client *nex.Client, callID uint32, param *nexproto.DataStoreGetMetaParam) {
|
||||
miiInfo := getUserMiiInfoByPID(param.PersistenceTarget.OwnerID)
|
||||
|
||||
encodedMiiData := miiInfo["data"].(string)
|
||||
decodedMiiData, _ := base64.StdEncoding.DecodeString(encodedMiiData)
|
||||
|
||||
metaBinaryStream := nex.NewStreamOut(nexServer)
|
||||
metaBinaryStream.Grow(140)
|
||||
metaBinaryStream.WriteBytesNext([]byte{
|
||||
0x42, 0x50, 0x46, 0x43, // BPFC magic
|
||||
0x00, 0x00, 0x00, 0x01, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x01, 0x00, 0x00, // Unknown
|
||||
})
|
||||
metaBinaryStream.WriteBytesNext(decodedMiiData) // Actual Mii data
|
||||
metaBinaryStream.WriteBytesNext([]byte{
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x01, // Unknown
|
||||
})
|
||||
|
||||
now := uint64(time.Now().Unix())
|
||||
|
||||
pMetaInfo := nexproto.NewDataStoreMetaInfo()
|
||||
|
||||
pMetaInfo.DataID = uint64(param.PersistenceTarget.OwnerID) // idk what this is, but it gets used elsewhere for request Mii data again. Setting it as a PID makes that easier for me
|
||||
pMetaInfo.OwnerID = param.PersistenceTarget.OwnerID
|
||||
pMetaInfo.Size = 0
|
||||
pMetaInfo.Name = miiInfo["name"].(string)
|
||||
pMetaInfo.DataType = 1 // Mii data type?
|
||||
pMetaInfo.MetaBinary = metaBinaryStream.Bytes()
|
||||
pMetaInfo.Permission = nexproto.NewDataStorePermission()
|
||||
pMetaInfo.Permission.Permission = 0 // idk?
|
||||
pMetaInfo.Permission.RecipientIds = []uint32{}
|
||||
pMetaInfo.DelPermission = nexproto.NewDataStorePermission()
|
||||
pMetaInfo.DelPermission.Permission = 3 // idk?
|
||||
pMetaInfo.DelPermission.RecipientIds = []uint32{}
|
||||
pMetaInfo.CreatedTime = nex.NewDateTime(now)
|
||||
pMetaInfo.UpdatedTime = nex.NewDateTime(now)
|
||||
pMetaInfo.Period = 90 // idk?
|
||||
pMetaInfo.Status = 0
|
||||
pMetaInfo.ReferredCnt = 0
|
||||
pMetaInfo.ReferDataID = 0
|
||||
pMetaInfo.Flag = 256 // idk?
|
||||
pMetaInfo.ReferredTime = nex.NewDateTime(now)
|
||||
pMetaInfo.ExpireTime = nex.NewDateTime(now)
|
||||
pMetaInfo.Tags = []string{"49"} // idk?
|
||||
pMetaInfo.Ratings = []*nexproto.DataStoreRatingInfoWithSlot{}
|
||||
pMetaInfo := userMiiDataToDataStoreMetaInfo(param.PersistenceTarget.OwnerID, miiInfo)
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(nexServer)
|
||||
rmcResponseStream.WriteStructure(pMetaInfo)
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
@@ -54,55 +52,5 @@ func getMetasMultipleParam(err error, client *nex.Client, callID uint32, params
|
||||
func getMetasMultipleParamMiiData(param *nexproto.DataStoreGetMetaParam) *nexproto.DataStoreMetaInfo {
|
||||
miiInfo := getUserMiiInfoByPID(param.PersistenceTarget.OwnerID)
|
||||
|
||||
encodedMiiData := miiInfo["data"].(string)
|
||||
decodedMiiData, _ := base64.StdEncoding.DecodeString(encodedMiiData)
|
||||
|
||||
metaBinaryStream := nex.NewStreamOut(nexServer)
|
||||
metaBinaryStream.Grow(140)
|
||||
metaBinaryStream.WriteBytesNext([]byte{
|
||||
0x42, 0x50, 0x46, 0x43, // BPFC magic
|
||||
0x00, 0x00, 0x00, 0x01, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x01, 0x00, 0x00, // Unknown
|
||||
})
|
||||
metaBinaryStream.WriteBytesNext(decodedMiiData) // Actual Mii data
|
||||
metaBinaryStream.WriteBytesNext([]byte{
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x01, // Unknown
|
||||
})
|
||||
|
||||
now := uint64(time.Now().Unix())
|
||||
|
||||
pMetaInfo := nexproto.NewDataStoreMetaInfo()
|
||||
|
||||
pMetaInfo.DataID = uint64(param.PersistenceTarget.OwnerID) // idk what this is, but it gets used elsewhere for request Mii data again. Setting it as a PID makes that easier for me
|
||||
pMetaInfo.OwnerID = param.PersistenceTarget.OwnerID
|
||||
pMetaInfo.Size = 0
|
||||
pMetaInfo.Name = miiInfo["name"].(string)
|
||||
pMetaInfo.DataType = 1 // Mii data type?
|
||||
pMetaInfo.MetaBinary = metaBinaryStream.Bytes()
|
||||
pMetaInfo.Permission = nexproto.NewDataStorePermission()
|
||||
pMetaInfo.Permission.Permission = 0 // idk?
|
||||
pMetaInfo.Permission.RecipientIds = []uint32{}
|
||||
pMetaInfo.DelPermission = nexproto.NewDataStorePermission()
|
||||
pMetaInfo.DelPermission.Permission = 3 // idk?
|
||||
pMetaInfo.DelPermission.RecipientIds = []uint32{}
|
||||
pMetaInfo.CreatedTime = nex.NewDateTime(now)
|
||||
pMetaInfo.UpdatedTime = nex.NewDateTime(now)
|
||||
pMetaInfo.Period = 90 // idk?
|
||||
pMetaInfo.Status = 0
|
||||
pMetaInfo.ReferredCnt = 0
|
||||
pMetaInfo.ReferDataID = 0
|
||||
pMetaInfo.Flag = 256 // idk?
|
||||
pMetaInfo.ReferredTime = nex.NewDateTime(now)
|
||||
pMetaInfo.ExpireTime = nex.NewDateTime(now)
|
||||
pMetaInfo.Tags = []string{"49"} // idk?
|
||||
pMetaInfo.Ratings = []*nexproto.DataStoreRatingInfoWithSlot{}
|
||||
|
||||
return pMetaInfo
|
||||
return userMiiDataToDataStoreMetaInfo(param.PersistenceTarget.OwnerID, miiInfo)
|
||||
}
|
||||
|
||||
@@ -13,93 +13,7 @@ func recommendedCourseSearchObject(err error, client *nex.Client, callID uint32,
|
||||
courseMetadatas := getCourseMetadatasByLimit(100) // In PCAPs param.minimalRatingFrequency is 100 but is 0 here?
|
||||
|
||||
for _, courseMetadata := range courseMetadatas {
|
||||
rankingResult := nexproto.NewDataStoreCustomRankingResult()
|
||||
|
||||
rankingResult.Order = 0 // unknown
|
||||
rankingResult.Score = courseMetadata.Stars
|
||||
rankingResult.MetaInfo = nexproto.NewDataStoreMetaInfo()
|
||||
rankingResult.MetaInfo.DataID = courseMetadata.DataID
|
||||
rankingResult.MetaInfo.OwnerID = courseMetadata.OwnerPID
|
||||
rankingResult.MetaInfo.Size = courseMetadata.Size
|
||||
rankingResult.MetaInfo.Name = courseMetadata.Name
|
||||
rankingResult.MetaInfo.DataType = courseMetadata.DataType
|
||||
rankingResult.MetaInfo.MetaBinary = courseMetadata.MetaBinary
|
||||
rankingResult.MetaInfo.Permission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.Permission.Permission = 0 // unknown
|
||||
rankingResult.MetaInfo.Permission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.DelPermission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.DelPermission.Permission = 3 // unknown
|
||||
rankingResult.MetaInfo.DelPermission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.CreatedTime = courseMetadata.CreatedTime
|
||||
rankingResult.MetaInfo.UpdatedTime = courseMetadata.UpdatedTime
|
||||
rankingResult.MetaInfo.Period = courseMetadata.Period
|
||||
rankingResult.MetaInfo.Status = 0 // unknown
|
||||
rankingResult.MetaInfo.ReferredCnt = 0 // unknown
|
||||
rankingResult.MetaInfo.ReferDataID = 0 // unknown
|
||||
rankingResult.MetaInfo.Flag = courseMetadata.Flag
|
||||
rankingResult.MetaInfo.ReferredTime = courseMetadata.CreatedTime
|
||||
rankingResult.MetaInfo.ExpireTime = nex.NewDateTime(671075926016) // December 31st, year 9999
|
||||
rankingResult.MetaInfo.Tags = []string{""} // unknown
|
||||
rankingResult.MetaInfo.Ratings = []*nexproto.DataStoreRatingInfoWithSlot{
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // attempts
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // completions
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // failures
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
}
|
||||
|
||||
// attempts
|
||||
rankingResult.MetaInfo.Ratings[0].Slot = 0
|
||||
rankingResult.MetaInfo.Ratings[0].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.TotalValue = int64(courseMetadata.Attempts)
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.Count = courseMetadata.Attempts
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.InitialValue = int64(courseMetadata.Attempts)
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[1].Slot = 1
|
||||
rankingResult.MetaInfo.Ratings[1].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.TotalValue = 0
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.Count = 0
|
||||
rankingResult.MetaInfo.Ratings[1].Rating.InitialValue = 0
|
||||
|
||||
// completions
|
||||
rankingResult.MetaInfo.Ratings[2].Slot = 2
|
||||
rankingResult.MetaInfo.Ratings[2].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.TotalValue = int64(courseMetadata.Completions)
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.Count = courseMetadata.Completions
|
||||
rankingResult.MetaInfo.Ratings[2].Rating.InitialValue = int64(courseMetadata.Completions)
|
||||
|
||||
// failures
|
||||
rankingResult.MetaInfo.Ratings[3].Slot = 3
|
||||
rankingResult.MetaInfo.Ratings[3].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.TotalValue = int64(courseMetadata.Failures)
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.Count = courseMetadata.Failures
|
||||
rankingResult.MetaInfo.Ratings[3].Rating.InitialValue = int64(courseMetadata.Failures)
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[4].Slot = 4
|
||||
rankingResult.MetaInfo.Ratings[4].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.TotalValue = 5
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.Count = 5
|
||||
rankingResult.MetaInfo.Ratings[4].Rating.InitialValue = 5
|
||||
|
||||
// unknown
|
||||
rankingResult.MetaInfo.Ratings[5].Slot = 5
|
||||
rankingResult.MetaInfo.Ratings[5].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.TotalValue = 6
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.Count = 6
|
||||
rankingResult.MetaInfo.Ratings[5].Rating.InitialValue = 6
|
||||
|
||||
// Number of new Miiverse comments
|
||||
rankingResult.MetaInfo.Ratings[6].Slot = 6
|
||||
rankingResult.MetaInfo.Ratings[6].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.TotalValue = 0
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.Count = 0
|
||||
rankingResult.MetaInfo.Ratings[6].Rating.InitialValue = 0
|
||||
|
||||
pRankingResults = append(pRankingResults, rankingResult)
|
||||
pRankingResults = append(pRankingResults, courseMetadataToDataStoreCustomRankingResult(courseMetadata))
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(nexServer)
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
@@ -17,47 +16,8 @@ func suggestedCourseSearchObject(err error, client *nex.Client, callID uint32, p
|
||||
|
||||
courseMetadatas := getCourseMetadatasByLimit(4) // In PCAPs param.minimalRatingFrequency is 4 but is 0 here?
|
||||
|
||||
for i := 0; i < len(courseMetadatas); i++ {
|
||||
now := uint64(time.Now().Unix())
|
||||
courseMetadata := courseMetadatas[i]
|
||||
|
||||
rankingResult := nexproto.NewDataStoreCustomRankingResult()
|
||||
|
||||
rankingResult.Order = 0 // idk?
|
||||
rankingResult.Score = courseMetadata.Stars
|
||||
rankingResult.MetaInfo = nexproto.NewDataStoreMetaInfo()
|
||||
rankingResult.MetaInfo.DataID = courseMetadata.DataID
|
||||
rankingResult.MetaInfo.OwnerID = courseMetadata.OwnerPID
|
||||
rankingResult.MetaInfo.Size = courseMetadata.Size
|
||||
rankingResult.MetaInfo.Name = courseMetadata.Name
|
||||
rankingResult.MetaInfo.DataType = courseMetadata.DataType
|
||||
rankingResult.MetaInfo.MetaBinary = courseMetadata.MetaBinary
|
||||
rankingResult.MetaInfo.Permission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.Permission.Permission = 0 // idk?
|
||||
rankingResult.MetaInfo.Permission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.DelPermission = nexproto.NewDataStorePermission()
|
||||
rankingResult.MetaInfo.DelPermission.Permission = 3 // idk?
|
||||
rankingResult.MetaInfo.DelPermission.RecipientIds = []uint32{}
|
||||
rankingResult.MetaInfo.CreatedTime = courseMetadata.CreatedTime
|
||||
rankingResult.MetaInfo.UpdatedTime = courseMetadata.UpdatedTime
|
||||
rankingResult.MetaInfo.Period = courseMetadata.Period
|
||||
rankingResult.MetaInfo.Status = 0 // idk?
|
||||
rankingResult.MetaInfo.ReferredCnt = 0 // idk?
|
||||
rankingResult.MetaInfo.ReferDataID = 0 // idk?
|
||||
rankingResult.MetaInfo.Flag = courseMetadata.Flag
|
||||
rankingResult.MetaInfo.ReferredTime = nex.NewDateTime(now)
|
||||
rankingResult.MetaInfo.ExpireTime = nex.NewDateTime(now)
|
||||
rankingResult.MetaInfo.Tags = []string{""} // idk?
|
||||
rankingResult.MetaInfo.Ratings = []*nexproto.DataStoreRatingInfoWithSlot{
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(),
|
||||
}
|
||||
rankingResult.MetaInfo.Ratings[0].Slot = 0
|
||||
rankingResult.MetaInfo.Ratings[0].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.TotalValue = 3
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.Count = 3
|
||||
rankingResult.MetaInfo.Ratings[0].Rating.InitialValue = 0
|
||||
|
||||
pRankingResults = append(pRankingResults, rankingResult)
|
||||
for _, courseMetadata := range courseMetadatas {
|
||||
pRankingResults = append(pRankingResults, courseMetadataToDataStoreCustomRankingResult(courseMetadata))
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(nexServer)
|
||||
|
||||
170
utility.go
Normal file
170
utility.go
Normal file
@@ -0,0 +1,170 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"time"
|
||||
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
func courseMetadataToDataStoreCustomRankingResult(courseMetadata *CourseMetadata) *nexproto.DataStoreCustomRankingResult {
|
||||
rankingResult := nexproto.NewDataStoreCustomRankingResult()
|
||||
|
||||
rankingResult.Order = 0 // unknown
|
||||
rankingResult.Score = courseMetadata.Stars
|
||||
rankingResult.MetaInfo = courseMetadataToDataStoreMetaInfo(courseMetadata)
|
||||
|
||||
return rankingResult
|
||||
}
|
||||
|
||||
func courseMetadataToDataStoreMetaInfo(courseMetadata *CourseMetadata) *nexproto.DataStoreMetaInfo {
|
||||
metaInfo := nexproto.NewDataStoreMetaInfo()
|
||||
|
||||
metaInfo.DataID = courseMetadata.DataID
|
||||
metaInfo.OwnerID = courseMetadata.OwnerPID
|
||||
metaInfo.Size = courseMetadata.Size
|
||||
metaInfo.Name = courseMetadata.Name
|
||||
metaInfo.DataType = courseMetadata.DataType
|
||||
metaInfo.MetaBinary = courseMetadata.MetaBinary
|
||||
metaInfo.Permission = nexproto.NewDataStorePermission()
|
||||
metaInfo.Permission.Permission = 0 // unknown
|
||||
metaInfo.Permission.RecipientIds = []uint32{}
|
||||
metaInfo.DelPermission = nexproto.NewDataStorePermission()
|
||||
metaInfo.DelPermission.Permission = 3 // unknown
|
||||
metaInfo.DelPermission.RecipientIds = []uint32{}
|
||||
metaInfo.CreatedTime = courseMetadata.CreatedTime
|
||||
metaInfo.UpdatedTime = courseMetadata.UpdatedTime
|
||||
metaInfo.Period = courseMetadata.Period
|
||||
metaInfo.Status = 0 // unknown
|
||||
metaInfo.ReferredCnt = 0 // unknown
|
||||
metaInfo.ReferDataID = 0 // unknown
|
||||
metaInfo.Flag = courseMetadata.Flag
|
||||
metaInfo.ReferredTime = courseMetadata.CreatedTime
|
||||
metaInfo.ExpireTime = nex.NewDateTime(671075926016) // December 31st, year 9999
|
||||
metaInfo.Tags = []string{""} // unknown
|
||||
metaInfo.Ratings = []*nexproto.DataStoreRatingInfoWithSlot{
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // attempts
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // completions
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // failures
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
nexproto.NewDataStoreRatingInfoWithSlot(), // unknown
|
||||
}
|
||||
|
||||
// attempts
|
||||
metaInfo.Ratings[0].Slot = 0
|
||||
metaInfo.Ratings[0].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
metaInfo.Ratings[0].Rating.TotalValue = int64(courseMetadata.Attempts)
|
||||
metaInfo.Ratings[0].Rating.Count = courseMetadata.Attempts
|
||||
metaInfo.Ratings[0].Rating.InitialValue = 0
|
||||
|
||||
// unknown
|
||||
metaInfo.Ratings[1].Slot = 1
|
||||
metaInfo.Ratings[1].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
metaInfo.Ratings[1].Rating.TotalValue = 2
|
||||
metaInfo.Ratings[1].Rating.Count = 2
|
||||
metaInfo.Ratings[1].Rating.InitialValue = 0
|
||||
|
||||
// completions
|
||||
metaInfo.Ratings[2].Slot = 2
|
||||
metaInfo.Ratings[2].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
metaInfo.Ratings[2].Rating.TotalValue = int64(courseMetadata.Completions)
|
||||
metaInfo.Ratings[2].Rating.Count = courseMetadata.Completions
|
||||
metaInfo.Ratings[2].Rating.InitialValue = 0
|
||||
|
||||
// failures
|
||||
metaInfo.Ratings[3].Slot = 3
|
||||
metaInfo.Ratings[3].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
metaInfo.Ratings[3].Rating.TotalValue = int64(courseMetadata.Failures)
|
||||
metaInfo.Ratings[3].Rating.Count = courseMetadata.Failures
|
||||
metaInfo.Ratings[3].Rating.InitialValue = 0
|
||||
|
||||
// unknown
|
||||
metaInfo.Ratings[4].Slot = 4
|
||||
metaInfo.Ratings[4].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
metaInfo.Ratings[4].Rating.TotalValue = 5
|
||||
metaInfo.Ratings[4].Rating.Count = 5
|
||||
metaInfo.Ratings[4].Rating.InitialValue = 0
|
||||
|
||||
// unknown
|
||||
metaInfo.Ratings[5].Slot = 5
|
||||
metaInfo.Ratings[5].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
metaInfo.Ratings[5].Rating.TotalValue = 6
|
||||
metaInfo.Ratings[5].Rating.Count = 6
|
||||
metaInfo.Ratings[5].Rating.InitialValue = 0
|
||||
|
||||
// Number of new Miiverse comments
|
||||
metaInfo.Ratings[6].Slot = 6
|
||||
metaInfo.Ratings[6].Rating = nexproto.NewDataStoreRatingInfo()
|
||||
metaInfo.Ratings[6].Rating.TotalValue = 0
|
||||
metaInfo.Ratings[6].Rating.Count = 0
|
||||
metaInfo.Ratings[6].Rating.InitialValue = 0
|
||||
|
||||
return metaInfo
|
||||
}
|
||||
|
||||
func userMiiDataToDataStoreCustomRankingResult(ownerID uint32, miiInfo primitive.M) *nexproto.DataStoreCustomRankingResult {
|
||||
rankingResult := nexproto.NewDataStoreCustomRankingResult()
|
||||
|
||||
rankingResult.Order = 0
|
||||
rankingResult.Score = 0
|
||||
rankingResult.MetaInfo = userMiiDataToDataStoreMetaInfo(ownerID, miiInfo)
|
||||
|
||||
return rankingResult
|
||||
}
|
||||
|
||||
func userMiiDataToDataStoreMetaInfo(ownerID uint32, miiInfo primitive.M) *nexproto.DataStoreMetaInfo {
|
||||
encodedMiiData := miiInfo["data"].(string)
|
||||
decodedMiiData, _ := base64.StdEncoding.DecodeString(encodedMiiData)
|
||||
|
||||
metaBinaryStream := nex.NewStreamOut(nexServer)
|
||||
metaBinaryStream.Grow(140)
|
||||
metaBinaryStream.WriteBytesNext([]byte{
|
||||
0x42, 0x50, 0x46, 0x43, // BPFC magic
|
||||
0x00, 0x00, 0x00, 0x01, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x01, 0x00, 0x00, // Unknown
|
||||
})
|
||||
metaBinaryStream.WriteBytesNext(decodedMiiData) // Actual Mii data
|
||||
metaBinaryStream.WriteBytesNext([]byte{
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x00, // Unknown
|
||||
0x00, 0x00, 0x00, 0x01, // Unknown
|
||||
})
|
||||
|
||||
now := uint64(time.Now().Unix())
|
||||
|
||||
metaInfo := nexproto.NewDataStoreMetaInfo()
|
||||
metaInfo.DataID = uint64(ownerID) // This isn;t actually a user PID in Nintendo's servers, but it makes it much easier for us to do it this way
|
||||
metaInfo.OwnerID = ownerID
|
||||
metaInfo.Size = 0
|
||||
metaInfo.Name = miiInfo["name"].(string)
|
||||
metaInfo.DataType = 1 // Mii data type?
|
||||
metaInfo.MetaBinary = metaBinaryStream.Bytes()
|
||||
metaInfo.Permission = nexproto.NewDataStorePermission()
|
||||
metaInfo.Permission.Permission = 0 // idk?
|
||||
metaInfo.Permission.RecipientIds = []uint32{}
|
||||
metaInfo.DelPermission = nexproto.NewDataStorePermission()
|
||||
metaInfo.DelPermission.Permission = 3 // idk?
|
||||
metaInfo.DelPermission.RecipientIds = []uint32{}
|
||||
metaInfo.CreatedTime = nex.NewDateTime(now)
|
||||
metaInfo.UpdatedTime = nex.NewDateTime(now)
|
||||
metaInfo.Period = 90 // idk?
|
||||
metaInfo.Status = 0
|
||||
metaInfo.ReferredCnt = 0
|
||||
metaInfo.ReferDataID = 0
|
||||
metaInfo.Flag = 256 // idk?
|
||||
metaInfo.ReferredTime = nex.NewDateTime(now)
|
||||
metaInfo.ExpireTime = nex.NewDateTime(now)
|
||||
metaInfo.Tags = []string{"49"} // idk?
|
||||
metaInfo.Ratings = []*nexproto.DataStoreRatingInfoWithSlot{}
|
||||
|
||||
return metaInfo
|
||||
}
|
||||
Reference in New Issue
Block a user