SphereCommunity
UO Packets - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: General Discussion (/Forum-General-Discussion)
+--- Forum: UO/Sphere Discussion (/Forum-UO-Sphere-Discussion)
+--- Thread: UO Packets (/Thread-UO-Packets)

Pages: 1 2 3


UO Packets - Ankron - 07-12-2015 01:18 PM

Just on a purely academic level How does the server send packets to the client. I've been playing with the packets and notice that after the client receives packet 0x91 the packets sent by the server seem to change and do not match the given list... why is that?


RE: UO Packets - XuN - 07-12-2015 05:17 PM

And which is that 'given list'? I can't find any packet guide telling that packet 0x91 request anything or expect anything to be sent back... to be 'changed'.

Packet 0x91 only means 'Login': http://ruosi.org/packetguide/index.xml#client91
It checks that the 'connection' is made by a uo client (it could be telnet, or http, but reached this point only clients can pass).
It checks for a login success (ie, wrong password, banned account, already using...) returning 0x82 (PacketLoginError) if something is wrong.
Packet 0xb9 is sent with the allowed flags for this client: http://ruosi.org/packetguide/index.xml#serverB9 (Maybe this is what 'changes' ?)
Then packet 0xA9 is composed, sending the characters for this account: http://ruosi.org/packetguide/index.xml#serverA9 (Maybe this one is changing too):
-This send the characters you already have, but it already send the [STARTS ], the starting points you can choose when creating a new character, it also send some more account related flags.
And, after all of this, if everything was OK packet 0x82 is sent with BYTE 0xFF, which means success.


RE: UO Packets - Shaklaban - 07-13-2015 12:52 AM

(07-12-2015 01:18 PM)Ankron Wrote:  Just on a purely academic level How does the server send packets to the client. I've been playing with the packets and notice that after the client receives packet 0x91 the packets sent by the server seem to change and do not match the given list... why is that?

server sends compressed packets. you can check runuo source code.


RE: UO Packets - Ankron - 07-14-2015 04:55 AM

I'm not familiar with RunUO's language. So what compression is it using?


RE: UO Packets - Ankron - 07-17-2015 04:58 AM

Ok, so I fugyred out the compression is supposed to be Huffman, but I don't understand the dictionary they are using...

Code:
private static int[] m_Table = new int[514]
        {
            0x2, 0x000,    0x5, 0x01F,    0x6, 0x022,    0x7, 0x034,    0x7, 0x075,    0x6, 0x028,    0x6, 0x03B,    0x7, 0x032,
            0x8, 0x0E0,    0x8, 0x062,    0x7, 0x056,    0x8, 0x079,    0x9, 0x19D,    0x8, 0x097,    0x6, 0x02A,    0x7, 0x057,
            0x8, 0x071,    0x8, 0x05B,    0x9, 0x1CC,    0x8, 0x0A7,    0x7, 0x025,    0x7, 0x04F,    0x8, 0x066,    0x8, 0x07D,
            0x9, 0x191,    0x9, 0x1CE,    0x7, 0x03F,    0x9, 0x090,    0x8, 0x059,    0x8, 0x07B,    0x8, 0x091,    0x8, 0x0C6,
            0x6, 0x02D,    0x9, 0x186,    0x8, 0x06F,    0x9, 0x093,    0xA, 0x1CC,    0x8, 0x05A,    0xA, 0x1AE,    0xA, 0x1C0,
            0x9, 0x148,    0x9, 0x14A,    0x9, 0x082,    0xA, 0x19F,    0x9, 0x171,    0x9, 0x120,    0x9, 0x0E7,    0xA, 0x1F3,
            0x9, 0x14B,    0x9, 0x100,    0x9, 0x190,    0x6, 0x013,    0x9, 0x161,    0x9, 0x125,    0x9, 0x133,    0x9, 0x195,
            0x9, 0x173,    0x9, 0x1CA,    0x9, 0x086,    0x9, 0x1E9,    0x9, 0x0DB,    0x9, 0x1EC,    0x9, 0x08B,    0x9, 0x085,
            0x5, 0x00A,    0x8, 0x096,    0x8, 0x09C,    0x9, 0x1C3,    0x9, 0x19C,    0x9, 0x08F,    0x9, 0x18F,    0x9, 0x091,
            0x9, 0x087,    0x9, 0x0C6,    0x9, 0x177,    0x9, 0x089,    0x9, 0x0D6,    0x9, 0x08C,    0x9, 0x1EE,    0x9, 0x1EB,
            0x9, 0x084,    0x9, 0x164,    0x9, 0x175,    0x9, 0x1CD,    0x8, 0x05E,    0x9, 0x088,    0x9, 0x12B,    0x9, 0x172,
            0x9, 0x10A,    0x9, 0x08D,    0x9, 0x13A,    0x9, 0x11C,    0xA, 0x1E1,    0xA, 0x1E0,    0x9, 0x187,    0xA, 0x1DC,
            0xA, 0x1DF,    0x7, 0x074,    0x9, 0x19F,    0x8, 0x08D,    0x8, 0x0E4,    0x7, 0x079,    0x9, 0x0EA,    0x9, 0x0E1,
            0x8, 0x040,    0x7, 0x041,    0x9, 0x10B,    0x9, 0x0B0,    0x8, 0x06A,    0x8, 0x0C1,    0x7, 0x071,    0x7, 0x078,
            0x8, 0x0B1,    0x9, 0x14C,    0x7, 0x043,    0x8, 0x076,    0x7, 0x066,    0x7, 0x04D,    0x9, 0x08A,    0x6, 0x02F,
            0x8, 0x0C9,    0x9, 0x0CE,    0x9, 0x149,    0x9, 0x160,    0xA, 0x1BA,    0xA, 0x19E,    0xA, 0x39F,    0x9, 0x0E5,
            0x9, 0x194,    0x9, 0x184,    0x9, 0x126,    0x7, 0x030,    0x8, 0x06C,    0x9, 0x121,    0x9, 0x1E8,    0xA, 0x1C1,
            0xA, 0x11D,    0xA, 0x163,    0xA, 0x385,    0xA, 0x3DB,    0xA, 0x17D,    0xA, 0x106,    0xA, 0x397,    0xA, 0x24E,
            0x7, 0x02E,    0x8, 0x098,    0xA, 0x33C,    0xA, 0x32E,    0xA, 0x1E9,    0x9, 0x0BF,    0xA, 0x3DF,    0xA, 0x1DD,
            0xA, 0x32D,    0xA, 0x2ED,    0xA, 0x30B,    0xA, 0x107,    0xA, 0x2E8,    0xA, 0x3DE,    0xA, 0x125,    0xA, 0x1E8,
            0x9, 0x0E9,    0xA, 0x1CD,    0xA, 0x1B5,    0x9, 0x165,    0xA, 0x232,    0xA, 0x2E1,    0xB, 0x3AE,    0xB, 0x3C6,
            0xB, 0x3E2,    0xA, 0x205,    0xA, 0x29A,    0xA, 0x248,    0xA, 0x2CD,    0xA, 0x23B,    0xB, 0x3C5,    0xA, 0x251,
            0xA, 0x2E9,    0xA, 0x252,    0x9, 0x1EA,    0xB, 0x3A0,    0xB, 0x391,    0xA, 0x23C,    0xB, 0x392,    0xB, 0x3D5,
            0xA, 0x233,    0xA, 0x2CC,    0xB, 0x390,    0xA, 0x1BB,    0xB, 0x3A1,    0xB, 0x3C4,    0xA, 0x211,    0xA, 0x203,
            0x9, 0x12A,    0xA, 0x231,    0xB, 0x3E0,    0xA, 0x29B,    0xB, 0x3D7,    0xA, 0x202,    0xB, 0x3AD,    0xA, 0x213,
            0xA, 0x253,    0xA, 0x32C,    0xA, 0x23D,    0xA, 0x23F,    0xA, 0x32F,    0xA, 0x11C,    0xA, 0x384,    0xA, 0x31C,
            0xA, 0x17C,    0xA, 0x30A,    0xA, 0x2E0,    0xA, 0x276,    0xA, 0x250,    0xB, 0x3E3,    0xA, 0x396,    0xA, 0x18F,
            0xA, 0x204,    0xA, 0x206,    0xA, 0x230,    0xA, 0x265,    0xA, 0x212,    0xA, 0x23E,    0xB, 0x3AC,    0xB, 0x393,
            0xB, 0x3E1,    0xA, 0x1DE,    0xB, 0x3D6,    0xA, 0x31D,    0xB, 0x3E5,    0xB, 0x3E4,    0xA, 0x207,    0xB, 0x3C7,
            0xA, 0x277,    0xB, 0x3D4,    0x8, 0x0C0,    0xA, 0x162,    0xA, 0x3DA,    0xA, 0x124,    0xA, 0x1B4,    0xA, 0x264,
            0xA, 0x33D,    0xA, 0x1D1,    0xA, 0x1AF,    0xA, 0x39E,    0xA, 0x24F,    0xB, 0x373,    0xA, 0x249,    0xB, 0x372,
            0x9, 0x167,    0xA, 0x210,    0xA, 0x23A,    0xA, 0x1B8,    0xB, 0x3AF,    0xA, 0x18E,    0xA, 0x2EC,    0x7, 0x062,
            0x4, 0x00D
        };



RE: UO Packets - Ankron - 07-25-2015 03:04 AM

... anyone have any ideas?


RE: UO Packets - WRWR - 07-25-2015 06:36 AM

http://docs.polserver.com/packets/index.php


RE: UO Packets - Ankron - 07-25-2015 06:13 PM

(07-25-2015 06:36 AM)WRWR Wrote:  http://docs.polserver.com/packets/index.php

Been there I understand that the packets are set up a certain way. What I'm trying to figure out now is how the server compresses those packets.

After selecting a game server from the server list the client seems to be expecting compressed or encrypted data. One of the other posts said encrypted. Further study says it's supposed to be compressed using the Huffman compression algorithm which uses a dictionary. The dictionary varies depending on which program uses it. In this case UO uses a very specific dictionary. I think I found the dictionary, but I have no idea how to decipher it. I'd like to know how this code from RUNUO works.


RE: UO Packets - Ankron - 07-26-2015 05:27 AM

ok, so I've been trying to convert the compression code I found for the pole server to PHP with out much luck.
Here's the orignal code:
Code:
static uint[,] bit_table = new uint[,]
      {
          {0x02, 0x00},     {0x05, 0x1F},     {0x06, 0x22},     {0x07, 0x34},     {0x07, 0x75},     {0x06, 0x28},     {0x06, 0x3B},     {0x07, 0x32},
          {0x08, 0xE0},     {0x08, 0x62},     {0x07, 0x56},     {0x08, 0x79},     {0x09, 0x19D},    {0x08, 0x97},     {0x06, 0x2A},     {0x07, 0x57},
          {0x08, 0x71},     {0x08, 0x5B},     {0x09, 0x1CC},    {0x08, 0xA7},     {0x07, 0x25},     {0x07, 0x4F},     {0x08, 0x66},     {0x08, 0x7D},
          {0x09, 0x191},    {0x09, 0x1CE},     {0x07, 0x3F},     {0x09, 0x90},     {0x08, 0x59},     {0x08, 0x7B},     {0x08, 0x91},     {0x08, 0xC6},
          {0x06, 0x2D},     {0x09, 0x186},     {0x08, 0x6F},     {0x09, 0x93},     {0x0A, 0x1CC},    {0x08, 0x5A},     {0x0A, 0x1AE},    {0x0A, 0x1C0},
          {0x09, 0x148},    {0x09, 0x14A},     {0x09, 0x82},     {0x0A, 0x19F},     {0x09, 0x171},    {0x09, 0x120},     {0x09, 0xE7},     {0x0A, 0x1F3},
          {0x09, 0x14B},    {0x09, 0x100},    {0x09, 0x190},    {0x06, 0x13},     {0x09, 0x161},    {0x09, 0x125},    {0x09, 0x133},    {0x09, 0x195},
          {0x09, 0x173},    {0x09, 0x1CA},    {0x09, 0x86},     {0x09, 0x1E9},     {0x09, 0xDB},     {0x09, 0x1EC},    {0x09, 0x8B},     {0x09, 0x85},
          {0x05, 0x0A},     {0x08, 0x96},     {0x08, 0x9C},     {0x09, 0x1C3},     {0x09, 0x19C},    {0x09, 0x8F},     {0x09, 0x18F},    {0x09, 0x91},
          {0x09, 0x87},     {0x09, 0xC6},     {0x09, 0x177},    {0x09, 0x89},     {0x09, 0xD6},     {0x09, 0x8C},     {0x09, 0x1EE},    {0x09, 0x1EB},
          {0x09, 0x84},     {0x09, 0x164},     {0x09, 0x175},    {0x09, 0x1CD},     {0x08, 0x5E},     {0x09, 0x88},     {0x09, 0x12B},    {0x09, 0x172},
          {0x09, 0x10A},    {0x09, 0x8D},     {0x09, 0x13A},    {0x09, 0x11C},     {0x0A, 0x1E1},    {0x0A, 0x1E0},     {0x09, 0x187},    {0x0A, 0x1DC},
          {0x0A, 0x1DF},    {0x07, 0x74},     {0x09, 0x19F},    {0x08, 0x8D},    {0x08, 0xE4},     {0x07, 0x79},     {0x09, 0xEA},     {0x09, 0xE1},
          {0x08, 0x40},     {0x07, 0x41},     {0x09, 0x10B},    {0x09, 0xB0},     {0x08, 0x6A},     {0x08, 0xC1},     {0x07, 0x71},     {0x07, 0x78},
          {0x08, 0xB1},     {0x09, 0x14C},     {0x07, 0x43},     {0x08, 0x76},     {0x07, 0x66},     {0x07, 0x4D},     {0x09, 0x8A},     {0x06, 0x2F},
          {0x08, 0xC9},        {0x09, 0xCE},     {0x09, 0x149},    {0x09, 0x160},     {0x0A, 0x1BA},     {0x0A, 0x19E},     {0x0A, 0x39F},     {0x09, 0xE5},
          {0x09, 0x194},     {0x09, 0x184},     {0x09, 0x126},     {0x07, 0x30},     {0x08, 0x6C},     {0x09, 0x121},     {0x09, 0x1E8},     {0x0A, 0x1C1},
          {0x0A, 0x11D},     {0x0A, 0x163},     {0x0A, 0x385},     {0x0A, 0x3DB},     {0x0A, 0x17D},     {0x0A, 0x106},     {0x0A, 0x397},     {0x0A, 0x24E},
          {0x07, 0x2E},     {0x08, 0x98},     {0x0A, 0x33C},     {0x0A, 0x32E},     {0x0A, 0x1E9},     {0x09, 0xBF},     {0x0A, 0x3DF},     {0x0A, 0x1DD},
          {0x0A, 0x32D},     {0x0A, 0x2ED},     {0x0A, 0x30B},     {0x0A, 0x107},     {0x0A, 0x2E8},     {0x0A, 0x3DE},     {0x0A, 0x125},     {0x0A, 0x1E8},
          {0x09, 0xE9},     {0x0A, 0x1CD},     {0x0A, 0x1B5},     {0x09, 0x165},     {0x0A, 0x232},     {0x0A, 0x2E1},     {0x0B, 0x3AE},     {0x0B, 0x3C6},
          {0x0B, 0x3E2},     {0x0A, 0x205},     {0x0A, 0x29A},     {0x0A, 0x248},     {0x0A, 0x2CD},     {0x0A, 0x23B},     {0x0B, 0x3C5},     {0x0A, 0x251},
          {0x0A, 0x2E9},     {0x0A, 0x252},     {0x09, 0x1EA},     {0x0B, 0x3A0},     {0x0B, 0x391},     {0x0A, 0x23C},     {0x0B, 0x392},     {0x0B, 0x3D5},
          {0x0A, 0x233},     {0x0A, 0x2CC},     {0x0B, 0x390},     {0x0A, 0x1BB},     {0x0B, 0x3A1},     {0x0B, 0x3C4},     {0x0A, 0x211},     {0x0A, 0x203},
          {0x09, 0x12A},     {0x0A, 0x231},     {0x0B, 0x3E0},     {0x0A, 0x29B},     {0x0B, 0x3D7},     {0x0A, 0x202},     {0x0B, 0x3AD},     {0x0A, 0x213},
          {0x0A, 0x253},     {0x0A, 0x32C},     {0x0A, 0x23D},     {0x0A, 0x23F},     {0x0A, 0x32F},     {0x0A, 0x11C},     {0x0A, 0x384},     {0x0A, 0x31C},
          {0x0A, 0x17C},     {0x0A, 0x30A},     {0x0A, 0x2E0},     {0x0A, 0x276},     {0x0A, 0x250},     {0x0B, 0x3E3},     {0x0A, 0x396},     {0x0A, 0x18F},
          {0x0A, 0x204},     {0x0A, 0x206},     {0x0A, 0x230},     {0x0A, 0x265},     {0x0A, 0x212},     {0x0A, 0x23E},     {0x0B, 0x3AC},     {0x0B, 0x393},
          {0x0B, 0x3E1},     {0x0A, 0x1DE},     {0x0B, 0x3D6},     {0x0A, 0x31D},     {0x0B, 0x3E5},     {0x0B, 0x3E4},     {0x0A, 0x207},     {0x0B, 0x3C7},
          {0x0A, 0x277},     {0x0B, 0x3D4},     {0x08, 0xC0},    {0x0A, 0x162},     {0x0A, 0x3DA},     {0x0A, 0x124},     {0x0A, 0x1B4},     {0x0A, 0x264},
          {0x0A, 0x33D},     {0x0A, 0x1D1},     {0x0A, 0x1AF},     {0x0A, 0x39E},     {0x0A, 0x24F},     {0x0B, 0x373},     {0x0A, 0x249},     {0x0B, 0x372},
          {0x09, 0x167},     {0x0A, 0x210},     {0x0A, 0x23A},     {0x0A, 0x1B8},     {0x0B, 0x3AF},     {0x0A, 0x18E},     {0x0A, 0x2EC},     {0x07, 0x62},
          {0x04, 0x0D}
      }

      byte[] Compress(byte[] source, int length)
      {
          byte[] retval = new byte[0];
          int nrBits = 0, cBits = 0, val = 0;
          byte current = 0;

          if(source == null || length == 0) return null;

          for(int i = 0; i < length; i++)
          {
              nrBits = (int)bit_table[source[i], 0] - 1;
              val = (int)bit_table[source[i], 1];

              for(int n = nrBits; n >= 0; n--)
              {
                  int x = (val >> n) % 2;
                  current <<= 1;
                  current += (byte)x;

                  cBits++;
                  if(cBits == 8)
                  {
                      byte[] temp = new byte[retval.Length + 1];
                      retval.CopyTo(temp, 0);
                      temp[temp.Length - 1] = current;
                      retval = new byte[temp.Length];
                      temp.CopyTo(retval, 0);
                      temp = null;
                      cBits = 0;
                  }
              }
          }

          nrBits = (int)bit_table[256, 0] - 1;
          val = (int)bit_table[256, 1];

          for(int n = nrBits; n >= 0; n--)
          {
              int x = (val >> n) % 2;
              current <<= 1;
              current += (byte)x;

              cBits++;
              if(cBits == 8)
              {
                  byte[] temp = new byte[retval.Length + 1];
                  retval.CopyTo(temp, 0);
                  temp[temp.Length - 1] = current;
                  retval = new byte[temp.Length];
                  temp.CopyTo(retval, 0);
                  temp = null;
                  cBits = 0;
              }
          }

          while(cBits != 0)
          {
              current <<= 1;
              cBits++;

              if(cBits == 8)
              {
                  byte[] temp = new byte[retval.Length + 1];
                  retval.CopyTo(temp, 0);
                  temp[temp.Length - 1] = current;
                  retval = new byte[temp.Length];
                  temp.CopyTo(retval, 0);
                  temp = null
                  cBits = 0;
              }
          }

          return retval;
      }

Here's what I made
Code:
function build_dictionary(){
        $this->bit_table=array(
          array(hexdec("02"), hexdec("0000")),        array(hexdec("05"), hexdec("001F")),        array(hexdec("06"), hexdec("0022")),        array(hexdec("07"), hexdec("0034")),        array(hexdec("07"), hexdec("0075")),        array(hexdec("06"), hexdec("0028")),        array(hexdec("06"), hexdec("003B")),        array(hexdec("07"), hexdec("0032")),
          array(hexdec("08"), hexdec("00E0")),        array(hexdec("08"), hexdec("0062")),        array(hexdec("07"), hexdec("0056")),        array(hexdec("08"), hexdec("0079")),        array(hexdec("09"), hexdec("019D")),        array(hexdec("08"), hexdec("0097")),        array(hexdec("06"), hexdec("002A")),        array(hexdec("07"), hexdec("0057")),
          array(hexdec("08"), hexdec("0071")),        array(hexdec("08"), hexdec("005B")),        array(hexdec("09"), hexdec("01CC")),        array(hexdec("08"), hexdec("00A7")),        array(hexdec("07"), hexdec("0025")),        array(hexdec("07"), hexdec("004F")),        array(hexdec("08"), hexdec("0066")),        array(hexdec("08"), hexdec("007D")),
          array(hexdec("09"), hexdec("0191")),        array(hexdec("09"), hexdec("01CE")),        array(hexdec("07"), hexdec("003F")),        array(hexdec("09"), hexdec("0090")),        array(hexdec("08"), hexdec("0059")),        array(hexdec("08"), hexdec("007B")),        array(hexdec("08"), hexdec("0091")),        array(hexdec("08"), hexdec("00C6")),
          array(hexdec("06"), hexdec("002D")),        array(hexdec("09"), hexdec("0186")),          array(hexdec("08"), hexdec("006F")),        array(hexdec("09"), hexdec("0093")),        array(hexdec("0A"), hexdec("01CC")),        array(hexdec("08"), hexdec("005A")),        array(hexdec("0A"), hexdec("01AE")),        array(hexdec("0A"), hexdec("01C0")),
          array(hexdec("09"), hexdec("0148")),        array(hexdec("09"), hexdec("014A")),        array(hexdec("09"), hexdec("0082")),        array(hexdec("0A"), hexdec("019F")),        array(hexdec("09"), hexdec("0171")),        array(hexdec("09"), hexdec("0120")),        array(hexdec("09"), hexdec("00E7")),        array(hexdec("0A"), hexdec("01F3")),
          array(hexdec("09"), hexdec("014B")),        array(hexdec("09"), hexdec("0100")),        array(hexdec("09"), hexdec("0190")),        array(hexdec("06"), hexdec("0013")),        array(hexdec("09"), hexdec("0161")),        array(hexdec("09"), hexdec("0125")),        array(hexdec("09"), hexdec("0133")),        array(hexdec("09"), hexdec("0195")),
          array(hexdec("09"), hexdec("0173")),        array(hexdec("09"), hexdec("01CA")),        array(hexdec("09"), hexdec("0086")),        array(hexdec("09"), hexdec("01E9")),        array(hexdec("09"), hexdec("00DB")),        array(hexdec("09"), hexdec("01EC")),        array(hexdec("09"), hexdec("008B")),        array(hexdec("09"), hexdec("0085")),
          array(hexdec("05"), hexdec("000A")),        array(hexdec("08"), hexdec("0096")),           array(hexdec("08"), hexdec("009C")),        array(hexdec("09"), hexdec("01C3")),        array(hexdec("09"), hexdec("019C")),        array(hexdec("09"), hexdec("008F")),        array(hexdec("09"), hexdec("018F")),        array(hexdec("09"), hexdec("0091")),
          array(hexdec("09"), hexdec("0087")),        array(hexdec("09"), hexdec("00C6")),        array(hexdec("09"), hexdec("0177")),        array(hexdec("09"), hexdec("0089")),        array(hexdec("09"), hexdec("00D6")),        array(hexdec("09"), hexdec("008C")),        array(hexdec("09"), hexdec("01EE")),        array(hexdec("09"), hexdec("01EB")),
          array(hexdec("09"), hexdec("0084")),        array(hexdec("09"), hexdec("0164")),          array(hexdec("09"), hexdec("0175")),        array(hexdec("09"), hexdec("01CD")),        array(hexdec("08"), hexdec("005E")),        array(hexdec("09"), hexdec("0088")),        array(hexdec("09"), hexdec("012B")),        array(hexdec("09"), hexdec("0172")),
          array(hexdec("09"), hexdec("010A")),        array(hexdec("09"), hexdec("008D")),           array(hexdec("09"), hexdec("013A")),        array(hexdec("09"), hexdec("011C")),        array(hexdec("0A"), hexdec("01E1")),        array(hexdec("0A"), hexdec("01E0")),        array(hexdec("09"), hexdec("0187")),        array(hexdec("0A"), hexdec("01DC")),
          array(hexdec("0A"), hexdec("01DF")),        array(hexdec("07"), hexdec("0074")),           array(hexdec("09"), hexdec("019F")),        array(hexdec("08"), hexdec("008D")),        array(hexdec("08"), hexdec("00E4")),        array(hexdec("07"), hexdec("0079")),        array(hexdec("09"), hexdec("00EA")),        array(hexdec("09"), hexdec("00E1")),
          array(hexdec("08"), hexdec("0040")),        array(hexdec("07"), hexdec("0041")),           array(hexdec("09"), hexdec("010B")),        array(hexdec("09"), hexdec("00B0")),        array(hexdec("08"), hexdec("006A")),        array(hexdec("08"), hexdec("00C1")),        array(hexdec("07"), hexdec("0071")),        array(hexdec("07"), hexdec("0078")),
          array(hexdec("08"), hexdec("00B1")),        array(hexdec("09"), hexdec("014C")),        array(hexdec("07"), hexdec("0043")),        array(hexdec("08"), hexdec("0076")),        array(hexdec("07"), hexdec("0066")),        array(hexdec("07"), hexdec("004D")),        array(hexdec("09"), hexdec("008A")),        array(hexdec("06"), hexdec("002F")),
          array(hexdec("08"), hexdec("00C9")),        array(hexdec("09"), hexdec("00CE")),        array(hexdec("09"), hexdec("0149")),        array(hexdec("09"), hexdec("0160")),        array(hexdec("0A"), hexdec("01BA")),        array(hexdec("0A"), hexdec("019E")),        array(hexdec("0A"), hexdec("039F")),        array(hexdec("09"), hexdec("00E5")),
          array(hexdec("09"), hexdec("0194")),        array(hexdec("09"), hexdec("0184")),        array(hexdec("09"), hexdec("0126")),        array(hexdec("07"), hexdec("0030")),        array(hexdec("08"), hexdec("006C")),        array(hexdec("09"), hexdec("0121")),        array(hexdec("09"), hexdec("01E8")),        array(hexdec("0A"), hexdec("01C1")),
          array(hexdec("0A"), hexdec("011D")),        array(hexdec("0A"), hexdec("0163")),        array(hexdec("0A"), hexdec("0385")),        array(hexdec("0A"), hexdec("03DB")),        array(hexdec("0A"), hexdec("017D")),        array(hexdec("0A"), hexdec("0106")),        array(hexdec("0A"), hexdec("0397")),        array(hexdec("0A"), hexdec("024E")),
          array(hexdec("07"), hexdec("002E")),        array(hexdec("08"), hexdec("0098")),        array(hexdec("0A"), hexdec("033C")),        array(hexdec("0A"), hexdec("032E")),        array(hexdec("0A"), hexdec("01E9")),        array(hexdec("09"), hexdec("00BF")),        array(hexdec("0A"), hexdec("03DF")),        array(hexdec("0A"), hexdec("01DD")),
          array(hexdec("0A"), hexdec("032D")),        array(hexdec("0A"), hexdec("02ED")),        array(hexdec("0A"), hexdec("030B")),        array(hexdec("0A"), hexdec("0107")),        array(hexdec("0A"), hexdec("02E8")),        array(hexdec("0A"), hexdec("03DE")),        array(hexdec("0A"), hexdec("0125")),        array(hexdec("0A"), hexdec("01E8")),
          array(hexdec("09"), hexdec("00E9")),        array(hexdec("0A"), hexdec("01CD")),        array(hexdec("0A"), hexdec("01B5")),        array(hexdec("09"), hexdec("0165")),        array(hexdec("0A"), hexdec("0232")),        array(hexdec("0A"), hexdec("02E1")),        array(hexdec("0B"), hexdec("03AE")),        array(hexdec("0B"), hexdec("03C6")),
          array(hexdec("0B"), hexdec("03E2")),        array(hexdec("0A"), hexdec("0205")),        array(hexdec("0A"), hexdec("029A")),        array(hexdec("0A"), hexdec("0248")),        array(hexdec("0A"), hexdec("02CD")),        array(hexdec("0A"), hexdec("023B")),        array(hexdec("0B"), hexdec("03C5")),        array(hexdec("0A"), hexdec("0251")),
          array(hexdec("0A"), hexdec("02E9")),        array(hexdec("0A"), hexdec("0252")),        array(hexdec("09"), hexdec("01EA")),        array(hexdec("0B"), hexdec("03A0")),        array(hexdec("0B"), hexdec("0391")),        array(hexdec("0A"), hexdec("023C")),        array(hexdec("0B"), hexdec("0392")),        array(hexdec("0B"), hexdec("03D5")),
          array(hexdec("0A"), hexdec("0233")),        array(hexdec("0A"), hexdec("02CC")),        array(hexdec("0B"), hexdec("0390")),        array(hexdec("0A"), hexdec("01BB")),        array(hexdec("0B"), hexdec("03A1")),        array(hexdec("0B"), hexdec("03C4")),        array(hexdec("0A"), hexdec("0211")),        array(hexdec("0A"), hexdec("0203")),
          array(hexdec("09"), hexdec("012A")),        array(hexdec("0A"), hexdec("0231")),        array(hexdec("0B"), hexdec("03E0")),        array(hexdec("0A"), hexdec("029B")),        array(hexdec("0B"), hexdec("03D7")),        array(hexdec("0A"), hexdec("0202")),        array(hexdec("0B"), hexdec("03AD")),        array(hexdec("0A"), hexdec("0213")),
          array(hexdec("0A"), hexdec("0253")),        array(hexdec("0A"), hexdec("032C")),        array(hexdec("0A"), hexdec("023D")),        array(hexdec("0A"), hexdec("023F")),        array(hexdec("0A"), hexdec("032F")),        array(hexdec("0A"), hexdec("011C")),        array(hexdec("0A"), hexdec("0384")),        array(hexdec("0A"), hexdec("031C")),
          array(hexdec("0A"), hexdec("017C")),        array(hexdec("0A"), hexdec("030A")),        array(hexdec("0A"), hexdec("02E0")),        array(hexdec("0A"), hexdec("0276")),        array(hexdec("0A"), hexdec("0250")),        array(hexdec("0B"), hexdec("03E3")),        array(hexdec("0A"), hexdec("0396")),        array(hexdec("0A"), hexdec("018F")),
          array(hexdec("0A"), hexdec("0204")),        array(hexdec("0A"), hexdec("0206")),        array(hexdec("0A"), hexdec("0230")),        array(hexdec("0A"), hexdec("0265")),        array(hexdec("0A"), hexdec("0212")),        array(hexdec("0A"), hexdec("023E")),        array(hexdec("0B"), hexdec("03AC")),        array(hexdec("0B"), hexdec("0393")),
          array(hexdec("0B"), hexdec("03E1")),        array(hexdec("0A"), hexdec("01DE")),        array(hexdec("0B"), hexdec("03D6")),        array(hexdec("0A"), hexdec("031D")),        array(hexdec("0B"), hexdec("03E5")),        array(hexdec("0B"), hexdec("03E4")),        array(hexdec("0A"), hexdec("0207")),        array(hexdec("0B"), hexdec("03C7")),
          array(hexdec("0A"), hexdec("0277")),        array(hexdec("0B"), hexdec("03D4")),        array(hexdec("08"), hexdec("00C0")),        array(hexdec("0A"), hexdec("0162")),        array(hexdec("0A"), hexdec("03DA")),        array(hexdec("0A"), hexdec("0124")),        array(hexdec("0A"), hexdec("01B4")),        array(hexdec("0A"), hexdec("0264")),
          array(hexdec("0A"), hexdec("033D")),        array(hexdec("0A"), hexdec("01D1")),        array(hexdec("0A"), hexdec("01AF")),        array(hexdec("0A"), hexdec("039E")),        array(hexdec("0A"), hexdec("024F")),        array(hexdec("0B"), hexdec("0373")),        array(hexdec("0A"), hexdec("0249")),        array(hexdec("0B"), hexdec("0372")),
          array(hexdec("09"), hexdec("0167")),        array(hexdec("0A"), hexdec("0210")),        array(hexdec("0A"), hexdec("023A")),        array(hexdec("0A"), hexdec("01B8")),        array(hexdec("0B"), hexdec("03AF")),        array(hexdec("0A"), hexdec("018E")),        array(hexdec("0A"), hexdec("02EC")),        array(hexdec("07"), hexdec("0062")),
          array(hexdec("04"), hexdec("000D"))
        );
        
    }
    
    function Compress($string)
      {
          if (!isset($this->bit_table)){
              $this->build_dictionary();
          }
          $nrBits = 0;
          $cBits = 0;
          $val = 0;
          $current = 0;
          $retval="";
          
          $length=strlen($string);
          echo "Encoding Packet: \n";
          if($string == null || $length == 0){
              return null;
          }else{

              for($i = 0; $i < $length; $i++)
              {
                  $bits = $this->bit_table[ord(substr($string, $i, 1))];
                  $nrBits = $bits[0];
                  $val = $bits[1];
                  
                  for($n = $nrBits; $n >= 0; $n--)
                  {
                      $x = ($val >> $n) % 2;
                      
                      $current <<= 1;
                      $current += $x;
                      $cBits++;
                      if($cBits == 8)
                      {
                        $retval= $current;
                        $cBits=0;
                      }
                  }
              }
              $bits = $this->bit_table[256];
              $nrBits = $bits[0];
              $val = $bits[1];

              for($n = $nrBits; $n >= 0; $n--)
              {
                  $x = ($val >> $n) % 2;

                  $current = $current << 1;

                  $current += $x;

                  $cBits++;
                  if($cBits == 8)
                  {

                      $retval= $current;
                      $cBits=0;
                  }
              }

              while($cBits != 0)
              {
                  $current <<= 1;
                  $cBits++;

                  if($cBits == 8)
                  {
                      $retval=$current;
                      $current=0;
                      $cBits=0;
                  }
              }
              
            
              $string=dechex($retval);
              echo $retval." ".$string."\n";
              $retval="";
              for($i=strlen($retval)/2;$i=>0; $i--){
                  $retval.=chr(hexdec(substr($string, ($i-2)*2, 2)));
              }
              echo strlen($retval)."\n";
              return $retval;
          }
      }



RE: UO Packets - Ankron - 07-28-2015 12:44 PM

It's so quiet these days...