private void ExportAmbient_Click(object sender, EventArgs e) { int Row = 0; if (dgwAmbient.SelectedRows.Count == 1) { Row = dgwAmbient.SelectedRows[0].Index; } else if (dgwAmbient.SelectedRows.Count == 0 && dgwAmbient.SelectedCells.Count == 1) { Row = dgwAmbient.SelectedCells[0].RowIndex; } else { MessageBox.Show("Unable to export Ambient Light!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } SaveFileDialog s = new SaveFileDialog(); s.Filter = "Binary Ambient Light (*bambl)|*.bambl"; if (s.ShowDialog() == DialogResult.OK) { BigEndianWriter Writer = new BigEndianWriter(File.Open(s.FileName, FileMode.Create)); Writer.WriteChars("BAML".ToCharArray(), 0, 4); Writer.WriteByte(byte.Parse(dgwAmbient.Rows[Row].Cells[1].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteByte(byte.Parse(dgwAmbient.Rows[Row].Cells[2].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteByte(byte.Parse(dgwAmbient.Rows[Row].Cells[3].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteByte(byte.Parse(dgwAmbient.Rows[Row].Cells[4].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteUInt32(UInt32.Parse(dgwAmbient.Rows[Row].Cells[5].Value.ToString(), NumberStyles.HexNumber)); Writer.Close(); } }
public override void Serialize(BigEndianWriter writer) { writer.WriteVarInt(symbioteUID); writer.WriteByte(symbiotePos); writer.WriteVarInt(hostUID); writer.WriteByte(hostPos); }
public virtual void Serialize(BigEndianWriter writer) { byte flag1 = 0; flag1 = BooleanByteWrapper.SetFlag(flag1, 0, cantBeAggressed); flag1 = BooleanByteWrapper.SetFlag(flag1, 1, cantBeChallenged); flag1 = BooleanByteWrapper.SetFlag(flag1, 2, cantTrade); flag1 = BooleanByteWrapper.SetFlag(flag1, 3, cantBeAttackedByMutant); flag1 = BooleanByteWrapper.SetFlag(flag1, 4, cantRun); flag1 = BooleanByteWrapper.SetFlag(flag1, 5, forceSlowWalk); flag1 = BooleanByteWrapper.SetFlag(flag1, 6, cantMinimize); flag1 = BooleanByteWrapper.SetFlag(flag1, 7, cantMove); writer.WriteByte(flag1); byte flag2 = 0; flag2 = BooleanByteWrapper.SetFlag(flag2, 0, cantAggress); flag2 = BooleanByteWrapper.SetFlag(flag2, 1, cantChallenge); flag2 = BooleanByteWrapper.SetFlag(flag2, 2, cantExchange); flag2 = BooleanByteWrapper.SetFlag(flag2, 3, cantAttack); flag2 = BooleanByteWrapper.SetFlag(flag2, 4, cantChat); flag2 = BooleanByteWrapper.SetFlag(flag2, 5, cantBeMerchant); flag2 = BooleanByteWrapper.SetFlag(flag2, 6, cantUseObject); flag2 = BooleanByteWrapper.SetFlag(flag2, 7, cantUseTaxCollector); writer.WriteByte(flag2); byte flag3 = 0; flag3 = BooleanByteWrapper.SetFlag(flag3, 0, cantUseInteractive); flag3 = BooleanByteWrapper.SetFlag(flag3, 1, cantSpeakToNPC); flag3 = BooleanByteWrapper.SetFlag(flag3, 2, cantChangeZone); flag3 = BooleanByteWrapper.SetFlag(flag3, 3, cantAttackMonster); flag3 = BooleanByteWrapper.SetFlag(flag3, 4, cantWalk8Directions); writer.WriteByte(flag3); }
public override void Serialize(BigEndianWriter writer) { byte flag = new byte(); BooleanByteWrapper.SetFlag(0, flag, m_autoconnect); BooleanByteWrapper.SetFlag(1, flag, m_useCertificate); BooleanByteWrapper.SetFlag(2, flag, m_useLoginToken); writer.WriteByte(flag); m_version.Serialize(writer); writer.WriteUTF(m_lang); writer.WriteShort(((short)(m_credentials.Count))); int credentialsIndex; for (credentialsIndex = 0; (credentialsIndex < m_credentials.Count); credentialsIndex = (credentialsIndex + 1)) { writer.WriteByte(m_credentials[credentialsIndex]); } writer.WriteShort(m_serverId); writer.WriteVarLong(m_sessionOptionalSalt); writer.WriteShort(((short)(m_failedAttempts.Count))); int failedAttemptsIndex; for (failedAttemptsIndex = 0; (failedAttemptsIndex < m_failedAttempts.Count); failedAttemptsIndex = (failedAttemptsIndex + 1)) { writer.WriteVarUhShort(m_failedAttempts[failedAttemptsIndex]); } }
public void Write(BigEndianWriter writer) { writer.WriteByte(150); writer.WriteByte((byte)MapVersion); writer.WriteInt(Id); writer.WriteByte((byte)Layers.Count); writer.WriteInt(this.TopNeighbourId); writer.WriteInt(this.BottomNeighbourId); writer.WriteInt(this.LeftNeighbourId); writer.WriteInt(this.RightNeighbourId); foreach (var item in Layers.OrderBy(x => x.LayerId)) { item.Write(writer, MapVersion); } foreach (var item in Cells) { writer.WriteBoolean(item.Mov); writer.WriteBoolean(item.IsTopChange); writer.WriteBoolean(item.IsBotChange); writer.WriteBoolean(item.IsRightChange); writer.WriteBoolean(item.IsLeftChange); } }
public void Write(string path) { var writer = new BigEndianWriter(); writer.WriteByte(150); writer.WriteByte((byte)MapVersion); writer.WriteInt(Id); writer.WriteByte((byte)Layers.Count); writer.WriteInt(-1); writer.WriteInt(-1); writer.WriteInt(-1); writer.WriteInt(-1); foreach (var item in Layers.OrderBy(x => x.LayerId)) { item.Write(writer, MapVersion); } foreach (var item in Cells) { writer.WriteBoolean(item.Mov); writer.WriteBoolean(item.IsTopChange); writer.WriteBoolean(item.IsBotChange); writer.WriteBoolean(item.IsRightChange); writer.WriteBoolean(item.IsLeftChange); } File.WriteAllBytes(path + @"\" + Id + ".mapEditor", writer.Data); }
public override void Serialize(BigEndianWriter writer) { base.Serialize(writer); writer.WriteByte(guildLevel); writer.WriteByte(nbMembers); writer.WriteBoolean(enabled); }
private void BuildPacket(BigEndianWriter writer) { byte[] data = writer.Data; writer.Clear(); int messageLenghtType = ComputeTypeLen(data.Length); short header = ComputeStaticHeader((int)MessageId, messageLenghtType); writer.WriteShort(header); switch (messageLenghtType) { case 1: writer.WriteByte((byte)data.Length); break; case 2: writer.WriteShort((short)data.Length); break; case 3: writer.WriteByte((byte)(data.Length >> 16 & 255)); writer.WriteShort((short)(data.Length & 65535)); break; } writer.WriteBytes(data); }
public void Pack(BigEndianWriter header) { var data = new BigEndianWriter(); Serialize(data); var size = data.Data.Length; var compute = ComputeTypeLen(size); short val = (short)((MessageId << 2) | compute); header.WriteShort(val); switch (compute) { case 1: header.WriteByte((byte)size); break; case 2: header.WriteUShort((ushort)size); break; case 3: header.WriteByte((byte)((size >> 0x10) & 0xff)); header.WriteUShort((ushort)(size & 0xffff)); break; } header.WriteBytes(data.Data); data.Dispose(); }
public virtual void Serialize(BigEndianWriter writer) { writer.WriteVarInt(guildId); writer.WriteVarInt(leaderId); writer.WriteByte(guildLevel); writer.WriteByte(nbMembers); }
public void Write(BigEndianWriter Writer) { Writer.WriteByte(0); for (int i = 0; i < Names.Count; i++) { Writer.WriteChars(Names[i].ToCharArray(), 0, Names[i].ToCharArray().Length); Writer.WriteByte(0); } }
public override void Serialize(BigEndianWriter writer) { writer.WriteByte(m_major); writer.WriteByte(m_minor); writer.WriteByte(m_release); writer.WriteInt(m_revision); writer.WriteByte(m_patch); writer.WriteByte(m_buildType); }
public override void Serialize(BigEndianWriter writer) { writer.WriteVarUhShort(m_ObjectId); writer.WriteByte(m_status); writer.WriteByte(m_completion); writer.WriteBoolean(m_isSelectable); writer.WriteByte(m_charactersCount); writer.WriteDouble(m_date); }
public void SaveAs(string destination, bool overwrite = true) { while (this.m_linksToSave.Count > 0) { D2pFile link = this.m_linksToSave.Dequeue(); link.Save(); } Stream stream; if (!File.Exists(destination)) { stream = File.Create(destination); } else { if (!overwrite) { throw new InvalidOperationException("Cannot perform SaveAs : file already exist, notify overwrite parameter to true"); } stream = File.OpenWrite(destination); } using (BigEndianWriter writer = new BigEndianWriter(stream)) { writer.WriteByte(2); writer.WriteByte(1); D2pEntry[] entries = this.GetEntriesOfInstanceOnly(); int offset = 2; D2pEntry[] array = entries; for (int i = 0; i < array.Length; i++) { D2pEntry entry = array[i]; byte[] data = this.ReadFile(entry); entry.Index = (int)writer.Position - offset; writer.WriteBytes(data); } int entriesDefOffset = (int)writer.Position; array = entries; for (int i = 0; i < array.Length; i++) { D2pEntry entry = array[i]; entry.WriteEntryDefinition(writer); } int propertiesOffset = (int)writer.Position; foreach (D2pProperty property in this.m_properties) { property.WriteProperty(writer); } this.IndexTable.OffsetBase = offset; this.IndexTable.EntriesCount = entries.Length; this.IndexTable.EntriesDefinitionOffset = entriesDefOffset; this.IndexTable.PropertiesCount = this.m_properties.Count; this.IndexTable.PropertiesOffset = propertiesOffset; this.IndexTable.Size = this.IndexTable.EntriesDefinitionOffset - this.IndexTable.OffsetBase; this.IndexTable.WriteTable(writer); } }
public override void Serialize(BigEndianWriter writer) { writer.WriteInt(mimicryUID); writer.WriteByte(mimicryPos); writer.WriteInt(foodUID); writer.WriteByte(foodPos); writer.WriteInt(hostUID); writer.WriteByte(hostPos); writer.WriteBoolean(preview); }
public static void Serialize(AuthClient client) { BigEndianWriter packet = new BigEndianWriter(); packet.WriteByte(1); packet.WriteByte((byte)Config.VERSION[0]); packet.WriteUShort((ushort)Config.VERSION[1]); packet.WriteByte((byte)Config.VERSION[2]); packet.WriteString((string)Config.VERSION[3]); client.Send(MessageConstant.S_VERSION, packet); }
public static void SerializeIp(AuthClient client) { BigEndianWriter packet = new BigEndianWriter(); string[] args = (client.GetSocket().RemoteEndPoint as IPEndPoint).Address.ToString().Split('.'); packet.WriteByte(byte.Parse(args[0])); packet.WriteByte(byte.Parse(args[1])); packet.WriteByte(byte.Parse(args[2])); packet.WriteByte(byte.Parse(args[3])); client.Send(MessageConstant.S_IP, packet); }
public void Send(NetworkElement message, ProtocolJsonContent content, bool clientSide) { if (message is null) { return; } using (BigEndianWriter writer = new BigEndianWriter()) { byte[] data = ProtocolTreatmentExtension.FromContent(content, message); int cmpLen = _cmpLen(data.Length); writer.WriteShort((short)((message.protocolID << 2) | cmpLen)); if (clientSide) { writer.WriteUnsignedInt(GetCustomInstanceId()); } switch (cmpLen) { case 0: break; case 1: writer.WriteByte((byte)data.Length); break; case 2: writer.WriteShort((short)data.Length); break; case 3: writer.WriteByte((byte)((data.Length >> 16) & 255)); writer.WriteShort((short)(data.Length & 65535)); break; } writer.WriteBytes(data); Send(writer.Data); OnCustomMessageSent?.Invoke(message, content); StartupConfiguration configuration = Configurations.ConfigurationManager.Instance.Startup; if (configuration.show_fake_message) { logger.Info($"fake message sent to {remoteIp} |{message.BasicString()}]"); if (configuration.show_fake_message_content) { logger.Info($"{content}"); } } } }
public byte[] Serialize() { var bytes = new byte[3]; var writer = new BigEndianWriter(new MemoryStream(bytes)); writer.WriteByte(0); writer.WriteByte(0); writer.WriteByte(Convert.ToByte(this.ProtocolId)); return(bytes); }
public override void Serialize(BigEndianWriter writer) { byte flag1 = 0; flag1 = BooleanByteWrapper.SetFlag(flag1, 0, enabled); flag1 = BooleanByteWrapper.SetFlag(flag1, 1, abandonnedPaddock); writer.WriteByte(flag1); writer.WriteByte(level); writer.WriteDouble(expLevelFloor); writer.WriteDouble(experience); writer.WriteDouble(expNextLevelFloor); writer.WriteInt(creationDate); }
public void WriteBLIGHT(string FilePath) { FileName = FilePath; BigEndianWriter Writer = new BigEndianWriter(File.Open(FilePath, FileMode.Create)); Writer.WriteChars("LGHT".ToCharArray(), 0, 4); Writer.WriteUInt32(Convert.ToUInt32(0x28 + dgwLOBJ.Rows.Count * 0x50 + dgwAmbient.Rows.Count * 8)); Writer.WriteUInt32(BLIGHT.Unknown1); Writer.WriteUInt32(BLIGHT.Unknown2); Writer.WriteUInt16(Convert.ToUInt16(dgwLOBJ.Rows.Count)); Writer.WriteUInt16(Convert.ToUInt16(dgwAmbient.Rows.Count)); Writer.WriteUInt32(BLIGHT.Unknown3); Writer.WriteUInt64(BLIGHT.Padding); Writer.WriteUInt64(BLIGHT.Padding2); for (int i = 0; i < dgwLOBJ.Rows.Count; i++) { Writer.WriteChars("LOBJ".ToCharArray(), 0, 4); Writer.WriteUInt32(0x50); Writer.WriteUInt64(UInt64.Parse(dgwLOBJ.Rows[i].Cells[20].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteUInt16(UInt16.Parse(dgwLOBJ.Rows[i].Cells[21].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteByte(byte.Parse(dgwLOBJ.Rows[i].Cells[1].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteByte(byte.Parse(dgwLOBJ.Rows[i].Cells[2].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteUInt16(UInt16.Parse(dgwLOBJ.Rows[i].Cells[13].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteUInt16(UInt16.Parse(dgwLOBJ.Rows[i].Cells[14].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteSingle(Convert.ToSingle(dgwLOBJ.Rows[i].Cells[3].Value.ToString())); Writer.WriteSingle(Convert.ToSingle(dgwLOBJ.Rows[i].Cells[4].Value.ToString())); Writer.WriteSingle(Convert.ToSingle(dgwLOBJ.Rows[i].Cells[5].Value.ToString())); Writer.WriteSingle(Convert.ToSingle(dgwLOBJ.Rows[i].Cells[6].Value.ToString())); Writer.WriteSingle(Convert.ToSingle(dgwLOBJ.Rows[i].Cells[7].Value.ToString())); Writer.WriteSingle(Convert.ToSingle(dgwLOBJ.Rows[i].Cells[8].Value.ToString())); Writer.WriteSingle(Convert.ToSingle(dgwLOBJ.Rows[i].Cells[9].Value.ToString())); Writer.WriteByte(byte.Parse(dgwLOBJ.Rows[i].Cells[16].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteByte(byte.Parse(dgwLOBJ.Rows[i].Cells[17].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteByte(byte.Parse(dgwLOBJ.Rows[i].Cells[18].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteByte(byte.Parse(dgwLOBJ.Rows[i].Cells[19].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteUInt32(UInt32.Parse(dgwLOBJ.Rows[i].Cells[15].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteSingle(Convert.ToSingle(dgwLOBJ.Rows[i].Cells[10].Value.ToString())); Writer.WriteSingle(Convert.ToSingle(dgwLOBJ.Rows[i].Cells[11].Value.ToString())); Writer.WriteSingle(Convert.ToSingle(dgwLOBJ.Rows[i].Cells[12].Value.ToString())); Writer.WriteUInt64(UInt64.Parse(dgwLOBJ.Rows[i].Cells[22].Value.ToString(), NumberStyles.HexNumber)); } for (int i = 0; i < dgwAmbient.Rows.Count; i++) { Writer.WriteByte(byte.Parse(dgwAmbient.Rows[i].Cells[1].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteByte(byte.Parse(dgwAmbient.Rows[i].Cells[2].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteByte(byte.Parse(dgwAmbient.Rows[i].Cells[3].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteByte(byte.Parse(dgwAmbient.Rows[i].Cells[4].Value.ToString(), NumberStyles.HexNumber)); Writer.WriteUInt32(UInt32.Parse(dgwAmbient.Rows[i].Cells[5].Value.ToString(), NumberStyles.HexNumber)); } Writer.Close(); }
public byte[] Serialize() { var bytes = new byte[30]; var writer = new BigEndianWriter(new MemoryStream(bytes)); writer.WriteByte(0); writer.WriteByte(0); writer.WriteByte(Convert.ToByte(this.ProtocolId)); writer.WriteShort((short)this.Snake.ID); writer.WriteShort((short)(this.Snake.Position.X)); writer.WriteShort((short)(this.Snake.Position.Y)); return(bytes); }
public void Send(int processId, NetworkElementField message, ProtocolJsonContent content, bool clientSide) { if (message is null) { return; } using (BigEndianWriter writer = new BigEndianWriter()) { byte[] data = message.ToByte(content); int cmpLen = _cmpLen(data.Length); writer.WriteShort((short)((message.protocolID << 2) | cmpLen)); ProxyManager.Instance[processId].FAKE_MESSAGE_SENT++; if (clientSide) { writer.WriteUnsignedInt(ProxyManager.Instance[processId].FAKE_MSG_INSTANCE_ID); } switch (cmpLen) { case 0: break; case 1: writer.WriteByte((byte)data.Length); break; case 2: writer.WriteShort((short)data.Length); break; case 3: writer.WriteByte((byte)((data.Length >> 16) & 255)); writer.WriteShort((short)(data.Length & 65535)); break; } writer.WriteBytes(data); Send(writer.Data); if (ConfigurationManager.Instance.Startup.show_fake_message_sent) { Console.WriteLine($"Fake Message sent to ({RemoteIP}) : (n°{ProxyManager.Instance[processId].FAKE_MSG_INSTANCE_ID}) [{message.name} ({message.protocolID})]"); if (ConfigurationManager.Instance.Startup.show_message_content) { Console.WriteLine($"{content}"); } } } }
public override void Serialize(BigEndianWriter writer) { byte flag1 = 0; flag1 = BooleanByteWrapper.SetFlag(flag1, 0, enabled); flag1 = BooleanByteWrapper.SetFlag(flag1, 1, abandonnedPaddock); writer.WriteByte(flag1); writer.WriteByte(level); writer.WriteVarLong(expLevelFloor); writer.WriteVarLong(experience); writer.WriteVarLong(expNextLevelFloor); writer.WriteInt(creationDate); writer.WriteVarShort(nbTotalMembers); writer.WriteVarShort(nbConnectedMembers); }
public override void Serialize(BigEndianWriter writer) { base.Serialize(writer); writer.WriteVarInt(foodUID); writer.WriteByte(foodPos); writer.WriteBoolean(preview); }
public override void Serialize(BigEndianWriter writer) { base.Serialize(writer); writer.WriteSByte(deathState); writer.WriteVarShort(deathCount); writer.WriteByte(deathMaxLevel); }
public override void Serialize(BigEndianWriter writer) { base.Serialize(writer); writer.WriteSByte(companionGenericId); writer.WriteByte(level); writer.WriteInt(masterId); }
public override void Serialize(BigEndianWriter writer) { base.Serialize(writer); writer.WriteVarInt(leaderId); writer.WriteByte(guildLevel); writer.WriteVarShort(nbMembers); }
public override void Serialize(BigEndianWriter writer) { base.Serialize(writer); writer.WriteByte(position); writer.WriteInt(spellId); writer.WriteSByte(spellLevel); }
public override void Serialize(BigEndianWriter writer) { byte flag = new byte(); BooleanByteWrapper.SetFlag(0, flag, m_hasRights); BooleanByteWrapper.SetFlag(1, flag, m_wasAlreadyConnected); writer.WriteByte(flag); writer.WriteUTF(m_login); writer.WriteUTF(m_nickname); writer.WriteInt(m_accountId); writer.WriteByte(m_communityId); writer.WriteUTF(m_secretQuestion); writer.WriteDouble(m_accountCreation); writer.WriteDouble(m_subscriptionElapsedDuration); writer.WriteDouble(m_subscriptionEndDate); }