Skip to content

Bugfix: offlevel reconnect and player count#806

Draft
eduardosmaniotto wants to merge 14 commits into
MUnique:masterfrom
eduardosmaniotto:bugfix/offlevel-reconnect
Draft

Bugfix: offlevel reconnect and player count#806
eduardosmaniotto wants to merge 14 commits into
MUnique:masterfrom
eduardosmaniotto:bugfix/offlevel-reconnect

Conversation

@eduardosmaniotto

Copy link
Copy Markdown
Contributor

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.

@eduardosmaniotto eduardosmaniotto marked this pull request as draft June 18, 2026 01:44
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, 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

  • Phantom Online Entries: Fixed an issue where players were not correctly removed from the GameContext, causing phantom entries and inflated online counts.
  • Graceful Disconnection: Updated the disconnection process to send a close-game packet, preventing clients from entering an infinite auto-reconnect loop.
  • Code Refactoring and Cleanup: Performed extensive refactoring of the Player experience logic, improved documentation across various modules, and cleaned up unused code and imports.
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 Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

nolt added a commit to nolt/OpenMU that referenced this pull request Jun 19, 2026
… 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).
@nolt

nolt commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

▎ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command /offlevel leaks the real player from the player list: online count stays inflated ("phantom online") after offline leveling starts

2 participants