Esempio n. 1
0
        public void CountWorks()
        {
            ulong test   = 0xFFFFFFFFFFFFFFFF;
            var   result = test.Count();

            Assert.Equal(64, result);
        }
Esempio n. 2
0
        public static void WriteUIntDataset(long file_id_inp, string datasetName_inp, uint[,] datasetValues_inp, bool overwrite_inp)
        {
            int  status     = 0;
            long dataset_id = 0;

            if (overwrite_inp)
            {
                dataset_id = H5D.open(file_id_inp, datasetName_inp);
            }
            else
            {
                ulong[] dims = new ulong[2];
                dims[0]    = (ulong)datasetValues_inp.GetLength(0);
                dims[1]    = (ulong)datasetValues_inp.GetLength(1);
                dataset_id = H5D.create(file_id_inp, datasetName_inp, H5T.NATIVE_UINT, H5S.create_simple(dims.Count(), dims, null));
            }

            GCHandle buf = GCHandle.Alloc(datasetValues_inp, GCHandleType.Pinned);

            status = H5D.write(dataset_id, H5T.NATIVE_UINT32, H5S.ALL, H5S.ALL, H5P.DEFAULT, buf.AddrOfPinnedObject());

            status = H5D.close(dataset_id);
        }
Esempio n. 3
0
        void WriteCharacterInfo(ByteBuffer packet, Character cha, byte add)
        {
            packet.WriteBytes(new byte[] { (byte)(0x86 + add), 0x00, 0x00, 0x40 }); // Dynamic
            packet.WriteUInt(0x4e7511aa);                                           // Static
            packet.WriteUInt(0x899);
            packet.WriteByte(0x80);

            packet.WriteBytes(new byte[] {
                0xe8, 0x7e, 0x20, 0x9b,               // E8 7E 20 9B
                (byte)(0x86 + add), 0x00, 0x00, 0x40, // 4F 00 00 40
                0xe8, 0x7e, 0x20, 0x9b,               // E8 7E 20 9B
                (byte)(0x86 + add), 0x00, 0x00, 0x40, // 4F 00 00 40
            });

            packet.WriteBytes(new byte[] { 0x05, 0x00, 0x02 });

            long detailsLengthPlaceholder = packet.Position;

            packet.WriteInt(0); // placeholder for details length

            packet.WriteBytes(new byte[] {
                0x14, 0x14, 0xCF, 0x40,
                0x00, 0x00, 0x04, 0xE0,
                0xD7, 0x68, 0xB5, 0x03,
                0x01, 0xCC, 0x07, 0xD8,
                0x87, 0xD6, 0x02, 0x03,
                0x00, 0xCC, 0x29, 0x40,
                0x56, 0x77, 0x5B, 0x03,
                0x01, 0xC4, 0x30, 0x1A,
                0x0D, 0x75, 0xB9, 0x15,
                0xCD, 0x0B,
            });                                                             // static

            packet.WriteBytes(new byte[] { 0xcc, 0xbd, 0x33, 0x9c, 0xdd }); // unk dynamic (CC BD 33 9C DD)

            packet.WriteBytes(new byte[] {
                0xCC, 0x07, 0x18, 0xC2,
                0x55, 0x7C, 0x09, 0x04,
                0x04, 0xCF, 0x40, 0x00,
                0x00, 0x30, 0x5C, 0x21,
                0xB1, 0x10, 0x02
            });                      // static

            packet.WriteBytes(new byte[] {
                //0x95, 0x01, 0x02,
                //0xC9, 0x02, 0x8A, 0x01, 0x02,
                //0xC9, 0x02, 0x8C, 0x01, 0x02, 0x9C, // C9 02 FC 01 02 8A 01 02 C9 02 F5 01 02 C9 03 08
                0xC9, 0x02, 0xFC, 0x01, 0x02, 0x8A, 0x01, 0x02,
                0xC9, 0x02, 0xF5, 0x01, 0x02, 0xC9, 0x03, 0x08,

                0xCB, 0x91, 0xFC, 0x05,
                0xB8, 0x02,
                0x06, 0xCC, 0x27, 0x32, 0x2B, // static
                0x0D, 0xFD, 0x02, 0xCA,       // static
                0x76,                         // static

                0xc4, 0x7f,                   // dynamic

                0xCB, 0x50, 0x5D, 0x6C, 0xC6, // static

                0x04, 0x33, 0x83, 0xc5,       // static
                0x44,                         // static
                0x01,                         // static
                0x04, 0x9a, 0xdd, 0xdc,       // static
                0x45,
                0xC4, 0x25, 0x42, 0x9A,       // Static
                0x25, 0xBA, 0x02, 0xCF
            });                               // Static

            packet.WriteUInt(cha.APP1);
            packet.WriteUInt(cha.APP2);
            packet.WriteUInt(cha.APP3);
            packet.WriteUShort(cha.APP4);
            packet.WriteByte(0xCF);

            /*packet.WriteBytes(new byte[] {
             *  0x56, 0xF6, 0x33, 0xF2, //0E B2 4F F8
             *  0xDD, 0xDE, 0x74, 0x77, //51 1E 46 3C
             *  0xCB, 0x6C, 0x9C, 0xB1, //CB 6C 9C B1
             *  0xA7, 0x01, 0xCF,
             *  //0xE0, 0x00, 0xFD, 0x35, 0xB1, 0x0B, 0x17, 0x60 //9B E1 60
             * });*/// appearance ? from char creation

            //packet.WriteBytes(BitConverter.GetBytes((ulong)CharacterClass.JediConsular));
            packet.WriteULongRev((ulong)cha.Class);

            packet.WriteBytes(new byte[] { 0xCC, 0x25, 0xEB, 0x85,
                                           0x46, 0x42, 0x03, 0x01, // 0 = 1
                                           0xC4, 0x25, 0xD0, 0x6C, 0xA1,
                                           0x13, 0x07, });

            // Inventory
            ulong[] ids = new ulong[] { 0xe000e32eacf6fe1c, 0xe00096830962E510, 0xE0002D97FFB1222D };
            packet.WriteByte(1);
            packet.WriteByte((byte)ids.Count());
            packet.WriteByte((byte)ids.Count());
            packet.WriteByte(1);
            packet.WriteByte(0xcf);

            int ctr = 0;

            foreach (ulong id in ids)
            {
                packet.WriteULongRev(id);
                if (ctr == 0)
                {
                    packet.WriteByte(0x02);
                }
                else if (ctr == 1)
                {
                    packet.WriteByte(0x03);
                }
                else
                {
                    packet.WriteShort(0x211);
                }
                packet.WriteByte(0xcf);
                ctr++;
            }
            // End Inventory

            packet.WriteBytes(new byte[] {
                0x15, 0xE2,
                0x38,       // 2D
                0x19, 0xB0, 0x9F,
                0xDB, 0x62, // C8 B1
                0xCC, 0x02, 0xEE, 0xCD, 0xCF, 0x87, 0x08, 0x00,
            });             // Static

            // Appearance
            packet.WriteByte(2);
            packet.WriteByte((byte)cha.Appearance.Length);
            packet.WriteByte((byte)cha.Appearance.Length);

            //cha.Appearance.OrderBy(tuple => tuple.Item1);

            // 01 05 07 0A 0B 0C 0E 10
            byte counter = 0;

            for (byte b = 0; b < cha.Appearance.Length; b++)
            {
                Tuple <byte, byte> tuple = cha.Appearance[b];
                packet.WriteByte(0xD2);
                if (tuple.Item1 < 0x0A)
                {
                    packet.WriteByte(0x01);
                    packet.WriteByte((byte)(0x30 + tuple.Item1));
                }
                else
                {
                    packet.WriteByte(0x02);
                    packet.WriteByte(0x31);
                    packet.WriteByte((byte)(0x30 + (tuple.Item1 - 0x0A)));
                }
                packet.WriteByte(0xc9);
                packet.WriteByte(0x04);
                packet.WriteByte(tuple.Item2);
                counter++;
            }
            packet.WriteByte(0xcf);

            // End Appearance

            /*packet.WriteBytes(new byte[] {
             *  0x02, 0x08, 0x08,
             *  0xD2, 0x01, 0x31, 0xC9, 0x04, 0x5D,
             *  0xD2, 0x01, 0x35, 0xC9, 0x04, 0x8B,
             *  0xD2, 0x01, 0x37, 0xC9, 0x04, 0x3D,
             *  0xD2, 0x02, 0x31, 0x30, 0xC9, 0x04, 0x51,
             *  0xD2, 0x02, 0x31, 0x31, 0xC9, 0x04, 0x46,
             *  0xD2, 0x02, 0x31, 0x32, 0xC9, 0x04, 0x83,
             *  0xD2, 0x02, 0x31, 0x34, 0xC9, 0x04, 0x20,
             *  0xD2, 0x02, 0x31, 0x36, 0xC9, 0x04, 0xA8,
             *  0xCF
             * });*/// list of something

            packet.WriteBytes(new byte[] {
                0x3F, 0xFF, 0xFF, 0xF5,
                0x58, 0x76, 0x5E, 0x0F, 0x01, 0xCF,
                0x40, 0x00, 0x00, (byte)(0x86 + add),
                0x9b, 0x20, 0x7f, 0xa5, // 9B 20 7F A5
                0x01, 0x06
            });

            // Character Name
            packet.WriteByte((byte)cha.Name.Length);
            packet.WriteBytes(Encoding.UTF8.GetBytes(cha.Name));

            packet.WriteShort(0x202);    // Static

            packet.WriteByte(cha.Level); // Character Level

            packet.WriteShort(0x103);

            packet.WriteByte(0xcf);                                                         // Separator

            packet.WriteBytes(Utility.Reverse(BitConverter.GetBytes((ulong)cha.AreaSpec))); // Current Map ID

            packet.WriteBytes(new byte[] {
                0xC7, 0x3F, 0xFF, 0xFF, // This is static - probably a separator
                0xD2, 0xA9, 0x55, 0x93, // static
                0x1A, 0x02, 0x01, 0xc7, // static ? or some len/offset data for next char
                0xaf, 0xff, 0xc0,       // dynamic unk
            });

            long curPos = packet.Position;

            packet.Position = detailsLengthPlaceholder;

            int value = (int)(curPos - detailsLengthPlaceholder - 8);

            Console.WriteLine("Len = " + value);

            packet.WriteInt((int)(curPos - detailsLengthPlaceholder - 8));
            packet.Position = curPos;
        }