public static void Parse(byte[] data, TreeNode node) { var bb = new BitBuffer(data); while (bb.BitsLeft() > 6) { var type = bb.ReadBits(6); MsgHandler handler; if (Handlers.TryGetValue(type, out handler)) { var sub = new TreeNode(handler.Method.Name); node.Nodes.Add(sub); handler(bb, sub); } else { node.Nodes.Add("unknown message type " + type).ForeColor = Color.Crimson; break; } } }
public static void Parse(byte[] data, TreeNode node) { var bb = new BitBuffer(data); while (bb.BitsLeft() > 6) { var type = bb.ReadBits(6); MsgHandler handler; if (Handlers.TryGetValue(type, out handler)) { var sub = new TreeNode(handler.Method.Name); node.Nodes.Add(sub); handler(bb, sub); } else { node.Nodes.Add("unknown message type " + type).ForeColor = Color.Crimson; break; } } }
/* static string ParseButtons(uint buttons) { string res = "(none)"; // TODO: IMPLEMENT return res; } */ public static void ParseIntoTreeNode(byte[] data, TreeNode node) { var bb = new BitBuffer(data); if (bb.ReadBool()) node.Nodes.Add("Command number: " + bb.ReadBits(32)); if (bb.ReadBool()) node.Nodes.Add("Tick count: " + bb.ReadBits(32)); if (bb.ReadBool()) node.Nodes.Add("Viewangle pitch: " + bb.ReadFloat()); if (bb.ReadBool()) node.Nodes.Add("Viewangle yaw: " + bb.ReadFloat()); if (bb.ReadBool()) node.Nodes.Add("Viewangle roll: " + bb.ReadFloat()); if (bb.ReadBool()) node.Nodes.Add("Foward move: " + bb.ReadFloat()); if (bb.ReadBool()) node.Nodes.Add("Side move: " + bb.ReadFloat()); if (bb.ReadBool()) node.Nodes.Add("Up move: " + bb.ReadFloat().ToString()); if (bb.ReadBool()) node.Nodes.Add("Buttons: 0x" + bb.ReadBits(32).ToString("X8")); if (bb.ReadBool()) node.Nodes.Add("Impulse: " + bb.ReadBits(8)); if (bb.ReadBool()) { node.Nodes.Add("Weaponselect: " + bb.ReadBits(11).ToString("X8")); if(bb.ReadBool()) node.Nodes.Add("Weaponsubtype: " + bb.ReadBits(11).ToString("X8")); } node.Nodes.Add("BITS LEFT: " + bb.BitsLeft()); if (bb.ReadBool()) node.Nodes.Add("dx: " + bb.ReadBits(16)); //These are supposed to be shorts - not sure how to read 16 bit short if (bb.ReadBool()) node.Nodes.Add("dy: " + bb.ReadBits(16)); // TODO: weaponselect/weaponsubtype, mousedx/dy }
public void Parse(byte[] data, TreeNode node) { var bb = new BitBuffer(data); while (bb.BitsLeft() > 6) { var type = bb.ReadBits(6); MsgHandler handler; if (Handlers.TryGetValue(type, out handler)) { var sub = new TreeNode(handler.Name); var offset = (int)(bb._pos / 8.0); sub.Tag = new PacketNodeData(data, offset); node.Nodes.Add(sub); if (handler.Handler != null) { handler.Handler(bb, sub); } else break; } else { node.Nodes.Add("unknown message type " + type).ForeColor = Color.Crimson; break; } } }