Esempio n. 1
0
        public TableForm(PackFile packFile)
        {
            _packFile = packFile;
            TableFormInit();

            try
            {
                _packFile.BeginDatReading();
            }
            catch(Exception e)
            {
                String message = "Unable to open accompanying data file: \n" + _packFile.NameWithoutExtension + ".dat\nYou will be unable to extract any files.\n" + e;
                MessageBox(message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Parses a single index file on the specified path. Checking for accompanying dat file and populating file index.
        /// </summary>
        /// <param name="packFile">The full path of the index file to parse.</param>
        private void _LoadIndexFile(PackFile packFile)
        {
            // loop through index files
            foreach (PackFileEntry currFileEntry in packFile.Files)
            {
                //if (currFileEntry.Name.Contains("bldg_c_station_warp_next_layout.xml.cooked") || currFileEntry.Name.Contains("sku."))
                //{
                //    int bp = 0;
                //}

                ulong pathHash = currFileEntry.PathHash;

                // have we added the file yet
                if (!FileEntries.ContainsKey(pathHash))
                {
                    FileEntries.Add(pathHash, currFileEntry);
                    continue;
                }

                // we haven't added the file, so we need to compare file times and backup states
                PackFileEntry origFileEntry = FileEntries[pathHash];

                // do backup checks first as they'll "override" the FileTime values (i.e. file not found causes game to go to older version)
                // if currFile IS a backup, and orig is NOT, then add to Siblings as game will be loading orig over "backup" anyways
                if (currFileEntry.IsPatchedOut && !origFileEntry.IsPatchedOut)
                {
                    if (origFileEntry.Siblings == null)
                    {
                        origFileEntry.Siblings = new List <PackFileEntry>();
                    }
                    origFileEntry.Siblings.Add(currFileEntry);

                    continue;
                }

                // if curr is NOT a backup, but orig IS, then we want to update (i.e. don't care about FileTime; as above)
                // OR if orig is older than curr, we also want to update/re-arrange Siblings, etc
                if ((!currFileEntry.IsPatchedOut && origFileEntry.IsPatchedOut) ||
                    origFileEntry.FileTime < currFileEntry.FileTime)
                {
                    // set the Siblings list to the updated FileEntry and null out other
                    if (origFileEntry.Siblings != null)
                    {
                        currFileEntry.Siblings = origFileEntry.Siblings;
                        origFileEntry.Siblings = null;
                    }

                    // add the "orig" (now old) to the curr FileEntry.Siblings list
                    if (currFileEntry.Siblings == null)
                    {
                        currFileEntry.Siblings = new List <PackFileEntry>();
                    }
                    currFileEntry.Siblings.Add(origFileEntry);
                    FileEntries[pathHash] = currFileEntry;

                    continue;
                }

                // if curr is older (or equal to; hellgate000 has duplicates) than the orig, then add this to the Siblings list (i.e. orig is newer)
                if (origFileEntry.FileTime >= currFileEntry.FileTime)
                {
                    if (origFileEntry.Siblings == null)
                    {
                        origFileEntry.Siblings = new List <PackFileEntry>();
                    }
                    origFileEntry.Siblings.Add(currFileEntry);

                    continue;
                }

                Debug.Assert(false, "End of 'if (FileEntries.ContainsKey(hash))'", "wtf??\n\nThis shouldn't happen, please report this.");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Parses a single index file on the specified path. Checking for accompanying dat file and populating file index.
        /// </summary>
        /// <param name="packFile">The full path of the index file to parse.</param>
        private void _LoadIndexFile(PackFile packFile)
        {
            // loop through index files
            foreach (PackFileEntry currFileEntry in packFile.Files)
            {
                //if (currFileEntry.Name.Contains("bldg_c_station_warp_next_layout.xml.cooked") || currFileEntry.Name.Contains("sku."))
                //{
                //    int bp = 0;
                //}

                ulong pathHash = currFileEntry.PathHash;

                // have we added the file yet
                if (!FileEntries.ContainsKey(pathHash))
                {
                    FileEntries.Add(pathHash, currFileEntry);
                    continue;
                }

                // we haven't added the file, so we need to compare file times and backup states
                PackFileEntry origFileEntry = FileEntries[pathHash];

                // do backup checks first as they'll "override" the FileTime values (i.e. file not found causes game to go to older version)
                // if currFile IS a backup, and orig is NOT, then add to Siblings as game will be loading orig over "backup" anyways
                if (currFileEntry.IsPatchedOut && !origFileEntry.IsPatchedOut)
                {
                    if (origFileEntry.Siblings == null) origFileEntry.Siblings = new List<PackFileEntry>();
                    origFileEntry.Siblings.Add(currFileEntry);

                    continue;
                }

                // if curr is NOT a backup, but orig IS, then we want to update (i.e. don't care about FileTime; as above)
                // OR if orig is older than curr, we also want to update/re-arrange Siblings, etc
                if ((!currFileEntry.IsPatchedOut && origFileEntry.IsPatchedOut) ||
                    origFileEntry.FileTime < currFileEntry.FileTime)
                {
                    // set the Siblings list to the updated FileEntry and null out other
                    if (origFileEntry.Siblings != null)
                    {
                        currFileEntry.Siblings = origFileEntry.Siblings;
                        origFileEntry.Siblings = null;
                    }

                    // add the "orig" (now old) to the curr FileEntry.Siblings list
                    if (currFileEntry.Siblings == null) currFileEntry.Siblings = new List<PackFileEntry>();
                    currFileEntry.Siblings.Add(origFileEntry);
                    FileEntries[pathHash] = currFileEntry;

                    continue;
                }

                // if curr is older (or equal to; hellgate000 has duplicates) than the orig, then add this to the Siblings list (i.e. orig is newer)
                if (origFileEntry.FileTime >= currFileEntry.FileTime)
                {
                    if (origFileEntry.Siblings == null) origFileEntry.Siblings = new List<PackFileEntry>();
                    origFileEntry.Siblings.Add(currFileEntry);

                    continue;
                }

                Debug.Assert(false, "End of 'if (FileEntries.ContainsKey(hash))'", "wtf??\n\nThis shouldn't happen, please report this.");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Generates of a list of all the files inside the .idx .dat files from the Hellgate path.
        /// </summary>
        /// <returns>Result of the initialization. Occurance of an error will return false.</returns>
        private bool _LoadFileTable()
        {
            if (!Directory.Exists(HellgateDataPath))
            {
                Console.WriteLine(@"Critical Error: HellgateDataPath data\ does not exist!");
                return(false);
            }

            List <String> idxPaths = new List <String>();

            string[] query = IsVersionTestCenter ? Common.MPFiles : Common.SPFiles;
            foreach (String fileQuery in query)
            {
                idxPaths.AddRange(Directory.GetFiles(HellgateDataPath, fileQuery).Where(p => p.EndsWith(IndexFile.Extension) || p.EndsWith(HellgatePackFile.Extension)));
            }
            if (idxPaths.Count == 0)
            {
                Console.WriteLine("Error: No index files found at path: " + HellgateDataPath);
                return(false);
            }

            foreach (String idxPath in idxPaths)
            {
                HellgateFile hellgateFile;
                String       datFullPath;
                if (idxPath.EndsWith(IndexFile.Extension))
                {
                    hellgateFile = new IndexFile(idxPath);
                    datFullPath  = idxPath.Replace(IndexFile.Extension, ((IndexFile)hellgateFile).DatExtension);
                }
                else
                {
                    hellgateFile = new HellgatePackFile(idxPath);
                    datFullPath  = idxPath.Replace(HellgatePackFile.Extension, ((HellgatePackFile)hellgateFile).DatExtension);
                }

                // if there is no accompanying .dat at all, then ignore .idx
                if (!File.Exists(datFullPath))
                {
                    continue;
                }

                // read in and parse index
                Debug.Write(String.Format("Loading pack file: {0}... ", Path.GetFileName(idxPath)));
                PackFile packFile = (PackFile)hellgateFile;
                try
                {
                    byte[] fileBytes = File.ReadAllBytes(idxPath);
                    hellgateFile.ParseFileBytes(fileBytes);

#if DEBUG
                    IndexFile indexFile = hellgateFile as IndexFile;
                    if (indexFile != null)
                    {
                        Debug.WriteLine("{0} files loaded.", indexFile.Files.Count);
                    }
                    HellgatePackFile hgPackFile = hellgateFile as HellgatePackFile;
                    if (hgPackFile != null)
                    {
                        Debug.WriteLine("{0} files loaded.", hgPackFile.Files.Count);
                    }
#endif
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Warning: Failed to read in index file: " + idxPath);
                    Debug.WriteLine(ex);
                    continue;
                }

                if (packFile.Count == 0)
                {
                    continue;
                }
                IndexFiles.Add(packFile);
                _LoadIndexFile(packFile);
            }

            return(FileEntries.Count != 0);
        }