1. Before discussing a bug, please verify you are using the latest TShock release. Do not post bug reports in the shoutbox, IRC, or the forums - post bug reports on the Github issues page (located at the top of this forum). TShock developers will not check for bugs in the shoutbox, IRC, and may not notice reports in the forums.

Terraria Protocol

Discussion in 'Development Resources' started by InanZen, Mar 5, 2012.

  1. InanZen TShock Plugin Developer

  2. Olink Nyx Developer, Occasional TShock Developer

  3. atom0s Member

    Keep in mind that the docs posted by Zidonuke are missing 1.1.2's new packet for spawning bosses/starting invasions:

    Packet Id: 61 (0x3D)
    Packet Description: Spawn Boss / Start Invasion Request
    Packet Format:
    • PayloadSize - 4 bytes
    • PacketId - 1 byte
    • PlayerId - 4 bytes
    • BossId - 4 bytes
    InanZen and k0rd like this.
  4. k0rd Tee Shawk Developer

    payload is 8b
  5. atom0s Member

    Uhm.. no?

    Connection Request packet:
    -        btPacket    {byte[0x0000000f]}    byte[]
            [0x00000000]    0x0b    byte
            [0x00000001]    0x00    byte
            [0x00000002]    0x00    byte
            [0x00000003]    0x00    byte
            [0x00000004]    0x01    byte
            [0x00000005]    0x54    byte
            [0x00000006]    0x65    byte
            [0x00000007]    0x72    byte
            [0x00000008]    0x72    byte
            [0x00000009]    0x61    byte
            [0x0000000a]    0x72    byte
            [0x0000000b]    0x69    byte
            [0x0000000c]    0x61    byte
            [0x0000000d]    0x33    byte
            [0x0000000e]    0x39    byte
    0x0B 0x00 0x00 0x00 0x01 0x54 0x65 0x72 0x72 0x61 0x72 0x69 0x61 0x33 0x39
    Payload Size
    Packet Id
    Payload Data

    Think you were confusing what I was saying with the size of the payload specific to that packet. I was referring to the raw packet itself.
  6. k0rd Tee Shawk Developer

    I see the miscommunication :) I was basing these off the standards outlined in the referenced document - not the raw network data iteself
  7. InanZen TShock Plugin Developer

    You are both wrong (or not but here is how it works for me) :

    packetID: 61, length: 9 bytes;
    • PlayerID: 4 bytes (int32);
    • BossID: 4 bytes (int32);
    • last byte - unknown
  8. atom0s Member

    Here is the actual packet code for this packet:
        if (msgType == 61)
    byte[] bytes244 BitConverter.GetBytes(msgType);
    byte[] bytes245 BitConverter.GetBytes(number);
    byte[] bytes246 BitConverter.GetBytes((int)number2);
    num2 += bytes245.Length bytes246.Length;
    byte[] bytes247 BitConverter.GetBytes(num2 4);
    num3 += bytes245.Length;
    There is no extra byte at the end. Are you sure you aren't reading too much from the buffer and just reading an invalid byte?

    -        btData    {byte[0x0000000d]}    byte[]
            [0x00000000]    0x09    byte // payload size
            [0x00000001]    0x00    byte
            [0x00000002]    0x00    byte
            [0x00000003]    0x00    byte
            [0x00000004]    0x3d    byte // packet id
            [0x00000005]    0x01    byte // player id
            [0x00000006]    0x00    byte
            [0x00000007]    0x00    byte
            [0x00000008]    0x00    byte
            [0x00000009]    0x32    byte // bossid
            [0x0000000a]    0x00    byte
            [0x0000000b]    0x00    byte
            [0x0000000c]    0x00    byte
    k0rd likes this.
  9. InanZen TShock Plugin Developer

    Well i'm using:
    public override void Initialize()
          NetHooks.GetData += GetData;
    GetData method:
    public void GetData(GetDataEventArgs e)
                    switch (e.MsgID)
                    case PacketTypes.SpawnBossorInvasion:
                                    using (var data = new MemoryStream(e.Msg.readBuffer, e.Index, e.Length))
                                        Console.WriteLine("e.length: {0}", e.Length);
                                        var reader = new BinaryReader(data);
                                        int playerID = reader.ReadInt32();
                                        int bossID = reader.ReadInt32();
                                        Console.WriteLine("plyID: {0}, bossID: {1}", playerID, bossID);
    And it works correctly.
    e.Length is 9, thats why i said its 9 bytes. And the first 4 are the important data, so i'm not bothering with the last one :)
  10. Andrio New Member

    The packet ID (0x3D) counts as one of the nine bytes.

Share This Page