Ejemplo n.º 1
0
        //TODO: save and load set of prefixes to options.
        private void AddLocalizedStrings()
        {
            HashSet <string> hs;

            if (locStringsPrefixes.Length == 0)
            {
                hs = new HashSet <string>();
            }
            else
            {
                hs = new HashSet <string>(locStringsPrefixes.AsEnumerable());
            }

            bool setUpdated = false;

            foreach (RawFileData rawfile in rawFiles)
            {
                int offset = rawfile.Contents.IndexOf("&\"");
                while (offset != -1)
                {
                    if (rawfile.Contents[offset + 2] != '\"')
                    {
                        int    underlineOffset = rawfile.Contents.IndexOf("_", offset);
                        string s  = rawfile.Contents.Substring(offset + 2, underlineOffset - offset - 2);
                        string rn = rawfile.Name;
                        hs.Add(s);
                        setUpdated = true;
                    }
                    offset = rawfile.Contents.IndexOf("&\"", offset + 2);
                }
            }
            if (setUpdated)
            {
                locStringsPrefixes = hs.ToArray();
            }

            int locStringIndex = 0;

            foreach (string prefix in hs)
            {
                byte[] seek = Encoding.ASCII.GetBytes(string.Format(":{0}:", prefix));
                seek[0] = 0;
                seek[seek.Length - 1] = (byte)'_';
                int offset = ByteHandling.FindBytes(zd.DecompressedData, seek);
                while (offset != -1)
                {
                    int    startOfValueOffset = ByteHandling.FindByteBackward(zd.DecompressedData, 0xFF, offset) + 1;
                    int    endOfKeyOffset     = ByteHandling.FindByte(zd.DecompressedData, 0x00, offset + 1);
                    string value = ByteHandling.GetString(zd.DecompressedData, startOfValueOffset, offset);
                    string key   = ByteHandling.GetString(zd.DecompressedData, offset + 1, endOfKeyOffset);
                    locStrings.Add(new LocalizedStringData(locStringIndex, prefix, key, value, offset + 1, startOfValueOffset));
                    ++locStringIndex;
                    offset = ByteHandling.FindBytes(zd.DecompressedData, seek, offset + 1);
                }
            }
        }
Ejemplo n.º 2
0
        void AddRawFiles(byte[] extension)
        {
            int offset = ByteHandling.FindBytes(zd.DecompressedData, extension);

            while (offset != -1)
            {
                int    startOfNameOffset = ByteHandling.FindByteBackward(zd.DecompressedData, 0xFF, offset + 1) + 1;
                int    endOfNameOffset   = ByteHandling.FindByte(zd.DecompressedData, 0x00, offset + 1);
                int    assetSize         = ByteHandling.GetDword(zd.DecompressedData, startOfNameOffset - 8);
                string assetName         = ByteHandling.GetString(zd.DecompressedData, startOfNameOffset, endOfNameOffset);
                int    startOfContents   = endOfNameOffset + 1;
                int    endOfContents     = ByteHandling.FindByte(zd.DecompressedData, 0x00, startOfContents);
                string contents          = ByteHandling.GetString(zd.DecompressedData, startOfContents, endOfContents);

                rawFiles.Add(new RawFileData(rawfileIndex, assetName, startOfNameOffset, contents, assetSize, startOfContents));
                ++rawfileIndex;
                offset = ByteHandling.FindBytes(zd.DecompressedData, extension, offset + 1);
            }
        }
Ejemplo n.º 3
0
        public void ParseZoneHeader()
        {
            g_streamOutSize = ByteHandling.GetDword(decompressedData, 0);
            for (int i = 0; i < 9; ++i)
            {
                g_streamBlockSize[i] = ByteHandling.GetDword(decompressedData, 4 * (i + 1));
            }

            listStringCount  = ByteHandling.GetDword(decompressedData, 0x2C);
            assetsCount      = ByteHandling.GetDword(decompressedData, 0x34);
            listStringOffset = 0x3C + listStringCount * 4;
            listStrings      = new string[listStringCount];

            //Getting the strings from list
            int listStringStrStartOffset = listStringOffset;
            int listStringStrEndOffset   = listStringOffset;

            for (int i = 0; i < listStringCount; ++i)
            {
                if ((uint)ByteHandling.GetDword(decompressedData, 0x3C + 4 * i) == 0xFFFFFFFF)
                {
                    listStringStrEndOffset   = ByteHandling.FindByte(decompressedData, 0x00, listStringStrStartOffset);
                    listStrings[i]           = ByteHandling.GetString(decompressedData, listStringStrStartOffset, listStringStrEndOffset);
                    listStringStrStartOffset = listStringStrEndOffset + 1;
                }
            }

            assetsListOffset = listStringCount > 0 ? listStringStrEndOffset + 1 : listStringStrEndOffset;

            //Getting the assets' count from assets list
            for (int i = 0; i < assetsCount; ++i)
            {
                int assetType = ByteHandling.GetDword(decompressedData, assetsListOffset + 8 * i);
                assetsTypesCount[assetType]++;
            }

            assetsDataOffset = assetsListOffset + assetsCount * 8;
        }