Skip to content

Templatize D2GSPacketSrvStatAndGuid for correct packet sizes - #221

Open
AudriusButkevicius wants to merge 1 commit into
ThePhrozenKeep:masterfrom
AudriusButkevicius:fix/172-packet-struct-template
Open

Templatize D2GSPacketSrvStatAndGuid for correct packet sizes#221
AudriusButkevicius wants to merge 1 commit into
ThePhrozenKeep:masterfrom
AudriusButkevicius:fix/172-packet-struct-template

Conversation

@AudriusButkevicius

Copy link
Copy Markdown
Contributor

Summary

  • Templatizes D2GSPacketSrvStatAndGuid so each packet variant has the correct value field width:
    • 9E, A1: uint8_t (7 bytes)
    • 9F, A2: uint16_t (8 bytes)
    • A0: uint32_t (10 bytes)
  • Previously all 5 aliases pointed to the same struct with uint8_t nValue, causing value truncation for 16-bit and 32-bit packets
  • Enables sizeof() for packet sizes in Server.cpp (previously hard-coded with sizeof commented out)

Fixes #172

Note: This PR was produced using Claude Code based on the upstream issue description. The change has not been compiled or tested, as the project requires a Windows build environment which was not available. Please review carefully before merging.

The packet struct was shared across all 5 packet types (9E/9F/A0/A1/A2)
with a uint8_t value field, causing truncation for 16-bit and 32-bit
variants. Now uses a template parameter for the value type:
- 9E, A1: uint8_t (7 bytes)
- 9F, A2: uint16_t (8 bytes)
- A0: uint32_t (10 bytes)

Also enables sizeof() for packet sizes in Server.cpp.

Fixes ThePhrozenKeep#172
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.

D2GAME_PACKETS_SendPacket0xA0_A1_A2_6FC3D610 Uses Incorrect Packets

3 participants