コード例 #1
0
        public int InjectResourcePage(ResourcePage page, IStream stream)
        {
            if (_resources == null)
            {
                return(-1);
            }
            if (page == null)
            {
                throw new ArgumentNullException("page is null");
            }

            // Don't inject the page if it's already been injected
            int newIndex;

            if (_pageIndices.TryGetValue(page, out newIndex))
            {
                return(newIndex);
            }

            // Add the page and associate its new index with it
            var extractedRaw = _container.FindExtractedResourcePage(page.Index);

            newIndex   = _resources.Pages.Count;
            page.Index = newIndex;             // haxhaxhax, oh aaron
            LoadResourceTable(stream);

            // Inject?
            if (_injectRaw && extractedRaw != null)
            {
                if (_findExistingPages && page.FilePath != null &&
                    (page.FilePath.Contains("mainmenu") || page.FilePath.Contains("shared") ||
                     ((page.FilePath.Contains("campaign") && (_cacheFile.Type == CacheFileType.SinglePlayer)))))
                {
                    // Nothing!
                }
                else
                {
                    var rawOffset = InjectExtractedResourcePage(page, extractedRaw, stream);
                    page.Offset   = rawOffset;
                    page.FilePath = null;
                }
            }

            _resources.Pages.Add(page);
            _pageIndices[page] = newIndex;
            return(newIndex);
        }
コード例 #2
0
        public int InjectResourcePage(ResourcePage page, IStream stream)
        {
            if (_resources == null)
            {
                return(-1);
            }
            if (page == null)
            {
                throw new ArgumentNullException("page is null");
            }

            // Don't inject the page if it's already been injected
            int newIndex;

            if (_pageIndices.TryGetValue(page, out newIndex))
            {
                return(newIndex);
            }

            // Add the page and associate its new index with it
            var extractedRaw = _container.FindExtractedResourcePage(page.Index);

            newIndex   = _resources.Pages.Count;
            page.Index = newIndex;             // haxhaxhax, oh aaron
            LoadResourceTable(stream);

            // Inject?
            if (extractedRaw != null)
            {
                var rawOffset = InjectExtractedResourcePage(page, extractedRaw, stream);
                page.Offset   = rawOffset;
                page.FilePath = null;
            }

            _resources.Pages.Add(page);
            _pageIndices[page] = newIndex;
            return(newIndex);
        }