From e36462c9ef8bde8df14560971225b0b2edab9d2c Mon Sep 17 00:00:00 2001 From: Jonathan Barrow Date: Sat, 8 Apr 2023 19:00:30 -0400 Subject: [PATCH] Added MatchmakeExtension::UpdateProgressScore --- matchmake-extension/protocol.go | 15 +++++++++ matchmake-extension/update_progress_score.go | 32 ++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 matchmake-extension/update_progress_score.go diff --git a/matchmake-extension/protocol.go b/matchmake-extension/protocol.go index 2e2970a0..c16bd1f5 100644 --- a/matchmake-extension/protocol.go +++ b/matchmake-extension/protocol.go @@ -41,6 +41,18 @@ const ( // MethodGetSimplePlayingSession is the method ID for method GetSimplePlayingSession MethodGetSimplePlayingSession = 0x1F + + // MethodUpdateProgressScore is the method ID for method UpdateProgressScore + MethodUpdateProgressScore = 0x22 + + // MethodCreateMatchmakeSessionWithParam is the method ID for method CreateMatchmakeSessionWithParam + MethodCreateMatchmakeSessionWithParam = 0x26 + + // MethodJoinMatchmakeSessionWithParam is the method ID for method JoinMatchmakeSessionWithParam + MethodJoinMatchmakeSessionWithParam = 0x27 + + // MethodAutoMatchmakeWithParam_Postpone is the method ID for method AutoMatchmakeWithParam_Postpone + MethodAutoMatchmakeWithParam_Postpone = 0x28 ) // MatchmakeExtensionProtocol handles the Matchmake Extension nex protocol @@ -56,6 +68,7 @@ type MatchmakeExtensionProtocol struct { GetPlayingSessionHandler func(err error, client *nex.Client, callID uint32, lstPID []uint32) JoinMatchmakeSessionExHandler func(err error, client *nex.Client, callID uint32, gid uint32, strMessage string, dontCareMyBlockList bool, participationCount uint16) GetSimplePlayingSessionHandler func(err error, client *nex.Client, callID uint32, listPID []uint32, includeLoginUser bool) + UpdateProgressScoreHandler func(err error, client *nex.Client, callID uint32, GID uint32, progressScore uint8) } // Setup initializes the protocol @@ -93,6 +106,8 @@ func (protocol *MatchmakeExtensionProtocol) HandlePacket(packet nex.PacketInterf go protocol.HandleJoinMatchmakeSessionEx(packet) case MethodGetSimplePlayingSession: go protocol.HandleGetSimplePlayingSession(packet) + case MethodUpdateProgressScore: + go protocol.HandleUpdateProgressScore(packet) default: go globals.RespondNotImplemented(packet, ProtocolID) fmt.Printf("Unsupported Matchmake Extension method ID: %#v\n", request.MethodID()) diff --git a/matchmake-extension/update_progress_score.go b/matchmake-extension/update_progress_score.go new file mode 100644 index 00000000..13844632 --- /dev/null +++ b/matchmake-extension/update_progress_score.go @@ -0,0 +1,32 @@ +package matchmake_extension + +import ( + nex "github.com/PretendoNetwork/nex-go" + "github.com/PretendoNetwork/nex-protocols-go/globals" +) + +// UpdateProgressScore sets the UpdateProgressScore handler function +func (protocol *MatchmakeExtensionProtocol) UpdateProgressScore(handler func(err error, client *nex.Client, callID uint32, GID uint32, progressScore uint8)) { + protocol.UpdateProgressScoreHandler = handler +} + +func (protocol *MatchmakeExtensionProtocol) HandleUpdateProgressScore(packet nex.PacketInterface) { + if protocol.UpdateProgressScoreHandler == nil { + globals.Logger.Warning("MatchmakeExtension::UpdateProgressScore not implemented") + go globals.RespondNotImplemented(packet, ProtocolID) + return + } + + client := packet.Sender() + request := packet.RMCRequest() + + callID := request.CallID() + parameters := request.Parameters() + + parametersStream := nex.NewStreamIn(parameters, protocol.Server) + + GID := parametersStream.ReadUInt32LE() + progressScore := parametersStream.ReadUInt8() + + go protocol.UpdateProgressScoreHandler(nil, client, callID, GID, progressScore) +}