mirror of
https://github.com/PretendoNetwork/splatoon.git
synced 2026-08-03 00:20:10 -05:00
Implement UploadCompetitionRankingScore for Splatfest
Finally got around to finishing the Splatfest implementation. The method was completely stubbed out so I added the handler to actually save competition ranking scores to the database. Basically what I did: - Created the handler that reads the CompetitionRankingUploadScoreParam from the packet and extracts festival_id, score, team_id, team_score, is_first_upload - Added the competition_ranking_scores table to store the results - Wired it up in the protocol registration Splatfest should now actually work instead of just silently dropping all the score data. Haven't tested it on actual Wii U yet but the server compiles and the handler logic looks solid.
This commit is contained in:
parent
b9d3bd3482
commit
13bc954dfb
9
competition_ranking_scores.sql
Normal file
9
competition_ranking_scores.sql
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
CREATE TABLE IF NOT EXISTS competition_ranking_scores (
|
||||
id bigserial PRIMARY KEY,
|
||||
pid numeric(10) NOT NULL,
|
||||
festival_id integer NOT NULL,
|
||||
score integer NOT NULL,
|
||||
team_id smallint NOT NULL,
|
||||
team_score integer NOT NULL,
|
||||
is_first_upload boolean NOT NULL
|
||||
);
|
||||
61
globals/upload_competition_ranking_score.go
Normal file
61
globals/upload_competition_ranking_score.go
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
package globals
|
||||
|
||||
import (
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
ranking "github.com/PretendoNetwork/nex-protocols-go/v2/ranking/splatoon"
|
||||
)
|
||||
|
||||
func UploadCompetitionRankingScore(err error, packet nex.PacketInterface, callID uint32, packetPayload []byte) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.Unknown, err.Error())
|
||||
}
|
||||
|
||||
request := packet.RMCMessage()
|
||||
parameters := request.Parameters
|
||||
endpoint := packet.Sender().Endpoint()
|
||||
parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings())
|
||||
|
||||
// Read CompetitionRankingUploadScoreParam data
|
||||
festivalID, streamErr := parametersStream.ReadUInt32LE()
|
||||
if streamErr != nil {
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.Unknown, "Failed to read festival_id")
|
||||
}
|
||||
|
||||
score, streamErr := parametersStream.ReadUInt32LE()
|
||||
if streamErr != nil {
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.Unknown, "Failed to read score")
|
||||
}
|
||||
|
||||
teamID, streamErr := parametersStream.ReadUInt8()
|
||||
if streamErr != nil {
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.Unknown, "Failed to read team_id")
|
||||
}
|
||||
|
||||
teamScore, streamErr := parametersStream.ReadUInt32LE()
|
||||
if streamErr != nil {
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.Unknown, "Failed to read team_score")
|
||||
}
|
||||
|
||||
isFirstUpload, streamErr := parametersStream.ReadBool()
|
||||
if streamErr != nil {
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.Unknown, "Failed to read is_first_upload")
|
||||
}
|
||||
|
||||
pid := packet.Sender().PID()
|
||||
|
||||
_, dbErr := Postgres.Exec(
|
||||
"INSERT INTO competition_ranking_scores (pid, festival_id, score, team_id, team_score, is_first_upload) VALUES ($1, $2, $3, $4, $5, $6)",
|
||||
pid, festivalID, score, teamID, teamScore, isFirstUpload,
|
||||
)
|
||||
if dbErr != nil {
|
||||
Logger.Error(dbErr.Error())
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.Unknown, "Database error")
|
||||
}
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(endpoint, nil)
|
||||
rmcResponse.ProtocolID = ranking.ProtocolID
|
||||
rmcResponse.MethodID = ranking.MethodUploadCompetitionRankingScore
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
@ -56,6 +56,7 @@ func registerCommonSecureServerProtocols() {
|
|||
commonMatchmakeExtensionProtocol.SetManager(globals.MatchmakingManager)
|
||||
|
||||
rankingProtocol := ranking.NewProtocol(globals.SecureEndpoint)
|
||||
rankingProtocol.UploadCompetitionRankingScore = globals.UploadCompetitionRankingScore
|
||||
globals.SecureEndpoint.RegisterServiceProtocol(rankingProtocol)
|
||||
commonranking.NewCommonProtocol(rankingProtocol)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user