Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }