Skip to content

Castle Siege Network Packets #731

@sven-n

Description

@sven-n

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 started: byte
CastleSiegeRemainingTime hour: byte, minute: byte
CastleSiegeGateState gateIndex: uint16, state: byte
CastleSiegeGateOperateResponse result: byte, gateIndex: uint16
CastleSiegeGateOperateState gateIndex: uint16, state: byte
CastleSiegeNpcList (C2) result: byte, count: int32, Body[]: { number, index, defenseLevel, regenLevel, maxHp, hp, x, y, live }
CastleSiegeGuildList (C2) result: byte, count: int32, Body[]: { side, involved, guildName[8], score }
CastleSiegeRegisteredGuildList (C2) count: int32, Body[]: { guildName[8], marks, registeredId, isOwner }
CastleSiegeMiniMapPlayerPositions (C2) count: int32, Body[]: { x, y }
CastleSiegeMiniMapNpcPositions (C2) count: int32, Body[]: { npcType, x, y }
CastleSiegeMachineUseResult npcIndex: uint16, x: byte, y: byte
CastleSiegeMachineRegionNotify x: byte, y: byte
CastleSiegeMachineInterface machineType: byte
CastleSiegeLifeStoneState state: byte (creation stage 0–4)
CastleOwnerLogo logoData: byte[32]
HuntingZoneGuardInfo huntEnabled: byte, taxRate: int32
GuildRelationshipChangeResponse result: byte, relationshipType: byte, targetGuildId: uint32
AllianceList (C2) count: byte, Body[]: { guildName[8], memberCount, guildMasterName[10] }

3. Packet Format Notes

  • C1 = small packet (1-byte size), C2 = large packet (2-byte size).
  • PBMSG_HEAD2 = {c=0xC1, size, headcode, subcode} (4 bytes).
  • Multi-byte integers are big-endian unless specified as LittleEndian in the XML.
  • String fields use fixed-length byte arrays, null-terminated.
  • Use IntegerBigEndian or IntegerLittleEndian as appropriate.

Files to Modify

File Changes
Network/Packets/ClientToServer/ClientToServerPackets.xml Verify completeness, add machine packets
Network/Packets/ServerToClient/ServerToClientPackets.xml Add all S→C Castle Siege and Alliance packets

Acceptance Criteria

  • All C→S packets have complete field definitions in the XML.
  • All S→C packets have complete field definitions in the XML.
  • Source generator produces valid C# structs for all new packets.
  • Packet field types, sizes, and endianness match the C++ reference.
  • C2 (large) packets are used for variable-length lists.
  • Fixed-length strings use the correct byte lengths.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions