mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-09-28 01:57:12 -05:00
More server list and general changes
- Server browser (Matchmaking) now returns a server list (although hardcoded) - GPCM now keeps track of an actual thread-safe session - Some int types were changed to reflect the actual size - Improvements made to logging in many places
This commit is contained in:
@@ -107,14 +107,14 @@ func LoginUserToGPCM(pool *pgxpool.Pool, ctx context.Context, authToken string)
|
||||
// Create the GPCM account
|
||||
user.CreateUser(pool, ctx)
|
||||
|
||||
logging.Notice("DATABASE", "Created new GPCM user:", aurora.Cyan(strconv.FormatInt(user.UserId, 10)).String(), aurora.Cyan(user.GsbrCode).String(), "-", aurora.Cyan(strconv.FormatInt(user.ProfileId, 10)).String())
|
||||
logging.Notice("DATABASE", "Created new GPCM user:", aurora.Cyan(strconv.FormatInt(user.UserId, 10)).String(), aurora.Cyan(user.GsbrCode).String(), "-", aurora.Cyan(strconv.FormatInt(int64(user.ProfileId), 10)).String())
|
||||
} else {
|
||||
err := pool.QueryRow(ctx, GetUserProfileID, userId, gsbrcd).Scan(&user.ProfileId)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
logging.Notice("DATABASE", "Log in GPCM user:", aurora.Cyan(strconv.FormatInt(user.UserId, 10)).String(), aurora.Cyan(user.GsbrCode).String(), "-", aurora.Cyan(strconv.FormatInt(user.ProfileId, 10)).String())
|
||||
logging.Notice("DATABASE", "Log in GPCM user:", aurora.Cyan(strconv.FormatInt(user.UserId, 10)).String(), aurora.Cyan(user.GsbrCode).String(), "-", aurora.Cyan(strconv.FormatInt(int64(user.ProfileId), 10)).String())
|
||||
}
|
||||
|
||||
return user, true
|
||||
|
||||
@@ -21,7 +21,7 @@ const (
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ProfileId int64
|
||||
ProfileId uint32
|
||||
UserId int64
|
||||
GsbrCode string
|
||||
Password string
|
||||
@@ -53,10 +53,7 @@ func UpdateUser(pool *pgxpool.Pool, ctx context.Context, firstName string, lastN
|
||||
return user
|
||||
}
|
||||
|
||||
func CreateSession(pool *pgxpool.Pool, ctx context.Context, profileId int64, loginTicket string) string {
|
||||
// Delete session first.
|
||||
deleteSession(pool, ctx, profileId)
|
||||
|
||||
func CreateSession(pool *pgxpool.Pool, ctx context.Context, profileId uint32, loginTicket string) string {
|
||||
sessionKey := common.RandomString(8)
|
||||
_, err := pool.Exec(ctx, CreateUserSession, sessionKey, profileId, loginTicket)
|
||||
if err != nil {
|
||||
@@ -66,14 +63,14 @@ func CreateSession(pool *pgxpool.Pool, ctx context.Context, profileId int64, log
|
||||
return sessionKey
|
||||
}
|
||||
|
||||
func deleteSession(pool *pgxpool.Pool, ctx context.Context, profileId int64) {
|
||||
func deleteSession(pool *pgxpool.Pool, ctx context.Context, profileId uint32) {
|
||||
_, err := pool.Exec(ctx, DeleteUserSession, profileId)
|
||||
if err != nil && !errors.Is(err, pgx.ErrNoRows) {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func GetProfile(pool *pgxpool.Pool, ctx context.Context, profileId int64) User {
|
||||
func GetProfile(pool *pgxpool.Pool, ctx context.Context, profileId uint32) User {
|
||||
user := User{}
|
||||
row := pool.QueryRow(ctx, GetUser, profileId)
|
||||
err := row.Scan(&user.UserId, &user.GsbrCode, &user.Password, &user.Email, &user.UniqueNick, &user.FirstName, &user.LastName)
|
||||
|
||||
Reference in New Issue
Block a user