Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Matchmaking notification hacks #6

Merged
merged 1 commit into from
Apr 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions matchmaking/update_session_host.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package matchmaking

import (
"encoding/hex"
"fmt"
"strconv"
"time"

nex "github.com/PretendoNetwork/nex-go"
match_making "github.com/PretendoNetwork/nex-protocols-go/match-making"
"github.com/PretendoNetwork/nex-protocols-go/notifications"
)

func updateSessionHost(err error, client *nex.Client, callID uint32, gid uint32) {
Expand Down Expand Up @@ -44,21 +45,26 @@ func updateSessionHost(err error, client *nex.Client, callID uint32, gid uint32)

server.Send(responsePacket)

rmcMessage := nex.RMCRequest{}
rmcMessage.SetProtocolID(0xe)
rmcMessage := nex.NewRMCRequest()
rmcMessage.SetProtocolID(notifications.ProtocolID)
rmcMessage.SetCallID(0xffff0000 + callID)
rmcMessage.SetMethodID(0x1)
rmcMessage.SetMethodID(notifications.MethodProcessNotificationEvent)

hostpidString := fmt.Sprintf("%.8x", (client.PID()))
hostpidString = hostpidString[6:8] + hostpidString[4:6] + hostpidString[2:4] + hostpidString[0:2]
clientPidString := fmt.Sprintf("%.8x", (client.PID()))
clientPidString = clientPidString[6:8] + clientPidString[4:6] + clientPidString[2:4] + clientPidString[0:2]
gidString := fmt.Sprintf("%.8x", (gid))
gidString = gidString[6:8] + gidString[4:6] + gidString[2:4] + gidString[0:2]
oEvent := notifications.NewNotificationEvent()
oEvent.PIDSource = client.PID()
oEvent.Type = 4000 // Ownership changed
oEvent.Param1 = gid
oEvent.Param2 = client.PID()

data, _ := hex.DecodeString("0017000000" + hostpidString + "A00F0000" + gidString + clientPidString + "01000001000000")
rmcMessage.SetParameters(data)
rmcMessageBytes := rmcMessage.Bytes()
// https://github.com/kinnay/NintendoClients/issues/101
unixTime := time.Now()
oEvent.StrParam = strconv.FormatInt(unixTime.UnixMicro(), 10)

stream := nex.NewStreamOut(server)
oEventBytes := oEvent.Bytes(stream)
rmcMessage.SetParameters(oEventBytes)

rmcRequestBytes := rmcMessage.Bytes()

for _, pid := range GetRoomPlayersHandler(gid) {
if pid == 0 {
Expand All @@ -81,7 +87,7 @@ func updateSessionHost(err error, client *nex.Client, callID uint32, gid uint32)
messagePacket.SetSource(0xA1)
messagePacket.SetDestination(0xAF)
messagePacket.SetType(nex.DataPacket)
messagePacket.SetPayload(rmcMessageBytes)
messagePacket.SetPayload(rmcRequestBytes)

messagePacket.AddFlag(nex.FlagNeedsAck)
messagePacket.AddFlag(nex.FlagReliable)
Expand All @@ -97,7 +103,7 @@ func updateSessionHost(err error, client *nex.Client, callID uint32, gid uint32)
messagePacket.SetSource(0xA1)
messagePacket.SetDestination(0xAF)
messagePacket.SetType(nex.DataPacket)
messagePacket.SetPayload(rmcMessageBytes)
messagePacket.SetPayload(rmcRequestBytes)

messagePacket.AddFlag(nex.FlagNeedsAck)
messagePacket.AddFlag(nex.FlagReliable)
Expand Down