static IMultilingualUnicodeStringReference AddOrGetReferenceByName(Blam.CacheFile c, IMultilingualUnicodeStringList list, Blam.StringId name) { // See if a reference already exists for [name]... foreach (var sref in list.StringRefs) { if (sref.Name.Handle == name) { return(sref); } } // one doesn't, so add it and return the new block data IMultilingualUnicodeStringReference sr = list.NewReference(); // Initialize name id sr.Name.Handle = name; sr.Name.OwnerId = c.TagIndexManager.IndexId; // Initialize all the offsets to be invalid foreach (var lang_offset in sr.LanguageOffsets) { lang_offset.Value = -1; } return(sr); }
public void ReconstructTagData(Blam.CacheFile c, IMultilingualUnicodeStringList list, int this_lang) { for (int x = 0, dst_offset = mTagDataOffset, size; x < mReferenceCount; x++, dst_offset += size) { var dst = list.StringData.Value; Blam.StringId name; size = mPack.CopyStringReferenceData(mReferenceIndex + x, dst, dst_offset, out name); var sref = AddOrGetReferenceByName(c, list, name); sref.LanguageOffsets[this_lang].Value = dst_offset; } }