/// <summary> /// Adds a new File to the Items /// </summary> /// <param name="item">the new File</param> public void Add(ClstItem item) { ClstItem[] its = new ClstItem[items.Length + 1]; items.CopyTo(its, 0); its[its.Length - 1] = item; items = its; }
/// <summary> /// Unserializes a BinaryStream into the Attributes of this Instance /// </summary> /// <param name="reader">The Stream that contains the FileData</param> protected override void Unserialize(System.IO.BinaryReader reader) { this.IndexType = package.Header.IndexType; long count = 0; if (iformat == Data.MetaData.IndexTypes.ptLongFileIndex) { count = reader.BaseStream.Length / 0x14; } else { count = reader.BaseStream.Length / 0x10; } items = new ClstItem[count]; long pos = reader.BaseStream.Position; bool switch_t = false; for (int i = 0; i < count; i++) { ClstItem item = new ClstItem(this.IndexType); item.Unserialize(reader); if ((i == 2) && (!switch_t)) { switch_t = true; if (Package.FindFile(item.Type, item.SubType, item.Group, item.Instance) == null) { i = 0; if (iformat == Data.MetaData.IndexTypes.ptLongFileIndex) { iformat = Data.MetaData.IndexTypes.ptShortFileIndex; } else { iformat = Data.MetaData.IndexTypes.ptLongFileIndex; } reader.BaseStream.Seek(pos, System.IO.SeekOrigin.Begin); item = new ClstItem(this.IndexType); item.Unserialize(reader); } } items[i] = item; } }
/// <summary> /// Returns the Number of the File matching the passed Descriptor /// </summary> /// <param name="pfd">A PackedFileDescriptor</param> /// <returns>-1 if none was foudn or the index number of the first matching file</returns> public int FindFile(IPackedFileDescriptor pfd) { if (items == null) { return(-1); } for (int i = 0; i < this.items.Length; i++) { ClstItem lfi = items[i]; if ((lfi.Group == pfd.Group) && (lfi.Instance == pfd.Instance) && ((lfi.SubType == pfd.SubType) || (iformat == Data.MetaData.IndexTypes.ptShortFileIndex)) && (lfi.Type == pfd.Type)) { return(i); } } return(-1); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj is ClstItem) { ClstItem ci = (ClstItem)obj; return(ci.Group == Group && ci.Instance == Instance && ci.Type == type && (ci.SubType == SubType || ci.format == Data.MetaData.IndexTypes.ptShortFileIndex || format == Data.MetaData.IndexTypes.ptShortFileIndex)); } else if (obj is SimPe.Interfaces.Files.IPackedFileDescriptor) { SimPe.Interfaces.Files.IPackedFileDescriptor ci = (SimPe.Interfaces.Files.IPackedFileDescriptor)obj; return(ci.Group == Group && ci.Instance == Instance && ci.Type == type && (ci.SubType == SubType || format == Data.MetaData.IndexTypes.ptShortFileIndex)); } else { return(base.Equals(obj)); } }
public void ScanPackage(ScannerItem si, SimPe.Cache.PackageState ps, System.Windows.Forms.ListViewItem lvi) { ps.Data = new uint[1]; ps.State = TriState.True; ps.Data[0] = (uint)HealthState.Ok; if (si.Package.Header.Version != 0x100000001) { ps.Data[0] = (uint)HealthState.UnknownVersion; } else { if (si.Package.FileListFile != null) { foreach (SimPe.PackedFiles.Wrapper.ClstItem item in si.Package.FileListFile.Items) { SimPe.Interfaces.Files.IPackedFileDescriptor p = si.Package.FindFile(item.Type, item.SubType, item.Group, item.Instance); if (p == null) { ps.Data[0] = (uint)HealthState.WrongDirectory; break; } } if (ps.Data[0] == (uint)HealthState.Ok) { foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in si.Package.Index) { SimPe.Interfaces.Files.IPackedFile fl = si.Package.Read(pfd); if (pfd.Type == Data.MetaData.OBJD_FILE) { SimPe.PackedFiles.Wrapper.ExtObjd obj = new ExtObjd(); obj.ProcessData(pfd, si.Package); if (obj.Ok != SimPe.PackedFiles.Wrapper.ObjdHealth.Ok) { ps.Data[0] = (uint)HealthState.NonDefaultObjd; } if (obj.Ok == SimPe.PackedFiles.Wrapper.ObjdHealth.UnmatchingFilenames && Helper.WindowsRegistry.HiddenMode) { ps.Data[0] = (uint)HealthState.FaultyNamedObjd; } if (obj.Ok == ObjdHealth.OverLength) { ps.Data[0] = (uint)HealthState.FaultySizedObjd; } } if (pfd.Type == Data.MetaData.GMDC) { SimPe.Plugin.GenericRcol rcol = new GenericRcol(); rcol.ProcessData(pfd, si.Package); SimPe.Plugin.GeometryDataContainer gmdc = (SimPe.Plugin.GeometryDataContainer)rcol.Blocks[0]; foreach (SimPe.Plugin.Gmdc.GmdcGroup g in gmdc.Groups) { if (g.FaceCount > SimPe.Plugin.Gmdc.AbstractGmdcImporter.CRITICAL_FACE_AMOUNT) { ps.Data[0] = (uint)HealthState.BigMeshGeometry; } else if (g.UsedVertexCount > SimPe.Plugin.Gmdc.AbstractGmdcImporter.CRITICAL_VERTEX_AMOUNT) { ps.Data[0] = (uint)HealthState.BigMeshGeometry; } } } if (!fl.IsCompressed) { continue; } int pos = si.Package.FileListFile.FindFile(pfd); if (pos == -1) { ps.Data[0] = (uint)HealthState.IncompleteDirectory; break; } SimPe.PackedFiles.Wrapper.ClstItem item = si.Package.FileListFile.Items[pos]; if (fl.UncompressedSize != item.UncompressedSize) { ps.Data[0] = (uint)HealthState.WrongCompressionSize; break; } } } } if (ps.Data[0] != (uint)HealthState.Ok) { ps.State = TriState.False; } } UpdateState(si, ps, lvi); }