use math; use trace; export fn encode_packet(out: *[]u8, packet_id: i32, in: []u8) void = { let id_size = math::bit_size_u32(packet_id: u32); if (id_size == 0) id_size = 1; const id_size = id_size / 7 + id_size % 7; assert(len(in) + id_size <= 0x1fffff, "TODO: sent packet too long. this should be handled better."); encode_varint(out, packet_id); append(out, in...); };