private CASC_ROOT_ENTRY_MNDX FindMNDXInfo2(string path, int dwPackage)
        {
            MNDXSearchResult result = new MNDXSearchResult()
            {
                SearchMask = path
            };
            MARFileNameDB marFile2 = MarFiles[2];

            if (marFile2.FindFileInDatabase(result))
            {
                var pRootEntry = mndxRootEntries[result.FileNameIndex];

                while ((pRootEntry.Flags & 0x00FFFFFF) != dwPackage)
                {
                    // The highest bit serves as a terminator if set
                    //if ((pRootEntry.Flags & 0x80000000) != 0)
                    //    throw new Exception("File not found!");

                    pRootEntry = pRootEntry.Next;
                }

                // Give the root entry pointer to the caller
                return(pRootEntry);
            }

            throw new Exception("File not found!");
        }
        private CASC_ROOT_ENTRY_MNDX FindMNDXInfo(string path, int dwPackage)
        {
            MNDXSearchResult result = new MNDXSearchResult()
            {
                SearchMask = path.Substring(Packages[dwPackage].Length + 1).ToLower()
            };
            MARFileNameDB marFile1 = MarFiles[1];

            if (marFile1.FindFileInDatabase(result))
            {
                var pRootEntry = mndxRootEntriesValid[result.FileNameIndex];

                while ((pRootEntry.Flags & 0x00FFFFFF) != dwPackage)
                {
                    // The highest bit serves as a terminator if set
                    if ((pRootEntry.Flags & 0x80000000) != 0)
                    {
                        throw new Exception("File not found!");
                    }

                    pRootEntry = pRootEntry.Next;
                }

                // Give the root entry pointer to the caller
                return(pRootEntry);
            }

            throw new Exception("File not found!");
        }
Beispiel #3
0
        public bool CheckNameFragment(MNDXSearchResult pStruct1C, int dwFragOffs)
        {
            SearchBuffer pStruct40 = pStruct1C.Buffer;

            if (FragmentEnds.TotalItemCount == 0)
            {
                // Get the offset of the fragment to compare. For convenience with pStruct40->CharIndex,
                // subtract the CharIndex from the fragment offset
                string szSearchMask = pStruct1C.SearchMask;

                var startPos = dwFragOffs - pStruct40.CharIndex;

                // Keep searching as long as the name matches with the fragment
                while (NameFragments[startPos + pStruct40.CharIndex] == szSearchMask[pStruct40.CharIndex])
                {
                    // Move to the next character
                    pStruct40.CharIndex++;

                    // Is it the end of the fragment or end of the path?
                    if (NameFragments[startPos + pStruct40.CharIndex] == 0)
                    {
                        return(true);
                    }

                    if (pStruct40.CharIndex >= pStruct1C.SearchMask.Length)
                    {
                        return(false);
                    }
                }

                return(false);
            }
            else
            {
                // Get the offset of the fragment to compare.
                string szSearchMask = pStruct1C.SearchMask;

                // Keep searching as long as the name matches with the fragment
                while (NameFragments[dwFragOffs] == szSearchMask[pStruct40.CharIndex])
                {
                    // Move to the next character
                    pStruct40.CharIndex++;

                    // Is it the end of the fragment or end of the path?
                    if (FragmentEnds.Contains(dwFragOffs++))
                    {
                        return(true);
                    }

                    if (dwFragOffs >= pStruct1C.SearchMask.Length)
                    {
                        return(false);
                    }
                }

                return(false);
            }
        }
Beispiel #4
0
        public void CopyNameFragment(MNDXSearchResult pStruct1C, int dwFragOffs)
        {
            SearchBuffer pStruct40 = pStruct1C.Buffer;

            if (FragmentEnds.TotalItemCount == 0)
            {
                while (NameFragments[dwFragOffs] != 0)
                {
                    pStruct40.Add(NameFragments[dwFragOffs++]);
                }
            }
            else
            {
                while (!FragmentEnds.Contains(dwFragOffs))
                {
                    pStruct40.Add(NameFragments[dwFragOffs++]);
                }
            }
        }
Beispiel #5
0
        public bool CheckAndCopyNameFragment(MNDXSearchResult pStruct1C, int dwFragOffs)
        {
            SearchBuffer pStruct40 = pStruct1C.Buffer;

            if (FragmentEnds.TotalItemCount == 0)
            {
                string szSearchMask = pStruct1C.SearchMask;

                var startPos = dwFragOffs - pStruct40.CharIndex;

                // Keep copying as long as we don't reach the end of the search mask
                while (pStruct40.CharIndex < pStruct1C.SearchMask.Length)
                {
                    // HOTS: 195A5A0
                    if (NameFragments[startPos + pStruct40.CharIndex] != szSearchMask[pStruct40.CharIndex])
                    {
                        return(false);
                    }

                    // HOTS: 195A5B7
                    pStruct40.Add(NameFragments[startPos + pStruct40.CharIndex]);
                    pStruct40.CharIndex++;

                    if (NameFragments[startPos + pStruct40.CharIndex] == 0)
                    {
                        return(true);
                    }
                }

                // HOTS: 195A660
                // Now we need to copy the rest of the fragment
                while (NameFragments[startPos + pStruct40.CharIndex] != 0)
                {
                    pStruct40.Add(NameFragments[startPos + pStruct40.CharIndex]);
                    startPos++;
                }
            }
            else
            {
                // Get the offset of the fragment to compare
                // HOTS: 195A6B7
                string szSearchMask = pStruct1C.SearchMask;

                // Keep copying as long as we don't reach the end of the search mask
                while (dwFragOffs < pStruct1C.SearchMask.Length)
                {
                    if (NameFragments[dwFragOffs] != szSearchMask[pStruct40.CharIndex])
                    {
                        return(false);
                    }

                    pStruct40.Add(NameFragments[dwFragOffs]);
                    pStruct40.CharIndex++;

                    // Keep going as long as the given bit is not set
                    if (FragmentEnds.Contains(dwFragOffs++))
                    {
                        return(true);
                    }
                }

                // Now we need to copy the rest of the fragment
                while (!FragmentEnds.Contains(dwFragOffs))
                {
                    // HOTS: 195A7A6
                    pStruct40.Add(NameFragments[dwFragOffs]);
                    dwFragOffs++;
                }
            }

            return(true);
        }