mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-03-21 17:44:58 -05:00
QR2: Only check relevant VR in public matches
This commit is contained in:
parent
65f0eb460e
commit
4c10435b92
|
|
@ -138,17 +138,19 @@ func heartbeat(moduleName string, conn net.PacketConn, addr net.UDPAddr, buffer
|
|||
}
|
||||
|
||||
func checkValidRating(moduleName string, payload map[string]string) string {
|
||||
if payload["gamename"] == "mariokartwii" {
|
||||
if payload["gamename"] != "mariokartwii" {
|
||||
return "ok"
|
||||
}
|
||||
|
||||
if public, isBattle := isPublicMatchRegion(payload["rk"]); public {
|
||||
// ev and eb values must be in range 1 to 9999
|
||||
if ev := payload["ev"]; ev != "" {
|
||||
if ev := payload["ev"]; !isBattle && ev != "" {
|
||||
evInt, err := strconv.ParseInt(ev, 10, 16)
|
||||
if err != nil || evInt < 1 || evInt > 9999 {
|
||||
logging.Error(moduleName, "Invalid ev value:", aurora.Cyan(ev))
|
||||
return "invalid_elo"
|
||||
}
|
||||
}
|
||||
|
||||
if eb := payload["eb"]; eb != "" {
|
||||
} else if eb := payload["eb"]; isBattle && eb != "" {
|
||||
ebInt, err := strconv.ParseInt(eb, 10, 16)
|
||||
if err != nil || ebInt < 1 || ebInt > 9999 {
|
||||
logging.Error(moduleName, "Invalid eb value:", aurora.Cyan(eb))
|
||||
|
|
@ -156,6 +158,20 @@ func checkValidRating(moduleName string, payload map[string]string) string {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "ok"
|
||||
}
|
||||
|
||||
func isPublicMatchRegion(rk string) (bool, bool) {
|
||||
if rk == "vs" {
|
||||
return true, false
|
||||
} else if rk == "bt" {
|
||||
return true, true
|
||||
} else if len(rk) == 4 && rk[3] >= '0' && rk[3] < '6' {
|
||||
if strings.HasPrefix(rk, "vs_") {
|
||||
return true, false
|
||||
} else if strings.HasPrefix(rk, "bt_") {
|
||||
return true, true
|
||||
}
|
||||
}
|
||||
return false, false
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user