From 8ea725a6b38a8430fdce57ed4b962d145353f791 Mon Sep 17 00:00:00 2001 From: mkwcat Date: Thu, 11 Jan 2024 03:45:38 -0500 Subject: [PATCH] GPCM: Handle new wwfc_report command --- gpcm/main.go | 1 + gpcm/report.go | 37 +++++++++++++++++++++++++++++++++++++ qr2/group.go | 4 ++++ 3 files changed, 42 insertions(+) create mode 100644 gpcm/report.go diff --git a/gpcm/main.go b/gpcm/main.go index aeea542..7accb2f 100644 --- a/gpcm/main.go +++ b/gpcm/main.go @@ -199,6 +199,7 @@ func handleRequest(conn net.Conn) { return } + commands = session.handleCommand("wwfc_report", commands, session.handleWWFCReport) commands = session.handleCommand("updatepro", commands, session.updateProfile) commands = session.handleCommand("status", commands, session.setStatus) commands = session.handleCommand("addbuddy", commands, session.addFriend) diff --git a/gpcm/report.go b/gpcm/report.go new file mode 100644 index 0000000..a6026dd --- /dev/null +++ b/gpcm/report.go @@ -0,0 +1,37 @@ +package gpcm + +import ( + "wwfc/common" + "wwfc/logging" + "wwfc/qr2" + + "github.com/logrusorgru/aurora/v3" +) + +func (g *GameSpySession) handleWWFCReport(command common.GameSpyCommand) { + for key, value := range command.OtherValues { + logging.Info(g.ModuleName, "WWFC Report:", aurora.Yellow(key)) + + switch key { + case "mkw_user": + if g.GameName != "mariokartwii" { + logging.Warn(g.ModuleName, "Ignoring mkw_user packet from wrong game") + continue + } + + packet, err := common.Base64DwcEncoding.DecodeString(value) + if err != nil { + logging.Error(g.ModuleName, "Error decoding mkw_user packet:", err.Error()) + continue + } + + if len(packet) != 0xC0 { + logging.Error(g.ModuleName, "Invalid mkw_user packet length:", len(packet)) + continue + } + + qr2.ProcessUSER(g.User.ProfileId, g.QR2IP, packet) + break + } + } +} diff --git a/qr2/group.go b/qr2/group.go index d75a392..ba10498 100644 --- a/qr2/group.go +++ b/qr2/group.go @@ -252,6 +252,10 @@ func CheckGPReservationAllowed(senderIP uint64, senderPid uint32, destPid uint32 return checkReservationAllowed(moduleName, from, to, joinType) } +func ProcessUSER(senderPid uint32, senderIP uint64, packet []byte) { + // TODO +} + // findNewServer attempts to find the new server/host in the group when the current server goes down. // If no server is found, the group's server pointer is set to nil. // Expects the mutex to be locked.