Skip to content

Fix client side for resets in character details#402

Merged
sven-n merged 1 commit into
sven-n:mainfrom
nolt:fix-resets-dword-word
May 20, 2026
Merged

Fix client side for resets in character details#402
sven-n merged 1 commit into
sven-n:mainfrom
nolt:fix-resets-dword-word

Conversation

@nolt
Copy link
Copy Markdown
Contributor

@nolt nolt commented May 20, 2026

Releated to last commits in MUnique/OpenMU#775

@gemini-code-assist
Copy link
Copy Markdown
Contributor

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 updates the network packet structure for character resets to ensure compatibility with recent server-side changes. It adjusts the data types within the packet definition to align with the expected protocol format.

Highlights

  • Packet Structure Adjustment: Updated the PRECEIVE_JOIN_MAP_SERVER_EXTENDED struct to correctly map the Resets field by replacing a DWORD with a BYTE for padding and a WORD for the reset count.
  • Memory Alignment Cleanup: Removed redundant #pragma pack directives surrounding the struct definition to simplify the code.
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.

Copy link
Copy Markdown
Contributor

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

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 updates the PRECEIVE_JOIN_MAP_SERVER_EXTENDED structure in src/source/Network/Server/WSclient.h by changing the Resets field from a DWORD to a WORD and introducing a BYTE spare field. Additionally, the #pragma pack directives have been removed from the struct definitions. I have no further feedback to provide.

@sven-n sven-n merged commit b3bea5c into sven-n:main May 20, 2026
2 checks passed
@nolt nolt deleted the fix-resets-dword-word branch May 20, 2026 16:46
Mosch0512 added a commit to Mosch0512/MuMain that referenced this pull request May 22, 2026
Replace the three hand-typed static_asserts with a generated header
sourced from OpenMU's authoritative packet schema. Same protection
against the PR sven-n#402 class of bug, but maintained automatically.

Pieces:
- third_party/OpenMU: git submodule pinned to 1a56f6dd5.
- tools/gen_wire_sizes.py: parses ServerToClientPackets.xml, joins
  against a hand-maintained packet-name mapping, emits
  wire_sizes.generated.h with one static_assert(sizeof(X) <= N) per
  mapped packet. The mapping is currently the three structs PR #66
  covered by hand -- adding more is a one-line append.
- src/CMakeLists.txt: add_custom_command runs the generator when the
  XML changes; output goes to ${CMAKE_BINARY_DIR}/generated/, which
  is added to the include path. Main depends on GenWireSizes.
- src/source/Network/Server/WSclient.h: drop the three hand-written
  asserts; #include the generated header at end-of-file.

We assert `<=` rather than `==` because some client structs
intentionally don't decode all trailing fields (e.g. PRECEIVE_CREATE_
CHARACTER doesn't decode PreviewData, so its sizeof is 19 vs the wire
length 42). The actual safety property is "client struct must fit in
wire packet so safe_cast succeeds," which `<=` expresses correctly.

To add coverage for another packet: append a tuple to PACKET_MAPPING
in tools/gen_wire_sizes.py and rebuild.
Mosch0512 added a commit to Mosch0512/MuMain that referenced this pull request May 23, 2026
Adds two defenses for the bug class behind PR sven-n#402 / fixed by sven-n#404:

1. static_assert(sizeof == N) on PRECEIVE_CREATE_CHARACTER (19),
   PRECEIVE_JOIN_MAP_SERVER_EXTENDED (92), and PRECEIVE_REVIVAL_EXTENDED
   (36). If the #pragma pack(push, 1) ever gets dropped or a field is
   added/reordered, the build now breaks at the offending struct with a
   pointer to check the pragma. Wire sizes match OpenMU's XML schema
   (CharacterInformationExtended, RespawnAfterDeathExtended).

2. Named overload safe_cast<T>(span, "TYPE_NAME") that logs an MCD_ERROR
   with packet type + received vs expected size on failure. Used at the
   join-map receive site. The dispatcher also logs the user-visible
   symptom ("loading screen will appear frozen") so a future drift turns
   a silent freeze into a one-line console diagnostic.
Mosch0512 added a commit to Mosch0512/MuMain that referenced this pull request May 23, 2026
Replace the three hand-typed static_asserts with a generated header
sourced from OpenMU's authoritative packet schema. Same protection
against the PR sven-n#402 class of bug, but maintained automatically.

Pieces:
- third_party/OpenMU: git submodule pinned to 1a56f6dd5.
- tools/gen_wire_sizes.py: parses ServerToClientPackets.xml, joins
  against a hand-maintained packet-name mapping, emits
  wire_sizes.generated.h with one static_assert(sizeof(X) <= N) per
  mapped packet. The mapping is currently the three structs PR #66
  covered by hand -- adding more is a one-line append.
- src/CMakeLists.txt: add_custom_command runs the generator when the
  XML changes; output goes to ${CMAKE_BINARY_DIR}/generated/, which
  is added to the include path. Main depends on GenWireSizes.
- src/source/Network/Server/WSclient.h: drop the three hand-written
  asserts; #include the generated header at end-of-file.

We assert `<=` rather than `==` because some client structs
intentionally don't decode all trailing fields (e.g. PRECEIVE_CREATE_
CHARACTER doesn't decode PreviewData, so its sizeof is 19 vs the wire
length 42). The actual safety property is "client struct must fit in
wire packet so safe_cast succeeds," which `<=` expresses correctly.

To add coverage for another packet: append a tuple to PACKET_MAPPING
in tools/gen_wire_sizes.py and rebuild.
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.

2 participants