Skip to content

refactor(lanapi): Make LANMessage accessible in LANAPI#2241

Merged
xezon merged 2 commits intoTheSuperHackers:mainfrom
Caball009:refactor_LANMessage
Feb 3, 2026
Merged

refactor(lanapi): Make LANMessage accessible in LANAPI#2241
xezon merged 2 commits intoTheSuperHackers:mainfrom
Caball009:refactor_LANMessage

Conversation

@Caball009
Copy link

@Caball009 Caball009 commented Feb 2, 2026

This change moves the LANMessage struct before the LANAPI class, so that the former can be used in the latter.

First commit is the move which includes no other changes.

@Caball009 Caball009 added Minor Severity: Minor < Major < Critical < Blocker Network Anything related to network, servers Refactor Edits the code with insignificant behavior changes, is never user facing labels Feb 2, 2026
@greptile-apps
Copy link

greptile-apps bot commented Feb 2, 2026

Greptile Overview

Greptile Summary

Relocated LANMessage struct definition to appear before LANAPI class (line 143-271), enabling potential future use of the complete type within the class definition. Added compile-time size validation with static_assert to ensure LANMessage doesn't exceed MAX_PACKET_SIZE.

  • Moved LANMessage struct from after LANAPI class to before it (pure relocation, no modifications)
  • Added static_assert(sizeof(LANMessage) <= MAX_PACKET_SIZE, ...) for compile-time size validation
  • Forward declaration at line 51 remains intact for interface usage
  • The refactoring maintains binary compatibility and doesn't change struct layout

Confidence Score: 5/5

  • Safe to merge - pure refactoring with no behavioral changes
  • This is a straightforward code reorganization that moves a struct definition to an earlier position in the header file without any modifications to the struct itself. The addition of a static_assert provides compile-time safety guarantees.
  • No files require special attention

Important Files Changed

Filename Overview
Core/GameEngine/Include/GameNetwork/LANAPI.h Moved LANMessage struct before LANAPI class and added static_assert for size validation

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Header as LANAPI.h
    participant Compiler as C++ Compiler
    
    Note over Dev,Header: Before: LANMessage defined after LANAPI class
    Dev->>Header: Move LANMessage struct definition
    Note over Header: LANMessage now defined before LANAPI class
    Dev->>Header: Add static_assert for size validation
    Note over Header: static_assert(sizeof(LANMessage) <= MAX_PACKET_SIZE)
    
    Dev->>Compiler: Compile code
    Note over Compiler: LANMessage fully defined when LANAPI class is parsed
    Note over Compiler: static_assert validates LANMessage size at compile time
    Compiler-->>Dev: Compilation successful
Loading

@Mauller
Copy link

Mauller commented Feb 2, 2026

Maybe put the struct at the beggining where the forward declaration is currently placed? but after all the static variables.

@Caball009
Copy link
Author

Caball009 commented Feb 2, 2026

Maybe put the struct at the beggining where the forward declaration is currently placed? but after all the static variables.

LANMessage::GameNotJoined and LANMessage::Chat use LANAPIInterface::, though. So there has to be a forward declaration of either class.

@Mauller
Copy link

Mauller commented Feb 2, 2026

Maybe put the struct at the beggining where the forward declaration is currently placed? but after all the static variables.

LANMessage::GameNotJoined and LANMessage::Chat use LANAPIInterface::, though. So there has to be a forward declaration of either class.

Ah that's fair, i didn;t notice that.

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

Looking good

@xezon xezon merged commit 794c633 into TheSuperHackers:main Feb 3, 2026
85 of 91 checks passed
@Caball009 Caball009 deleted the refactor_LANMessage branch February 3, 2026 19:24
githubawn pushed a commit to githubawn/GeneralsGameCode that referenced this pull request Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Minor Severity: Minor < Major < Critical < Blocker Network Anything related to network, servers Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants