public CacheExtractionInfo(CacheFile cf, DatumIndex tag_datum, CacheExtractionArguments args) { var bd = Program.GetManager(cf.EngineVersion); Database = bd.CreateCacheTagDatabase(cf.CacheId); DatabaseErrors = bd.CreateErrorTagDatabase(); root_definition = cf.Index.Tags[tag_datum.Index]; Reset(root_definition); Arguments = args; Arguments.CreateOutputDirectory(); }
public static void OutputStringIds(CacheFile cache, string path, bool map_string_ids_only) { var sidm = cache.StringIds; using (System.IO.StreamWriter s = new System.IO.StreamWriter(path)) { if (!map_string_ids_only) { switch (sidm.Definition.Description.Method) { case Blam.StringIdDesc.GenerateIdMethod.ByLength: foreach (var kv in sidm.StaticIdsContainer.StringIdsEnumerator()) { s.WriteLine("{0}\t{1}", kv.Key.ToUInt32().ToString("X8"), kv.Value); } break; case Blam.StringIdDesc.GenerateIdMethod.BySet: foreach (var kv in sidm.StaticIdsContainer.StringIdsEnumerator()) { if (kv.Key.Set == 0) { s.WriteLine("{0}\t{1}", kv.Key.ToUInt32().ToString("X8"), kv.Value); } } break; } } s.WriteLine("Cache String Ids:"); foreach (var kv in sidm.DynamicIdsContainer.StringIdsEnumerator()) { s.WriteLine("\t{0}\t{1}", kv.Key.ToUInt32().ToString("X8"), kv.Value); } } }
/// <summary> /// Don't call me directly. Call <see cref="CacheFile.AddFeignTagInstance"/> /// </summary> /// <param name="cf">Owner of this tag index</param> /// <param name="tag_name"></param> /// <param name="group_tag"></param> /// <returns></returns> internal virtual CacheIndex.Item AddFeignItem(CacheFile cf, string tag_name, TagInterface.TagGroup group_tag) { return(null); }
public static void OutputTags(CacheFile cf, string path) { using (System.IO.StreamWriter s = new System.IO.StreamWriter(path)) { s.WriteLine("Mask: {0}", cf.AddressMask.ToString("X8")); s.WriteLine(); OutputHeader(cf.Header, s); cf.OutputExtraHeaderInfo(s); s.WriteLine(); cf.OutputExtraTagIndexInfo(s); int x; CacheIndex.Item[] items = cf.Index.Tags; Dictionary <uint, List <CacheIndex.Item> > dic = new Dictionary <uint, List <CacheIndex.Item> >(); s.WriteLine("Tag Instances:"); x = 0; foreach (var item in items) { if (!item.IsEmpty) { s.WriteLine("\t0x{0}\t{1}\t{2}\t{3}\t{4}\t{5}", x.ToString("X"), item.Datum.Handle.ToString("X8"), item.Address.ToString("X8"), item.Offset.ToString("X8"), item.GroupTag.TagToString(), cf.GetReferenceName(item)); List <CacheIndex.Item> list; if (!dic.TryGetValue(item.GroupTagInt, out list)) { dic.Add(item.GroupTagInt, list = new List <CacheIndex.Item>()); } list.Add(item); } x++; } s.WriteLine(); cf.OutputExtraTagInstanceInfo(s); s.WriteLine(); foreach (KeyValuePair <uint, List <CacheIndex.Item> > kv in dic) { s.WriteLine("Group:\t--{0}--", new string(TagInterface.TagGroup.FromUInt(kv.Key, false))); foreach (CacheIndex.Item ci in kv.Value) { s.WriteLine("\t{0}\t{1}\t{2}\t{3}\t{4}", ci.Datum.Handle.ToString("X8"), ci.Address.ToString("X8"), ci.Offset.ToString("X8"), ci.GroupTag.TagToString(), cf.GetReferenceName(ci)); } s.WriteLine(); s.WriteLine(); } } }
/// <summary> /// Share the cache information from <paramref name="src"/> with /// <paramref name="dst"/> /// </summary> /// <param name="dst">Destination cache object</param> /// <param name="src">Source cache object with the information we want shared</param> internal protected static void ShareCacheStreams(CacheFile dst, CacheFile src) { dst.InputStream = src.InputStream; dst.OutputStream = src.OutputStream; dst.IsSharedReference = true; }
/// <summary> /// Determines if <paramref name="other"/> is a shared reference /// </summary> /// <param name="path"></param> /// <param name="other"></param> /// <returns></returns> internal static bool SharableReference(string path, CacheFile other) { return(other != null && other.InputStream.FileName == path); }