Ejemplo n.º 1
0
        //added of the gpk, leaving the game files untouched
        private void AddCompsite(GpkPackage package, string savepath, string tmpPath, string compositeFile)
        {
            var patchDataSize = new FileInfo(tmpPath).Length;

            //patch mappings
            if (package.CompositeEntry != null)
            {
                //remove from old
                CompositeMap[Path.GetFileNameWithoutExtension(package.Path)].Remove(package.CompositeEntry);


                //modify our entry
                package.CompositeEntry.FileLength = (int)patchDataSize;
                package.CompositeEntry.FileOffset = 0;
                package.CompositeEntry.SubGPKName = compositeFile;

                if (!CompositeMap.ContainsKey(compositeFile))
                {
                    CompositeMap[compositeFile] = new List <CompositeMapEntry>();
                }

                CompositeMap[compositeFile].Add(package.CompositeEntry);

                MapperTools.WriteMappings(savepath, this, true, false);
            }
        }
Ejemplo n.º 2
0
        //in-sito patch of a composite gpk file, as in modifing the actual game files
        private void PatchComposite(GpkPackage package, string savepath, string tmpPath)
        {
            //ugly and quick, replace with direct memory save
            //patch, move entries
            var compositeData = File.ReadAllBytes(package.Path);
            var patchData     = File.ReadAllBytes(tmpPath);
            var patchDiff     = patchData.Length - package.CompositeEntry.FileLength;

            var compositeSize   = compositeData.Length;
            var compsiteFileEnd = package.CompositeEntry.FileOffset + package.CompositeEntry.FileLength;

            if (patchDiff >= 0)
            {
                //enlarge
                Array.Resize(ref compositeData, compositeSize + patchDiff);
            }
            //move data up/down
            var upperData = new byte[compositeSize - compsiteFileEnd];

            Array.ConstrainedCopy(compositeData, compsiteFileEnd, upperData, 0, upperData.Length);

            //patchdiff could be negative, so data can be moved down
            Array.ConstrainedCopy(upperData, 0, compositeData, compsiteFileEnd + patchDiff, upperData.Length);

            //copy it in
            Array.ConstrainedCopy(patchData, 0, compositeData, package.CompositeEntry.FileOffset, patchData.Length);


            if (patchDiff < 0)
            {
                //shrink
                Array.Resize(ref compositeData, compositeSize + patchDiff);
            }


            File.WriteAllBytes(savepath, compositeData);

            //patch mappings
            if (package.CompositeEntry != null && package.CompositeEntry.FileLength != patchData.Length)
            {
                //modify entries accordingly
                foreach (var entry in CompositeMap[Path.GetFileNameWithoutExtension(package.Path)])
                {
                    if (entry.FileOffset > package.CompositeEntry.FileOffset)
                    {
                        entry.FileOffset += patchDiff;
                    }
                }

                //modify our entry
                package.CompositeEntry.FileLength = patchData.Length;

                MapperTools.WriteMappings(CoreSettings.Default.CookedPCPath, this, true, false);
            }
        }
Ejemplo n.º 3
0
        internal void CheckNamePresence(GpkPackage package)
        {
            package.GetStringIndex(ObjectName);

            foreach (IProperty iProp in Properties)
            {
                GpkBaseProperty baseProperty = (GpkBaseProperty)iProp;
                package.GetStringIndex(baseProperty.name);
                package.GetStringIndex(baseProperty.type);

                iProp.CheckAndAddNames(package);
            }
        }
Ejemplo n.º 4
0
        public string CopyObjectFromPackage(string objectname, GpkPackage foreignPackage, bool replaceDuplicates)
        {
            //recurse it down!
            if (objectname == null || objectname == "none")
            {
                return("none");
            }

            object copyObj = foreignPackage.GetObjectByUID(objectname);
            object ownObj  = GetObjectByUID(objectname);

            //found a dup (likely something such as a common import Core.Core or Core.Engine)
            if (ownObj != null && replaceDuplicates)
            {
                return(null);
            }

            if (copyObj is GpkImport)
            {
                var importObj = (GpkImport)copyObj;
                AddImport(importObj);
                //resolve owners
                string newOwnerUID = CopyObjectFromPackage(importObj.OwnerObject, foreignPackage, false);

                importObj.OwnerObject = newOwnerUID;

                return(importObj.UID);
            }
            else
            {
                var exportObj = (GpkExport)copyObj;
                AddExport(exportObj);

                CopyObjectFromPackage(exportObj.ClassName, foreignPackage, false);
                CopyObjectFromPackage(exportObj.PackageName, foreignPackage, false);
                CopyObjectFromPackage(exportObj.SuperName, foreignPackage, false);
                CopyObjectFromPackage(exportObj.NetIndexName, foreignPackage, false);

                return(exportObj.UID);
            }
        }
Ejemplo n.º 5
0
        //patch pkgmapper to not include the modified entrys
        public void MultiPatchObjectMapper(GpkPackage package, string savepath)
        {
            int count = 0;

            foreach (var export in package.ExportList)
            {
                //generate name
                //S1UI_SelectServer.SelectServer_I4
                var fullUID = $"{package.Filename.Split('.')[0]}.{export.Value.UID}";

                var compositeUID = FindObjectMapperEntryForObjectname(fullUID);
                if (compositeUID != null)
                {
                    ObjectMapperList.Remove(compositeUID);
                    logger.Debug("ObjectMapperList: removing uid " + fullUID);
                    count++;
                }
            }

            logger.Info("Removed the mappings for {0} entries. For details see debug log.", count);
            MapperTools.WriteMappings(savepath, this, false, true);
        }
Ejemplo n.º 6
0
 public void CheckNamePresence(GpkPackage package)
 {
     package.GetStringIndex(ClassPackage);
     package.GetStringIndex(ClassName);
     package.GetStringIndex(ObjectName);
 }
Ejemplo n.º 7
0
 public GpkExport(GpkPackage mothership)
 {
     motherPackage = mothership;
     Properties    = new List <IProperty>();
 }
Ejemplo n.º 8
0
        public void DeleteGpk(GpkPackage package)
        {
            LoadedGpkPackages.Remove(package);

            PackagesChanged?.Invoke();
        }
Ejemplo n.º 9
0
 public void RecalculateCounts(GpkPackage package)
 {
     NameCount   = package.NameList.Count;
     ExportCount = package.ExportList.Count;
     ImportCount = package.ImportList.Count;
 }