public static void HandleMessage(Packet packet, IClient client, bool fromQueue) { Packet reply = new Packet(PacketFamily.Welcome, PacketAction.Reply); client.EnterGame(); client.Character.Map.Enter(client.Character, WarpAnimation.Admin); reply.AddShort((short)WelcomeReply.WorldInfo); reply.AddBreak(); for (int i = 0; i < 9; ++i) { reply.AddBreakString("A"); } reply.AddChar(client.Character.Weight); // Weight reply.AddChar(client.Character.MaxWeight); // Max Weight // Inventory foreach (ItemStack item in client.Character.Items) { reply.AddShort(item.Id); reply.AddInt(item.Amount); } reply.AddBreak(); // Spells reply.AddBreak(); IEnumerable<Character> characters = client.Character.GetInRange<Character>(); IEnumerable<NPC> npcs = client.Character.GetInRange<NPC>(); IEnumerable<MapItem> items = client.Character.GetInRange<MapItem>(); reply.AddChar((byte)characters.Count()); reply.AddBreak(); // Characters // { foreach (Character character in characters) { character.InfoBuilder(ref reply); reply.AddBreak(); } // } // NPCs foreach (NPC npc in npcs) { npc.InfoBuilder(ref reply); } reply.AddBreak(); // Items foreach (MapItem item in items) { item.InfoBuilder(ref reply); } client.Send(reply); }
public bool AccountCreate(string uName, string pass, string realName, string location, string email, string HDDSerial, out AccountReply result) { result = AccountReply.THIS_IS_WRONG; if (!m_client.ConnectedAndInitialized || !Initialized) return false; Packet builder = new Packet(PacketFamily.Account, PacketAction.Create); //eoserv doesn't care... builder.AddShort(1337); builder.AddByte(42); builder.AddBreakString(uName); builder.AddBreakString(pass); builder.AddBreakString(realName); builder.AddBreakString(location); builder.AddBreakString(email); builder.AddBreakString(System.Net.Dns.GetHostName()); builder.AddBreakString(HDDSerial); if (!m_client.SendPacket(builder) || !m_account_responseEvent.WaitOne(Constants.ResponseTimeout)) return false; result = m_account_reply; return true; }
public bool AccountChangePassword(string username, string old_password, string new_password, out AccountReply result) { result = AccountReply.THIS_IS_WRONG; if (!m_client.ConnectedAndInitialized || !Initialized) return false; Packet builder = new Packet(PacketFamily.Account, PacketAction.Agree); builder.AddBreakString(username); builder.AddBreakString(old_password); builder.AddBreakString(new_password); if (!m_client.SendPacket(builder) || !m_account_responseEvent.WaitOne(Constants.ResponseTimeout)) return false; result = m_account_reply; return true; }
public bool LoginRequest(string user, string pass, out LoginReply reply, out CharacterRenderData[] data) { reply = LoginReply.THIS_IS_WRONG; data = null; if (!m_client.ConnectedAndInitialized || !Initialized) return false; Packet pkt = new Packet(PacketFamily.Login, PacketAction.Request); pkt.AddBreakString(user); pkt.AddBreakString(pass); if(!m_client.SendPacket(pkt) || !m_login_responseEvent.WaitOne(Constants.ResponseTimeout)) return false; reply = m_login_reply; if (reply == LoginReply.Ok && m_character_data != null) { data = m_character_data; } return true; }
public static void HandleRequest(Packet packet, IClient client, bool fromQueue) { short count = (short)client.Server.Characters.Count; // TODO: Don't list hidden admins Packet reply = new Packet(PacketFamily.Init, PacketAction.Init); reply.AddChar((byte)EO.InitReply.Players); reply.AddShort(count); reply.AddBreak(); foreach (Character character in client.Server.Characters) { reply.AddBreakString(character.Name); reply.AddBreakString(character.Title ?? ""); reply.AddChar(0); // What's this? reply.AddChar((byte)EO.PaperdollIcon.HGM); reply.AddChar((byte)character.ClassId); reply.AddString("TAG"); reply.AddBreak(); } client.Send(reply); }
/// <summary> /// sends all different types of Talk packets to server based on which chat type we're doing /// </summary> /// <param name="chatType">Which type of chat message is being sent</param> /// <param name="message">The message being sent</param> /// <param name="character">The character (required for TalkType.PM)</param> /// <returns></returns> public static bool Speak(TalkType chatType, string message, string character = null) { EOClient client = (EOClient)World.Instance.Client; if (!client.ConnectedAndInitialized) { return(false); } Packet builder; switch (chatType) { case TalkType.Local: builder = new Packet(PacketFamily.Talk, PacketAction.Report); break; case TalkType.PM: builder = new Packet(PacketFamily.Talk, PacketAction.Tell); if (string.IsNullOrWhiteSpace(character)) { return(false); } builder.AddBreakString(character); break; case TalkType.Global: builder = new Packet(PacketFamily.Talk, PacketAction.Message); break; case TalkType.Guild: builder = new Packet(PacketFamily.Talk, PacketAction.Request); break; case TalkType.Party: builder = new Packet(PacketFamily.Talk, PacketAction.Open); break; default: throw new NotImplementedException(); } builder.AddString(message); return(client.SendPacket(builder)); }
public bool Speak(TalkType chatType, string message, string character = null) { if (!m_client.ConnectedAndInitialized || !Initialized) return false; Packet builder; switch (chatType) { case TalkType.Local: builder = new Packet(PacketFamily.Talk, PacketAction.Report); break; case TalkType.PM: builder = new Packet(PacketFamily.Talk, PacketAction.Tell); if (string.IsNullOrWhiteSpace(character)) throw new ArgumentException("Unable to send a PM to invalid character!", "character"); builder.AddBreakString(character); break; case TalkType.Global: builder = new Packet(PacketFamily.Talk, PacketAction.Message); break; case TalkType.Guild: builder = new Packet(PacketFamily.Talk, PacketAction.Request); break; case TalkType.Party: builder = new Packet(PacketFamily.Talk, PacketAction.Open); break; case TalkType.Admin: builder = new Packet(PacketFamily.Talk, PacketAction.Admin); break; case TalkType.Announce: builder = new Packet(PacketFamily.Talk, PacketAction.Announce); break; default: throw new NotImplementedException(); } builder.AddString(message); return m_client.SendPacket(builder); }
public static void HandleRequest(Packet packet, IClient client, bool fromQueue) { int id = packet.GetInt(); if (id < 0 || id > client.Account.Characters.Count) throw new ArgumentOutOfRangeException("Login character ID out of range"); client.SelectCharacter(client.Account.Characters[id]); Packet reply = new Packet(PacketFamily.Welcome, PacketAction.Reply); reply.AddShort((short)WelcomeReply.CharacterInfo); reply.AddShort((short)client.Id); reply.AddInt(id); reply.AddShort((short)client.Character.Map.Data.Id); reply.AddBytes(client.Character.Map.Data.RevisionID); reply.AddThree((int)client.Character.Map.Data.PubFileLength); reply.AddBytes(client.Server.ItemData.revisionId); reply.AddShort((short)client.Server.ItemData.Count); reply.AddBytes(client.Server.NpcData.revisionId); reply.AddShort((short)client.Server.NpcData.Count); reply.AddBytes(client.Server.SpellData.revisionId); reply.AddShort((short)client.Server.SpellData.Count); reply.AddBytes(client.Server.ClassData.revisionId); reply.AddShort((short)client.Server.ClassData.Count); reply.AddBreakString(client.Character.Name); reply.AddBreakString(client.Character.Title ?? ""); reply.AddBreakString("Guild Name"); reply.AddBreakString("Guild Rank"); reply.AddChar(0); // Class reply.AddString("TAG"); // Guild tag reply.AddChar((byte)client.Character.Admin); reply.AddChar(client.Character.Level); // Level reply.AddInt(client.Character.Exp); // Exp reply.AddInt(client.Character.Usage); // Usage reply.AddShort(client.Character.Hp); // HP reply.AddShort(client.Character.MaxHp); // MaxHP reply.AddShort(client.Character.Tp); // TP reply.AddShort(client.Character.MaxTp); // MaxTP reply.AddShort(client.Character.MaxSp); // MaxSP reply.AddShort(client.Character.StatPoints); // StatPts reply.AddShort(client.Character.SkillPoints); // SkillPts reply.AddShort(client.Character.Karma); // Karma reply.AddShort(client.Character.MinDamage); // MinDam reply.AddShort(client.Character.MaxDamage); // MaxDam reply.AddShort(client.Character.Accuracy); // Accuracy reply.AddShort(client.Character.Evade); // Evade reply.AddShort(client.Character.Defence); // Armor reply.AddShort(client.Character.Strength); // Str reply.AddShort(client.Character.Wisdom); // Wis reply.AddShort(client.Character.Intelligence); // Int reply.AddShort(client.Character.Agility); // Agi reply.AddShort(client.Character.Constitution); // Con reply.AddShort(client.Character.Charisma); // Cha // Inventory reply.AddBreak(); reply.AddChar(1); // Guild Rank reply.AddShort(2); // Jail map reply.AddShort(4); // ? reply.AddChar(24); // ? reply.AddChar(24); // ? reply.AddShort(10); // ? reply.AddShort(10); // ? reply.AddShort(0); // Admin command flood rate reply.AddShort(2); // ? reply.AddChar(0); // Login warning message reply.AddBreak(); client.Send(reply); }
public bool CharacterCreate(byte gender, byte hairStyle, byte hairColor, byte race, string name, out CharacterReply reply, out CharacterRenderData[] data) { data = null; reply = CharacterReply.THIS_IS_WRONG; if (!m_client.ConnectedAndInitialized || !Initialized) return false; Packet builder = new Packet(PacketFamily.Character, PacketAction.Create); builder.AddShort(255); builder.AddShort(gender); builder.AddShort(hairStyle); builder.AddShort(hairColor); builder.AddShort(race); builder.AddByte(255); builder.AddBreakString(name); if (!m_client.SendPacket(builder) || !m_character_responseEvent.WaitOne(Constants.ResponseTimeout)) return false; reply = m_character_reply; if (reply == CharacterReply.THIS_IS_WRONG || m_character_data == null || m_character_data.Length == 0) return false; data = m_character_data; return true; }
public static void HandleCreate(Packet packet, IClient client, bool fromQueue) { short createId = packet.GetShort(); Gender gender = (Gender)packet.GetShort(); short hairStyle = packet.GetShort(); short hairColor = packet.GetShort(); Skin skin = (Skin)packet.GetShort(); packet.GetByte(); string name = packet.GetBreakString().ToLower(); if (!Enum.IsDefined(typeof(Gender), gender)) throw new ArgumentOutOfRangeException("Invalid gender on character creation (" + gender + ")"); // TODO: Make these configurable if (hairStyle < 1 || hairStyle > 20 || hairColor < 0 || hairColor > 9) throw new ArgumentOutOfRangeException("Hair parameters out of range on character creation (" + hairStyle + ", " + hairColor + ")"); if (!Enum.IsDefined(typeof(Skin), skin)) throw new ArgumentOutOfRangeException("Invalid skin on character creation (" + skin + ")"); Packet reply = new Packet(PacketFamily.Character, PacketAction.Reply); // TODO: Make this configurable if (client.Account.Characters.Count >= 3) { reply.AddShort((short)CharacterReply.Full); client.Send(reply); return; } if (!Character.ValidName(name)) { reply.AddShort((short)CharacterReply.NotApproved); client.Send(reply); return; } // TODO: Make a CharacterExists function var checkCharacter = from Character c in client.Server.Database.Container where c.name == name select 1; if (checkCharacter.Count() != 0) { reply.AddShort((short)CharacterReply.Exists); client.Send(reply); return; } Character newCharacter = new Character(client.Server, client, name, gender, (byte)hairStyle, (byte)hairColor, skin); client.Account.Characters.Add(newCharacter); newCharacter.Store(); client.Account.Store(); client.Server.Database.Commit(); reply.AddShort((short)CharacterReply.OK); reply.AddChar((byte)client.Account.Characters.Count); reply.AddByte(1); // TODO: What is this? reply.AddBreak(); // TODO: Some kind of character list packet builder int i = 0; foreach (Character character in client.Account.Characters) { reply.AddBreakString(character.Name); reply.AddInt(i++); reply.AddChar(character.Level); reply.AddChar((byte)character.Gender); reply.AddChar(character.HairStyle); reply.AddChar(character.HairColor); reply.AddChar((byte)character.Skin); reply.AddChar((byte)character.Admin); reply.AddShort((short)(character.Boots != null ? character.Boots.Data.special1 : 0)); reply.AddShort((short)(character.Armor != null ? character.Armor.Data.special1 : 0)); reply.AddShort((short)(character.Hat != null ? character.Hat.Data.special1 : 0)); reply.AddShort((short)(character.Shield != null ? character.Shield.Data.special1 : 0)); reply.AddShort((short)(character.Weapon != null ? character.Weapon.Data.special1 : 0)); reply.AddBreak(); } client.Send(reply); }
public static void HandleRemove(Packet packet, IClient client, bool fromQueue) { /*short deleteId = */packet.GetShort(); int id = packet.GetShort(); if (id < 0 || id > client.Account.Characters.Count) throw new ArgumentOutOfRangeException("Login character ID out of range"); Character deleteMe = client.Account.Characters[id]; client.Account.Characters.Remove(deleteMe); deleteMe.Delete(); client.Account.Store(); client.Server.Database.Commit(); Packet reply = new Packet(PacketFamily.Character, PacketAction.Reply); reply.AddShort((short)CharacterReply.Deleted); reply.AddChar((byte)client.Account.Characters.Count); reply.AddByte(1); // TODO: What is this? reply.AddBreak(); // TODO: Some kind of character list packet builder int i = 0; foreach (Character character in client.Account.Characters) { reply.AddBreakString(character.Name); reply.AddInt(i++); reply.AddChar(character.Level); reply.AddChar((byte)character.Gender); reply.AddChar(character.HairStyle); reply.AddChar(character.HairColor); reply.AddChar((byte)character.Skin); reply.AddChar((byte)character.Admin); reply.AddShort((short)(character.Boots != null ? character.Boots.Data.special1 : 0)); reply.AddShort((short)(character.Armor != null ? character.Armor.Data.special1 : 0)); reply.AddShort((short)(character.Hat != null ? character.Hat.Data.special1 : 0)); reply.AddShort((short)(character.Shield != null ? character.Shield.Data.special1 : 0)); reply.AddShort((short)(character.Weapon != null ? character.Weapon.Data.special1 : 0)); reply.AddBreak(); } client.Send(reply); }