Exemple #1
0
        /// <summary>
        /// Reads the data-block from a stream.
        /// </summary>
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            // read structure data
            this.VFT         = reader.ReadUInt32();
            this.Unknown_4h  = reader.ReadUInt32();
            this.Unknown_8h  = reader.ReadUInt32();
            this.Unknown_Ch  = reader.ReadUInt32();
            this.Unknown_10h = reader.ReadUInt32();
            this.Unknown_14h = reader.ReadUInt32();
            this.Unknown_18h = reader.ReadUInt32();
            this.Unknown_1Ch = reader.ReadUInt32();
            this.Unknown_20h = reader.ReadUInt32();
            this.Unknown_24h = reader.ReadUInt32();
            this.NamePointer = reader.ReadUInt64();
            this.Unknown_30h = reader.ReadUInt32();
            this.Unknown_34h = reader.ReadUInt32();
            this.Unknown_38h = reader.ReadUInt32();
            this.Unknown_3Ch = reader.ReadUInt32();

            // read reference data
            this.Name = reader.ReadStringAt( //BlockAt<string_r>(
                this.NamePointer             // offset
                );

            if (!string.IsNullOrEmpty(Name))
            {
                NameHash = JenkHash.GenHash(Name.ToLowerInvariant());
            }
        }
Exemple #2
0
 public virtual void ReadXml(XmlNode node, string ddsfolder)
 {
     Name        = Xml.GetChildInnerText(node, "Name");
     NameHash    = JenkHash.GenHash(Name?.ToLowerInvariant());
     Unknown_32h = (ushort)Xml.GetChildUIntAttribute(node, "Unk32", "value");
     Usage       = Xml.GetChildEnumInnerText <TextureUsage>(node, "Usage");
     UsageFlags  = Xml.GetChildEnumInnerText <TextureUsageFlags>(node, "UsageFlags");
     ExtraFlags  = Xml.GetChildUIntAttribute(node, "ExtraFlags", "value");
 }
Exemple #3
0
 private static MetaHash GetHash(string str)
 {
     if (str.StartsWith("hash_"))
     {
         return((MetaHash)Convert.ToUInt32(str.Substring(5), 16));
     }
     else
     {
         return(JenkHash.GenHash(str));
     }
 }
Exemple #4
0
 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));
     }
 }
Exemple #5
0
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            // read structure data
            this.VFT         = reader.ReadUInt32();
            this.Unknown_4h  = reader.ReadUInt32();
            this.Unknown_8h  = reader.ReadUInt32();
            this.Unknown_Ch  = reader.ReadUInt32();
            this.Unknown_10h = reader.ReadUInt32();
            this.Unknown_14h = reader.ReadUInt32();
            this.Unknown_18h = reader.ReadUInt32();
            this.Unknown_1Ch = reader.ReadUInt32();
            this.Unknown_20h = reader.ReadUInt32();
            this.Unknown_24h = reader.ReadUInt32();
            this.NamePointer = reader.ReadUInt64();
            this.Unknown_30h = reader.ReadUInt16();
            this.Unknown_32h = reader.ReadUInt16();
            this.Unknown_34h = reader.ReadUInt32();
            this.Unknown_38h = reader.ReadUInt32();
            this.Unknown_3Ch = reader.ReadUInt32();

            // read reference data
            this.Name = reader.ReadStringAt( //BlockAt<string_r>(
                this.NamePointer             // offset
                );

            if (!string.IsNullOrEmpty(Name))
            {
                NameHash = JenkHash.GenHash(Name.ToLowerInvariant());
            }

            switch (Unknown_32h)
            {
            case 0x20:
            case 0x28:
            case 0x30:
            case 0x38:
            case 0x40:
            case 0x48:
            case 0x80:
            case 0x90:
            case 0x2:    //embedded
                break;

            default:
                break;
            }
        }
Exemple #6
0
        public void BuildMap()
        {
            ExprMap = new Dictionary <MetaHash, Expression>();

            if ((Expressions?.data_items != null) && (ExpressionNameHashes?.data_items != null))
            {
                var exprs = Expressions.data_items;
                var names = ExpressionNameHashes.data_items;

                for (int i = 0; i < exprs.Length; i++)
                {
                    var expr = exprs[i];
                    var name = (i < names.Length) ? names[i] : (MetaHash)JenkHash.GenHash(expr?.Name?.ToString()?.ToLowerInvariant() ?? "");
                    ExprMap[name] = expr;
                }
            }
        }
Exemple #7
0
        public static bool Ensure(string str)
        {
            uint hash = JenkHash.GenHash(str);

            if (hash == 0)
            {
                return(true);
            }
            lock (syncRoot)
            {
                if (!Index.ContainsKey(hash))
                {
                    Index.Add(hash, str);
                    return(false);
                }
            }
            return(true);
        }
Exemple #8
0
        public static TextHash GetTextHash(string str)
        {
            if (string.IsNullOrEmpty(str))
            {
                return(0);
            }
            if (str.StartsWith("hash_"))
            {
                return(Convert.ToUInt32(str.Substring(5), 16));
            }
            else
            {
                uint h = GlobalText.TryFindHash(str);
                if (h != 0)
                {
                    return(h);
                }

                return(JenkHash.GenHash(str));
            }
        }
Exemple #9
0
        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;
            }
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        private void AddRpfFile(RpfFile file, bool isdlc, bool ismod)
        {
            isdlc = isdlc || (file.NameLower == "dlc.rpf") || (file.NameLower == "update.rpf");
            ismod = ismod || (file.Path.StartsWith("mods\\"));

            if (file.AllEntries != null)
            {
                AllRpfs.Add(file);
                if (!ismod)
                {
                    AllNoModRpfs.Add(file);
                }
                if (isdlc)
                {
                    DlcRpfs.Add(file);
                    if (!ismod)
                    {
                        DlcNoModRpfs.Add(file);
                    }
                }
                else
                {
                    if (ismod)
                    {
                        ModRpfs.Add(file);
                    }
                    else
                    {
                        BaseRpfs.Add(file);
                    }
                }
                if (ismod)
                {
                    ModRpfDict[file.Path.Substring(5)] = file;
                }

                RpfDict[file.Path] = file;

                foreach (RpfEntry entry in file.AllEntries)
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(entry.Name))
                        {
                            if (ismod)
                            {
                                ModEntryDict[entry.Path] = entry;
                                ModEntryDict[entry.Path.Substring(5)] = entry;
                            }
                            else
                            {
                                EntryDict[entry.Path] = entry;
                            }

                            if (entry is RpfFileEntry)
                            {
                                RpfFileEntry fentry = entry as RpfFileEntry;
                                entry.NameHash = JenkHash.GenHash(entry.NameLower);
                                int ind = entry.NameLower.LastIndexOf('.');
                                entry.ShortNameHash = (ind > 0) ? JenkHash.GenHash(entry.NameLower.Substring(0, ind)) : entry.NameHash;
                                if (entry.ShortNameHash != 0)
                                {
                                    //EntryHashDict[entry.ShortNameHash] = entry;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        file.LastError     = ex.ToString();
                        file.LastException = ex;
                        ErrorLog(entry.Path + ": " + ex.ToString());
                    }
                }
            }

            if (file.Children != null)
            {
                foreach (RpfFile cfile in file.Children)
                {
                    AddRpfFile(cfile, isdlc, ismod);
                }
            }
        }
Exemple #12
0
        public override void Read(ResourceDataReader reader, params object[] parameters)
        {
            // read structure data
            this.VFT         = reader.ReadUInt32();
            this.Unknown_4h  = reader.ReadUInt32();
            this.Unknown_8h  = reader.ReadUInt32();
            this.Unknown_Ch  = reader.ReadUInt32();
            this.Unknown_10h = reader.ReadUInt32();
            this.Unknown_14h = reader.ReadUInt32();
            this.Unknown_18h = reader.ReadUInt32();
            this.Unknown_1Ch = reader.ReadUInt32();
            this.Unknown_20h = reader.ReadUInt32();
            this.Unknown_24h = reader.ReadUInt32();
            this.NamePointer = reader.ReadUInt64();
            this.Unknown_30h = reader.ReadUInt16();
            this.Unknown_32h = reader.ReadUInt16();
            this.Unknown_34h = reader.ReadUInt32();
            this.Unknown_38h = reader.ReadUInt32();
            this.Unknown_3Ch = reader.ReadUInt32();
            this.UsageData   = reader.ReadUInt32();
            this.Unknown_44h = reader.ReadUInt32();
            this.ExtraFlags  = reader.ReadUInt32();
            this.Unknown_4Ch = reader.ReadUInt32();



            // read reference data
            this.Name = reader.ReadStringAt( //BlockAt<string_r>(
                this.NamePointer             // offset
                );

            if (!string.IsNullOrEmpty(Name))
            {
                NameHash = JenkHash.GenHash(Name.ToLowerInvariant());
            }

            //switch (Unknown_32h)
            //{
            //    case 0x20:
            //    case 0x28:
            //    case 0x30:
            //    case 0x38:
            //    case 0x40:
            //    case 0x48:
            //    case 0x80:
            //    case 0x90:
            //    case 0x2://base/shaderparam
            //        break;
            //    default:
            //        break;//no hit
            //}

            //switch (Usage)
            //{
            //    case TextureUsage.UNKNOWN:// = 0,
            //    case TextureUsage.DEFAULT:// = 1,
            //    case TextureUsage.TERRAIN:// = 2,
            //    case TextureUsage.CLOUDDENSITY:// = 3,
            //    case TextureUsage.CLOUDNORMAL:// = 4,
            //    case TextureUsage.CABLE:// = 5,
            //    case TextureUsage.FENCE:// = 6,
            //    case TextureUsage.SCRIPT:// = 8,
            //    case TextureUsage.WATERFLOW:// = 9,
            //    case TextureUsage.WATERFOAM:// = 10,
            //    case TextureUsage.WATERFOG:// = 11,
            //    case TextureUsage.WATEROCEAN:// = 12,
            //    case TextureUsage.FOAMOPACITY:// = 14,
            //    case TextureUsage.DIFFUSEMIPSHARPEN:// = 16,
            //    case TextureUsage.DIFFUSEDARK:// = 18,
            //    case TextureUsage.DIFFUSEALPHAOPAQUE:// = 19,
            //    case TextureUsage.DIFFUSE:// = 20,
            //    case TextureUsage.DETAIL:// = 21,
            //    case TextureUsage.NORMAL:// = 22,
            //    case TextureUsage.SPECULAR:// = 23,
            //    case TextureUsage.EMISSIVE:// = 24,
            //    case TextureUsage.TINTPALETTE:// = 25,
            //    case TextureUsage.SKIPPROCESSING:// = 26,
            //        break;
            //    case TextureUsage.ENVEFF:// = 7, //unused by V
            //    case TextureUsage.WATER:// = 13, //unused by V
            //    case TextureUsage.FOAM:// = 15,  //unused by V
            //    case TextureUsage.DIFFUSEDETAIL:// = 17, //unused by V
            //    case TextureUsage.DONOTOPTIMIZE:// = 27, //unused by V
            //    case TextureUsage.TEST:// = 28,  //unused by V
            //    case TextureUsage.COUNT:// = 29, //unused by V
            //        break;//no hit
            //    default:
            //        break;//no hit
            //}

            //var uf = UsageFlags;
            //if ((uf & TextureUsageFlags.EMBEDDEDSCRIPTRT) > 0) // .ydr embedded script_rt textures, only 3 uses
            //{ }
            //if ((uf & TextureUsageFlags.UNK19) > 0)
            //{ }//no hit
            //if ((uf & TextureUsageFlags.UNK20) > 0)
            //{ }//no hit
            //if ((uf & TextureUsageFlags.UNK21) > 0)
            //{ }//no hit
            //if ((uf & TextureUsageFlags.UNK24) == 0)//wtf isthis? only 0 on special resident(?) textures and some reused ones
            //{ }

            //if (!(this is Texture))
            //{
            //    if (Unknown_32h != 0x2)//base/shaderparam
            //    { }//no hit
            //    if (UsageData != 0)
            //    { }//no hit
            //    if (Unknown_44h != 0)
            //    { }//no hit
            //    if (ExtraFlags != 0)
            //    { }//no hit
            //    if (Unknown_4Ch != 0)
            //    { }//no hit
            //}
        }
Exemple #13
0
 public virtual void ReadXml(XmlNode node, string ddsfolder)
 {
     Name        = Xml.GetChildInnerText(node, "Name");
     NameHash    = JenkHash.GenHash(Name?.ToLowerInvariant());
     Unknown_32h = (ushort)Xml.GetChildUIntAttribute(node, "Unk32", "value");
 }
Exemple #14
0
        public byte[] Save()
        {
            //direct save to a raw, compressed ymap file (openIV-compatible format)


            //since Ymap object contents have been modified, need to recreate the arrays which are what is saved.
            BuildCEntityDefs();
            BuildCCarGens();


            //TODO:
            //BuildInstances();
            //BuildLodLights();
            //BuildDistantLodLights();
            //BuildTimecycleModifiers(); //already being saved - update them..
            //BuildBoxOccluders();
            //BuildOccludeModels();
            //BuildContainerLods();



            MetaBuilder mb = new MetaBuilder();


            var mdb = mb.EnsureBlock(MetaName.CMapData);

            CMapData mapdata = CMapData;


            if (CEntityDefs != null)
            {
                for (int i = 0; i < CEntityDefs.Length; i++)
                {
                    var yent = AllEntities[i]; //save the extensions..
                    CEntityDefs[i].extensions = mb.AddWrapperArrayPtr(yent.Extensions);
                }
            }

            mapdata.entities = mb.AddItemPointerArrayPtr(MetaName.CEntityDef, CEntityDefs);

            mapdata.timeCycleModifiers = mb.AddItemArrayPtr(MetaName.CTimeCycleModifier, CTimeCycleModifiers);

            mapdata.physicsDictionaries = mb.AddHashArrayPtr(physicsDictionaries);

            mapdata.carGenerators = mb.AddItemArrayPtr(MetaName.CCarGen, CCarGens);

            if (CMloInstanceDefs != null)
            {
                LogSaveWarning("CMloInstanceDefs were present, may not save properly. (TODO!)");
            }

            //clear everything out for now - TODO: fix
            if (mapdata.containerLods.Count1 != 0)
            {
                LogSaveWarning("containerLods were not saved. (TODO!)");
            }
            if (mapdata.occludeModels.Count1 != 0)
            {
                LogSaveWarning("occludeModels were not saved. (TODO!)");
            }
            if (mapdata.boxOccluders.Count1 != 0)
            {
                LogSaveWarning("boxOccluders were not saved. (TODO!)");
            }
            if (mapdata.instancedData.GrassInstanceList.Count1 != 0)
            {
                LogSaveWarning("instancedData.GrassInstanceList was not saved. (TODO!)");
            }
            if (mapdata.instancedData.PropInstanceList.Count1 != 0)
            {
                LogSaveWarning("instancedData.PropInstanceList was not saved. (TODO!)");
            }
            if (mapdata.LODLightsSOA.direction.Count1 != 0)
            {
                LogSaveWarning("LODLightsSOA was not saved. (TODO!)");
            }
            if (mapdata.DistantLODLightsSOA.position.Count1 != 0)
            {
                LogSaveWarning("DistantLODLightsSOA was not saved. (TODO!)");
            }
            mapdata.containerLods       = new Array_Structure();
            mapdata.occludeModels       = new Array_Structure();
            mapdata.boxOccluders        = new Array_Structure();
            mapdata.instancedData       = new rage__fwInstancedMapData();
            mapdata.LODLightsSOA        = new CLODLight();
            mapdata.DistantLODLightsSOA = new CDistantLODLight();



            var block = new CBlockDesc();

            block.name       = mb.AddStringPtr(Path.GetFileNameWithoutExtension(Name));
            block.exportedBy = mb.AddStringPtr("CodeWalker");
            block.time       = mb.AddStringPtr(DateTime.UtcNow.ToString("dd MMMM yyyy HH:mm"));

            mapdata.block = block;


            string name     = Path.GetFileNameWithoutExtension(Name);
            uint   nameHash = JenkHash.GenHash(name);

            mapdata.name = new MetaHash(nameHash);//make sure name is upto date...


            mb.AddItem(MetaName.CMapData, mapdata);



            //make sure all the relevant structure and enum infos are present.
            mb.AddStructureInfo(MetaName.rage__fwInstancedMapData);
            mb.AddStructureInfo(MetaName.CLODLight);
            mb.AddStructureInfo(MetaName.CDistantLODLight);
            mb.AddStructureInfo(MetaName.CBlockDesc);
            mb.AddStructureInfo(MetaName.CMapData);
            mb.AddStructureInfo(MetaName.CEntityDef);
            mb.AddStructureInfo(MetaName.CTimeCycleModifier);
            if ((CCarGens != null) && (CCarGens.Length > 0))
            {
                mb.AddStructureInfo(MetaName.CCarGen);
            }

            mb.AddEnumInfo((MetaName)1264241711); //LODTYPES_
            mb.AddEnumInfo((MetaName)648413703);  //PRI_


            Meta meta = mb.GetMeta();

            byte[] data = ResourceBuilder.Build(meta, 2); //ymap is version 2...


            return(data);
        }
Exemple #15
0
        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);
        }