refactor(netpacket): Simplify initialization of net packet field types#2288
Merged
xezon merged 2 commits intoTheSuperHackers:mainfrom Feb 13, 2026
Merged
Conversation
Greptile Overview
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Include/GameNetwork/NetPacketStructs.h | Reordered field type constants to match struct usage order and renamed header to fieldType in all structs; added constructors to initialize field types |
| Core/GameEngine/Source/GameNetwork/NetPacket.cpp | Replaced reinterpret_cast with placement new to leverage struct constructors for automatic field type initialization, removing manual header assignments |
Sequence Diagram
sequenceDiagram
participant Caller
participant NetPacket
participant Buffer as UnsignedByte* buffer
participant Struct as NetPacket*Command
Caller->>NetPacket: FillBufferWithXXXCommand(buffer, msg)
Note over NetPacket: Extract command data from msg
NetPacket->>Buffer: new (buffer) NetPacketXXXCommand
Note over Buffer,Struct: Placement new constructs object at buffer location
Struct-->>NetPacket: packet pointer
Note over Struct: Constructor auto-initializes fieldType
NetPacket->>Struct: packet->commandType.commandType = value
NetPacket->>Struct: packet->frame.frame = value
NetPacket->>Struct: packet->relay.relay = value
NetPacket->>Struct: packet->playerId.playerId = value
Note over Struct: Other fields explicitly assigned
NetPacket-->>Caller: Buffer filled with serialized packet
Last reviewed commit: a0b6d3f
Mauller
reviewed
Feb 12, 2026
9e33c4f to
a0b6d3f
Compare
Mauller
approved these changes
Feb 13, 2026
Mauller
left a comment
There was a problem hiding this comment.
Looks good, just needs that followup
Author
xezon
added a commit
that referenced
this pull request
Feb 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge with Rebase
This change has 2 commits:
Streamlines the order of the net packet fields for easier reading
Simplifies the initialization of the net packet field types by using constructor initialization and the placement new operator
TODO
Fix undefined behavior