public override string ToString() { var str = JenkIndex.TryGetString(Hash); if (!string.IsNullOrEmpty(str)) { return(str); } return(GlobalText.GetString(Hash)); }
public void Read(BinaryReader br) { u003 = br.ReadUInt32(); //176, 16 //256 us001 = br.ReadUInt16(); //6, 5 us002 = br.ReadUInt16(); //6, 12 us003 = br.ReadUInt16(); //6, 5 us004 = br.ReadUInt16(); //6, 5 us005 = br.ReadUInt16(); //6, 5 us006 = br.ReadUInt16(); //6, 5 Name = FxcFile.ReadString(br); // <fxc name> _locals //"rage_matrices", "misc_globals", "lighting_globals", "more_stuff" JenkIndex.Ensure(Name); //why not :P }
private static MetaHash GetHash(string str) { if (str.StartsWith("hash_")) { return((MetaHash)Convert.ToUInt32(str.Substring(5), 16)); } else { JenkIndex.Ensure(str); return(JenkHash.GenHash(str)); } }
public override string ToString() { var str = JenkIndex.TryGetString(Hash); if (!string.IsNullOrEmpty(str)) { return(str); } if (Enum.IsDefined(typeof(MetaName), Hash)) { return(((MetaName)Hash).ToString()); } return(GlobalText.GetString(Hash)); }
private void LoadMeta() { var vVariationInfo = MetaTypes.GetTypedData <CPedVariationInfo>(Meta, MetaName.CPedVariationInfo); VariationInfo = new MCPedVariationInfo(); VariationInfo.Load(Meta, vVariationInfo); Strings = MetaTypes.GetStrings(Meta); if (Strings != null) { foreach (string str in Strings) { JenkIndex.Ensure(str); //just shove them in there } } }
public static MetaHash GetHash(string str) { if (string.IsNullOrEmpty(str)) { return(0); } if (str.StartsWith("hash_")) { return((MetaHash)Convert.ToUInt32(str.Substring(5), 16)); } else { JenkIndex.Ensure(str); return(JenkHash.GenHash(str)); } }
public void Read(DataReader reader) { Ident = reader.ReadInt32(); Length = reader.ReadInt32(); List <string> strs = new List <string>(); while (reader.Position < reader.Length) { strs.Add(reader.ReadString()); } foreach (var str in strs) { JenkIndex.Ensure(str); JenkIndex.Ensure(str.ToLowerInvariant()); } Strings = strs.ToArray(); }
public void BuildCutsceneMap(int cutIndex) { CutsceneMap = new Dictionary <MetaHash, ClipMapEntry>(); var replstr = "-" + cutIndex.ToString(); foreach (var cme in ClipMapEntries) { var sn = cme?.Clip?.ShortName ?? ""; if (sn.EndsWith(replstr)) { sn = sn.Substring(0, sn.Length - replstr.Length); } if (sn.EndsWith("_dual")) { sn = sn.Substring(0, sn.Length - 5); } JenkIndex.Ensure(sn); var h = JenkHash.GenHash(sn); CutsceneMap[h] = cme; } }
public void Load(byte[] data, RpfFileEntry entry) { Name = entry.Name; RpfFileEntry = entry; RpfResourceFileEntry resentry = entry as RpfResourceFileEntry; if (resentry == null) { throw new Exception("File entry wasn't a resource! (is it binary data?)"); } ResourceDataReader rd = new ResourceDataReader(resentry, data); DrawableDict = rd.ReadBlock <DrawableDictionary>(); //MemoryUsage = 0; //uses decompressed filesize now... //if (DrawableDict != null) //{ // MemoryUsage += DrawableDict.MemoryUsage; //} if ((DrawableDict != null) && (DrawableDict.Drawables != null) && (DrawableDict.Drawables.data_items != null) && (DrawableDict.Hashes != null)) { Dict = new Dictionary <uint, Drawable>(); var drawables = DrawableDict.Drawables.data_items; var hashes = DrawableDict.Hashes; for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++) { var drawable = drawables[i]; var hash = hashes[i]; Dict[hash] = drawable; drawable.Owner = this; } for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++) { var drawable = drawables[i]; var hash = hashes[i]; if ((drawable.Name == null) || (drawable.Name.EndsWith("#dd"))) { string hstr = JenkIndex.TryGetString(hash); if (!string.IsNullOrEmpty(hstr)) { drawable.Name = hstr; } else { } } } Drawables = Dict.Values.ToArray(); } Loaded = true; }
public void Load(byte[] data, RpfFileEntry entry) { Name = entry.Name; RpfFileEntry = entry; RpfResourceFileEntry resentry = entry as RpfResourceFileEntry; if (resentry == null) { throw new Exception("File entry wasn't a resource! (is it binary data?)"); } ResourceDataReader rd = new ResourceDataReader(resentry, data); //MemoryUsage = 0; try { PtfxList = rd.ReadBlock <ParticleEffectsList>(); //Drawable.Owner = this; //MemoryUsage += Drawable.MemoryUsage; //uses decompressed filesize now... } catch (Exception ex) { ErrorMessage = ex.ToString(); } var dDict = PtfxList?.DrawableDictionary; if ((dDict != null) && (dDict.Drawables != null) && (dDict.Drawables.data_items != null) && (dDict.Hashes != null)) { DrawableDict = new Dictionary <uint, Drawable>(); var drawables = dDict.Drawables.data_items; var hashes = dDict.Hashes; for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++) { var drawable = drawables[i]; var hash = hashes[i]; DrawableDict[hash] = drawable; drawable.Owner = this; } for (int i = 0; (i < drawables.Length) && (i < hashes.Length); i++) { var drawable = drawables[i]; var hash = hashes[i]; if ((drawable.Name == null) || (drawable.Name.EndsWith("#dd"))) { string hstr = JenkIndex.TryGetString(hash); if (!string.IsNullOrEmpty(hstr)) { drawable.Name = hstr; } else { drawable.Name = "0x" + hash.ToString("X").PadLeft(8, '0'); } } } } Loaded = true; }
public void Load(byte[] data, RpfFileEntry entry) { Name = entry.Name; RpfFileEntry = entry; RpfResourceFileEntry resentry = entry as RpfResourceFileEntry; if (resentry == null) { MemoryStream ms = new MemoryStream(data); if (RbfFile.IsRBF(ms)) { Rbf = new RbfFile(); Rbf.Load(ms); } else if (PsoFile.IsPSO(ms)) { Pso = new PsoFile(); Pso.Load(ms); //PsoTypes.EnsurePsoTypes(Pso); } else { } return; } ResourceDataReader rd = new ResourceDataReader(resentry, data); Meta = rd.ReadBlock <Meta>(); _CMapTypes = MetaTypes.GetTypedData <CMapTypes>(Meta, MetaName.CMapTypes); List <Archetype> allarchs = new List <Archetype>(); var ptrs = MetaTypes.GetPointerArray(Meta, _CMapTypes.archetypes); if (ptrs != null) { for (int i = 0; i < ptrs.Length; i++) { var ptr = ptrs[i]; var offset = ptr.Offset; var block = Meta.GetBlock(ptr.BlockID); if (block == null) { continue; } if ((offset < 0) || (block.Data == null) || (offset >= block.Data.Length)) { continue; } Archetype a = null; switch (block.StructureNameHash) { case MetaName.CBaseArchetypeDef: var basearch = PsoTypes.ConvertDataRaw <CBaseArchetypeDef>(block.Data, offset); a = new Archetype(); a.Init(this, ref basearch); a.Extensions = MetaTypes.GetExtensions(Meta, basearch.extensions); break; case MetaName.CTimeArchetypeDef: var timearch = PsoTypes.ConvertDataRaw <CTimeArchetypeDef>(block.Data, offset); var ta = new TimeArchetype(); ta.Init(this, ref timearch); ta.Extensions = MetaTypes.GetExtensions(Meta, timearch._BaseArchetypeDef.extensions); a = ta; break; case MetaName.CMloArchetypeDef: var mloarch = PsoTypes.ConvertDataRaw <CMloArchetypeDef>(block.Data, offset); var ma = new MloArchetype(); ma.Init(this, ref mloarch); ma.Extensions = MetaTypes.GetExtensions(Meta, mloarch._BaseArchetypeDef.extensions); ma.LoadChildren(Meta); a = ma; break; default: continue; } if (a != null) { allarchs.Add(a); } } } AllArchetypes = allarchs.ToArray(); Extensions = MetaTypes.GetExtensions(Meta, _CMapTypes.extensions); if (Extensions != null) { } //AudioEmitters = MetaTypes.GetTypedDataArray<CExtensionDefAudioEmitter>(Meta, MetaName.CExtensionDefAudioEmitter); //if (AudioEmitters != null) //{ } //CEntityDefs = MetaTypes.GetTypedDataArray<CEntityDef>(Meta, MetaName.CEntityDef); CompositeEntityTypes = MetaTypes.ConvertDataArray <CCompositeEntityType>(Meta, MetaName.CCompositeEntityType, _CMapTypes.compositeEntityTypes); if (CompositeEntityTypes != null) { } NameHash = _CMapTypes.name; if (NameHash == 0) { int ind = entry.NameLower.LastIndexOf('.'); if (ind > 0) { NameHash = JenkHash.GenHash(entry.NameLower.Substring(0, ind)); } else { NameHash = JenkHash.GenHash(entry.NameLower); } } Strings = MetaTypes.GetStrings(Meta); if (Strings != null) { foreach (string str in Strings) { JenkIndex.Ensure(str); //just shove them in there } } //foreach (var block in Meta.DataBlocks) //{ // switch(block.StructureNameHash) // { // case MetaName.CMapTypes: // case MetaName.CTimeArchetypeDef: // case MetaName.CBaseArchetypeDef: // case MetaName.CMloArchetypeDef: // case MetaName.CMloTimeCycleModifier: // case MetaName.CMloRoomDef: // case MetaName.CMloPortalDef: // case MetaName.CMloEntitySet: // case MetaName.CEntityDef: // case MetaName.CExtensionDefParticleEffect: // case MetaName.CExtensionDefAudioCollisionSettings: // case MetaName.CExtensionDefSpawnPoint: // case MetaName.CExtensionDefSpawnPointOverride: // case MetaName.CExtensionDefExplosionEffect: // case MetaName.CExtensionDefAudioEmitter: // case MetaName.CExtensionDefLadder: // case MetaName.CExtensionDefBuoyancy: // case MetaName.CExtensionDefExpression: // case MetaName.CExtensionDefLightShaft: // case MetaName.CExtensionDefLightEffect: // case MetaName.CExtensionDefDoor: // case MetaName.CExtensionDefWindDisturbance: // case MetaName.CExtensionDefProcObject: // case MetaName.CLightAttrDef: // case (MetaName)MetaTypeName.STRING: // case (MetaName)MetaTypeName.POINTER: // case (MetaName)MetaTypeName.UINT: // case (MetaName)MetaTypeName.VECTOR4: // break; // default: // break; // } //} //MetaTypes.ParseMetaData(Meta); }
public void BuildBaseJenkIndex() { JenkIndex.Clear(); foreach (RpfFile file in AllRpfs) { try { JenkIndex.Ensure(file.Name); foreach (RpfEntry entry in file.AllEntries) { var nlow = entry.NameLower; if (string.IsNullOrEmpty(nlow)) { continue; } JenkIndex.Ensure(entry.Name); JenkIndex.Ensure(nlow); //JenkIndex.Ensure(entry.Path); //JenkIndex.Ensure(entry.Path.ToLower()); int ind = nlow.LastIndexOf('.'); if (ind > 0) { JenkIndex.Ensure(entry.Name.Substring(0, ind)); JenkIndex.Ensure(nlow.Substring(0, ind)); //if (ind < entry.Name.Length - 2) //{ // JenkIndex.Ensure(entry.Name.Substring(0, ind) + ".#" + entry.Name.Substring(ind + 2)); // JenkIndex.Ensure(entry.NameLower.Substring(0, ind) + ".#" + entry.NameLower.Substring(ind + 2)); //} } if (nlow.EndsWith(".ydr") || nlow.EndsWith(".yft")) { var sname = nlow.Substring(0, nlow.Length - 4); JenkIndex.Ensure(sname + "_lod"); JenkIndex.Ensure(sname + "_loda"); JenkIndex.Ensure(sname + "_lodb"); } if (nlow.EndsWith(".ydd")) { if (nlow.EndsWith("_children.ydd")) { var strn = nlow.Substring(0, nlow.Length - 13); JenkIndex.Ensure(strn); JenkIndex.Ensure(strn + "_lod"); JenkIndex.Ensure(strn + "_loda"); JenkIndex.Ensure(strn + "_lodb"); } var idx = nlow.LastIndexOf('_'); if (idx > 0) { var str1 = nlow.Substring(0, idx); var idx2 = str1.LastIndexOf('_'); if (idx2 > 0) { var str2 = str1.Substring(0, idx2); JenkIndex.Ensure(str2 + "_lod"); var maxi = 100; for (int i = 1; i <= maxi; i++) { var str3 = str2 + "_" + i.ToString().PadLeft(2, '0'); //JenkIndex.Ensure(str3); JenkIndex.Ensure(str3 + "_lod"); } } } } } } catch { //failing silently!! not so good really } } }
public override string ToString() { return((string.IsNullOrEmpty(Name)) ? JenkIndex.GetString(Key.Hash) : Name); }
public void BuildBaseJenkIndex() { JenkIndex.Clear(); StringBuilder sb = new StringBuilder(); foreach (RpfFile file in AllRpfs) { try { JenkIndex.Ensure(file.Name); foreach (RpfEntry entry in file.AllEntries) { var nlow = entry.NameLower; if (string.IsNullOrEmpty(nlow)) { continue; } //JenkIndex.Ensure(entry.Name); //JenkIndex.Ensure(nlow); int ind = nlow.LastIndexOf('.'); if (ind > 0) { JenkIndex.Ensure(entry.Name.Substring(0, ind)); JenkIndex.Ensure(nlow.Substring(0, ind)); //if (ind < entry.Name.Length - 2) //{ // JenkIndex.Ensure(entry.Name.Substring(0, ind) + ".#" + entry.Name.Substring(ind + 2)); // JenkIndex.Ensure(entry.NameLower.Substring(0, ind) + ".#" + entry.NameLower.Substring(ind + 2)); //} } else { JenkIndex.Ensure(entry.Name); JenkIndex.Ensure(nlow); } if (BuildExtendedJenkIndex) { if (nlow.EndsWith(".ydr"))// || nlow.EndsWith(".yft")) //do yft's get lods? { var sname = nlow.Substring(0, nlow.Length - 4); JenkIndex.Ensure(sname + "_lod"); JenkIndex.Ensure(sname + "_loda"); JenkIndex.Ensure(sname + "_lodb"); } if (nlow.EndsWith(".ydd")) { if (nlow.EndsWith("_children.ydd")) { var strn = nlow.Substring(0, nlow.Length - 13); JenkIndex.Ensure(strn); JenkIndex.Ensure(strn + "_lod"); JenkIndex.Ensure(strn + "_loda"); JenkIndex.Ensure(strn + "_lodb"); } var idx = nlow.LastIndexOf('_'); if (idx > 0) { var str1 = nlow.Substring(0, idx); var idx2 = str1.LastIndexOf('_'); if (idx2 > 0) { var str2 = str1.Substring(0, idx2); JenkIndex.Ensure(str2 + "_lod"); var maxi = 100; for (int i = 1; i <= maxi; i++) { var str3 = str2 + "_" + i.ToString().PadLeft(2, '0'); //JenkIndex.Ensure(str3); JenkIndex.Ensure(str3 + "_lod"); } } } } if (nlow.EndsWith(".sps")) { JenkIndex.Ensure(nlow); //for shader preset filename hashes! } if (nlow.EndsWith(".awc")) //create audio container path hashes... { string[] parts = entry.Path.Split('\\'); int pl = parts.Length; if (pl > 2) { string fn = parts[pl - 1]; string fd = parts[pl - 2]; string hpath = fn.Substring(0, fn.Length - 4); if (fd.EndsWith(".rpf")) { fd = fd.Substring(0, fd.Length - 4); } hpath = fd + "/" + hpath; if (parts[pl - 3] != "sfx") { } //no hit JenkIndex.Ensure(hpath); } } if (nlow.EndsWith(".nametable")) { RpfBinaryFileEntry binfe = entry as RpfBinaryFileEntry; if (binfe != null) { byte[] data = file.ExtractFile(binfe); if (data != null) { sb.Clear(); for (int i = 0; i < data.Length; i++) { byte c = data[i]; if (c == 0) { string str = sb.ToString(); if (!string.IsNullOrEmpty(str)) { string strl = str.ToLowerInvariant(); //JenkIndex.Ensure(str); JenkIndex.Ensure(strl); ////DirMod_Sounds_ entries apparently can be used to infer SP audio strings ////no luck here yet though //if (strl.StartsWith("dirmod_sounds_") && (strl.Length > 14)) //{ // strl = strl.Substring(14); // JenkIndex.Ensure(strl); //} } sb.Clear(); } else { sb.Append((char)c); } } } } else { } } } } } catch { //failing silently!! not so good really } } }
public void Load(byte[] data, RpfFileEntry entry) { Name = entry.Name; RpfFileEntry = entry; //Hash = entry.ShortNameHash; RpfResourceFileEntry resentry = entry as RpfResourceFileEntry; if (resentry == null) { throw new Exception("File entry wasn't a resource! (is it binary data?)"); } ResourceDataReader rd = new ResourceDataReader(resentry, data); ClipDictionary = rd.ReadBlock <ClipDictionary>(); ClipMap = new Dictionary <MetaHash, ClipMapEntry>(); AnimMap = new Dictionary <MetaHash, AnimationMapEntry>(); if (ClipDictionary != null) { if ((ClipDictionary.Clips != null) && (ClipDictionary.Clips.data_items != null)) { foreach (var cme in ClipDictionary.Clips.data_items) { if (cme != null) { ClipMap[cme.Hash] = cme; var nxt = cme.Next; while (nxt != null) { ClipMap[nxt.Hash] = nxt; nxt = nxt.Next; } } } } if ((ClipDictionary.Animations != null) && (ClipDictionary.Animations.Animations != null) && (ClipDictionary.Animations.Animations.data_items != null)) { foreach (var ame in ClipDictionary.Animations.Animations.data_items) { if (ame != null) { AnimMap[ame.Hash] = ame; var nxt = ame.NextEntry; while (nxt != null) { AnimMap[nxt.Hash] = nxt; nxt = nxt.NextEntry; } } } } } foreach (var cme in ClipMap.Values) { var clip = cme.Clip; if (clip == null) { continue; } clip.Ycd = this; if (string.IsNullOrEmpty(clip.Name)) { continue; } string name = clip.Name.Replace('\\', '/'); var slidx = name.LastIndexOf('/'); if ((slidx >= 0) && (slidx < name.Length - 1)) { name = name.Substring(slidx + 1); } var didx = name.LastIndexOf('.'); if ((didx > 0) && (didx < name.Length)) { name = name.Substring(0, didx); } clip.ShortName = name; name = name.ToLowerInvariant(); JenkIndex.Ensure(name); //if (name.EndsWith("_uv_0")) //hash for these entries match string with this removed, +1 //{ //} //if (name.EndsWith("_uv_1")) //same as above, but +2 //{ //} } foreach (var ame in AnimMap.Values) { var anim = ame.Animation; if (anim == null) { continue; } anim.Ycd = this; } ClipMapEntries = ClipMap.Values.ToArray(); AnimMapEntries = AnimMap.Values.ToArray(); }
public void Load(byte[] data, RpfFileEntry entry) { FileEntry = entry; RpfResourceFileEntry resentry = entry as RpfResourceFileEntry; if (resentry == null) { MemoryStream ms = new MemoryStream(data); if (RbfFile.IsRBF(ms)) { Rbf = new RbfFile(); Rbf.Load(ms); } else if (PsoFile.IsPSO(ms)) { Pso = new PsoFile(); Pso.Load(ms); //PsoTypes.EnsurePsoTypes(Pso); } else { } return; } ResourceDataReader rd = new ResourceDataReader(resentry, data); Meta = rd.ReadBlock <Meta>(); CMapTypes = MetaTypes.GetTypedData <CMapTypes>(Meta, MetaName.CMapTypes); List <Archetype> allarchs = new List <Archetype>(); var ptrs = MetaTypes.GetPointerArray(Meta, CMapTypes.archetypes); if (ptrs != null) { for (int i = 0; i < ptrs.Length; i++) { var ptr = ptrs[i]; int blocki = ptr.BlockID - 1; int offset = ptr.ItemOffset * 16;//block data size... if (blocki >= Meta.DataBlocks.Count) { continue; } var block = Meta.DataBlocks[blocki]; if ((offset < 0) || (block.Data == null) || (offset >= block.Data.Length)) { continue; } var ba = new Archetype(); switch (block.StructureNameHash) { case MetaName.CBaseArchetypeDef: var basearch = PsoTypes.ConvertDataRaw <CBaseArchetypeDef>(block.Data, offset); ba.Init(this, basearch); ba.Extensions = MetaTypes.GetExtensions(Meta, basearch.extensions); break; case MetaName.CTimeArchetypeDef: var timearch = PsoTypes.ConvertDataRaw <CTimeArchetypeDef>(block.Data, offset); ba.Init(this, timearch); ba.Extensions = MetaTypes.GetExtensions(Meta, timearch.CBaseArchetypeDef.extensions); break; case MetaName.CMloArchetypeDef: var mloarch = PsoTypes.ConvertDataRaw <CMloArchetypeDef>(block.Data, offset); ba.Init(this, mloarch); ba.Extensions = MetaTypes.GetExtensions(Meta, mloarch.CBaseArchetypeDef.extensions); MloArchetypeData mlod = new MloArchetypeData(); mlod.entities = MetaTypes.ConvertDataArray <CEntityDef>(Meta, MetaName.CEntityDef, mloarch.entities); mlod.rooms = MetaTypes.ConvertDataArray <CMloRoomDef>(Meta, MetaName.CMloRoomDef, mloarch.rooms); mlod.portals = MetaTypes.ConvertDataArray <CMloPortalDef>(Meta, MetaName.CMloPortalDef, mloarch.portals); mlod.entitySets = MetaTypes.ConvertDataArray <CMloEntitySet>(Meta, MetaName.CMloEntitySet, mloarch.entitySets); mlod.timeCycleModifiers = MetaTypes.ConvertDataArray <CMloTimeCycleModifier>(Meta, MetaName.CMloTimeCycleModifier, mloarch.timeCycleModifiers); ba.MloData = mlod; //if (mlod.entities != null) //{ // for (int e = 0; e < mlod.entities.Length; e++) // { // EnsureEntityExtensions(Meta, ref mlod.entities[e]); // } //} break; default: continue; } allarchs.Add(ba); } } AllArchetypes = allarchs.ToArray(); Extensions = MetaTypes.GetExtensions(Meta, CMapTypes.extensions); if (Extensions != null) { } AudioEmitters = MetaTypes.GetTypedDataArray <CExtensionDefAudioEmitter>(Meta, MetaName.CExtensionDefAudioEmitter); if (AudioEmitters != null) { } //CEntityDefs = MetaTypes.GetTypedDataArray<CEntityDef>(Meta, MetaName.CEntityDef); CompositeEntityTypes = MetaTypes.ConvertDataArray <CCompositeEntityType>(Meta, MetaName.CCompositeEntityType, CMapTypes.compositeEntityTypes); if (CompositeEntityTypes != null) { } NameHash = CMapTypes.name; if (NameHash == 0) { int ind = entry.NameLower.LastIndexOf('.'); if (ind > 0) { NameHash = JenkHash.GenHash(entry.NameLower.Substring(0, ind)); } else { NameHash = JenkHash.GenHash(entry.NameLower); } } Strings = MetaTypes.GetStrings(Meta); if (Strings != null) { foreach (string str in Strings) { JenkIndex.Ensure(str); //just shove them in there } } foreach (var block in Meta.DataBlocks) { switch (block.StructureNameHash) { case MetaName.CMapTypes: case MetaName.CTimeArchetypeDef: case MetaName.CBaseArchetypeDef: case MetaName.CMloArchetypeDef: case MetaName.CMloTimeCycleModifier: case MetaName.CMloRoomDef: case MetaName.CMloPortalDef: case MetaName.CMloEntitySet: case MetaName.CEntityDef: case MetaName.CExtensionDefParticleEffect: case MetaName.CExtensionDefAudioCollisionSettings: case MetaName.CExtensionDefSpawnPoint: case MetaName.CExtensionDefSpawnPointOverride: case MetaName.CExtensionDefExplosionEffect: case MetaName.CExtensionDefAudioEmitter: case MetaName.CExtensionDefLadder: case MetaName.CExtensionDefBuoyancy: case MetaName.CExtensionDefExpression: case MetaName.CExtensionDefLightShaft: case MetaName.CExtensionDefLightEffect: case MetaName.CExtensionDefDoor: case MetaName.CExtensionDefWindDisturbance: case MetaName.CExtensionDefProcObject: case MetaName.CLightAttrDef: case MetaName.STRING: //case MetaName.SectionUNKNOWN2: //case MetaName.SectionUNKNOWN3: //case MetaName.SectionUNKNOWN8: case MetaName.POINTER: case MetaName.UINT: case MetaName.VECTOR4: break; default: break; } } //MetaTypes.ParseMetaData(Meta); //RpfResourceFileEntry resentry = entry as RpfResourceFileEntry; //if (resentry == null) //{ // throw new Exception("File entry wasn't a resource! (is it binary data?)"); //} //ResourceDataReader rd = new ResourceDataReader(resentry, data); //Meta = rd.ReadBlock<Meta>(); //MetaTypes.EnsureMetaTypes(Meta); //MetaTypes.ParseMetaData(Meta); }
public void Load(byte[] data, RpfFileEntry entry) { Name = entry.Name; RpfFileEntry = entry; RpfResourceFileEntry resentry = entry as RpfResourceFileEntry; if (resentry == null) { NonMetaLoad(data); return; } ResourceDataReader rd = new ResourceDataReader(resentry, data); Meta = rd.ReadBlock <Meta>(); CMapData = MetaTypes.GetTypedData <CMapData>(Meta, MetaName.CMapData); Strings = MetaTypes.GetStrings(Meta); if (Strings != null) { foreach (string str in Strings) { JenkIndex.Ensure(str); //just shove them in there } } physicsDictionaries = MetaTypes.GetHashArray(Meta, CMapData.physicsDictionaries); EnsureEntities(Meta); //load all the entity data and create the YmapEntityDefs EnsureInstances(Meta); EnsureLodLights(Meta); EnsureDistantLODLights(Meta); EnsureTimeCycleModifiers(Meta); EnsureCarGens(Meta); EnsureBoxOccluders(Meta); EnsureOccludeModels(Meta); EnsureContainerLods(Meta); #region data block test and old code //foreach (var block in Meta.DataBlocks) //{ // switch (block.StructureNameHash) // { // case MetaName.STRING: // case MetaName.POINTER: // case MetaName.HASH: // case MetaName.UINT: // case MetaName.VECTOR3: //distant lod lights uses this // case MetaName.CMapData: // case MetaName.CEntityDef: // case MetaName.CTimeCycleModifier: //these sections are handled already // case MetaName.CCarGen: // case MetaName.CLightAttrDef: // case MetaName.CMloInstanceDef: // case MetaName.CExtensionDefDoor: // case MetaName.CExtensionDefLightEffect: // case MetaName.CExtensionDefSpawnPointOverride: // case MetaName.rage__fwGrassInstanceListDef: //grass instance buffer // case MetaName.rage__fwGrassInstanceListDef__InstanceData: //grass instance buffer data // break; // case MetaName.PhVerletClothCustomBounds: //these sections still todo.. // case MetaName.SectionUNKNOWN1: // case MetaName.SectionUNKNOWN5://occlusion vertex data container // case MetaName.SectionUNKNOWN7://occlusion related? // break; // case (MetaName)17: //vertex data - occlusion related - SectionUNKNOWN5 // break; // case (MetaName)33: //what is this? maybe lodlights related // break; // default: // break; // } //} //MetaTypes.ParseMetaData(Meta); //string shortname = resentry.Name.Substring(0, resentry.Name.LastIndexOf('.')); //uint namehash = JenkHash.GenHash(shortname); //CLightAttrDefs = MetaTypes.GetTypedDataArray<CLightAttrDef>(Meta, MetaName.CLightAttrDef); //if (CLightAttrDefs != null) //{ } //var unk5s = MetaTypes.GetTypedDataArray<SectionUNKNOWN5>(Meta, MetaName.SectionUNKNOWN5); //if (unk5s != null) //used in occlusion ymaps //{ // foreach (var unk5 in unk5s) // { // if ((unk5.verts.Ptr > 0) && (unk5.verts.Ptr <= (ulong)Meta.DataBlocks.Length)) // { // var indicesoffset = unk5.Unk_853977995; // var datablock = Meta.DataBlocks[((int)unk5.verts.Ptr) - 1]; // if (datablock != null) // { }//vertex data... occlusion mesh? // } // } //} //var unk7s = MetaTypes.GetTypedDataArray<SectionUNKNOWN7>(Meta, MetaName.SectionUNKNOWN7); //if (unk7s != null) //{ } //used in occlusion ymaps //var unk10s = MetaTypes.GetTypedDataArray<SectionUNKNOWN10>(Meta, MetaName.SectionUNKNOWN10); //if (unk10s != null) //{ } //entity pointer array.. //CDoors = MetaTypes.GetTypedDataArray<CExtensionDefDoor>(Meta, MetaName.CExtensionDefDoor); //if (CDoors != null) //{ } //needs work - doors can be different types? not enough bytes for one //CExtLightEffects = MetaTypes.GetTypedDataArray<CExtensionDefLightEffect>(Meta, MetaName.CExtensionDefLightEffect); //if (CExtLightEffects != null) //{ } //CSpawnOverrides = MetaTypes.GetTypedDataArray<CExtensionDefSpawnPointOverride>(Meta, MetaName.CExtensionDefSpawnPointOverride); //if (CSpawnOverrides != null) //{ } #endregion }
} //8 Bounds//3298223272: Array: 8: 1 {256: INT_0Bh: 0} public override string ToString() { return(JenkIndex.GetString(Name)); }