Beispiel #1
0
        public void OnRequestManifestList()
        {
            if (!VerifyLoggedIn())
            {
                return;
            }

            if (Program.Config.ServerState == ServerState.PATCH)
            {
                return;
            }

            var list = PatchMgr._Patch_Assets;


            var files = PatchMgr._Patch_Files.ToList();

            PacketOut Out = new PacketOut((byte)Opcodes.LCR_REQUEST_MANIFEST_LIST);

            Out.WriteInt32(list.Count);

            foreach (var myp in list)
            {
                Patch_MYP         pMYP    = myp.Key;
                List <PatchAsset> pAssets = myp.Value;

                uint hashhash = 0;

                var hashes = pAssets.ToList();
                foreach (var asset in hashes)
                {
                    var newcrc = BitConverter.GetBytes(asset.CRC32);
                    hashhash = Utils.Adler32(hashhash, newcrc, 4);
                    //Console.WriteLine("CRC32: " + asset.CRC32 + " HH:" + hashhash);
                }


                Out.WriteByte((byte)pMYP.Id);
                Out.WriteUInt32(pMYP.AssetCount);
                Out.WriteUInt64(pMYP.ExtractedSize);
                Out.WriteUInt32(hashhash);
            }

            Out.WriteInt32(files.Count);

            foreach (var file in files)
            {
                Out.WriteString(file.Name);
                Out.WriteUInt32(file.CRC32);
                Out.WriteUInt64((ulong)file.Size);
            }
            SendTCPRaw(Out);
        }
Beispiel #2
0
        public static Dictionary <Patch_MYP, List <PatchAsset> > LoadAssetsFromDisk()
        {
            Dictionary <Patch_MYP, List <PatchAsset> > patch_assets = new Dictionary <Patch_MYP, List <PatchAsset> >();

            DirectoryInfo d = new DirectoryInfo(Program.Config.PatcherFilesPath);

#if DEBUG
            if (!d.Exists)
            {
                return(patch_assets);
            }
#endif

            var myps = d.GetDirectories().Where(e => e.Name.EndsWith(".MYP")).ToArray();

            foreach (var myp in myps)
            {
                Patch_MYP pMYP = new Patch_MYP();
                pMYP.Name = myp.Name.Replace(".MYP", "");
                pMYP.Id   = (int)strToArchive(myp.Name);

                List <PatchAsset> assets = new List <PatchAsset>();

                DirectoryInfo m        = new DirectoryInfo(myp.FullName);
                var           mypFiles = m.GetFiles("*", SearchOption.AllDirectories);

                foreach (var file in mypFiles)
                {
                    using (var fs = File.OpenRead(file.FullName))
                    {
                        PatchAsset pAsset = new PatchAsset();
                        pAsset.CRC32     = Utils.Adler32(fs, fs.Length);
                        pAsset.File      = (myp.Name + "\\" + file.FullName.Remove(0, myp.FullName.Length + 1));
                        pAsset.Name      = file.FullName.Remove(0, myp.FullName.Length + 1).Replace('\\', '/');
                        pAsset.Size      = fs.Length;
                        pAsset.Hash      = (ulong)HashWAR(pAsset.Name);
                        pAsset.ArchiveId = pMYP.Id;
                        assets.Add(pAsset);
                    }
                }

                pMYP.AssetCount = (uint)assets.Count;

                patch_assets.Add(pMYP, assets);
            }

            return(patch_assets);
        }