Skip to content

Commit 584601e

Browse files
committed
Modify region normalization logic
Fixes an issue with RR's "Start WW from Froom" feature, where public lobbies started from a friend room did not show the rk region on the API.
1 parent 4341293 commit 584601e

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

qr2/group.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ type Group struct {
3333

3434
var groups = map[string]*Group{}
3535

36+
func normalizeMKWRegion(rk string) string {
37+
// Check and remove regional searches due to the limited player count
38+
// China (ID 6) gets a pass because it was never released
39+
if len(rk) == 4 && (strings.HasPrefix(rk, "vs_") || strings.HasPrefix(rk, "bt_")) && rk[3] >= '0' && rk[3] < '6' {
40+
return rk[:2]
41+
}
42+
43+
return rk
44+
}
45+
3646
func processResvOK(moduleName string, matchVersion int, reservation common.MatchCommandDataReservation, resvOK common.MatchCommandDataResvOK, sender, destination *Session) bool {
3747
if len(groups) >= 100000 {
3848
logging.Error(moduleName, "Hit arbitrary global maximum group count (somehow)")
@@ -64,15 +74,7 @@ func processResvOK(moduleName string, matchVersion int, reservation common.Match
6474
}
6575

6676
if group.GameName == "mariokartwii" {
67-
rk := sender.Data["rk"]
68-
69-
// Check and remove regional searches due to the limited player count
70-
// China (ID 6) gets a pass because it was never released
71-
if len(rk) == 4 && (strings.HasPrefix(rk, "vs_") || strings.HasPrefix(rk, "bt_")) && rk[3] >= '0' && rk[3] < '6' {
72-
rk = rk[:2]
73-
}
74-
75-
group.MKWRegion = rk
77+
group.MKWRegion = normalizeMKWRegion(sender.Data["rk"])
7678
}
7779

7880
sender.Data["+joinindex"] = "0"

qr2/group_info.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ func getGroupsRaw(gameNames []string, groupNames []string) []GroupInfo {
152152
}
153153
}
154154

155+
if groupInfo.GameName == "mariokartwii" {
156+
region := normalizeMKWRegion(groupInfo.PlayersRaw[groupInfo.SortedJoinIndex[0]]["rk"])
157+
158+
group.MKWRegion = region
159+
groupInfo.MKWRegion = region
160+
}
161+
155162
groupsCopy = append(groupsCopy, groupInfo)
156163
}
157164

0 commit comments

Comments
 (0)