GPCM: Update report to use the "wl:" namespace

This commit is contained in:
Palapeli
2025-03-06 05:20:32 -05:00
parent 1212a4f64c
commit c0196a65bd
4 changed files with 31 additions and 67 deletions

View File

@@ -385,19 +385,6 @@ 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 WFC.\n" +
"\n" +
"Error Code: %[1]d",
},
}
)
func (err GPError) GetMessage() string {

View File

@@ -25,9 +25,6 @@ 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)

View File

@@ -1,7 +1,6 @@
package gpcm
import (
"fmt"
"strconv"
"wwfc/common"
"wwfc/logging"
@@ -12,75 +11,54 @@ import (
func (g *GameSpySession) handleWWFCReport(command common.GameSpyCommand) {
for key, value := range command.OtherValues {
logging.Info(g.ModuleName, "WWFC Report:", aurora.Yellow(key))
logging.Info(g.ModuleName, "WiiLink Report:", aurora.Yellow(key))
keyColored := aurora.BrightCyan(key).String()
switch key {
case "mkw_user":
if g.GameName != "mariokartwii" {
logging.Warn(g.ModuleName, "Ignoring mkw_user packet from wrong game")
continue
}
packet, err := common.Base64DwcEncoding.DecodeString(value)
if err != nil {
logging.Error(g.ModuleName, "Error decoding mkw_user packet:", err.Error())
continue
}
if len(packet) != 0xC0 {
logging.Error(g.ModuleName, "Invalid mkw_user packet length:", len(packet))
continue
}
qr2.ProcessUSER(g.User.ProfileId, g.QR2IP, packet)
case "mkw_malicious_packet":
if g.GameName != "mariokartwii" {
logging.Warn(g.ModuleName, "Ignoring mkw_malicious_packet from wrong game")
continue
}
default:
logging.Error(g.ModuleName, "Unknown record", aurora.Cyan(key).String()+":", aurora.Cyan(value))
case "wl:bad_packet":
profileId, err := strconv.ParseUint(value, 10, 32)
if err != nil {
logging.Error(g.ModuleName, "Error decoding mkw_malicious_packet:", err.Error())
logging.Error(g.ModuleName, "Error decoding", keyColored+":", err.Error())
continue
}
logging.Warn(g.ModuleName, "Malicious packet from", aurora.BrightCyan(strconv.FormatUint(profileId, 10)))
case "mkw_room_stall":
if g.GameName != "mariokartwii" {
logging.Warn(g.ModuleName, "Ignoring mkw_room_stall from wrong game")
continue
}
logging.Warn(g.ModuleName, "Report bad packet from", aurora.BrightCyan(strconv.FormatUint(profileId, 10)))
case "wl:stall":
profileId, err := strconv.ParseUint(value, 10, 32)
if err != nil {
logging.Error(g.ModuleName, "Error decoding mkw_room_stall:", err.Error())
logging.Error(g.ModuleName, "Error decoding", keyColored+":", err.Error())
continue
}
logging.Warn(g.ModuleName, "Room stall caused by", aurora.BrightCyan(strconv.FormatUint(profileId, 10)))
case "mkw_too_many_frames_dropped":
case "wl:mkw_user":
if g.GameName != "mariokartwii" {
logging.Warn(g.ModuleName, "Ignoring mkw_too_many_frames_dropped from wrong game")
logging.Warn(g.ModuleName, "Ignoring", keyColored+":", "from wrong game")
continue
}
framesDropped, err := strconv.ParseUint(value, 10, 32)
packet, err := common.Base64DwcEncoding.DecodeString(value)
if err != nil {
logging.Error(g.ModuleName, "Error decoding mkw_too_many_frames_dropped:", err.Error())
logging.Error(g.ModuleName, "Error decoding", keyColored+":", 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")
if len(packet) != 0xC0 {
logging.Error(g.ModuleName, "Invalid", keyColored, "record length:", len(packet))
continue
}
case "mkw_select_course", "mkw_select_cc":
qr2.ProcessUSER(g.User.ProfileId, g.QR2IP, packet)
case "wl:mkw_select_course", "wl:mkw_select_cc":
if g.GameName != "mariokartwii" {
logging.Warn(g.ModuleName, "Ignoring mkw_select_* from wrong game")
logging.Warn(g.ModuleName, "Ignoring", keyColored, "from wrong game")
continue
}

View File

@@ -379,7 +379,7 @@ func ProcessUSER(senderPid uint32, senderIP uint64, packet []byte) {
if miiGroupCount != 2 {
logging.Error(moduleName, "Received USER packet with unexpected Mii group count", aurora.Cyan(miiGroupCount))
// Kick the client
gpErrorCallback(senderPid, "malpacket")
gpErrorCallback(senderPid, "bad_packet")
return
}
@@ -396,7 +396,7 @@ func ProcessUSER(senderPid uint32, senderIP uint64, packet []byte) {
mii := common.Mii(packet[index : index+0x4C])
if mii.RFLCalculateCRC() != 0x0000 {
logging.Error(moduleName, "Received USER packet with invalid Mii data CRC")
gpErrorCallback(senderPid, "malpacket")
gpErrorCallback(senderPid, "bad_packet")
return
}
@@ -408,7 +408,7 @@ func ProcessUSER(senderPid uint32, senderIP uint64, packet []byte) {
decodedName, err := common.GetWideString(packet[index+0x2:index+0x2+20], binary.BigEndian)
if err != nil {
logging.Error(moduleName, "Failed to parse Mii name:", err)
gpErrorCallback(senderPid, "malpacket")
gpErrorCallback(senderPid, "bad_packet")
return
}
@@ -487,11 +487,13 @@ func ProcessMKWSelectRecord(profileId uint32, key string, value string) {
return
}
keyColored := aurora.BrightCyan(key).String()
switch key {
case "mkw_select_course":
case "wl:mkw_select_course":
courseId, err := strconv.ParseUint(value, 10, 32)
if err != nil {
logging.Error(moduleName, "Error decoding mkw_select_course:", err.Error())
logging.Error(moduleName, "Error decoding", keyColored+":", err.Error())
return
}
@@ -505,10 +507,10 @@ func ProcessMKWSelectRecord(profileId uint32, key string, value string) {
group.MKWEngineClassID = -1
return
case "mkw_select_cc":
case "wl:mkw_select_cc":
ccId, err := strconv.ParseUint(value, 10, 32)
if err != nil {
logging.Error(moduleName, "Error decoding mkw_select_cc:", err.Error())
logging.Error(moduleName, "Error decoding", keyColored+":", err.Error())
return
}