Skip to content

Commit

Permalink
Merge pull request #58 from MikeIsAStar/kick-players-who-drop-too-man…
Browse files Browse the repository at this point in the history
…y-frames

GPCM: Kick players who drop too many frames
  • Loading branch information
mkwcat authored Jul 26, 2024
2 parents 9591255 + 5e4eecc commit 381c85a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
13 changes: 13 additions & 0 deletions gpcm/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion gpcm/kick.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -37,7 +40,6 @@ func kickPlayer(profileID uint32, reason string) {
Fatal: true,
WWFCMessage: errorMessage,
})
common.CloseConnection(ServerName, session.ConnIndex)
}
}

Expand Down
1 change: 0 additions & 1 deletion gpcm/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
17 changes: 17 additions & 0 deletions gpcm/report.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gpcm

import (
"fmt"
"strconv"
"wwfc/common"
"wwfc/logging"
Expand Down Expand Up @@ -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")
}
}
}

0 comments on commit 381c85a

Please sign in to comment.