public JazzGraphContainer(int index, string name, Control view) { this.Index = index; this.mName = name ?? ""; this.UndoRedo = new UndoManager(); this.SaveState = JazzSaveState.Dirty; ulong iid = 0; if (!this.mName.StartsWith("0x") || !ulong.TryParse(this.mName.Substring(2), System.Globalization.NumberStyles.HexNumber, null, out iid)) { iid = FNVHash.HashString64(this.mName); } this.Key = new RK(GlobalManager.kJazzTID, 0, iid); this.Comp = true; this.JP = null; this.RIE = null; StateMachine sm = new StateMachine(name); this.Scene = new StateMachineScene(sm, view, this); KKLayoutAlgorithm <StateNode, StateEdge> layout = new KKLayoutAlgorithm <StateNode, StateEdge>( this.Scene.StateGraph, this.Scene); layout.LengthFactor = 1.25f; this.Scene.Layout = layout; layout.ShuffleNodes(); this.Scene.LayoutPaused = true; this.Scene.StartLayout(); }
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 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 void RefreshName(bool unhash = false) { if (!this.bNameIsLabel && this.IID != FNVHash.HashString64(this.mName)) { if (KeyNameReg.TryFindName( this.IID, out this.mName)) { this.bNameIsLabel = false; } else if (KeyNameReg.TryFindLabel( this.IID, out this.mName)) { this.bNameIsLabel = true; } else if (unhash) { this.mName = KeyNameReg.UnhashName(this.IID); this.bNameIsLabel = false; } else { this.mName = "0x" + this.IID.ToString("X16"); this.bNameIsLabel = false; } } }
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 void fnv64_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.HashString64(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(); } } }
public override int GetHashCode() { FNVHash fnv = new FNVHash(); uint floats = fnv.Hash((uint)voronoiInf, (uint)cloudInf, (uint)1f); uint ints = fnv.Hash((uint)size, (uint)seed, (uint)seed); return (int)fnv.Hash(floats, ints, (uint)seed); }
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; }
public JazzGraphContainer(int index, StateMachine sm, Control view, TabPage page) { this.Index = index; this.mName = sm.Name; this.UndoRedo = new UndoManager(); this.SaveState = JazzSaveState.Dirty; this.Key = new RK(GlobalManager.kJazzTID, 0, FNVHash.HashString64(this.mName)); this.Comp = true; this.JP = null; this.RIE = null; this.Scene = new StateMachineScene(sm, view, this); KKLayoutAlgorithm <StateNode, StateEdge> layout = new KKLayoutAlgorithm <StateNode, StateEdge>( this.Scene.StateGraph, this.Scene); layout.LengthFactor = 1.25f; this.Scene.Layout = layout; layout.ShuffleNodes(); this.Scene.LayoutPaused = true; this.Scene.StartLayout(); this.mPage = page; this.mPage.Controls.Add(view); this.mPage.Text = this.mName + " *"; this.mPage.SizeChanged += new EventHandler(this.OnTabSizeChanged); }
public override int GetHashCode() { FNVHash fnv = new FNVHash(); uint pass1 = fnv.Hash((uint)upperLeftStart, (uint)lowerLeftStart, (uint)lowerRightStart); uint pass2 = fnv.Hash((uint)lowerLeftStart, (uint)lowerRightStart, (uint)upperRightStart); uint pass3 = fnv.Hash((uint)lowerRightStart, (uint)upperRightStart, (uint)upperLeftStart); return (int)fnv.Hash(pass1, pass2, pass3); }
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 ulong NVMULongHashSpecializedInt() { ulong sum = 0; for (int i = 0; i < N; i++) { sum += FNVHash <ulong> .GetHashValueULong(i); } return(sum); }
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)); }
public override void Undo() { this.mContainer.mName = this.mOldName; ulong iid = FNVHash.HashString64(this.mOldName); this.mContainer.Key.IID = iid; if (this.mContainer.RIE != null) { this.mContainer.RIE.Instance = iid; } if (this.mContainer.Scene != null) { this.mContainer.Scene.StateMachine.Name = this.mOldName; } }
public override bool Execute() { this.mContainer.mName = this.mNewName; ulong iid = FNVHash.HashString64(this.mNewName); this.mContainer.Key.IID = iid; if (this.mContainer.RIE != null) { this.mContainer.RIE.Instance = iid; } if (this.mContainer.Scene != null) { this.mContainer.Scene.StateMachine.Name = this.mNewName; } return(true); }
private void ParseIID() { ulong iid = 0; if (this.mName.Length == 0) { iid = FNVHash.HashString64(this.mName); this.bNameIsValid = false; } else if (RK.TryParseHex64(this.mName, out iid)) { this.bNameIsValid = this.AllowHexNumberName; } else { iid = FNVHash.HashString64(this.mName); this.bNameIsValid = true; } this.mKey.IID = iid; }
public override int GetHashCode() { FNVHash fnv = new FNVHash(); return (int)fnv.Hash((uint)metric, (uint)combiner, (uint)(numberOfFeaturePoints^numberOfSubregions)); }
public static unsafe int Checksum(this MemoryRegion region) { return(FNVHash.ComputeInt32((byte *)region.Start, (int)region.Size)); }
public override int GetHashCode() { return(FNVHash.GetFNVHash(Type, NodeAlias, RelationshipOrNodeAlias)); }
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; } } } }
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; } } }
public void GenerateGuid(E_WeaponID parentID, string parentIdAsStr) { ParentID = parentID; GUID = Mathf.Abs(FNVHash.CalcModFNVHash(parentIdAsStr + GetSettingsClass() + GetIdAsStr())); }
} // true, pokud ma byt zarazen do DefaultPPI internal int CalcGUIDFromID() { return(Mathf.Abs(FNVHash.CalcModFNVHash(GUID_CALC_PREFIX + GetSettingsClass() + GetIdAsStr()))); }
private string ShortenUrl(string longUrl) { UInt32 hash = FNVHash.fnv_32a_str(longUrl); return(Base58Converter.Encode(hash)); }