Bugfix: offlevel fixes#806
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses critical bugs related to player disconnection and server state management. By ensuring that players are explicitly removed from the GameContext and improving the client-server handshake during disconnection, the server now maintains accurate online counts and prevents unnecessary reconnection attempts. The PR also includes a wide range of maintenance tasks, including documentation updates, code refactoring, and improved test assertions. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request performs extensive code cleanup, refactoring, and documentation updates across the codebase. Key changes include extracting the ResetProgression struct and AppearanceChangedExtendedPlugIn class into separate files, updating unit tests to use modern NUnit constraint-based assertions, and fixing various XML documentation comments. Additionally, minor logic improvements were introduced, such as explicitly removing disconnected players in OfflinePlayerManager to ensure player list consistency. As there are no review comments provided, we have no feedback to offer.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…nt clean up naturally
… the online list is purged Replace SuppressDisconnectedEvent() in the offline-session handover with a proper close-game logout view call before DisconnectAsync(). Letting the PlayerDisconnected event fire naturally makes GameContext.RemovePlayerAsync run (removing the phantom-online entry), while the close-game packet stops the client from auto-reconnecting. Removes the now-unused Player.SuppressDisconnectedEvent(). Extracted minimal fix from eduardosmaniotto's bugfix/offlevel-reconnect (PR MUnique#806).
|
▎ Heads-up on a data-loss issue I hit with this offline flow: OfflinePlayer attaches the real player's already-tracked Account/Character graph into its own fresh PersistenceContext instead of loading it fresh, which corrupts EF change tracking — so every periodic SaveChangesAsync throws DbUpdateConcurrencyException ("expected 1 row, affected 0") and no offline progress is ever persisted. The result is that the character silently rolls back to its pre-/offlevel state on the next login (also worth disposing the OfflinePlayer on stop, since the connectionless ghost never triggers the game server's disconnect/dispose path). ▎ Fix that worked for me: load the account/character via GetAccountByLoginNameAsync into the offline player's own context (no cross-context Attach), mirroring the normal login. |
|
Heads-up: offline MU Helper hoards non-jewel items when "Pick Jewels" is enabled With "Pick Jewels" on, a /offlevel session fills the inventory with non-jewels — Ale, Devil's Eye/Key/Invitation, Symbol of Kundun and potions. Root cause is in ItemPickupHandler.ShouldPickUp, where the jewel check is item.Definition?.Group == 14: group 14 is "Pots and Misc", not just jewels, so the whole group gets collected. The online MU Helper only picks actual jewels, so the offline behavior diverges and the bag fills up over a long session. Fix hint: match jewels by concrete (group, number) instead of the whole group — Bless (14,13), Soul (14,14), Life (14,16), Creation (14,22), Guardian (14,31), Gemstone (14,41), Harmony (14,42), Lower/Higher refine stone (14,43/44), plus Jewel of Chaos (12,15) which the group-14-only check misses today. |
There was a problem hiding this comment.
Code Review
This pull request refactors the offline player initialization and lifecycle management. Key changes include loading accounts and characters fresh from the database during initialization, replacing the Timer in OfflinePlayerMuHelper with a PeriodicTimer loop, and refining the disconnect and cleanup process. Additionally, jewel pickup logic was improved to target specific jewel IDs, supported by new unit tests. Feedback on these changes highlights a potential ObjectDisposedException during shutdown in the timer loop, a possible NullReferenceException if account.Characters is null, and redundant progress saving during player disconnection.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Closes #804
Phantom online entries
SuppressDisconnectedEvent() nulled all PlayerDisconnected subscribers, including GameContext.RemovePlayerAsync. Since RemovePlayerAsync is the only place that cleans up _playerList PlayerCounter, and PlayersByCharacterName, the real player leaked as a "phantom online" entry that permanently inflated the online count until server restart.
Client not closing gracefully
DisconnectAsync() just dropped the TCP connection without sending a close-game packet, so the client's auto-reconnect feature kicked in and tried to reconnect immediately.
Offlevel jewel pickup
Match jewels by concrete (group, number) instead of broad group-14 check in offline helper. Add test case for this.
Cross-context entity corruption
OfflinePlayer.InitializeAsync received the real player's already-tracked Account/Character references and attached them to a fresh DbContext via Attach. If SaveProgressAsync failed during the handover, entities with non-default GUIDs got Unchanged instead of Added in the new context, causing DbUpdateConcurrencyException on subsequent saves. Fixed by loading the account fresh via GetAccountByLoginNameAsync instead.