Skip to content

Commit 2b91d5c

Browse files
committed
Add OpenHost to QR2 Login for use in groups api
1 parent c0f54e5 commit 2b91d5c

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

gpcm/login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ func (g *GameSpySession) login(command common.GameSpyCommand) {
377377
g.ModuleName += "/" + common.CalcFriendCodeString(g.User.ProfileId, g.User.GsbrCode[:4])
378378

379379
// Notify QR2 of the login
380-
qr2.Login(g.User.ProfileId, gamecd, ingamesn, cfc, g.User.GsbrCode[:4], g.RemoteAddr, g.NeedsExploit, g.DeviceAuthenticated, g.User.Restricted)
380+
qr2.Login(g.User.ProfileId, gamecd, ingamesn, cfc, g.User.GsbrCode[:4], g.RemoteAddr, g.NeedsExploit, g.DeviceAuthenticated, g.User.Restricted, g.User.OpenHost)
381381

382382
replyUserId := g.User.UserId
383383
if g.UnitCode == UnitCodeDS {

gpcm/profile.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"wwfc/common"
66
"wwfc/database"
77
"wwfc/logging"
8+
"wwfc/qr2"
89

910
"github.com/logrusorgru/aurora/v3"
1011
)
@@ -89,6 +90,8 @@ func (g *GameSpySession) updateProfile(command common.GameSpyCommand) {
8990
} else if g.User.OpenHost && !enabled {
9091
g.openHostDisabled()
9192
}
93+
94+
qr2.SetLoginOpenHost(g.User.ProfileId, enabled)
9295
}
9396

9497
g.User.UpdateProfile(pool, ctx, command.OtherValues)

qr2/group_info.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type PlayerInfo struct {
2525
VersusELO string `json:"ev,omitempty"`
2626
BattleELO string `json:"eb,omitempty"`
2727
Mii []MiiInfo `json:"mii,omitempty"`
28+
OpenHost string `json:"openhost,omitempty"`
2829
}
2930

3031
type GroupInfo struct {
@@ -109,6 +110,7 @@ func getGroupsRaw(gameNames []string, groupNames []string) []GroupInfo {
109110

110111
if login := session.login; login != nil {
111112
mapData["+ingamesn"] = login.InGameName
113+
mapData["+openhost"] = strconv.FormatBool(login.OpenHost)
112114
} else {
113115
mapData["+ingamesn"] = ""
114116
}
@@ -160,6 +162,7 @@ func GetGroups(gameNames []string, groupNames []string, sorted bool) []GroupInfo
160162
Count: rawPlayer["+localplayers"],
161163
ProfileID: rawPlayer["dwc_pid"],
162164
InGameName: rawPlayer["+ingamesn"],
165+
OpenHost: rawPlayer["+openhost"],
163166
}
164167

165168
pid, err := strconv.ParseUint(rawPlayer["dwc_pid"], 10, 32)

qr2/logins.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import (
44
"encoding/gob"
55
"os"
66
"strconv"
7+
"wwfc/logging"
8+
9+
"github.com/logrusorgru/aurora/v3"
710
)
811

912
type LoginInfo struct {
@@ -16,12 +19,13 @@ type LoginInfo struct {
1619
NeedsExploit bool
1720
DeviceAuthenticated bool
1821
Restricted bool
22+
OpenHost bool
1923
session *Session
2024
}
2125

2226
var logins = map[uint32]*LoginInfo{}
2327

24-
func Login(profileID uint32, gameCode string, inGameName string, consoleFriendCode uint64, fcGame string, publicIP string, needsExploit bool, deviceAuthenticated bool, restricted bool) {
28+
func Login(profileID uint32, gameCode string, inGameName string, consoleFriendCode uint64, fcGame string, publicIP string, needsExploit bool, deviceAuthenticated bool, restricted bool, openHost bool) {
2529
mutex.Lock()
2630
defer mutex.Unlock()
2731

@@ -35,6 +39,7 @@ func Login(profileID uint32, gameCode string, inGameName string, consoleFriendCo
3539
NeedsExploit: needsExploit,
3640
DeviceAuthenticated: deviceAuthenticated,
3741
Restricted: restricted,
42+
OpenHost: openHost,
3843
session: nil,
3944
}
4045
}
@@ -51,6 +56,17 @@ func SetDeviceAuthenticated(profileID uint32) {
5156
}
5257
}
5358

59+
func SetLoginOpenHost(profileID uint32, openHost bool) {
60+
mutex.Lock()
61+
defer mutex.Unlock()
62+
63+
if login, exists := logins[profileID]; exists {
64+
login.OpenHost = openHost
65+
}
66+
67+
logging.Info("QR2", "Updated open host value for login on profileID", aurora.Cyan(profileID), "to", aurora.Cyan(strconv.FormatBool(openHost)))
68+
}
69+
5470
func Logout(profileID uint32) {
5571
mutex.Lock()
5672
defer mutex.Unlock()

0 commit comments

Comments
 (0)