Fix client side for resets in character details#402
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 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
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 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.
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.
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.
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.
Releated to last commits in MUnique/OpenMU#775