Exemple #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);
            }
        }
Exemple #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);
            }
        }
Exemple #3
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);
        }