Exemplo n.º 1
0
 private void btnCalc_Click(object sender, EventArgs e)
 {
     tbFNV32.Text   = "0x" + FNV32.GetHash(tbInput.Text).ToString("X8");
     tbFNV64.Text   = "0x" + FNV64.GetHash(tbInput.Text).ToString("X16");
     tbCLIPIID.Text = "0x" + FNV64CLIP.GetHash(tbInput.Text).ToString("X16");
     tbFVV24.Text   = "0x" + FNV24.GetHash(tbInput.Text).ToString("X6");
 }
Exemplo n.º 2
0
 public void SetName(string name)
 {
     materialName = name;
     materialHash = FNV64.Hash(name);
     Console.WriteLine(FNV64.Hash(name));
     Console.WriteLine(FNV32.Hash(name));
 }
Exemplo n.º 3
0
            public void UnParse(BinaryWriter w)
            {
                myPosition = (uint)w.BaseStream.Position;

                if (this.name == null)
                {
                    this.name = "";
                }
                this.nameHash = FNV32.GetHash(this.name);

                if (this.fieldList == null)
                {
                    this.fieldList = new FieldList(this.handler);
                }
                if (this.fieldList.Count == 0)
                {
                    this.fieldTablePosition = Util.NullOffset;
                }

                w.Write(Util.Zero32); // Name Offset
                w.Write(this.nameHash);
                w.Write(this.unknown08);
                w.Write(this.size);
                w.Write(Util.Zero32); // Field Table Offset
                w.Write(this.fieldList.Count);
            }
Exemplo n.º 4
0
        private static void GetInfo(BoneManager manager, RigResource.RigResource.Bone bone, StringBuilder sb)
        {
            Matrix t  = GetAbsoluteTransform(manager, bone);
            Matrix ti = t.GetInverse();

            sb.AppendLine("============================");
            sb.AppendFormat("Name:\t{0}\r\n", bone.Name);
            sb.AppendFormat("Hashed:\t0x{0:X8}\r\n", FNV32.GetHash(bone.Name));
            sb.AppendLine("Absolute Transform (RSLT):");
            sb.AppendLine(t.TransposedString());
            sb.AppendLine("Absolute Transform Inverse (SKIN):");
            sb.AppendLine(ti.ToString());
        }
Exemplo n.º 5
0
            public void UnParse(BinaryWriter w)
            {
                myPosition = (uint)w.BaseStream.Position;

                if (this.name == null)
                {
                    this.name = "";
                }
                this.nameHash = FNV32.GetHash(this.name);

                w.Write(Util.Zero32); // Name Offset
                w.Write(this.nameHash);
                w.Write(this.type);
                w.Write(this.dataOffset);
                w.Write(Util.Zero32); // Unknown 10 Offset
            }
Exemplo n.º 6
0
        private void ReadExternalHashes()
        {
            try
            {
                string[] hashes = File.ReadAllLines(Path.Combine("Resources", "hashes.txt"));

                foreach (var hash in hashes)
                {
                    uint key = FNV32.Hash(hash);
                    columnNames.Add(key, hash);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Missing hashes.txt, No column names will be present.", "Toolkit", MessageBoxButtons.OK);
                columnNames = new Dictionary <uint, string>();
            }
        }
Exemplo n.º 7
0
            public void UnParse(BinaryWriter w)
            {
                myPosition = (uint)w.BaseStream.Position;

                if (this.name == null)
                {
                    this.name = "";
                }
                this.nameHash = FNV32.GetHash(this.name);

                w.Write(Util.Zero32); // Name Offset
                w.Write(this.nameHash);
                w.Write(Util.Zero32); // Structure Offset
                w.Write(this.unknown0C);
                w.Write(this.unknown10);
                w.Write(Util.Zero32); // Field Offset
                w.Write(this.fieldCount);
            }
Exemplo n.º 8
0
        private void OnButtonCalculate(object sender, EventArgs e)
        {
            try
            {
                byte[] data = ConvertString(textBoxSrc.Text);

                uint hash32 = FNV32.Hash(data, 0, data.Length);
                hash32         = _CheckSwap.Checked ? hash32.Swap() : hash32;
                textBox32.Text = string.Format("0x{0:X8}", hash32);

                ulong hash64 = FNV64.Hash(data, 0, data.Length);
                hash64         = _CheckSwap.Checked ? hash64.Swap() : hash64;
                textBox64.Text = string.Format("0x{0:X16}", hash64);
            }
            catch (Exception ex)
            {
                Helpers.ShowError(ex);
            }
        }
Exemplo n.º 9
0
        private static Dictionary <uint, string> LoadDictionary(string name)
        {
            var    dict         = new Dictionary <uint, string>();
            string geostatePath = Path.Combine(Path.GetDirectoryName(typeof(App).Assembly.Location), name + ".txt");

            if (File.Exists(geostatePath))
            {
                using (var sr = new StreamReader(File.OpenRead(geostatePath)))
                {
                    String line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (!line.Contains("#"))
                        {
                            dict[FNV32.GetHash(line)] = line;
                        }
                    }
                }
            }
            return(dict);
        }
Exemplo n.º 10
0
        public static void LoadStorage()
        {
            // Load string table for XBins.
            string[] LoadedLines = File.ReadAllLines("Resources//GameData//XBin_Hashes.txt");

            // Create all arrays
            StringTable  = new string[LoadedLines.Length];
            FNV32Storage = new Dictionary <uint, uint>();
            FNV64Storage = new Dictionary <ulong, uint>();

            // iterate through all lines and build our storage.
            for (uint i = 0; i < LoadedLines.Length; i++)
            {
                string Line = LoadedLines[i];
                StringTable[i] = Line;

                ulong FNV64Hash = FNV64.Hash(Line);
                uint  FNV32Hash = FNV32.Hash(Line);

                FNV64Storage.TryAdd(FNV64Hash, i);
                FNV32Storage.TryAdd(FNV32Hash, i);
            }
        }
Exemplo n.º 11
0
 private static void ExecuteAddBone(BoneViewModel target)
 {
     target.Manager.AddBone(new RigResource.RigResource.Bone(0, null, new Vertex(0, null), new s3pi.Interfaces.Quaternion(0, null, 0f, 0f, 0f, 1f), new Vertex(0, null), NEW_BONE_NAME, target.Manager.Bones.Count, -1, FNV32.GetHash(NEW_BONE_NAME), 0x23), target.Bone);
 }
Exemplo n.º 12
0
 private void ChangePropertyFromString(object result, IList <string> filedNames, string hashsalt, bool setHighBit = true)
 {
     foreach (var fieldName in filedNames)
     {
         var prop = result.GetType().GetProperty(fieldName);
         if (prop == null)
         {
             continue;
         }
         var value = prop.GetValue(result, null);
         if (value == null)
         {
             continue;
         }
         if (value.GetType() == typeof(int) || value.GetType() == typeof(Int32))
         {
             int v        = (int)value;
             int newValue = v ^ (int)FNV32.GetHash(hashsalt);
             SetProperty(result, fieldName, newValue);
         }
         else if (value.GetType() == typeof(uint) || value.GetType() == typeof(UInt32))
         {
             uint v        = (uint)value;
             uint newValue = v ^ FNV32.GetHash(hashsalt);
             SetProperty(result, fieldName, newValue);
         }
         else if (value.GetType() == typeof(short) || value.GetType() == typeof(Int16))
         {
             short v        = (short)value;
             short newValue = Convert.ToInt16((uint)v ^ FNV32.GetHash(hashsalt));
             SetProperty(result, fieldName, newValue);
         }
         else if (value.GetType() == typeof(ushort) || value.GetType() == typeof(UInt16))
         {
             ushort v        = (ushort)value;
             ushort newValue = Convert.ToUInt16((uint)v ^ FNV32.GetHash(hashsalt));
             SetProperty(result, fieldName, newValue);
         }
         else if (value.GetType() == typeof(byte) || value.GetType() == typeof(Byte))
         {
             byte v        = (byte)value;
             byte newValue = Convert.ToByte((uint)v ^ FNV32.GetHash(hashsalt));
             SetProperty(result, fieldName, newValue);
         }
         else if (value.GetType() == typeof(TGIBlock))
         {
             TGIBlock v = value as TGIBlock;
             if (v != null)
             {
                 v.Instance ^= FNV64.GetHash(hashsalt);
                 if (setHighBit)
                 {
                     v.Instance |= (ulong)1 << 63; v.ResourceGroup |= (uint)1 << 31;
                 }
             }
             SetProperty(result, fieldName, v);
         }
         else if (value.GetType() == typeof(TGIBlock[]))
         {
             TGIBlock[] v = value as TGIBlock[];
             if (v != null)
             {
                 foreach (var tgi in v)
                 {
                     tgi.Instance ^= FNV64.GetHash(hashsalt);
                     if (setHighBit)
                     {
                         tgi.Instance |= (ulong)1 << 63; tgi.ResourceGroup |= (uint)1 << 31;
                     }
                 }
             }
             SetProperty(result, fieldName, v);
         }
     }
 }
Exemplo n.º 13
0
 .Bind(x => default(EqB)
       .GetHashCodeAsync(pair.Item2)
       .Map(y => FNV32.Next(x, y)));
 private void btnFNV32_Click(object sender, EventArgs e)
 {
     tbInstance.Text = "0x" + FNV32.GetHash(tbName.Text).ToString("X16");
 }
Exemplo n.º 15
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                RigResource.RigResource grd = mRig;

                saveFileDialog1.FileName = "rigfile.txt";
                saveFileDialog1.Filter   = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
                DialogResult result = saveFileDialog1.ShowDialog();
                if (result == DialogResult.OK)
                {
                    var sb = new StringBuilder();
                    for (int i = 0; i < clbBones.Items.Count; i++)
                    {
                        if (clbBones.GetItemChecked(i))
                        {
                            RigResource.RigResource.Bone bone = ((BoneListItem)clbBones.Items[i]).Bone;
                            bool flip = bone.ParentBoneIndex == -1;
                            sb.AppendFormat("\"{0}\" \"{1}\" {2} {3:F10} {4:F10} {5:F10}\r\n", cbHashBones.Checked ? String.Format("0x{0:X8}", FNV32.GetHash(bone.Name)) : bone.Name,
                                            bone.ParentBoneIndex == -1
                                                ? "unparented"
                                                : cbHashBones.Checked ? String.Format("0x{0:X8}", FNV32.GetHash(grd.Bones[bone.ParentBoneIndex].Name)) : grd.Bones[bone.ParentBoneIndex].Name,
                                            bone.Position.X,
                                            bone.Position.Y,
                                            bone.Position.Z,
                                            ToEuler(bone.Orientation, flip));
                        }
                    }
                    using (var s = new StreamWriter(File.Create(saveFileDialog1.FileName))) s.Write(sb.ToString());
                }
            }
            finally
            {
                Close();
            }
        }
Exemplo n.º 16
0
 public void SetName(string Value)
 {
     _name = Value;
     Hash  = FNV32.Hash(Name);
 }