public ParamDefinition(string name) : base(ResourceType, ResourceTag) { this.mName = name; if (name == null) { this.mNameHash = 0; this.bNameIsHash = true; } else if (!name.StartsWith("0x") || !uint.TryParse(name.Substring(2), System.Globalization.NumberStyles.HexNumber, null, out this.mNameHash)) { this.mNameHash = FNVHash.HashString32(name); this.bNameIsHash = false; } else { this.bNameIsHash = true; } this.mDefaultValue = null; this.mDefaultHash = 0; this.bDefaultIsHash = true; }
private void fnv32_Click(object sender, EventArgs e) { DataGridViewSelectedRowCollection rows = this.resDGV.SelectedRows; if (rows != null && rows.Count > 0) { INamedResourceIndexEntry rie; foreach (DataGridViewRow row in rows) { rie = this.mResources[row.Index]; rie.Instance = FNVHash.HashString32(rie.ResourceName); this.resDGV.UpdateCellValue( (int)ColumnName.IID, row.Index); } if (this.bDetectConflicts) { this.ClearConflictHighlighting(); this.HighlightConflicts(); } if (this.mColIndex == (int)ColumnName.IID) { this.UpdateResDGV(); } } }
private void hash_Click(object sender, EventArgs e) { if (this.unhasher32 != null && !this.unhasher32.Finished) { return; } if (this.unhasher64 != null && !this.unhasher64.Finished) { return; } string strToHash = this.inputTxt.Text; uint xor32Hash = FNVHash.HashString24(strToHash) & filter32; uint fnv32Hash = FNVHash.HashString32(strToHash) & filter32; ulong xor64Hash = FNVHash.HashString48(strToHash) & filter64; ulong fnv64Hash = FNVHash.HashString64(strToHash) & filter64; this.resultsLST.Items.AddRange(new object[] { string.Concat("FNV Hash of ", strToHash), string.Concat("0x", fnv32Hash.ToString("X8"), " | FNV 32"), string.Concat("0x", fnv64Hash.ToString("X16"), " | FNV 64"), string.Concat("0x", xor32Hash.ToString("X8"), " | Xor Folded FNV 32"), string.Concat("0x", xor64Hash.ToString("X16"), " | Xor Folded FNV 64") }); }
private static void AddValue(string val, string lbl, KNAPackage knap) { ulong hash = FNVHash.HashString32(val); if (knap.Names.ContainsKey(hash)) { knap.Labels[hash] = ""; } else { knap.Names[hash] = val; if (lbl != null) { knap.Labels[hash] = lbl; } } hash = FNVHash.HashString64(val); if (knap.Names.ContainsKey(hash)) { knap.Labels[hash] = ""; } else { knap.Names[hash] = val; if (lbl != null) { knap.Labels[hash] = lbl; } } }
public State(string name) : base(ResourceType, ResourceTag) { this.mStateMachine = null; this.mName = name; if (name == null) { this.mNameHash = 0; this.bNameIsHash = true; } else if (!name.StartsWith("0x") || !uint.TryParse(name.Substring(2), System.Globalization.NumberStyles.HexNumber, null, out this.mNameHash)) { this.mNameHash = FNVHash.HashString32(name); this.bNameIsHash = false; } else { this.bNameIsHash = true; } this.mFlags = JazzState.Flags.None; this.mDecisionGraph = null; this.mTransitions = new List <State>(); this.mAwarenessOverlayLevel = JazzChunk.AwarenessLevel.Unset; }
private JazzStateMachine.Animation ExportEntry( string sourceFile, uint code, bool useSourceFile, string nameSpace, ActorDefinition actor, IDictionary <ulong, string> nameMap, bool ean) { System.IO.Stream s = null; uint hash; string name; JazzStateMachine.Animation animation = new JazzStateMachine.Animation(0, null, s); if (useSourceFile) { // TODO: sourceFile should not allow parsable numbers // Try to create a better brute force unhasher for // reading animation source files. if (!sourceFile.StartsWith("0x") || !uint.TryParse(sourceFile.Substring(2), System.Globalization.NumberStyles.HexNumber, null, out hash)) { hash = FNVHash.HashString32(sourceFile); if (!nameMap.TryGetValue(hash, out name) && (ean || !KeyNameReg.TryFindName(hash, out name))) { nameMap[hash] = sourceFile; } } animation.NameHash = hash; } else { animation.NameHash = code; } if (nameSpace.StartsWith("0x") && uint.TryParse(nameSpace.Substring(2), System.Globalization.NumberStyles.HexNumber, null, out hash)) { animation.Actor1Hash = hash; } else { hash = FNVHash.HashString32(nameSpace); if (!nameMap.TryGetValue(hash, out name) && (ean || !KeyNameReg.TryFindName(hash, out name))) { nameMap[hash] = sourceFile; } animation.Actor1Hash = hash; } animation.Actor2Hash = actor == null ? 0 : actor.NameHash; return(animation); }
public override GenericRCOLResource.ChunkEntry Export( IDictionary <ulong, string> nameMap, bool exportAllNames) { System.IO.Stream s = null; TGIBlock tgi = new TGIBlock(0, null, "ITG", ResourceType, 0, 0); JazzSelectOnParameterNode jsopn = new JazzSelectOnParameterNode(0, null, s); jsopn.ParameterDefinitionIndex = this.mParameter == null ? NullCRef : this.mParameter.ChunkReference; if (this.mCases.Count > 0) { int j; uint hash = 0; JazzSelectOnParameterNode.Match match; JazzSelectOnParameterNode.MatchList mList = jsopn.Matches; JazzChunk.ChunkReferenceList dgi; List <DecisionGraphNode> targets; foreach (CaseImpl c in this.mCases) { match = new JazzSelectOnParameterNode.Match(0, null); if (c.Value == null) { hash = 0; } else if (!c.Value.StartsWith("0x") || !uint.TryParse(c.Value.Substring(2), System.Globalization.NumberStyles.HexNumber, null, out hash)) { hash = FNVHash.HashString32(c.Value); if (nameMap != null && !nameMap.ContainsKey(hash) && (exportAllNames || !KeyNameReg.HasName(hash))) { nameMap[hash] = c.Value; } } match.TestValue = hash; dgi = match.DecisionGraphIndexes; targets = c.Targets; for (j = 0; j < targets.Count; j++) { dgi.Add(targets[j] == null ? NullCRef : targets[j].ChunkReference); } mList.Add(match); } } return(new GenericRCOLResource.ChunkEntry(0, null, tgi, jsopn)); }
private void resCellValuePushed(object sender, DataGridViewCellValueEventArgs e) { if (e.RowIndex < this.mResources.Length) { uint val32; ulong val64; string str = e.Value == null ? null : e.Value.ToString(); INamedResourceIndexEntry rie = this.mResources[e.RowIndex]; switch ((ColumnName)e.ColumnIndex) { case ColumnName.Tag: string[] strs = str.Split(' '); if (RK.TryParseHex32(strs[1], out val32)) { rie.ResourceType = val32; } if (this.mColIndex == (int)ColumnName.Tag || this.mColIndex == (int)ColumnName.TID) { if (this.CheckResDGVSorted(e.RowIndex)) { this.resDGV.UpdateCellValue( (int)ColumnName.TID, e.RowIndex); } else { this.UpdateResDGV(); } } else { this.resDGV.UpdateCellValue( (int)ColumnName.TID, e.RowIndex); } if (this.bDetectConflicts) { this.ClearConflictHighlighting(); this.HighlightConflicts(); } break; case ColumnName.TID: if (RK.TryParseUInt32(str, out val32)) { rie.ResourceType = val32; } if (this.mColIndex == (int)ColumnName.Tag || this.mColIndex == (int)ColumnName.TID) { if (this.CheckResDGVSorted(e.RowIndex)) { this.resDGV.UpdateCellValue( (int)ColumnName.Tag, e.RowIndex); } else { this.UpdateResDGV(); } } else { this.resDGV.UpdateCellValue( (int)ColumnName.Tag, e.RowIndex); } if (this.bDetectConflicts) { this.ClearConflictHighlighting(); this.HighlightConflicts(); } break; case ColumnName.GID: if (RK.TryParseUInt32(str, out val32)) { rie.ResourceGroup = val32; } if (this.mColIndex == (int)ColumnName.GID && !this.CheckResDGVSorted(e.RowIndex)) { this.UpdateResDGV(); } if (this.bDetectConflicts) { this.ClearConflictHighlighting(); this.HighlightConflicts(); } break; case ColumnName.IID: if (RK.TryParseUInt64(str, out val64)) { rie.Instance = val64; } if (this.mColIndex == (int)ColumnName.IID && !this.CheckResDGVSorted(e.RowIndex)) { this.UpdateResDGV(); } if (this.bDetectConflicts) { this.ClearConflictHighlighting(); this.HighlightConflicts(); } break; case ColumnName.Comp: bool comp = (bool)e.Value; rie.Compressed = (ushort)(comp ? 0xFFFF : 0x0000); if (this.mColIndex == (int)ColumnName.Comp && !this.CheckResDGVSorted(e.RowIndex)) { this.UpdateResDGV(); } break; case ColumnName.Name: rie.ResourceName = str; if (this.mAutoHashing != Hashing.None) { val64 = 0; if (str != null) { switch (this.mAutoHashing) { case Hashing.FNV32: val64 = FNVHash.HashString32(str); break; case Hashing.FNV64: val64 = FNVHash.HashString64(str); break; case Hashing.FNVCLIP: val64 = FNVCLIP.HashString(str); break; } } rie.Instance = val64; if (this.mColIndex == (int)ColumnName.IID || this.mColIndex == (int)ColumnName.Name) { if (this.CheckResDGVSorted(e.RowIndex)) { this.resDGV.UpdateCellValue( (int)ColumnName.IID, e.RowIndex); } else { this.UpdateResDGV(); } } else { this.resDGV.UpdateCellValue( (int)ColumnName.IID, e.RowIndex); } if (this.bDetectConflicts) { this.ClearConflictHighlighting(); this.HighlightConflicts(); } } if (this.mColIndex == (int)ColumnName.Name && !this.CheckResDGVSorted(e.RowIndex)) { this.UpdateResDGV(); } break; } } }
private void FillKNMP(KNMPackage knmp, IDictionary <ulong, string> map) { GenCLIP gc; ulong h, ch; string s, cs; foreach (KeyValuePair <ulong, string> nm in map) { h = nm.Key; s = nm.Value; if (FNVHash.HashString64(s) == h || FNVHash.HashString32(s) == h) { knmp.Names[h] = s; } else if (FNVCLIP.HashString(s) == h) { cs = FNVCLIP.GetGenericValue(s); ch = FNVHash.HashString64(cs) & 0x7FFFFFFFFFFFFFFF; knmp.Generics[ch] = cs; if (!this.mGenCLIPs.TryGetValue(ch, out gc)) { gc = new GenCLIP(cs); this.mGenCLIPs.Add(ch, gc); } gc.CLIPNames[h] = new CLIP(s, knmp.Path); } else { knmp.Labels[h] = s; } } if (knmp.Names.Count > 0) { List <KeyValuePair <ulong, string> > names = new List <KeyValuePair <ulong, string> >(knmp.Names); foreach (KeyValuePair <ulong, string> name in names) { s = name.Value; if (name.Key < 0x100000000) { h = FNVHash.HashString64(s); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = s; } } else { h = FNVHash.HashString32(s); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = s; } } cs = FNVCLIP.GetGenericValue(s); if (!string.Equals(s, cs, StringComparison.OrdinalIgnoreCase)) { h = FNVHash.HashString32(cs); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = cs; } h = FNVHash.HashString64(cs); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = cs; } } } } if (knmp.Generics.Count > 0) { foreach (KeyValuePair <ulong, string> gen in knmp.Generics) { s = gen.Value; h = FNVHash.HashString32(s); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = s; } h = FNVHash.HashString64(s); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = s; } cs = FNVCLIP.GetGenericValue(s); h = FNVHash.HashString32(cs); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = cs; } h = FNVHash.HashString64(cs); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = cs; } cs = string.Concat(cs, ".ma"); h = FNVHash.HashString32(cs); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = cs; } h = FNVHash.HashString64(cs); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = cs; } s = string.Concat(s, ".ma"); h = FNVHash.HashString32(s); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = s; } h = FNVHash.HashString64(s); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = s; } } } if (knmp.Labels.Count > 0) { foreach (KeyValuePair <ulong, string> label in knmp.Labels) { s = label.Value; h = FNVHash.HashString32(s); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = s; } h = FNVHash.HashString64(s); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = s; } cs = FNVCLIP.GetGenericValue(s); if (!string.Equals(s, cs, StringComparison.OrdinalIgnoreCase)) { h = FNVHash.HashString32(cs); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = cs; } h = FNVHash.HashString64(cs); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = cs; } cs = string.Concat(cs, ".ma"); h = FNVHash.HashString32(cs); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = cs; } h = FNVHash.HashString64(cs); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = cs; } } s = string.Concat(s, ".ma"); h = FNVHash.HashString32(s); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = s; } h = FNVHash.HashString64(s); if (!knmp.Names.ContainsKey(h)) { knmp.Names[h] = s; } } } }