Пример #1
0
        public void generateBinFile(int gameId)
        {
            MD5FileEntry[] entries = null;

            switch (gameId)
            {
            case 1:
                MD5TablesME1 tablesME1 = new MD5TablesME1();
                entries = tablesME1.entriesME1;
                break;

            case 2:
                MD5TablesME2 tablesME2 = new MD5TablesME2();
                entries = tablesME2.entriesME2;
                break;

            case 3:
                MD5TablesME3 tablesME3 = new MD5TablesME3();
                entries = tablesME3.entriesME3;
                break;
            }

            MemoryStream stream = new MemoryStream();

            stream.WriteInt32(entries.Length);
            for (int p = 0; p < entries.Length; p++)
            {
                stream.WriteFromBuffer(entries[p].md5);
                stream.WriteStringASCIINull(entries[p].path);
            }
            using (FileStream fs = new FileStream("MD5EntriesME" + gameId + ".bin", FileMode.Create, FileAccess.Write))
            {
                fs.WriteUInt32(md5Tag);
                byte[] tmp = stream.ToArray();
                fs.WriteInt32(tmp.Length);
                fs.WriteFromBuffer(Zlib.Compress(tmp, 9));
            }
        }
Пример #2
0
        public void generateBinFile(int gameId)
        {
            MD5FileEntry[] entries = null;

            switch (gameId)
            {
            case 1:
                MD5TablesME1 tablesME1 = new MD5TablesME1();
                entries = tablesME1.entriesME1;
                break;

            case 2:
                MD5TablesME2 tablesME2 = new MD5TablesME2();
                entries = tablesME2.entriesME2;
                break;

            case 3:
                MD5TablesME3 tablesME3 = new MD5TablesME3();
                entries = tablesME3.entriesME3;
                break;
            }

            MemoryStream stream = new MemoryStream();

            List <string> files = new List <string>();

            for (int p = 0; p < entries.Length; p++)
            {
                if (!files.Exists(s => s == entries[p].path))
                {
                    files.Add(entries[p].path);
                }
            }

            stream.WriteInt32(files.Count);
            for (int p = 0; p < files.Count; p++)
            {
                stream.WriteStringASCIINull(files[p]);
            }

            stream.WriteInt32(entries.Length);
            for (int p = 0; p < entries.Length; p++)
            {
                stream.WriteInt32(files.IndexOf(entries[p].path));
                stream.WriteInt32(entries[p].size);
                stream.WriteFromBuffer(entries[p].md5);
            }
            using (FileStream fs = new FileStream("MD5EntriesME" + gameId + ".bin", FileMode.Create, FileAccess.Write))
            {
                fs.WriteUInt32(md5Tag);
                byte[] tmp = stream.ToArray();
                fs.WriteInt32(tmp.Length);
                fs.WriteFromBuffer(Zlib.Compress(tmp, 9));
            }

            if (gameId == 1)
            {
                // Polish version DB
                MD5TablesME1PL tablesME1PL = new MD5TablesME1PL();
                entries = tablesME1PL.entriesME1PL;
                files   = new List <string>();
                stream  = new MemoryStream();
                for (int p = 0; p < entries.Length; p++)
                {
                    if (!files.Exists(s => s == entries[p].path))
                    {
                        files.Add(entries[p].path);
                    }
                }

                stream.WriteInt32(files.Count);
                for (int p = 0; p < files.Count; p++)
                {
                    stream.WriteStringASCIINull(files[p]);
                }

                stream.WriteInt32(entries.Length);
                for (int p = 0; p < entries.Length; p++)
                {
                    stream.WriteInt32(files.IndexOf(entries[p].path));
                    stream.WriteInt32(entries[p].size);
                    stream.WriteFromBuffer(entries[p].md5);
                }
                using (FileStream fs = new FileStream("MD5EntriesME1PL.bin", FileMode.Create, FileAccess.Write))
                {
                    fs.WriteUInt32(md5Tag);
                    byte[] tmp = stream.ToArray();
                    fs.WriteInt32(tmp.Length);
                    fs.WriteFromBuffer(Zlib.Compress(tmp, 9));
                }
            }
        }