Jump to content
TrinityCore

How do opcodes work?


StormByte
 Share

Recommended Posts

Hi there, this question is specially directed to trinity devs, as I am very curious (note: only for curiosity sake, it is not my intention to put any kind of pressure on opcode implementing!).

I've read the opcode implementation, but I have to say there is a thing I did not get correctly.

I only saw in code, the definition of the opcode macro name, along with the class which is responsible to handle it, and it is being registered as UNHANDLED, NEVER, etc.. But what I did not find, is the opcode value itself.

Am I wrong guessing that opcodes are sent in binary with some value and format, like <opcode_value><opcode_param1><opcode_param2> and the like? I always thought that the value for loot=1, cast=2, etc (only examples).

How do they work? This is the part I have missing long time to learn how it work, but from my point of view, and my guessing, it is very similar to what a CPU receive.

Any hint on this?

 

EDIT: I recently saw https://github.com/TrinityCore/TrinityCore/blob/6.x/src/server/game/Server/Protocol/Opcodes.h which was exactly what I was looking for. So just a question missing, when an opcode is missing implementation? Is it because the opcode value changed, because there is no code to "construct" the packet, both? Thanks for the clarify, I just want to understand the work done here better

Edited by StormByte
  • Upvote 1
Link to comment
Share on other sites

Packet opcodes and structs are reverse engineered from the client. You can find a bit about that from the WPP project

Packets have a header and a body. In the header it's defined the direction (client->server, server->client), the timestamp it was sent, the opcode id and some other fields. The body is simply a bunch of bytes that only make sense once the opcode is known.

Here's an example of reading a packet: https://github.com/TrinityCore/WowPacketParser/blob/master/WowPacketParser/Parsing/Parsers/GuildHandler.cs#L705-L712

  • Upvote 1
Link to comment
Share on other sites

Packet opcodes and structs are reverse engineered from the client. You can find a bit about that from the WPP project

Packets have a header and a body. In the header it's defined the direction (client->server, server->client), the timestamp it was sent, the opcode id and some other fields. The body is simply a bunch of bytes that only make sense once the opcode is known.

Here's an example of reading a packet: https://github.com/TrinityCore/WowPacketParser/blob/master/WowPacketParser/Parsing/Parsers/GuildHandler.cs#L705-L712

​Thanks Nay

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...