forked from PretendoNetwork/super-mario-maker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_metas_multiple_param.go
108 lines (86 loc) · 3.45 KB
/
get_metas_multiple_param.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package main
import (
"encoding/base64"
"fmt"
"time"
nex "github.com/PretendoNetwork/nex-go"
nexproto "github.com/PretendoNetwork/nex-protocols-go"
)
func getMetasMultipleParam(err error, client *nex.Client, callID uint32, params []*nexproto.DataStoreGetMetaParam) {
pMetaInfo := make([]*nexproto.DataStoreMetaInfo, 0)
pResults := make([]uint32, 0)
for i := 0; i < len(params); i++ {
param := params[i]
if param.DataID == 0 {
pMetaInfo = append(pMetaInfo, getMetasMultipleParamMiiData(param))
} else {
fmt.Println("Unknown meta multiple data ID")
}
pResults = append(pResults, 0x690001)
}
rmcResponseStream := nex.NewStreamOut(nexServer)
rmcResponseStream.WriteListStructure(pMetaInfo)
rmcResponseStream.WriteListUInt32LE(pResults)
rmcResponseBody := rmcResponseStream.Bytes()
rmcResponse := nex.NewRMCResponse(nexproto.DataStoreSMMProtocolID, callID)
rmcResponse.SetSuccess(nexproto.DataStoreMethodGetMetasMultipleParam, rmcResponseBody)
rmcResponseBytes := rmcResponse.Bytes()
responsePacket, _ := nex.NewPacketV1(client, nil)
responsePacket.SetVersion(1)
responsePacket.SetSource(0xA1)
responsePacket.SetDestination(0xAF)
responsePacket.SetType(nex.DataPacket)
responsePacket.SetPayload(rmcResponseBytes)
responsePacket.AddFlag(nex.FlagNeedsAck)
responsePacket.AddFlag(nex.FlagReliable)
nexServer.Send(responsePacket)
}
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
}