Beispiel #1
0
        public void SendUploadInfo(PatcherFile file)
        {
            _uploadFile = file;

            // Send out notification of file transfer
            PacketOut Out = new PacketOut((byte)Opcodes.LCR_DATA_START);

            Out.WriteUInt32((uint)_uploadFile.ArchiveID);
            Out.WriteUInt64(_uploadFile.FilenameHash);
            Out.WriteUInt32((uint)_uploadFile.FileHash);
            Out.WriteUInt64((ulong)_uploadFile.CompressedSize);
            Out.WriteUInt64((ulong)_uploadFile.FileSize);
            Out.WriteInt32((int)_uploadFile.Compress);
            Out.WriteInt32((int)_uploadFile.Type);
            Out.WriteInt32((int)_uploadFile.OldCrc);
            if (_uploadFile.Filename != null)
            {
                Out.WriteUInt16((ushort)_uploadFile.Filename.Length);
                Out.Write(System.Text.ASCIIEncoding.ASCII.GetBytes(_uploadFile.Filename));
            }
            else
            {
                Out.WriteUInt16(0);
            }

            SendTCPRaw(Out);
        }
Beispiel #2
0
        public void OnRequestManifest(List <Archive> archiveList)
        {
            CSV csv = new CSV();

            if (archiveList.Count == 0)
            {
                var list = PatchMgr._Patch_Assets;

                foreach (var myp in list)
                {
                    List <PatchAsset> pAssets = myp.Value;
                    foreach (var asset in pAssets)
                    {
                        csv.NewRow();
                        csv.WriteCol(0, ((int)asset.ArchiveId).ToString());
                        csv.WriteCol(1, asset.Hash.ToString());
                        csv.WriteCol(2, "");
                        csv.WriteCol(3, asset.CRC32.ToString());
                        csv.WriteCol(5, asset.Size.ToString());
                        csv.WriteCol(6, asset.MetaDataSize.ToString());
                        csv.WriteCol(7, String.IsNullOrEmpty(asset.File) ? 0 : 1);
                    }
                }
            }
            else
            {
                foreach (var archive in archiveList)
                {
                    var pAssets = PatchMgr._Patch_Assets.Where(m => m.Key.Id == (int)archive).First().Value;

                    foreach (var asset in pAssets)
                    {
                        csv.NewRow();
                        csv.WriteCol(0, ((int)archive).ToString());
                        csv.WriteCol(1, asset.Hash.ToString());
                        csv.WriteCol(2, "");
                        csv.WriteCol(3, asset.CRC32.ToString());
                        csv.WriteCol(5, asset.Size.ToString());
                        csv.WriteCol(6, asset.MetaDataSize.ToString());
                        csv.WriteCol(7, String.IsNullOrEmpty(asset.File) ? 0 : 1);
                    }
                }
            }

            PatcherFile p    = new PatcherFile();
            var         data = System.Text.ASCIIEncoding.ASCII.GetBytes(csv.ToText());

            QueueFileUpload(FileType.MANIFEST_SET, "MANIFEST", data, FileCompressionMode.WHOLE);
            ProcessFileUploadQueue();
        }
Beispiel #3
0
        private void ProcessFileUploadQueue()
        {
            FileUploadInfo upload = null;

            if (_uploading)
            {
                return;
            }

            lock (_uploadQueue)
            {
                if (_uploadQueue.Count > 0)
                {
                    upload = _uploadQueue.Dequeue();
                }
            }

            if (upload != null)
            {
                _uploading = true;
                var p = new PatcherFile();

                if (upload.Asset != null) // Asset
                {
                    var content = File.ReadAllBytes(Path.Combine(Program.Config.PatcherFilesPath, upload.Asset.File));
                    p.CreateUpload(upload.Asset, content, FileCompressionMode.WHOLE, FileType.MYP_ASSET);
                }
                else if (upload.Data != null) // Manifest
                {
                    p.CreateUpload(upload.Destination, upload.Data, upload.Compress, upload.FileType);
                }
                else
                {
                    p.CreateUpload(upload.LocalFile, upload.File.Name, upload.Compress, FileType.GENERIC, upload.File.CRC32);
                }

                SendUploadInfo(p);
            }
        }
Beispiel #4
0
 public void OnFilePartRequest(long offset, int size, int sequence)
 {
     if (_uploadFile != null)
     {
         byte[] data      = new byte[UPLOAD_SIZE];
         long   read_size = _uploadFile.Read(data, (long)offset, size);
         if (read_size > 0)
         {
             PacketOut Out = new PacketOut((byte)Opcodes.LCR_DATA_PART);
             Out.WriteInt64(offset);
             Out.WriteInt32((int)read_size);
             Out.WriteInt32((int)sequence);
             Out.Write(data, 0, data.Length);
             SendTCPRaw(Out);
         }
         if (offset + size >= (long)_uploadFile.CompressedSize)
         {
             _uploadFile.Close();
             _uploadFile = null;
             _uploading  = false;
             ProcessFileUploadQueue();
         }
     }
 }