Game Server Protocol - kukfa/mmoserver GitHub Wiki

This page is an overview of the custom protocol used to communicate with the game server. Documentation for the actual use cases of these packets (e.g. character selection, zone loading...) can be found on other pages.

Packet structure

So far, there are 4 different structures used to send a packet. 3 of these involve compressing the packet data with Zlib at the default compression level.

Note: there is still some uncertainty in the packet structures -- these are actively being reverse engineered, and are subject to change.

Zlib Packet 1

ZlibPacket1 packets are structured as follows:

  1. [1] Packet type
  2. [3] DFCMessage destination address
  3. [4] Compressed size of packet data + 12 (little-endian)
  4. [3] DFCMessage source address
  5. [5] ??
  6. [4] Uncompressed size of packet data (little-endian)
  7. [Variable] Zlib-compressed packet data

Zlib Packet 2

ZlibPacket2 packets are structured as follows:

  1. [1] Packet type
  2. [3] Unknown data
  3. [4] Compressed size of packet data + 4 (little-endian)
  4. [Variable] Zlib-compressed packet data
  5. [4] Uncompressed size of packet data (little-endian)

Zlib Packet 3

ZlibPacket3 packets are structured as follows:

  1. [1] Packet type
  2. [3] DFCMessage destination address
  3. [4] Compressed size of packet data + 7 (little-endian)
  4. [3] DFCMessage source address
  5. [4] Uncompressed size of packet data (little-endian)
  6. [Variable] Zlib-compressed packet data

Uncompressed

This packet format does not use compression, and is structured as follows:

  1. [1] Packet type
  2. [3] DFCMessage destination address
  3. [4] Length of data (little-endian)
  4. [Variable] Packet data

Packet Types

The following packet types are used in the game client. So far, it appears that each packet type uses a specific packet structure.

  • Type 01
    • Uses structure: TODO
  • Type 02
    • Uses uncompressed structure
  • Type 04
    • Uses uncompressed structure
  • Type 06
    • Uses uncompressed structure
  • Type 08
    • Uses Zlib Packet 1
  • Type 0a
    • Uses Zlib Packet 3
  • Type 0c
    • Uses Zlib Packet 2
  • Type 0e
    • Uses Zlib Packet 1
  • Type 10
    • Uses uncompressed structure
  • Type 12
    • Uses Zlib Packet 2
  • Type 14
    • Uses Zlib Packet 2
  • Type 16
    • Uses Zlib Packet 2
  • Type 18
    • Uses Zlib Packet 1
  • Type 1a
    • Uses Zlib Packet 3

Channel Types

Packets use a 1-byte Channel Type to identify which 'component' of the server they are communicating with. This Channel Type is the first byte within the packet data (i.e. the portion called "packet data" in the packet structures above). Each Channel performs a specific role in the game, which collectively allow the game to function. These Channels and the role they perform are as follows:

  • UserManagerClient
    • Friends list
  • CharacterManagerClient
    • Sending, creating, and deleting characters
  • ChatClient
    • In-game chat
  • ClientEntityManager
    • Synchronizing game entities from server to client
  • GroupClient
    • Creating, managing, and disbanding groups/parties
  • TradeClient
    • In-game trade
  • ZoneClient
    • Loading in and out of zones
  • PosseClient
    • Creating, managing, and disbanding posses/guilds

Each Channel has associated processing functions, which perform different tasks for that Channel by processing the incoming packet data. These processing functions also use a 1-byte identifier to determine which processing function should be used to process the packet data. This processing function identifier is located directly after the Channel Type identifier in the packet data.

The Channel Types (and their 1-byte identifiers) are as follows, with their associated processing functions (and 1-byte identifiers) nested underneath:

  • 03: UserManagerClient
    • Followed by 00: Connected
    • Followed by 01: Rosters
    • Followed by 02: AddContact
    • Followed by 03: RemoveContact
    • Followed by 04: AddIgnore
    • Followed by 05: RemoveIgnore
    • Followed by 06: RosterNotify
    • Followed by 07: RosterPropertyChanged
    • Followed by 08: RostersWritable
    • Followed by 09: Users
    • Followed by 0A: UserListEvent
    • Followed by 0B: FriendsPublicity
  • 04: CharacterManagerClient
    • Followed by 00: Connected
    • Followed by 01: Disconnected
    • Followed by 02: CharacterCreated
    • Followed by 03: GotCharacter
    • Followed by 04: Character Creation
    • Followed by 05: Select Character
  • 06: ChatClient
    • TODO
  • 07: ClientEntityManager
    • Followed by 01: EntityCreate
    • Followed by 02: EntityInit
    • Followed by 03: EntityUpdate
    • Followed by 05: EntityRemove
    • Followed by 06: End packet
    • Followed by 07: Error?
    • Followed by 08: EntityCreateInit
    • Followed by 0c: RandomSeed
    • Followed by 0d: Interval
    • Followed by 14: Reset
    • Followed by 15: ClearEntityManager
    • Followed by 1e: ClearSubEntities
    • Followed by 1f: InitSubEntities
    • Followed by 20: InitSubEntity
    • Followed by 32: ComponentCreate
    • Followed by 33: ComponentInit
    • Followed by 35: ComponentUpdate
    • Followed by 36: UpdateComponent
    • Followed by 46: Connected
  • 09: GroupClient
    • Followed by 30: Connected
    • Followed by 32: Invitation
    • Followed by 33: Unvitation
    • Followed by 34: InviteResult
    • Followed by 35: UserChangedGroup
    • Followed by 42: AddUser
    • Followed by 43: RemoveUser
    • Followed by 44: SetLeader
    • Followed by 45: ChangedUserLevel
    • Followed by 47: ChangedDesiredPublicity
    • Followed by 48: ChangedFindMode
    • Followed by 49: MemberDisconnected
    • Followed by 4A: MemberReconnected
    • Followed by 4B: MemberHealthManaChange
    • Followed by 4C: UserChangedZone
    • Followed by 4D: ChangedInviteMode
    • Followed by 4E: ChangedPVPStatus
    • Followed by 4F: ReadPVPDuelStatus
    • Followed by 50: JoinTalkbackGroup
    • Followed by 51: EnterPVPZoneBailed
    • Followed by 52: EnterPVPQueueYellow
    • Followed by 53: AutoJoinError
    • Followed by 54: EnterPVPQueueDisconnected
    • Followed by 55: MonsterDifficultySet
    • Followed by 56: Error (can't goto player)
    • Followed by 57: Nothing
  • 0a: TradeClient
    • TODO
  • 0d: ZoneClient
    • Followed by 00: Connected
    • Followed by 01: Ready
    • Followed by 02: Disconnected
    • Followed by 05: InstanceCount
  • 0f: PosseClient
    • TODO

Initial Packet Sequence

[Sender] [PacketType] Packet data

  1. (Client connects to game server)
  2. [C] [0a] 01 + first 4 bytes of session key + 00
  3. [S] [0a] 03
    • Authorizes the client's connection to the gameserver
    • DFC Message source address is 0.03 (0x000300)
  4. [S] [0a] (3 byte DFC Message Address)
    • Connects the client's DFCMessageClient and assigns the client a DFC Message Address
    • DFC Message source address is 0.03 (0x000300)
  5. At this point, components on the client and server can start communicating via Channels. See Use Cases