Repository navigation
fix: keep the XP tracker's player id tied to the name it was checked against - #38
Merged
Merged
Conversation
…against A failed profile read handed back whatever id was cached for the account, even when the read was for a different username. After a Ranking username change with the fetch failing, the tracker stored the old login's player id under the new name and offered that pair to the leaderboard. The cached id is still the one tried first, since an id survives an in-game rename, but a failed read now only falls back on the last good read when it was made under the same username. A failed first read also cleared an explicitly linked player id for the rest of the session, so a player outside the top 200 stopped being tracked. A failed read can now supply a missing id but never clears or replaces one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two pre-existing defects in how the XP tracker resolves a player id. Both were found by code reading; each is now reproduced by a test that failed on
mainbefore the fix.1. A failed read reported an id cached for a different username
PlayerProfileServicecaches the last good(player id, snapshot)per account.Failure(...)returned that entry no matter which username the failed read was for.Reproduced: track an account as
Login(id 7), change it toRanked, and have the fetch fail.GetActiveLeaderboardProfiles()returned(account, 7, "Ranked").Fix: a failed read only falls back on the last good read when that read was made under the same username (case-insensitive).
The cached id is still the first one tried under the new name. A player's id survives an in-game rename, so it may well still be right. It just is not reported until a read confirms it.
2. A failed first read discarded a linked player id
In
XpTrackerCoordinator.PollAccountAsync, the generic failure branch didaccount.PlayerId = result.PlayerId. With nothing cached that isnull, so an id passed toStart(...)was gone for the session.Reproduced: link id 42 for a player outside the top 200, fail the first read, then let reads succeed. The tracker fell through to the ranking lookup and never got a snapshot.
Fix:
account.PlayerId ??= result.PlayerId. A failed read can supply an id the account lacks, but never clears or replaces one.Also changed
XpTrackerCoordinator.ProfileRetryDelay(internal, default still 5 s). Every failed first read waits 5 s before its one retry, so without this the two tests add 10 s to a suite that runs in under a second.Not changed
MainWindow.PublicPlayerId/PublicInGameName.Tests
dotnet test src/FourFoldAccountManager.Desktop.Tests: 30 passed.dotnet test src/FourFoldAccountManager.Core.Tests: 309 passed.Each new test was also checked against its own fix: undoing either fix alone fails exactly one of them.
Merging publishes a client release, since this touches
src/.