Skip to content

Commit

Permalink
Database: Limit user ID to signed 32-bit limit
Browse files Browse the repository at this point in the history
  • Loading branch information
mkwcat committed Jan 23, 2024
1 parent 07d8f3d commit 659ec8d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion database/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ func (user *User) UpdateDeviceID(pool *pgxpool.Pool, ctx context.Context, newDev

func GetUniqueUserID() uint64 {
// Not guaranteed unique but doesn't matter in practice if multiple people have the same user ID.
return uint64(rand.Int63n(0x80000000000))
// The maximum size here is 0x80000000000, but older DS games have a bug causing connection issues
// if the user ID is greater than the signed 32-bit limit.
return uint64(rand.Int63n(0x80000000))
}

func (user *User) UpdateProfile(pool *pgxpool.Pool, ctx context.Context, data map[string]string) {
Expand Down

0 comments on commit 659ec8d

Please sign in to comment.