mirror of
https://github.com/PretendoNetwork/splatoon.git
synced 2026-08-02 08:12:27 -05:00
Merge e4639d4e2c into 26b651f2d5
This commit is contained in:
commit
8353733587
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 bigint NOT NULL,
|
||||
score bigint NOT NULL,
|
||||
team_id smallint NOT NULL,
|
||||
team_score bigint NOT NULL,
|
||||
is_first_upload boolean NOT NULL
|
||||
);
|
||||
62
globals/upload_competition_ranking_score.go
Normal file
62
globals/upload_competition_ranking_score.go
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
package globals
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
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, fmt.Sprintf("Failed to read festival_id: %v", streamErr))
|
||||
}
|
||||
|
||||
score, streamErr := parametersStream.ReadUInt32LE()
|
||||
if streamErr != nil {
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.Unknown, fmt.Sprintf("Failed to read score: %v", streamErr))
|
||||
}
|
||||
|
||||
teamID, streamErr := parametersStream.ReadUInt8()
|
||||
if streamErr != nil {
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.Unknown, fmt.Sprintf("Failed to read team_id: %v", streamErr))
|
||||
}
|
||||
|
||||
teamScore, streamErr := parametersStream.ReadUInt32LE()
|
||||
if streamErr != nil {
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.Unknown, fmt.Sprintf("Failed to read team_score: %v", streamErr))
|
||||
}
|
||||
|
||||
isFirstUpload, streamErr := parametersStream.ReadBool()
|
||||
if streamErr != nil {
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.Unknown, fmt.Sprintf("Failed to read is_first_upload: %v", streamErr))
|
||||
}
|
||||
|
||||
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