public static HMessage TurnEntityToPet(HEntity entity, int petid, int pettypeid, string petcolor, ushort header) { var ret = new HMessage(header); ret.WriteInteger(1); ret.WriteInteger(entity.Id); ret.WriteString(entity.Name); ret.WriteString(entity.Motto); ret.WriteString(string.Concat(new object[] { petid, " ", pettypeid, " ", petcolor })); ret.WriteInteger(entity.Index); ret.WriteInteger(entity.Tile.X); ret.WriteInteger(entity.Tile.Y); ret.WriteString("0.0"); ret.WriteInteger(0); ret.WriteInteger(2); ret.WriteInteger(0); ret.WriteInteger(entity.Id); ret.WriteString(entity.Name); ret.WriteBoolean(false); ret.WriteInteger(0); ret.WriteInteger(0); ret.WriteBoolean(false); ret.WriteInteger(0); ret.WriteString("std"); return(ret); }
public override void HandleOutgoing(DataInterceptedEventArgs e) { // Console.WriteLine("OuTOING! > " + e.Packet.Header); // Sulakore.Habbo.MessageItem message; if (this.Game.OutMessages.TryGetValue(e.Packet.Header, out message)) { // Console.WriteLine(message.Hash); switch (message.Hash) { case "ba6e5ec5767486804f64557233e71a03": { e.Packet.ReadString(); var clickevent = e.Packet.ReadString(); Console.WriteLine($"Toolbar clicked : {clickevent}"); if (clickevent == "MEMENU") { HMessage reloadEvent = new HMessage(CatalogReload); reloadEvent.WriteBoolean(false); this.Connection.SendToClientAsync(reloadEvent); } break; } } } base.HandleOutgoing(e); }
private Task SendInterceptedDataResponseAsync(string stamp, DataInterceptedEventArgs args) { var interceptedData = new HMessage((ushort)(args.Packet.Destination + 6)); interceptedData.WriteString(stamp); interceptedData.WriteInteger(args.Step); interceptedData.WriteBoolean(args.IsBlocked); interceptedData.WriteInteger(args.Packet.Length + 4); interceptedData.WriteBytes(args.Packet.ToBytes()); return(_remoteContractor.SendPacketAsync(interceptedData)); }
private void ToggleActivation_Click(object sender, EventArgs e) { this.isActivated = !isActivated; ToggleActivation.Text = this.isActivated ? "Enabled" : "Disabled"; ToggleActivation.BackColor = this.isActivated ? Color.LightGreen : Color.LightCoral; if (this.isActivated) { HMessage message = new HMessage(this.In.UserPermissions); message.WriteInteger(9); message.WriteInteger(9); message.WriteBoolean(true); this.Connection.SendToClientAsync(message); } }
public void SendMessage(int itemId) { HMessage message = new HMessage(Form.wiredEffectData); message.WriteBoolean(false); message.WriteInteger(5); message.WriteInteger(0); message.WriteInteger(3393); message.WriteInteger(itemId); message.WriteString(""); message.WriteInteger(0); message.WriteInteger(0); message.WriteInteger(0); message.WriteInteger(5); message.WriteInteger(0); Form.connection.SendToClientAsync(message); }
public void SendMessage(int itemId) { HMessage message = new HMessage(Form.wiredTriggerData); message.WriteBoolean(false); message.WriteInteger(5); message.WriteInteger(0); message.WriteInteger(3383); message.WriteInteger(itemId); message.WriteString(string.Empty); message.WriteInteger(1); message.WriteInteger(0); message.WriteInteger(0); message.WriteInteger(0); message.WriteInteger(0); Form.connection.SendToClientAsync(message); }
public void SendMessage(int itemId) { HMessage message = new HMessage(Form.wiredEffectData); message.WriteBoolean(false); message.WriteInteger(5); message.WriteInteger(0); message.WriteInteger(7555); message.WriteInteger(itemId); message.WriteString(((char)9).ToString()); message.WriteInteger(1); message.WriteInteger(0); message.WriteInteger(0); message.WriteInteger(27); message.WriteInteger(0); message.WriteInteger(0); Form.connection.SendToClientAsync(message); }
public HMessage Compose(IEnumerator <Token> e, bool isOutgoing, bool consumeToken = true) { if (Game == null) { throw new Exception("The game has not been disassembled, unable to parse packet"); } ushort header; if (consumeToken) { e.AssertTokenType("header", new[] { TokenType.Integer, TokenType.Identifier }); } else { e.Current.AssertTokenType("header", new[] { TokenType.Integer, TokenType.Identifier }); } if (e.Current.Type == TokenType.Integer) { header = ushort.Parse(e.Current.Value); } else { string messageName = e.Current.Value; var identifiers = isOutgoing ? (Identifiers)Out : In; if (!identifiers.TryGetId(messageName, out header)) { throw new Exception($"Unknown {(isOutgoing ? "outgoing" : "incoming")} message name: {messageName}"); } } var packet = new HMessage(header); while (e.MoveNext()) { if (e.Current.Type == TokenType.NewLine || e.Current.Type == TokenType.SequenceTerminator) { break; } switch (e.Current.Type) { case TokenType.Identifier: { var identifier = e.Current.Value.ToLower(); switch (identifier) { case "true": packet.WriteBoolean(true); break; case "false": packet.WriteBoolean(false); break; case "b": // byte { e.AssertTokenType("':'", TokenType.Colon); byte[] bytes = new byte[1] { e.ParseByte() }; packet.WriteBytes(bytes); } break; case "s": // short { e.AssertTokenType("':'", TokenType.Colon); packet.WriteShort((ushort)e.ParseShort()); } break; case "i": // int { e.AssertTokenType("':'", TokenType.Colon); packet.WriteInteger(e.ParseInt()); } break; case "a": // byte array { e.AssertTokenType("':'", TokenType.Colon); byte[] bytes = e.ParseByteArray(); packet.WriteInteger(bytes.Length); packet.WriteBytes(bytes); } break; default: throw new Exception($"Unexpected identifier '{identifier}'"); } } break; case TokenType.Subtract: case TokenType.Integer: { bool negate = e.Current.Type == TokenType.Subtract; if (negate) { e.AssertTokenType("integer", TokenType.Integer); } var s = (negate ? "-" : "") + e.Current.Value; if (!int.TryParse(s, out int value)) { throw new Exception($"Invalid integer value: {s}"); } packet.WriteInteger(value); } break; case TokenType.String: packet.WriteString(e.Current.Value); break; case TokenType.ByteArray: { byte[] bytes = ParserExtensions.ParseByteArray(e.Current); packet.WriteBytes(bytes); } break; case TokenType.NewLine: break; default: throw new Exception($"Unexpected token type {e.Current.Type}"); } } return(packet); }
private void HandleData(DataInterceptedEventArgs e) { ModuleItem[] moduleItems = Contractor.GetModuleItems(); bool isOutgoing = (e.Packet.Destination == HDestination.Server); if (Contractor.RemoteModule != null) { string stamp = DateTime.Now.Ticks.ToString(); stamp += isOutgoing; stamp += e.Step; Contractor.DataAwaiters[stamp] = new TaskCompletionSource <DataInterceptedEventArgs>(); var interceptedData = new HMessage((ushort)(e.Packet.Destination + 4)); interceptedData.WriteString(stamp); interceptedData.WriteInteger(e.Step); interceptedData.WriteBoolean(e.IsBlocked); interceptedData.WriteInteger(e.Packet.Length + 4); interceptedData.WriteBytes(e.Packet.ToBytes()); Contractor.RemoteModule.SendAsync(interceptedData); DataInterceptedEventArgs args = Contractor .DataAwaiters[stamp].Task.Result; if (args != null) { e.Packet = args.Packet; e.IsBlocked = args.IsBlocked; } Contractor.DataAwaiters.Remove(stamp); } foreach (ModuleItem moduleItem in moduleItems) { if (!moduleItem.IsInitialized) { continue; } ITExtension extension = moduleItem.Extension; if (extension == null) { continue; } try { if (isOutgoing) { extension.HandleOutgoing(e); extension.Triggers?.HandleOutgoing(e); } else { extension.HandleIncoming(e); extension.Triggers?.HandleIncoming(e); } } catch (Exception ex) { if (!e.HasContinued) { e.Continue(); } WriteLog(ex); DisplayModuleException(moduleItem, e, ex); } } }