Add OpenHost to QR2 Login for use in groups api

This commit is contained in:
ppeb 2025-04-08 03:03:15 -05:00
parent c0f54e554a
commit 2b91d5c103
No known key found for this signature in database
GPG Key ID: CC147AD1B3D318D0
4 changed files with 24 additions and 2 deletions

View File

@ -377,7 +377,7 @@ func (g *GameSpySession) login(command common.GameSpyCommand) {
g.ModuleName += "/" + common.CalcFriendCodeString(g.User.ProfileId, g.User.GsbrCode[:4])
// Notify QR2 of the login
qr2.Login(g.User.ProfileId, gamecd, ingamesn, cfc, g.User.GsbrCode[:4], g.RemoteAddr, g.NeedsExploit, g.DeviceAuthenticated, g.User.Restricted)
qr2.Login(g.User.ProfileId, gamecd, ingamesn, cfc, g.User.GsbrCode[:4], g.RemoteAddr, g.NeedsExploit, g.DeviceAuthenticated, g.User.Restricted, g.User.OpenHost)
replyUserId := g.User.UserId
if g.UnitCode == UnitCodeDS {

View File

@ -5,6 +5,7 @@ import (
"wwfc/common"
"wwfc/database"
"wwfc/logging"
"wwfc/qr2"
"github.com/logrusorgru/aurora/v3"
)
@ -89,6 +90,8 @@ func (g *GameSpySession) updateProfile(command common.GameSpyCommand) {
} else if g.User.OpenHost && !enabled {
g.openHostDisabled()
}
qr2.SetLoginOpenHost(g.User.ProfileId, enabled)
}
g.User.UpdateProfile(pool, ctx, command.OtherValues)

View File

@ -25,6 +25,7 @@ type PlayerInfo struct {
VersusELO string `json:"ev,omitempty"`
BattleELO string `json:"eb,omitempty"`
Mii []MiiInfo `json:"mii,omitempty"`
OpenHost string `json:"openhost,omitempty"`
}
type GroupInfo struct {
@ -109,6 +110,7 @@ func getGroupsRaw(gameNames []string, groupNames []string) []GroupInfo {
if login := session.login; login != nil {
mapData["+ingamesn"] = login.InGameName
mapData["+openhost"] = strconv.FormatBool(login.OpenHost)
} else {
mapData["+ingamesn"] = ""
}
@ -160,6 +162,7 @@ func GetGroups(gameNames []string, groupNames []string, sorted bool) []GroupInfo
Count: rawPlayer["+localplayers"],
ProfileID: rawPlayer["dwc_pid"],
InGameName: rawPlayer["+ingamesn"],
OpenHost: rawPlayer["+openhost"],
}
pid, err := strconv.ParseUint(rawPlayer["dwc_pid"], 10, 32)

View File

@ -4,6 +4,9 @@ import (
"encoding/gob"
"os"
"strconv"
"wwfc/logging"
"github.com/logrusorgru/aurora/v3"
)
type LoginInfo struct {
@ -16,12 +19,13 @@ type LoginInfo struct {
NeedsExploit bool
DeviceAuthenticated bool
Restricted bool
OpenHost bool
session *Session
}
var logins = map[uint32]*LoginInfo{}
func Login(profileID uint32, gameCode string, inGameName string, consoleFriendCode uint64, fcGame string, publicIP string, needsExploit bool, deviceAuthenticated bool, restricted bool) {
func Login(profileID uint32, gameCode string, inGameName string, consoleFriendCode uint64, fcGame string, publicIP string, needsExploit bool, deviceAuthenticated bool, restricted bool, openHost bool) {
mutex.Lock()
defer mutex.Unlock()
@ -35,6 +39,7 @@ func Login(profileID uint32, gameCode string, inGameName string, consoleFriendCo
NeedsExploit: needsExploit,
DeviceAuthenticated: deviceAuthenticated,
Restricted: restricted,
OpenHost: openHost,
session: nil,
}
}
@ -51,6 +56,17 @@ func SetDeviceAuthenticated(profileID uint32) {
}
}
func SetLoginOpenHost(profileID uint32, openHost bool) {
mutex.Lock()
defer mutex.Unlock()
if login, exists := logins[profileID]; exists {
login.OpenHost = openHost
}
logging.Info("QR2", "Updated open host value for login on profileID", aurora.Cyan(profileID), "to", aurora.Cyan(strconv.FormatBool(openHost)))
}
func Logout(profileID uint32) {
mutex.Lock()
defer mutex.Unlock()