GPCM: Kick players who drop too many frames

This commit is contained in:
MikeIsAStar
2024-07-25 23:40:45 -04:00
parent a5d5bace43
commit 5e4eecc382
4 changed files with 33 additions and 2 deletions

View File

@@ -351,6 +351,19 @@ var (
"Error Code: %[1]d",
},
}
WWFCMsgTooManyFramesDropped = WWFCErrorMessage{
ErrorCode: 22010,
MessageRMC: map[byte]string{
LangEnglish: "" +
"Your game is dropping too many frames.\n" +
"Please remove any modifications that may\n" +
"be causing frame rate problems to avoid\n" +
"being banned from WiiLink Wi-Fi Connection.\n" +
"\n" +
"Error Code: %[1]d",
},
}
)
func (err GPError) GetMessage() string {

View File

@@ -25,6 +25,9 @@ func kickPlayer(profileID uint32, reason string) {
case "invalid_elo":
errorMessage = WWFCMsgInvalidELO
case "too_many_frames_dropped":
errorMessage = WWFCMsgTooManyFramesDropped
case "network_error":
// No error message
common.CloseConnection(ServerName, session.ConnIndex)
@@ -37,7 +40,6 @@ func kickPlayer(profileID uint32, reason string) {
Fatal: true,
WWFCMessage: errorMessage,
})
common.CloseConnection(ServerName, session.ConnIndex)
}
}

View File

@@ -269,7 +269,6 @@ func (g *GameSpySession) login(command common.GameSpyCommand) {
otherSession, exists := sessions[g.User.ProfileId]
if exists {
otherSession.replyError(ErrForcedDisconnect)
common.CloseConnection(ServerName, otherSession.ConnIndex)
for i := 0; ; i++ {
mutex.Unlock()

View File

@@ -1,6 +1,7 @@
package gpcm
import (
"fmt"
"strconv"
"wwfc/common"
"wwfc/logging"
@@ -60,6 +61,22 @@ func (g *GameSpySession) handleWWFCReport(command common.GameSpyCommand) {
}
logging.Warn(g.ModuleName, "Room stall caused by", aurora.BrightCyan(strconv.FormatUint(profileId, 10)))
case "mkw_too_many_frames_dropped":
if g.GameName != "mariokartwii" {
logging.Warn(g.ModuleName, "Ignoring mkw_too_many_frames_dropped from wrong game")
continue
}
framesDropped, err := strconv.ParseUint(value, 10, 32)
if err != nil {
logging.Error(g.ModuleName, "Error decoding mkw_too_many_frames_dropped:", err.Error())
continue
}
profileId := g.User.ProfileId
logging.Warn(g.ModuleName, "Kicking", aurora.BrightCyan(strconv.FormatUint(uint64(profileId), 10)), fmt.Sprintf("for dropping too many frames (%d)", framesDropped))
kickPlayer(profileId, "too_many_frames_dropped")
}
}
}