Skip to content

Add Castle Siege ServerToClient packet definitions#736

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/define-castle-siege-packet-structures
Draft

Add Castle Siege ServerToClient packet definitions#736
Copilot wants to merge 4 commits intomasterfrom
copilot/define-castle-siege-packet-structures

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

All C→S Castle Siege packets were already defined; this PR fills the gap by adding all Castle Siege S→C packet definitions to ServerToClientPackets.xml so the XSLT source generator produces the corresponding C# structs.

The guild alliance packets (E5 GuildRelationshipRequest, E6 GuildRelationshipChangeResult, E9 AllianceList, EB-01 RemoveAllianceGuildResult) were added and validated in #737 and are included here via a merge of master.

S→C Packets Added

B2 subcode group (C1HeaderWithSubCode) — direct responses mirror request subcodes:

  • 00–07: Status, Registration, Unregister, RegistrationState, MarkRegistration, DefenseBuy, DefenseRepair, DefenseUpgrade responses
  • 08–10: TaxInfo, TaxChange, TributeWithdraw responses
  • 11–19: JoinSideNotification, GateOperateResponse, CrownStateUpdate, CrownAccessState, SwitchInfo, OwnershipChangeNotification, BattleStartEnd, RemainingTime, GateOperateState

B2 subcode group (C2HeaderWithSubCode) — variable-length list notifications:

  • 1A: CastleSiegeMiniMapPlayerPositions{ x, y }[]
  • 1B: CastleSiegeMiniMapNpcPositions{ npcType, x, y }[]

Other groups:

  • B3-00: CastleSiegeGateState
  • C2-B3-02: CastleSiegeNpcList{ npcNumber, npcIndex, defenseLevel, regenLevel, maxHp, hp, x, y, isAlive }[]
  • C2-B4: CastleSiegeRegisteredGuildList{ guildName, markCount, registrationId, isCastleOwner }[]
  • C2-B5: CastleSiegeGuildList{ side, isInvolved, guildName, score }[]
  • B7-01–03, 05: MachineUseResult, MachineRegionNotify, MachineInterface, LifeStoneState
  • B9-02: CastleOwnerLogo (32-byte binary logo)
  • B9-03: HuntingZoneGuardInfo

Guild Alliance packets (from master / #737, validated by sven-n):

  • E5: GuildRelationshipRequest{ relationshipType, requestType, senderId }
  • E6: GuildRelationshipChangeResult{ relationshipType, requestType, result, guildMasterId } with full result enum
  • C2-E9: AllianceList{ memberCount, logo[32], guildName }[] with success/rival/union count fields
  • EB-01: RemoveAllianceGuildResult{ result, requestType, relationshipType }

Field Layout Conventions Used

  • Multi-byte integers default to big-endian except NPC number/index fields, which use little-endian to match the corresponding C→S request packets
  • Money/treasury fields use LongBigEndian (int64)
  • Fixed-length strings use explicit <Length> matching protocol byte widths
  • C2 packets carry IntegerBigEndian count fields

Generated Artifacts

The XSLT pre-build regenerated ServerToClientPackets.cs, ServerToClientPacketsRef.cs, ConnectionExtensions.cs, and the corresponding docs/Packets/C*-by-server.md files.

Original prompt

This section details on the original issue you should resolve

<issue_title>Castle Siege Network Packets</issue_title>
<issue_description>## Summary

Define all Castle Siege and Guild Alliance network packet structures in the XML packet definition files. These definitions are used by the source generator to produce C# packet structs for both client→server and server→client communication.

Prerequisites

None — this phase is needed incrementally by all other phases. Can be done in parallel.

Background

OpenMU defines packets in XML files:

  • Network/Packets/ClientToServer/ClientToServerPackets.xml
  • Network/Packets/ServerToClient/ServerToClientPackets.xml

The source generator in Network/Packets/MUnique.OpenMU.Network.Packets.csproj reads these XML files and produces C# structs (e.g., CastleSiegeStatusRequest, CastleSiegeRegistrationResponse).

Existing Castle Siege packet documentation in docs/Packets/C1-B2-* provides field layouts.

Requirements

1. Verify/Complete Client→Server Packets

The following packets already exist in ClientToServerPackets.xml — verify they have complete field definitions matching the C++ reference:

Code Name Key Fields
C1-B2-00 CastleSiegeStatusRequest (no fields)
C1-B2-01 CastleSiegeRegistrationRequest (no fields)
C1-B2-02 CastleSiegeUnregisterRequest (no fields)
C1-B2-03 CastleSiegeRegistrationStateRequest (no fields)
C1-B2-04 CastleSiegeMarkRegistration slot: byte (inventory slot)
C1-B2-05 CastleSiegeDefenseBuyRequest npcType: int32, npcId: int32
C1-B2-06 CastleSiegeDefenseRepairRequest npcType: int32, npcId: int32
C1-B2-07 CastleSiegeDefenseUpgradeRequest npcType: int32, npcId: int32, upgradeType: int32
C1-B2-08 CastleSiegeTaxInfoRequest (no fields)
C1-B2-09 CastleSiegeTaxChangeRequest taxType: byte, taxRate: int32 (big-endian)
C1-B2-10 CastleSiegeTaxMoneyWithdraw money: int32 (big-endian)
C1-B2-12 ToggleCastleGateRequest operation: byte, gateIndex: uint16
C1-B2-1D CastleGuildCommand team: byte, x: byte, y: byte, command: byte
C1-B2-1F CastleSiegeHuntingZoneEntranceSetting enabled: byte
C1-B3-01 CastleSiegeGateListRequest (no fields)
C1-B3-02 CastleSiegeStatueListRequest (no fields)
C1-B4 CastleSiegeRegisteredGuildsListRequest (no fields)
C1-B5 CastleOwnerListRequest (no fields)
C1-B9-02 GuildLogoOfCastleOwnerRequest (no fields)
C1-B9-05 CastleSiegeHuntingZoneEnterRequest (no fields)
C1-E6 GuildRelationshipChangeRequest targetGuildId: uint32, relationshipType: byte, requestType: byte
C1-E9 RequestAllianceList (no fields)
C1-EB-01 RemoveAllianceGuildRequest guildName: string

Add if missing:

Code Name Key Fields
C1-B7-?? CastleSiegeMachineUseRequest npcIndex: uint16, targetZone: byte
C1-B7-?? CastleSiegeMachineDamageCallback (impact coordinates, etc.)

2. Define Server→Client Packets

Add full XML definitions for all S→C packets in ServerToClientPackets.xml:

Name Key Fields
CastleSiegeStatusResponse result: byte, state: byte, startYear/Month/Day/Hour/Minute, endYear/Month/Day/Hour/Minute, siegeStartYear/Month/Day/Hour/Minute, guildName: string[8], guildMasterName: string[10], remainTime: int32
CastleSiegeRegistrationResponse result: byte, guildName: string[8]
CastleSiegeUnregisterResponse result: byte
CastleSiegeRegistrationStateResponse guildName: string[8], marks: uint32, registrationId: int32
CastleSiegeMarkRegistrationResponse result: byte, guildName: string[8], marks: uint32
CastleSiegeDefenseBuyResponse result: byte, npcType: int32, npcId: int32
CastleSiegeDefenseRepairResponse result: byte, npcType: int32, npcId: int32
CastleSiegeDefenseUpgradeResponse result: byte, npcType: int32, npcId: int32, upgradeType: int32, upgradeValue: int32
CastleSiegeTaxInfoResponse taxChaos: byte, taxStore: byte, taxHunt: int32, huntAllowed: byte, money: int64
CastleSiegeTaxChangeResponse result: byte, taxType: byte, taxRate: int32
CastleSiegeTributeWithdrawResponse result: byte, money: int64
CastleSiegeJoinSideNotification side: byte
CastleSiegeCrownStateUpdate state: byte (0=locked, 1=available)
CastleSiegeCrownAccessState state: byte, accumulatedTimeMs: uint32
CastleSiegeSwitchInfo switchIndex: uint16, switchId: byte, state: byte, joinSide: byte, guildName: string[9], userName: string[11]
CastleSiegeOwnershipChangeNotification guildName: string[8]
`CastleSiegeBattleStartEnd...

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Copilot AI and others added 2 commits March 24, 2026 22:57
Co-authored-by: sven-n <5238610+sven-n@users.noreply.github.com>
Agent-Logs-Url: https://github.com/MUnique/OpenMU/sessions/e54e4799-894b-41f7-9cb1-9ecf15b0e759
…oClientPackets.xml

Co-authored-by: sven-n <5238610+sven-n@users.noreply.github.com>
Agent-Logs-Url: https://github.com/MUnique/OpenMU/sessions/e54e4799-894b-41f7-9cb1-9ecf15b0e759
Copilot AI changed the title [WIP] Define all Castle Siege and Guild Alliance network packet structures Add Castle Siege & Guild Alliance ServerToClient packet definitions Mar 24, 2026
Copilot AI requested a review from sven-n March 24, 2026 23:05
@sven-n
Copy link
Copy Markdown
Member

sven-n commented Apr 3, 2026

@copilot Please merge the current main into this PR. With #737 the guild alliance packets were added, please take them without changes as I validated their correctness.

- Keep guild alliance packets from master (#737) unchanged (validated by sven-n)
- Remove duplicate E6/E9 packets and global enum definitions added by this branch
- The GuildRelationshipChangeResult (E6), AllianceList (E9), GuildRelationshipRequest (E5),
  and RemoveAllianceGuildResult (EB-01) from master are retained as-is

Co-authored-by: sven-n <5238610+sven-n@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 3, 2026

@copilot Please merge the current main into this PR. With #737 the guild alliance packets were added, please take them without changes as I validated their correctness.

Done in commit 0e8746f6. Merged master into this branch and kept all guild alliance packets from #737 unchanged (GuildRelationshipRequest E5, GuildRelationshipChangeResult E6, AllianceList E9, RemoveAllianceGuildResult EB-01). The duplicate E6/E9 entries and global enum definitions that my branch had added were removed, as master's validated versions supersede them.

Copilot AI changed the title Add Castle Siege & Guild Alliance ServerToClient packet definitions Add Castle Siege ServerToClient packet definitions Apr 3, 2026
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.

Castle Siege Network Packets

2 participants