Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add extension point for CanJoinMatchmakeSession
Browse files Browse the repository at this point in the history
Useful for games with custom behaviours, like Minecraft's friends-of-friends feature
and Splatoon's fests
ashquarky committed Aug 12, 2024

Verified

This commit was signed with the committer’s verified signature.
Doctor-wu Doctor Wu
1 parent 9639ab6 commit 46a800f
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions globals/matchmaking_globals.go
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import (

"github.com/PretendoNetwork/nex-go/v2"
"github.com/PretendoNetwork/nex-go/v2/types"
match_making_types "github.com/PretendoNetwork/nex-protocols-go/v2/match-making/types"
)

// MatchmakingManager manages a matchmaking instance
@@ -15,6 +16,7 @@ type MatchmakingManager struct {
Mutex *sync.RWMutex
GetUserFriendPIDs func(pid uint32) []uint32
GetDetailedGatheringByID func(manager *MatchmakingManager, gatheringID uint32) (types.RVType, string, *nex.Error)
CanJoinMatchmakeSession func(manager *MatchmakingManager, pid *types.PID, matchmakeSession *match_making_types.MatchmakeSession) *nex.Error
}

// NewMatchmakingManager returns a new MatchmakingManager
5 changes: 5 additions & 0 deletions globals/utils.go
Original file line number Diff line number Diff line change
@@ -79,6 +79,11 @@ func CheckValidMatchmakeSession(matchmakeSession *match_making_types.MatchmakeSe

// CanJoinMatchmakeSession checks if a PID is allowed to join a matchmake session
func CanJoinMatchmakeSession(manager *MatchmakingManager, pid *types.PID, matchmakeSession *match_making_types.MatchmakeSession) *nex.Error {
// * Allow game servers to do their own permissions checks
if manager.CanJoinMatchmakeSession != nil {
return manager.CanJoinMatchmakeSession(manager, pid, matchmakeSession)
}

// TODO - Is this the right error?
if !matchmakeSession.OpenParticipation.Value {
return nex.NewError(nex.ResultCodes.RendezVous.PermissionDenied, "change_error")

0 comments on commit 46a800f

Please sign in to comment.