packet_struct_notation.txt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //===== rAthena Documentation ================================
  2. //= Packet Structure Notation
  3. //===== By: ==================================================
  4. //= Ai4rei
  5. //===== Last Updated: ========================================
  6. //= 20120810
  7. //===== Description: =========================================
  8. //= Explanation how packets are and should be documented.
  9. //============================================================
  10. This document specifies how packets are and should be documented, to
  11. keep packet structure comments consistent in the entire codebase. It
  12. also serves as a guide to those, who are unfamiliar with the general
  13. packet layout.
  14. All mentioned data types are assumed to be little-endian (least-
  15. significant byte first, least significant bit last) and of same size
  16. regardless of architecture.
  17. = Typical description of a packet =
  18. /// Notifies the client about entering a chatroom (ZC_ENTER_ROOM).
  19. /// 00db <packet len>.W <chat id>.L { <role>.L <name>.24B }*
  20. /// role:
  21. /// 0 = owner (menu)
  22. /// 1 = normal
  23. The first line contains a brief description of what the packet does,
  24. or what it is good for, followed by it's AEGIS name in parentheses;
  25. first two letters of the AEGIS name specify origin (first letter)
  26. and destination (second letter) of the packet. If the packet's name
  27. is not known or is not applicable (rAthena server-server packets),
  28. specify at least these two letters to indicate the direction of the
  29. packet. Do not use S(end)/R(ecv) for this, as it is inaccurate and
  30. location dependent (if the description is copied to different server
  31. or other RO-related projects, it might change it's meaning).
  32. If there are multiple versions of the packet, the AEGIS name is
  33. appended to the end of the packet's structure instead. If the name
  34. did not change between versions, a PACKETVER expression is appended,
  35. such as (PACKETVER >= 20111111).
  36. Second line describes the packet's field structure, beginning with a
  37. %04x formatted packet type, followed by the individual fields and
  38. their types. Each field begins with it's name enclosed in angle
  39. brackets ( <field name> ) followed by a dot and the data size type.
  40. Field names should be lower-case and without underscores. If other
  41. packets already have a field in common, use that name, rather than
  42. inventing your own (ex. "packet len" and "account id"). Repeated and
  43. optional fields are designated with curly and square brackets
  44. respectively, padded with a single space at each side.
  45. Further lines are optional and either include details about the
  46. the packet's mechanics or further explanation on the packet fields'
  47. values.
  48. = Packet field data size type =
  49. B = 1 byte (byte)
  50. W = 2 bytes (word)
  51. L = 4 bytes (long, dword)
  52. F = 4 bytes (float)
  53. Q = 8 bytes (quad)
  54. nB = n bytes
  55. ?B = variable/unknown amount of bytes
  56. nS = n bytes, zero-terminated
  57. ?S = variable/unknown amount of bytes, zero-terminated
  58. = Repetition of packet fields =
  59. {} = repeated block
  60. {}* = variable/unknown amount of consecutive blocks
  61. {}*n = n times repeated block
  62. [] = optional fields
  63. = Packet origin and destination letters =
  64. A = Account (Login)
  65. C = Client
  66. H = Character
  67. I = Inter
  68. S = Server (any type of server)
  69. Z = Zone (Map)
  70. = Examples =
  71. Packet with nested repetition blocks:
  72. /// Presents a textual list of producable items (ZC_MAKABLEITEMLIST).
  73. /// 018d <packet len>.W { <name id>.W { <material id>.W }*3 }*
  74. /// material id:
  75. /// unused by the client
  76. Packet with multiple versions identified with different AEGIS names:
  77. /// Request for server's tick.
  78. /// 007e <client tick>.L (CZ_REQUEST_TIME)
  79. /// 0360 <client tick>.L (CZ_REQUEST_TIME2)
  80. Packet with multiple versions identified with same AEGIS name:
  81. /// Cashshop Buy Ack (ZC_PC_CASH_POINT_UPDATE).
  82. /// 0289 <cash point>.L <error>.W
  83. /// 0289 <cash point>.L <kafra point>.L <error>.W (PACKETVER >= 20070711)
  84. Packet with combination of both different AEGIS names and different
  85. versions with same name:
  86. /// Sends hotkey bar.
  87. /// 02b9 { <is skill>.B <id>.L <count>.W }*27 (ZC_SHORTCUT_KEY_LIST)
  88. /// 07d9 { <is skill>.B <id>.L <count>.W }*36 (ZC_SHORTCUT_KEY_LIST_V2, PACKETVER >= 20090603)
  89. /// 07d9 { <is skill>.B <id>.L <count>.W }*38 (ZC_SHORTCUT_KEY_LIST_V2, PACKETVER >= 20090617)
  90. Packet for a client command:
  91. /// /item /monster (CZ_ITEM_CREATE).
  92. /// Request to make items or spawn monsters.
  93. /// 013f <item/mob name>.24B