Skip to content

Conversation

@bobtista
Copy link

@bobtista bobtista commented Oct 23, 2025

  • Added NetPacketStructs.h, which introduces packed struct definitions for all 25 network command message types
  • Implemented getPackedByteCount() Interface
  • Eliminated manual size calculations in NetPacket.cpp
  • Updated ConnectionManager to use specific command message classes directly instead of generic NetCommandMsg

Add packed struct definitions for all 25 network command message types
to enable compile-time size validation and cleaner serialization code.

Each struct corresponds to a NetCommandMsg subclass and defines the
exact binary layout of that message type on the wire.
…classes

Add virtual getPackedByteCount() method to NetCommandMsg base class and
implement it in all 25 derived classes to return compile-time packet sizes.

Changes to NetCommandMsg.h:
- Add pure virtual getPackedByteCount() method to base class
- Add NetLoadCompleteCommandMsg class
- Add NetTimeOutGameStartCommandMsg class
- Restore EA comment dividers and documentation comments

Changes to NetCommandMsg.cpp:
- Implement getPackedByteCount() for all 25 NetCommandMsg subclasses
- Each returns sizeof() the corresponding packed struct

This provides a polymorphic interface for getting packet sizes and
eliminates the need for manual size calculations.
Refactor NetPacket.cpp to use the new getPackedByteCount() polymorphic
interface instead of manual size calculations.

Changes:
- Replace large switch statement in GetGameCommandSize() with single
  call to msg->getPackedByteCount()
- Simplify size calculations throughout by using getPackedByteCount()
- Replace C-style casts with static_cast for type safety
- Remove redundant manual size computations
Update ConnectionManager to instantiate specific NetCommandMsg subclasses
directly instead of creating generic NetCommandMsg and setting the type.

Changes:
- Use NetLoadCompleteCommandMsg in loadProgressComplete()
- Use NetTimeOutGameStartCommandMsg in sendTimeOutGameStart()
- Remove manual setNetCommandType() calls (type set in constructor)

Applied to both Generals and Zero Hour
@bobtista bobtista force-pushed the bobtista/network-refactor branch from f5b9a5e to b413c2f Compare October 23, 2025 20:02
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.

1 participant