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

[Rewrite] Implement Matchmaking Rewrite #10

Draft
wants to merge 32 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f71c3da
feat(secure): Mark Splatfest sessions as OpenParticipation
ashquarky Jul 18, 2024
faf469e
feat(secure): Add stubbed Splatoon Ranking protocol
ashquarky Aug 1, 2024
a1aae94
feat: matchmaking rewrite implementation
AToska21 Sep 29, 2024
9bd50d4
Merge branch 'PretendoNetwork:master' into mm-rewrite
AToska21 Sep 29, 2024
8dec161
feat(secure): attempt to fix index bugs
AToska21 Sep 30, 2024
63fb020
fix: merge issue
AToska21 Sep 30, 2024
366de5a
fix(secure): forgot to change the import name
AToska21 Sep 30, 2024
6a1b0bd
Merge branch 'mm-rewrite' of https://github.com/AToska21/splatoon int…
AToska21 Sep 30, 2024
1692ea3
fix(secure): remove old index ignore
AToska21 Sep 30, 2024
448083d
fix(secure): misspelling
AToska21 Sep 30, 2024
24fa36d
fix(secure): remove unused var
AToska21 Sep 30, 2024
f80551f
fix(secure): revert previous fix
AToska21 Sep 30, 2024
5fffd1c
fix(secure): using another function
AToska21 Sep 30, 2024
67eb714
fix(secure): using another function
AToska21 Sep 30, 2024
7190a31
Merge branch 'mm-rewrite' of https://github.com/AToska21/splatoon int…
AToska21 Sep 30, 2024
a80f33b
working on it
AToska21 Sep 30, 2024
4044f29
fix(secure): i hate these variable names
AToska21 Sep 30, 2024
eeb2a34
fix(secure): misspelled again
AToska21 Sep 30, 2024
24c5e11
debug(secure): adding debugging
AToska21 Sep 30, 2024
008344e
fix(secure): hopefully fix the error (thanks dani)
AToska21 Sep 30, 2024
b2414b6
std(secure): standardize variable names
AToska21 Sep 30, 2024
52bb341
fix(secure): fix string issue
AToska21 Sep 30, 2024
970cf48
fix(secure): oops
AToska21 Sep 30, 2024
e1d5697
fix(secure): remove attribute 1
AToska21 Sep 30, 2024
4e3b9cb
fix(secure): final fixups
AToska21 Sep 30, 2024
89a1998
fix(secure): final fixups
AToska21 Sep 30, 2024
ccf9c34
Merge branch 'mm-rewrite' of https://github.com/AToska21/splatoon int…
AToska21 Sep 30, 2024
36ee29d
feat(secure): try fixing fest rooms
AToska21 Sep 30, 2024
4bf6c91
feat(secure): implement postgresql fix
AToska21 Sep 30, 2024
b2ada39
merge
AToska21 Sep 30, 2024
513ebf7
fix(secure): try once again to fix fests
AToska21 Sep 30, 2024
ab9e9af
fix(secure): ignore first param
AToska21 Sep 30, 2024
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
5 changes: 5 additions & 0 deletions globals/globals.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package globals

import (
"database/sql"
pb "github.com/PretendoNetwork/grpc-go/account"
"github.com/PretendoNetwork/nex-protocols-common-go/v2/globals"
"github.com/PretendoNetwork/nex-go/v2"
"github.com/PretendoNetwork/plogger-go"
"google.golang.org/grpc"
Expand All @@ -20,3 +22,6 @@ var SecureEndpoint *nex.PRUDPEndPoint
var GRPCAccountClientConnection *grpc.ClientConn
var GRPCAccountClient pb.AccountClient
var GRPCAccountCommonMetadata metadata.MD

var Postgres *sql.DB
var MatchmakingManager *common_globals.MatchmakingManager
10 changes: 7 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/PretendoNetwork/splatoon

go 1.21

toolchain go1.21.9
go 1.22.1

require (
github.com/PretendoNetwork/grpc-go v1.0.2
Expand All @@ -15,11 +13,13 @@ require (
)

require (
github.com/PretendoNetwork/pq-extended v1.0.0 // indirect
github.com/dolthub/maphash v0.1.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/jwalton/go-supportscolor v1.2.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/lxzan/gws v1.8.5 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -34,3 +34,7 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20240617180043-68d350f18fd4 // indirect
google.golang.org/protobuf v1.34.2 // indirect
)

replace github.com/PretendoNetwork/nex-protocols-common-go/v2 => /root/nex-protocols-common-go

replace github.com/PretendoNetwork/nex-protocols-go/v2 => /root/nex-protocols-go
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ github.com/PretendoNetwork/grpc-go v1.0.2 h1:9TvKmX7dCOANyoHEra1MMYqS1N/RGav66TR
github.com/PretendoNetwork/grpc-go v1.0.2/go.mod h1:XZjEsij9lL7HJBNkH6JPbBIkUSq/1rjflvjGdv+DAj0=
github.com/PretendoNetwork/nex-go/v2 v2.0.2 h1:mPp27Ero3Rr28nekuKg4f0tdp28NzmCJXgupt2paT18=
github.com/PretendoNetwork/nex-go/v2 v2.0.2/go.mod h1:O5v200Ro8bdrmqSAmzV0cqQsG7cdmwLHAet5X7Jxz20=
github.com/PretendoNetwork/nex-protocols-common-go/v2 v2.0.5 h1:17b7vA8wjWLW9JdJTHeOoX2g2e4S/EwA32m9AuPEA80=
github.com/PretendoNetwork/nex-protocols-common-go/v2 v2.0.5/go.mod h1:0wDEYxDYbUOjsKjsTUjU0/f3pL1MT54h+tGn4UyeB+A=
github.com/PretendoNetwork/nex-protocols-go/v2 v2.0.3 h1:80CG7f9w/34MN1vAZ1XP3ec4LJ4mqKlkests+HQzrvc=
github.com/PretendoNetwork/nex-protocols-go/v2 v2.0.3/go.mod h1:2UN8khoMDNaeJ4GcIG7ez7MqqmbLfLzbVS6hSa+kGnk=
github.com/PretendoNetwork/plogger-go v1.0.4 h1:PF7xHw9eDRHH+RsAP9tmAE7fG0N0p6H4iPwHKnsoXwc=
github.com/PretendoNetwork/plogger-go v1.0.4/go.mod h1:7kD6M4vPq1JL4LTuPg6kuB1OvUBOwQOtAvTaUwMbwvU=
github.com/PretendoNetwork/pq-extended v1.0.0 h1:GHZ0hLvCvmYKQPTV9I9XtTx8J1iB5Z9CEnfW2tUpsYg=
github.com/PretendoNetwork/pq-extended v1.0.0/go.mod h1:bq6Ai+3lG4/M0iamUBt2Uzi5vL/nYy1a1Ar2ow9NDF0=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dolthub/maphash v0.1.0 h1:bsQ7JsF4FkkWyrP3oCnFJgrCUAFbFf3kOl4L/QxPDyQ=
Expand All @@ -24,6 +22,8 @@ github.com/jwalton/go-supportscolor v1.2.0 h1:g6Ha4u7Vm3LIsQ5wmeBpS4gazu0UP1DRDE
github.com/jwalton/go-supportscolor v1.2.0/go.mod h1:hFVUAZV2cWg+WFFC4v8pT2X/S2qUUBYMioBD9AINXGs=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lxzan/gws v1.8.5 h1:6x+wW3EHtoGFNeCtZP1OVZ1IHrpZZzDaEjQGg1lUJqU=
github.com/lxzan/gws v1.8.5/go.mod h1:FcGeRMB7HwGuTvMLR24ku0Zx0p6RXqeKASeMc4VYgi4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
Expand Down
6 changes: 6 additions & 0 deletions init.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"database/sql"
"fmt"
"os"
"strconv"
Expand Down Expand Up @@ -104,4 +105,9 @@ func init() {
globals.GRPCAccountCommonMetadata = metadata.Pairs(
"X-API-Key", accountGRPCAPIKey,
)
globals.Postgres, err = sql.Open("postgres", os.Getenv("PN_SPLATOON_POSTGRES_URI"))
if err != nil {
globals.Logger.Critical(err.Error())
}
globals.Logger.Success("Connected to Postgres!")
}
54 changes: 27 additions & 27 deletions nex/register_common_secure_server_protocols.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package nex
import (
"github.com/PretendoNetwork/nex-go/v2"
"github.com/PretendoNetwork/nex-go/v2/types"
// common_globals "github.com/PretendoNetwork/nex-protocols-common-go/v2/globals"
commonnattraversal "github.com/PretendoNetwork/nex-protocols-common-go/v2/nat-traversal"
commonsecure "github.com/PretendoNetwork/nex-protocols-common-go/v2/secure-connection"
nattraversal "github.com/PretendoNetwork/nex-protocols-go/v2/nat-traversal"
Expand All @@ -14,10 +15,12 @@ import (
commonmatchmaking "github.com/PretendoNetwork/nex-protocols-common-go/v2/match-making"
commonmatchmakingext "github.com/PretendoNetwork/nex-protocols-common-go/v2/match-making-ext"
commonmatchmakeextension "github.com/PretendoNetwork/nex-protocols-common-go/v2/matchmake-extension"
commonranking "github.com/PretendoNetwork/nex-protocols-common-go/v2/ranking"
matchmaking "github.com/PretendoNetwork/nex-protocols-go/v2/match-making"
matchmakingext "github.com/PretendoNetwork/nex-protocols-go/v2/match-making-ext"
matchmakingtypes "github.com/PretendoNetwork/nex-protocols-go/v2/match-making/types"
match_making_types "github.com/PretendoNetwork/nex-protocols-go/v2/match-making/types"
matchmakeextension "github.com/PretendoNetwork/nex-protocols-go/v2/matchmake-extension"
ranking "github.com/PretendoNetwork/nex-protocols-go/v2/ranking/splatoon"
)

func CreateReportDBRecord(_ *types.PID, _ *types.PrimitiveU32, _ *types.QBuffer) error {
Expand All @@ -33,12 +36,7 @@ func stubGetPlayingSession(err error, packet nex.PacketInterface, callID uint32,
connection := packet.Sender().(*nex.PRUDPConnection)
endpoint := connection.Endpoint().(*nex.PRUDPEndPoint)

lstPlayingSession := types.NewList[*matchmakingtypes.PlayingSession]()

// * There are no sessions, I tell you!
//for _, playingSession := range playingSessions {
// lstPlayingSession.Append(playingSession)
//}
lstPlayingSession := types.NewList[*match_making_types.PlayingSession]()

rmcResponseStream := nex.NewByteStreamOut(endpoint.LibraryVersions(), endpoint.ByteStreamSettings())

Expand Down Expand Up @@ -83,27 +81,21 @@ func compareSearchCriteria[T ~uint16 | ~uint32](original T, search string) bool
}
}

func gameSpecificMatchmakeSessionSearchCriteriaChecksHandler(searchCriteria *matchmakingtypes.MatchmakeSessionSearchCriteria, matchmakeSession *matchmakingtypes.MatchmakeSession) bool {
original := matchmakeSession.Attributes.Slice()
search := searchCriteria.Attribs.Slice()
if len(original) != len(search) {
return false
func cleanupMatchmakeSessionSearchCriteriasHandler(searchCriterias *types.List[*match_making_types.MatchmakeSessionSearchCriteria]) {
for _, searchCriteria := range searchCriterias.Slice() {
searchCriteria.Attribs.SetIndex(4, types.NewString(""))
}
}

for index, originalAttribute := range original {
// ignore dummy criterias for matchmaking
// everyone ends up in different rooms if you don't skip these
if index == 1 || index == 4 {
continue
}
searchAttribute := search[index]
func onAfterAutoMatchmakeWithParamPostpone(_ nex.PacketInterface, _ *match_making_types.AutoMatchmakeParam) {
globals.MatchmakingManager.Mutex.Lock()

if !compareSearchCriteria(originalAttribute.Value, searchAttribute.Value) {
return false
}
}
_, err := globals.MatchmakingManager.Database.Exec(`UPDATE matchmaking.matchmake_sessions SET open_participation=true WHERE game_mode=12`)
if err != nil {
globals.Logger.Error(err.Error())
}

return true
globals.MatchmakingManager.Mutex.Unlock()
}

func registerCommonSecureServerProtocols() {
Expand All @@ -119,15 +111,23 @@ func registerCommonSecureServerProtocols() {

matchMakingProtocol := matchmaking.NewProtocol()
globals.SecureEndpoint.RegisterServiceProtocol(matchMakingProtocol)
commonmatchmaking.NewCommonProtocol(matchMakingProtocol)
commonMatchMakingProtocol := commonmatchmaking.NewCommonProtocol(matchMakingProtocol)
commonMatchMakingProtocol.SetManager(globals.MatchmakingManager)

matchMakingExtProtocol := matchmakingext.NewProtocol()
globals.SecureEndpoint.RegisterServiceProtocol(matchMakingExtProtocol)
commonmatchmakingext.NewCommonProtocol(matchMakingExtProtocol)
commonMatchMakingExtProtocol := commonmatchmakingext.NewCommonProtocol(matchMakingExtProtocol)
commonMatchMakingExtProtocol.SetManager(globals.MatchmakingManager)

matchmakeExtensionProtocol := matchmakeextension.NewProtocol()
globals.SecureEndpoint.RegisterServiceProtocol(matchmakeExtensionProtocol)
commonMatchmakeExtensionProtocol := commonmatchmakeextension.NewCommonProtocol(matchmakeExtensionProtocol)
matchmakeExtensionProtocol.SetHandlerGetPlayingSession(stubGetPlayingSession)
commonMatchmakeExtensionProtocol.GameSpecificMatchmakeSessionSearchCriteriaChecks = gameSpecificMatchmakeSessionSearchCriteriaChecksHandler
commonMatchmakeExtensionProtocol.CleanupMatchmakeSessionSearchCriterias = cleanupMatchmakeSessionSearchCriteriasHandler
commonMatchmakeExtensionProtocol.OnAfterAutoMatchmakeWithParamPostpone = onAfterAutoMatchmakeWithParamPostpone
commonMatchmakeExtensionProtocol.SetManager(globals.MatchmakingManager)

rankingProtocol := ranking.NewProtocol(globals.SecureEndpoint)
globals.SecureEndpoint.RegisterServiceProtocol(rankingProtocol)
commonranking.NewCommonProtocol(rankingProtocol)
}
3 changes: 3 additions & 0 deletions nex/secure.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package nex

import (
"fmt"
common_globals "github.com/PretendoNetwork/nex-protocols-common-go/v2/globals"
"os"
"strconv"

Expand Down Expand Up @@ -36,6 +37,8 @@ func StartSecureServer() {
globals.Logger.Errorf("Secure: %v", err)
})

globals.MatchmakingManager = common_globals.NewMatchmakingManager(globals.SecureEndpoint, globals.Postgres)

registerCommonSecureServerProtocols()

port, _ := strconv.Atoi(os.Getenv("PN_SPLATOON_SECURE_SERVER_PORT"))
Expand Down
Binary file added splatoon
Binary file not shown.