packet_struct_notation.txt 4.3 KB

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