private static void SendCharacterList(Socket connection, Account account) { var builder = new PacketBuilder(Send.CharacterList); if (account.Characters != null) { builder.AddU8((byte)account.Characters.Length); for (int i = 0; i < account.Characters.Length; i++) { var world = Cache.GetWorld(account.Characters[i].World); if (world == null) { Console.WriteLine($"Character '{account.Characters[i].Name}' has invalid world id: {account.Characters[i].World}"); return; } builder.AddString(account.Characters[i].Name); builder.AddString(world.Name); var ip = world.IpAddress.GetAddressBytes(); builder.AddBytes(ip); builder.AddU16((ushort)world.Port); } } builder.AddU16(account.PremiumDays); builder.Send(connection); }
public static void Sorry(this Socket connection, string message) { var builder = new PacketBuilder(Send.Sorry); builder.AddString(message); builder.Send(connection); }
/// <summary> /// Message of the day has to be followed by either a "sorry" or the character list, otherwise the client gets stuck. /// </summary> public static void MotD(this Socket connection, ushort id, string message) { var builder = new PacketBuilder(Send.MotD); builder.AddString($"+{id}\n{message}"); builder.Send(connection); }