/// <summary> /// Десериализует процесс /// </summary> /// <param name="br">Читатель из потока</param> protected virtual void DeserializeInternal(CustomBinaryReader br) { this.CompleteExecution = br.ReadBoolean(); this.Id = br.ReadGuid(); this.PopulateExceptions = br.ReadBoolean(); this.Stage = (BpStage)br.ReadByte(); this.StartedOnServer = br.ReadNullableBoolean(); this._status = (BpStatus)br.ReadByte(); this.TrackMode = (BpTrackMode)br.ReadByte(); this.StartTime = br.ReadDateTime(); this.FinishTime = br.ReadDateTime(); if (br.ReadBoolean()) { this._contextData = new ContextData(); this._contextData.DeserializeInternal(br); } int count = br.Read7BitEncodedInt(); List <string> paramNames = new List <string>(count); this.Parameters = new Dictionary <string, object>(count); for (int i = 0; i < count; i++) { paramNames.Add(br.ReadString()); } for (int i = 0; i < count; i++) { this.Parameters.Add(paramNames[i], br.ReadObject()); } //this.Progress = (BpProgressData)br.ReadObject(); //this.Result = (BpResultData)br.ReadObject(); if (br.ReadBoolean()) { this.Progress = this.GetProgressInstance(); ((ICustomSerializable)this.Progress).DeserializeInternal(br); } if (br.ReadBoolean()) { this.Result = this.GetResultInstance(); ((ICustomSerializable)this.Result).DeserializeInternal(br); } count = br.Read7BitEncodedInt(); this.ChildProcesses = new List <BizProcess>(count); for (int i = 0; i < count; i++) { BizProcess process = this.ReadChildProcess(br); this.AddChild(process); } BpRunningNode.Type brnType = (BpRunningNode.Type)br.ReadByte(); string brnName = br.ReadString(); this.Node = new BpRunningNode(brnType, brnName); }
public void Read(CustomBinaryReader reader) { gameParameterID = reader.ReadUInt32(); yType = reader.ReadUInt32(); unknownID = reader.ReadUInt32(); //_unknown = reader.ReadByte(); numPoints = reader.ReadByte(); _unknown2 = reader.ReadByte(); points = reader.ReadMany((r) => new Point(r), (ulong)numPoints); }
public void Read(CustomBinaryReader reader) { id = reader.ReadUInt32(); changeOccursWhen = reader.ReadByte(); numberOfStates = reader.ReadUInt16(); states = reader.ReadMany((r) => new CustomSettingsState(r), numberOfStates); }
private void DoResponse(ushort code, byte[] postbytes, IProtocol data) { object[] args = new object[] { code, data.GetType().FullName }; Debugger.Log(Utils.FormatString("静默处理 code:{0} class:{1}", args)); switch (code) { case 7: { Debugger.Log("宝箱开启缓存请求 静默处理"); CustomBinaryReader reader = new CustomBinaryReader(new MemoryStream(postbytes)); byte num = reader.ReadByte(); ushort num2 = reader.ReadUInt16(); ushort num3 = reader.ReadUInt16(); if (num2 == code) { IProtocol protocol = this.CreateProtocol(code, reader); if (protocol != null) { protocol.ReadFromStream(reader); CReqItemPacket packet = protocol as CReqItemPacket; object[] objArray2 = new object[] { packet.m_nCoinAmount, packet.m_nExperince, packet.arrayEquipItems.Length }; Debugger.Log(Utils.FormatString("金币:{0} 经验:{1} 装备数量:{2}", objArray2)); for (int i = 0; i < packet.arrayEquipItems.Length; i++) { object[] objArray3 = new object[] { i, packet.arrayEquipItems[i].m_nEquipID, packet.arrayEquipItems[i].m_nFragment }; Debugger.Log(Utils.FormatString("装备[{0}] id:{1} count:{2}", objArray3)); } } } break; } } }
public void Read(CustomBinaryReader reader) { header = reader.ReadBytes(4); headerName = Encoding.UTF8.GetString(header); size = reader.ReadUInt32(); long _startPosition = reader.Position; count = reader.ReadInt32(); objects = new List <HIRCObject>(); long offset = reader.Position; for (int i = 0; i < count; i++) { byte objType = reader.ReadByte(); HIRCObject tmp; switch (objType) { case HIRCObject.TYPE_SOUNDSFXVOICE: tmp = new SFXHIRCObject(reader, objType); break; case HIRCObject.TYPE_EVENT: tmp = new EventHIRCObject(reader, objType); break; case HIRCObject.TYPE_MUSICSEGMENT: tmp = new MusicSegmentHIRCObject(reader, objType); break; case HIRCObject.TYPE_MUSICTRACK: tmp = new MusicTrackHIRCObject(reader, objType); break; case HIRCObject.TYPE_MUSICSWITCHCONTAINER: tmp = new MusicSwitchContainerHIRCObject(reader, objType); //tmp = new HIRCObject(reader, objType); //File.WriteAllBytes("tempSwitchContainer.dat", tmp.Data); break; default: tmp = new HIRCObject(reader, objType); break; } tmp.Offset = offset.ToString("X"); offset = reader.Position; objects.Add(tmp); } // Double check! if (size - (reader.Position - _startPosition) != 0) { Console.WriteLine("Incorrect IO!"); } }
public override void Read(CustomBinaryReader reader, bool readData = true) { base.Read(reader, false); _unknown = reader.ReadUInt32(); State = reader.ReadUInt32(); IDAudio = reader.ReadUInt32(); IDSource = reader.ReadUInt32(); SoundType = reader.ReadByte(); if (readData) { ReadData(reader); } }
public override void Read(CustomBinaryReader reader, bool readData = true) { base.Read(reader, false); // I'm hoping this is ALWAYS 10 _startByte = reader.ReadByte(); type_state = reader.ReadByte(); _unknown1 = reader.ReadBytes(8); // Followed by ID ID1 = reader.ReadUInt32(); if (type_state == 1) { _unknown2 = reader.ReadBytes(13); } else { _unknown2 = reader.ReadBytes(10); } ID2 = reader.ReadUInt32(); if (readData) { ReadData(reader); } }
public void Read(CustomBinaryReader reader) { //overrideParentEffects = reader.ReadBoolean(); //effectCount = reader.ReadByte(); //if (effectCount > 0) //{ // bitmaskEffect = reader.ReadByte(); // effects = reader.ReadMany((r) => new EffectStructure(r), (ulong)effectCount); //} //outputBusID = reader.ReadUInt32(); //parentID = reader.ReadUInt32(); //overrideParentPlayback = reader.ReadBoolean(); //offsetPrioritySetting = reader.ReadBoolean(); //additionalParametersCount = reader.ReadByte(); //additionalParameters = reader.ReadMany((r) => r.ReadByte(), (ulong)additionalParametersCount); //additionalParameterValues = reader.ReadMany((r) => r.ReadBytes(4), (ulong)additionalParametersCount); //_zero = reader.ReadByte(); //positioningSection = reader.ReadBoolean(); //if (positioningSection) //{ // positioningType = reader.ReadByte(); // if (positioningType == 0) // { // enablePanner = reader.ReadBoolean(); // } else if (positioningType == 1) // { // positionSource = reader.ReadUInt32(); // attenuationID = reader.ReadUInt32(); // enableSpatialization = reader.ReadBoolean(); // } else if (positioningType == 2) // { // playType = reader.ReadUInt32(); // loop = reader.ReadBoolean(); // transitionTime = reader.ReadUInt32(); // listenerOrientation = reader.ReadBoolean(); // } else if (positioningType == 3) // { // update = reader.ReadBoolean(); // } else // { // // ERROR! // throw new ParseException($"Could not parse positioningType from {nameof(SoundStructure)}! Value: {positioningType} is not between 0 - 3, at reader offset: 0x{reader.Position:X}"); // } //} //overrideParentAuxiliary = reader.ReadBoolean(); //gameDefinedAuxiliary = reader.ReadBoolean(); //overrideParentUserAuxiliary = reader.ReadBoolean(); //userAuxiliaryExists = reader.ReadBoolean(); //if (userAuxiliaryExists) //{ // busID0 = reader.ReadUInt32(); // busID1 = reader.ReadUInt32(); // busID2 = reader.ReadUInt32(); // busID3 = reader.ReadUInt32(); //} //playbackLimit = reader.ReadBoolean(); //if (playbackLimit) //{ // priorityEqualApproach = reader.ReadByte(); // limitReachedApproach = reader.ReadByte(); // limitSoundsTo = reader.ReadUInt16(); //} //limitSoundInstances = reader.ReadByte(); //virtualVoiceBehavior = reader.ReadByte(); //overrideParentPlaybackLimit = reader.ReadBoolean(); //overrideVirtualVoice = reader.ReadBoolean(); unknown4_0 = reader.ReadUInt32(); unknown_id = reader.ReadUInt32(); _unknown4_0 = reader.ReadBytes(4); unknown1_0 = reader.ReadByte(); unknown1_1 = reader.ReadByte(); unknown1_2 = reader.ReadByte(); someFloat = reader.ReadSingle(); twoFlags = reader.ReadUInt32(); id = reader.ReadUInt32(); _unknown12_0 = reader.ReadBytes(12); booleanData = reader.ReadUInt32(); stateGroupsCount = reader.ReadUInt32(); stateGroups = reader.ReadMany((r) => new StateGroup(r), (ulong)stateGroupsCount); rtpcCount = reader.ReadUInt16(); rtpcs = reader.ReadMany((r) => new RTPC(r), (ulong)rtpcCount); }
protected override void DoOpen() { using (CustomBinaryReader reader = new CustomBinaryReader(new FileStream(ArchivePath, FileMode.Open, FileAccess.Read))) { uint signature = reader.ReadUInt32(); if (signature != 0x415342) { throw new InvalidDataException("File is not BSA"); } uint version = reader.ReadUInt32(); uint folderOffset = reader.ReadUInt32(); flags = (ArchiveFlags)reader.ReadUInt32(); uint folderCount = reader.ReadUInt32(); uint fileCount = reader.ReadUInt32(); uint totalFolderNameLength = reader.ReadUInt32(); uint totalFileNameLength = reader.ReadUInt32(); uint fileExtensions = reader.ReadUInt32(); FolderInfo[] folders = new FolderInfo[(int)folderCount]; // Read folders reader.BaseStream.Position = folderOffset; for (int i = 0; i < folderCount; i++) { ulong hash = reader.ReadUInt64(); uint count = reader.ReadUInt32(); uint unknown = reader.ReadUInt32(); ulong offset = reader.ReadUInt64() - totalFileNameLength; folders[i] = new FolderInfo() { FileCount = count, ContentOffset = offset }; } // Read folder content (name and files) foreach (var folder in folders) { byte folderNameLength = reader.ReadByte(); folder.Path = Encoding.UTF8.GetString(reader.ReadBytes(folderNameLength - 1)); byte zero = reader.ReadByte(); folder.Files = new FileInfo[folder.FileCount]; for (ulong i = 0; i < folder.FileCount; i++) { ulong hash = reader.ReadUInt64(); uint size = reader.ReadUInt32(); bool compressed = flags.HasFlag(ArchiveFlags.DefaultCompressed); if ((size & 0xf0000000) != 0) { size &= 0xfffffff; compressed = !compressed; } uint offset = reader.ReadUInt32(); folder.Files[i] = new FileInfo() { Size = size, DataOffset = offset, IsCompressed = compressed }; } } long total = fileCount; long loaded = 0; string filename = Path.GetFileName(ArchivePath); // Read file names foreach (var folder in folders) { foreach (var file in folder.Files) { file.Filename = reader.ReadStringZeroTerminated(); loaded++; } } // Convert to nested sorted dictionary for fast search for (int i = 0; i < folderCount; i++) { var files = new SortedDictionary <string, FileInfo>(); for (ulong j = 0; j < folders[i].FileCount; j++) { files.Add(folders[i].Files[j].Filename, folders[i].Files[j]); } sorted.Add(folders[i].Path, files); } return; } }
public void Read(CustomBinaryReader reader) { index = reader.ReadByte(); id = reader.ReadUInt32(); _unknown = reader.ReadBytes(2); }