示例#1
0
        public static void OnCreateNewCharacter(MapleClient c, InPacket p)
        {
            string name = p.ReadMapleString();

            if (Database.Instance.NameAvailable(name))
            {
                Character character = new Character(name);
                character.AccountId = c.Account.AccountId;
                character.CharId    = Database.Instance.GetNewCharacterId();
                character.Level     = 1;

                character.HP    = 50;
                character.MaxHP = 50;
                character.MP    = 5;
                character.MaxMP = 5;

                character.Face      = p.ReadInt();
                character.Hair      = p.ReadInt() + p.ReadInt();
                character.SkinColor = (byte)p.ReadInt();

                int top    = p.ReadInt();
                int bottom = p.ReadInt();
                int shoes  = p.ReadInt();
                int weapon = p.ReadInt();

                character.Inventory[InventorySlot.Equipped].Items.Add(-5, new Item(top));
                character.Inventory[InventorySlot.Equipped].Items.Add(-6, new Item(bottom));
                character.Inventory[InventorySlot.Equipped].Items.Add(-7, new Item(shoes));
                character.Inventory[InventorySlot.Equipped].Items.Add(-11, new Item(weapon));

                character.Str = p.ReadByte();
                character.Dex = p.ReadByte();
                character.Int = p.ReadByte();
                character.Luk = p.ReadByte();

                c.Characters.Add(character);
                Database.Instance.Save <Character>(Database.Characters, character);

                using (OutPacket packet = new OutPacket(SendOps.CreateNewCharacterResult))
                {
                    packet.WriteByte();

                    PacketCreator.Helper.AddCharacterData(packet, character);
                    PacketCreator.Helper.AddCharaterLook(packet, character);
                    packet.WriteBool(false); //rank

                    packet.WriteZero(24);
                    c.Send(packet);
                }
            }
            else
            {
                using (OutPacket packet = new OutPacket(SendOps.CheckDuplicatedIDResult))
                {
                    packet.WriteMapleString(name);
                    packet.WriteBool(true);
                    c.Send(packet);
                }
            }
        }
示例#2
0
        public void ReCharge(MapleClient c, byte slot)
        {
            var ii = MapleItemInformationProvider.Instance;

            IMapleItem item;

            if (!c.Player.Inventorys[MapleInventoryType.Use.Value].Inventory.TryGetValue(slot, out item) || (!ii.IsThrowingStar(item.ItemId) && !ii.IsBullet(item.ItemId)))
            {
                if (item != null && (!ii.IsThrowingStar(item.ItemId) || !ii.IsBullet(item.ItemId)))
                {
                    Console.WriteLine($"{c.Player.Name} is trying to recharge {item.ItemId}");
                }
                return;
            }
            var slotMax = ii.GetSlotMax(c, item.ItemId);

            if (item.Quantity < 0)
            {
                Console.WriteLine($"{c.Player.Name} is trying to recharge {item.ItemId} with quantity {item.Quantity}");
            }
            if (item.Quantity < slotMax)
            {
                var price = (int)Math.Round(ii.GetPrice(item.ItemId) * (slotMax - item.Quantity));
                if (c.Player.Meso.Value >= price)
                {
                    item.Quantity = slotMax;
                    c.Send(PacketCreator.UpdateInventorySlot(MapleInventoryType.Use, (Item)item));
                    c.Player.GainMeso(-price, false, true, false);
                    c.Send(PacketCreator.ConfirmShopTransaction(0x8));
                }
            }
        }
示例#3
0
 public override void SendSpawnData(MapleClient client)
 {
     if (Meso > 0)
     {
         client.Send(PacketCreator.DropMesoFromMapObject(Meso, ObjectId, Dropper.ObjectId, Owner.Id, Point.Empty,
                                                         Position, 2));
     }
     else
     {
         client.Send(PacketCreator.DropItemFromMapObject(Item.ItemId, ObjectId, 0, Owner.Id, Point.Empty,
                                                         Position, 2));
     }
 }
示例#4
0
 public override void SendSpawnData(MapleClient client)
 {
     if (TargetMap.MapId == client.Player.Map.MapId || Owner == client.Player && Owner.Party == null)
     {
         client.Send(PacketCreator.SpawnDoor(Owner.Id,
                                             Town.MapId == client.Player.Map.MapId ? TownPortal.Position : TargetMapPosition, true));
         if (Owner.Party != null &&
             (Owner == client.Player || Owner.Party.ContainsMember(new MaplePartyCharacter(client.Player))))
         {
             client.Send(PacketCreator.PartyPortal(Town.MapId, TargetMap.MapId, TargetMapPosition));
         }
         client.Send(PacketCreator.SpawnPortal(Town.MapId, TargetMap.MapId, TargetMapPosition));
     }
 }
示例#5
0
 public override void SendDestroyData(MapleClient client)
 {
     if (TargetMap.MapId == client.Player.Map.MapId || Owner == client.Player ||
         Owner.Party != null && Owner.Party.ContainsMember(new MaplePartyCharacter(client.Player)))
     {
         if (Owner.Party != null &&
             (Owner == client.Player || Owner.Party.ContainsMember(new MaplePartyCharacter(client.Player))))
         {
             client.Send(PacketCreator.PartyPortal(999999999, 999999999, new Point(-1, -1)));
         }
         client.Send(PacketCreator.RemoveDoor(Owner.Id, false));
         client.Send(PacketCreator.RemoveDoor(Owner.Id, true));
     }
 }
示例#6
0
 public override void SendSpawnData(MapleClient client)
 {
     if (Name.Contains("Maple TV"))
     {
         return;
     }
     if (Id >= 9010011 && Id <= 9010013)
     {
         client.Send(PacketCreator.SpawnNpcRequestController(this, false));
     }
     else
     {
         client.Send(PacketCreator.SpawnNpc(this));
         client.Send(PacketCreator.SpawnNpcRequestController(this, true));
     }
 }
示例#7
0
        public static void HandleWorldSelect(MapleClient client, InPacket iPacket)
        {
            iPacket.Skip(1);
            client.World   = iPacket.ReadByte();
            client.Channel = iPacket.ReadByte();

            byte characterCount = (byte)(long)Database.Scalar("SELECT COUNT(*) FROM `characters` WHERE `account_id` = @account_id", new MySqlParameter("@account_id", client.Account.ID));

            using (OutPacket oPacket = new OutPacket(SendOps.SelectWorldResult))
            {
                oPacket
                .WriteBool(false)
                .WriteByte(characterCount);

                if (characterCount > 0)
                {
                    using (DatabaseQuery query = Database.Query("SELECT * FROM `characters` WHERE `account_id` = @account_id AND `world_id` = @world_id", new MySqlParameter("@account_id", client.Account.ID), new MySqlParameter("world_id", client.World)))
                    {
                        while (query.NextRow())
                        {
                            LoginHandler.AddCharacterEntry(oPacket, query);
                        }
                    }
                }

                oPacket
                .WriteByte(2)
                .WriteInt(3);     // TODO: Account specific character creation slots. For now, use default 3.

                client.Send(oPacket);
            }
        }
示例#8
0
        private static void SendLoginResult(MapleClient client, LoginResult result)
        {
            using (OutPacket oPacket = new OutPacket(SendOps.CheckPasswordResult))
            {
                oPacket
                .WriteInt((int)result)
                .WriteByte()
                .WriteByte();

                if (result == LoginResult.Valid)
                {
                    oPacket
                    .WriteInt(client.Account.ID)
                    .WriteByte()
                    .WriteBool()
                    .WriteByte()
                    .WriteByte()
                    .WriteMapleString(client.Account.Username)
                    .WriteByte()
                    .WriteBool()
                    .WriteLong()
                    .WriteLong()
                    .WriteInt()
                    .WriteShort(2);
                }

                client.Send(oPacket);
            }
        }
示例#9
0
        public static void Move(MapleClient c, MapleInventoryType type, short src, short dst)
        {
            byte srcSlot = (byte)src;
            byte dstSlot = (byte)dst;

            if (srcSlot > 127 || dstSlot > 127 || srcSlot > c.Player.Inventorys[type.Value].SlotLimit || dstSlot > c.Player.Inventorys[type.Value].SlotLimit)
            {
                return;
            }
            MapleItemInformationProvider ii = MapleItemInformationProvider.Instance;
            IMapleItem source;
            IMapleItem initialTarget;

            if (!c.Player.Inventorys[type.Value].Inventory.TryGetValue(srcSlot, out source))
            {
                return;
            }
            short olddstQ = -1;

            if (c.Player.Inventorys[type.Value].Inventory.TryGetValue(dstSlot, out initialTarget))
            {
                olddstQ = initialTarget.Quantity;
            }
            short oldsrcQ = source.Quantity;
            short slotMax = ii.GetSlotMax(c, source.ItemId);
            bool  op      = c.Player.Inventorys[type.Value].Move(srcSlot, dstSlot, slotMax);

            if (!op)
            {
                c.Send(PacketCreator.EnableActions());
                return;
            }
            if (type != MapleInventoryType.Equip && initialTarget != null && initialTarget.ItemId == source.ItemId && !ii.IsThrowingStar(source.ItemId) && !ii.IsBullet(source.ItemId))
            {
                c.Send(olddstQ + oldsrcQ > slotMax
                    ? PacketCreator.MoveAndMergeWithRestInventoryItem(type, srcSlot, dstSlot,
                                                                      (short)((olddstQ + oldsrcQ) - slotMax), slotMax)
                    : PacketCreator.MoveAndMergeInventoryItem(type, srcSlot, dstSlot,
                                                              ((Item)c.Player.Inventorys[type.Value].Inventory[dstSlot]).Quantity));
            }
            else
            {
                c.Send(PacketCreator.MoveInventoryItem(type, src, dst, 0));
            }
        }
示例#10
0
        public static void OnMobMove(MapleClient client, InPacket iPacket)
        {
            int objectID = iPacket.ReadInt();

            Mob mob;

            try
            {
                mob = client.Character.ControlledMobs[objectID];
            }
            catch (KeyNotFoundException)
            {
                return;
            }

            short moveAction      = iPacket.ReadShort();
            bool  cheatResult     = (iPacket.ReadByte() & 0xF) != 0;
            byte  centerSplit     = iPacket.ReadByte();
            int   illegalVelocity = iPacket.ReadInt();
            byte  unknown         = iPacket.ReadByte();

            iPacket.ReadInt();

            Movements movements = Movements.Decode(iPacket);

            Movement lastMovement = movements[movements.Count - 1];

            mob.Position = lastMovement.Position;
            mob.Foothold = lastMovement.Foothold;
            mob.Stance   = lastMovement.Stance;

            using (OutPacket oPacket = new OutPacket(SendOps.MobCtrlAck))
            {
                oPacket
                .WriteInt(objectID)
                .WriteShort(moveAction)
                .WriteBool(cheatResult)
                .WriteShort()    // NOTE: Mob mana.
                .WriteByte()     // NOTE: Ability ID.
                .WriteByte();    // NOTE: Ability level.

                client.Send(oPacket);
            }

            using (OutPacket oPacket = new OutPacket(SendOps.MobMove))
            {
                oPacket
                .WriteInt(objectID)
                .WriteBool(cheatResult)
                .WriteByte(centerSplit)
                .WriteInt(illegalVelocity);

                movements.Encode(oPacket);

                client.Character.Map.Broadcast(oPacket, client.Character);
            }
        }
示例#11
0
        public void Buy(MapleClient c, int itemId, short quantity)
        {
            if (quantity <= 0)
            {
                Console.WriteLine($"{c.Player.Name} is buying an invalid amount: { quantity } of itemid: { itemId}");
                c.Close();
                return;
            }
            MapleShopItem item = FindByItemId(itemId);
            MapleItemInformationProvider ii = MapleItemInformationProvider.Instance;

            if (item != null && item.Price > 0 && c.Player.Meso.Value >= item.Price * quantity)
            {
                if (MapleInventoryManipulator.CheckSpace(c, itemId, quantity, ""))
                {
                    if (itemId >= 5000000 && itemId <= 5000100)
                    {
                        if (quantity > 1)
                        {
                            quantity = 1;
                        }
                        int petId = MaplePet.Create(itemId);
                        MapleInventoryManipulator.AddById(c, itemId, quantity, "Pet was purchased.", null, petId);
                    }
                    else if (ii.IsRechargable(itemId))
                    {
                        short rechquantity = ii.GetSlotMax(c, item.ItemId);
                        MapleInventoryManipulator.AddById(c, itemId, rechquantity, "Rechargable item purchased.", null, -1);
                    }
                    else
                    {
                        MapleInventoryManipulator.AddById(c, itemId, quantity, c.Player.Name + " bought " + quantity + " for " + item.Price * quantity + " from shop " + ShopId);
                    }
                    c.Player.GainMeso(-(item.Price * quantity), false);
                    c.Send(PacketCreator.ConfirmShopTransaction(0));
                }
                else
                {
                    c.Send(PacketCreator.ConfirmShopTransaction(3));
                }
            }
        }
示例#12
0
 public void AddBuddyRequest(MapleClient c, int cidFrom, string nameFrom, int channelFrom)
 {
     Add(new MapleBuddyListEntry(nameFrom, cidFrom, channelFrom, false));
     if (!m_pendingRequests.Any())
     {
         c.Send(PacketCreator.RequestBuddylistAdd(cidFrom, nameFrom));
     }
     else
     {
         m_pendingRequests.Add(new CharacterNameAndId(cidFrom, nameFrom));
     }
 }
示例#13
0
        public static void OnCheckDuplicatedID(MapleClient c, InPacket p)
        {
            string name  = p.ReadMapleString();
            bool   taken = !Database.Instance.NameAvailable(name);

            using (OutPacket packet = new OutPacket(SendOps.CheckDuplicatedIDResult))
            {
                packet.WriteMapleString(name);
                packet.WriteBool(taken);
                c.Send(packet);
            }
        }
        public void RemoveAll(int id, MapleClient cl)
        {
            var possessed =
                cl.Player.Inventorys[MapleItemInformationProvider.Instance.GetInventoryType(id).Value].CountById(id);

            if (possessed > 0)
            {
                MapleInventoryManipulator.RemoveById(cl, MapleItemInformationProvider.Instance.GetInventoryType(id), id,
                                                     possessed, true, false);
                cl.Send(PacketCreator.GetShowItemGain(id, (short)-possessed, true));
            }
        }
示例#15
0
        public static void HandleCheckUserLimit(MapleClient client, InPacket iPacket)
        {
            byte        worldID = iPacket.ReadByte();
            WorldServer world   = MasterServer.Instance.Worlds[worldID];

            using (OutPacket oPacket = new OutPacket(SendOps.CheckUserLimitResult))
            {
                oPacket.WriteShort((short)world.Status);

                client.Send(oPacket);
            }
        }
示例#16
0
        public static void UnEquip(MapleClient c, short src, short dst)
        {
            byte srcSlot = (byte)src;
            byte dstSlot = (byte)dst;

            Equip source = c.Player.Inventorys[MapleInventoryType.Equipped.Value].Inventory.FirstOrDefault(x => x.Key == srcSlot).Value as Equip;
            Equip target = c.Player.Inventorys[MapleInventoryType.Equip.Value].Inventory.FirstOrDefault(x => x.Key == dstSlot).Value as Equip;

            if (dstSlot > 127)
            {
                Console.WriteLine("Unequipping to negative slot. ({0}: {1}->{2})", c.Player.Name, srcSlot, dstSlot);
            }
            if (source == null)
            {
                return;
            }
            if (target != null && (srcSlot > 127 || srcSlot == 0))
            {
                // do not allow switching with equip
                c.Send(PacketCreator.GetInventoryFull());
                return;
            }

            c.Player.Inventorys[MapleInventoryType.Equipped.Value].RemoveSlot(srcSlot);
            if (target != null)
            {
                c.Player.Inventorys[MapleInventoryType.Equip.Value].RemoveSlot(dstSlot);
            }
            source.Position = dstSlot;
            c.Player.Inventorys[MapleInventoryType.Equip.Value].AddFromDb(source);
            if (target != null)
            {
                target.Position = srcSlot;
                c.Player.Inventorys[MapleInventoryType.Equipped.Value].AddFromDb(target);
            }
            c.Send(PacketCreator.MoveInventoryItem(MapleInventoryType.Equip, src, dst, 1));
            c.Player.EquipChanged();
        }
示例#17
0
        public static void HandleWorldList(MapleClient client, InPacket iPacket)
        {
            foreach (WorldServer world in MasterServer.Instance.Worlds)
            {
                using (OutPacket oPacket = new OutPacket(SendOps.WorldInformation))
                {
                    oPacket
                    .WriteByte(world.ID)
                    .WriteMapleString(world.Name)
                    .WriteByte()
                    .WriteMapleString(string.Empty)
                    .WriteShort(100)
                    .WriteShort(100)
                    .WriteByte()
                    .WriteByte((byte)world.Channels.Length);

                    foreach (ChannelServer channel in world.Channels)
                    {
                        oPacket
                        .WriteMapleString(string.Format("{0}-{1}", world.Name, channel.ID))
                        .WriteInt()
                        .WriteByte(1)
                        .WriteShort(channel.ID);
                    }

                    oPacket.WriteShort();

                    client.Send(oPacket);
                }
            }

            using (OutPacket oPacket = new OutPacket(SendOps.WorldInformation))
            {
                oPacket.WriteByte(byte.MaxValue);

                client.Send(oPacket);
            }
        }
示例#18
0
        public static void HandleCharacterNameCheck(MapleClient client, InPacket iPacket)
        {
            string name     = iPacket.ReadMapleString();
            bool   unusable = (long)Database.Scalar("SELECT COUNT(*) FROM `characters` WHERE `name` = @name", new MySqlParameter("name", name)) != 0;

            using (OutPacket oPacket = new OutPacket(SendOps.CheckDuplicatedIDResult))
            {
                oPacket
                .WriteMapleString(name)
                .WriteBool(unusable);

                client.Send(oPacket);
            }
        }
示例#19
0
        public static void RemoveFromSlot(MapleClient c, MapleInventoryType type, byte slot, short quantity, bool fromDrop, bool consume = false)
        {
            if (quantity < 0)
            {
                return;
            }
            var item      = c.Player.Inventorys[type.Value].Inventory[slot];
            var ii        = MapleItemInformationProvider.Instance;
            var allowZero = consume && (ii.IsThrowingStar(item.ItemId) || ii.IsBullet(item.ItemId));

            c.Player.Inventorys[type.Value].RemoveItem(slot, quantity, allowZero);
            if (item.Quantity == 0 && !allowZero)
            {
                c.Send(PacketCreator.ClearInventoryItem(type, item.Position, fromDrop));
            }
            else
            {
                if (!consume)
                {
                    //item.l(c.Player.getName() + " removed " + quantity + ". " + item.getQuantity() + " left.", false);
                }
                c.Send(PacketCreator.UpdateInventorySlot(type, (Item)item, fromDrop));
            }
        }
示例#20
0
        public override void SendSpawnData(MapleClient client)
        {
            if (!IsAlive)
            {
                return;
            }

            client.Send(IsFake ? PacketCreator.SpawnFakeMonster(this, 0) : PacketCreator.SpawnMonster(this, false));

            if (m_stati.Any())
            {
                m_activeEffects.ForEach(
                    mse =>
                {
                    client.Send(PacketCreator.ApplyMonsterStatus(ObjectId, mse.Stati, mse.GetSkill().SkillId, false,
                                                                 0));
                });
            }

            if (HasBossHpBar)
            {
                client.Send(BossHpBarPacket);
            }
        }
示例#21
0
        public void Sell(MapleClient c, MapleInventoryType type, byte slot, short quantity)
        {
            if (quantity == short.MinValue || quantity == 0)
            {
                quantity = 1;
            }

            MapleItemInformationProvider ii = MapleItemInformationProvider.Instance;
            IMapleItem item = c.Player.Inventorys[type.Value].Inventory[slot];

            if (ii.IsThrowingStar(item.ItemId))
            {
                quantity = item.Quantity;
            }
            if (quantity < 0)
            {
                AutobanManager.Instance.AddPoints(c, 1000, 0, "Selling " + quantity + " " + item.ItemId + " (" + type + "/" + slot + ")");
                return;
            }
            short iQuant = item.Quantity;

            if (iQuant == short.MinValue)
            {
                iQuant = 1;
            }

            if (quantity <= iQuant && iQuant > 0)
            {
                MapleInventoryManipulator.RemoveFromSlot(c, type, slot, quantity, false);
                double price;
                if (ii.IsThrowingStar(item.ItemId))
                {
                    price = ii.GetWholePrice(item.ItemId) / (double)ii.GetSlotMax(c, item.ItemId);
                }
                else
                {
                    price = ii.GetPrice(item.ItemId);
                }
                int recvMesos = (int)Math.Max(Math.Ceiling(price * quantity), 0);
                if (Math.Abs(price + 1) > 0.000001 && recvMesos > 0)
                {
                    c.Player.GainMeso(recvMesos, true);
                }

                c.Send(PacketCreator.ConfirmShopTransaction(0x8));
            }
        }
示例#22
0
        public void EnterPortal(MapleClient c)
        {
            var player = c.Player;

            var distanceSq = Position.DistanceSquare(player.Position);

            if (distanceSq > 22500)
            {
                player.AntiCheatTracker.RegisterOffense(CheatingOffense.UsingFarawayPortal, "D" + Math.Sqrt(distanceSq));
            }

            var changed = false;

            if (ScriptName != null)
            {
                //if (!FourthJobQuestsPortalHandler.handlePortal(ScriptName, player))
                //{
                changed = PortalScriptManager.Instance.Execute(this, c);
                //}
            }
            else if (TargetMapId != 999999999)
            {
                MapleMap to;
                //if (player.getEventInstance() == null)
                //{
                to = c.ChannelServer.MapFactory.GetMap(TargetMapId);
                //}
                //else {
                //    to = player.getEventInstance().getMapInstance(TargetMapID);
                //}
                var pto = to.GetPortal(TargetName);
                if (pto == null)
                {
                    // fallback for missing portals - no real life case anymore - intresting for not implemented areas
                    pto = to.GetPortal(0);
                }
                player.ChangeMap(to, pto);
                //late resolving makes this harder but prevents us from loading the whole world at once
                changed = true;
            }
            if (!changed)
            {
                c.Send(PacketCreator.EnableActions());
            }
        }
示例#23
0
        public static void OnMigrateIn(MapleClient c, InPacket p)
        {
            int charId = p.ReadInt();

            c.Character = Database.Instance.GetCharacter(charId);
            c.Account   = Database.Instance.GetAccount(c.Character.AccountId);
            c.LoggedIn  = true;

            using (OutPacket packet = new OutPacket(SendOps.SetField))
            {
                packet.WriteInt(c.Channel);
                packet.WriteByte();         //pcount
                packet.WriteBool(true);     //new channel

                for (int i = 0; i < 3; i++) //rand seeds
                {
                    packet.WriteInt(Randomizer.Generate());
                }

                packet.WriteInt();
                packet.WriteShort(-1); // Flags (contains everything: 0xFFFF)

                PacketCreator.Helper.AddCharacterData(packet, c.Character);

                packet.WriteByte(20); //Buddylist

                PacketCreator.Helper.AddInventory(packet, c.Character);

                packet.WriteShort(); //skills
                packet.WriteShort(); //quests
                packet.WriteShort(); //rps
                packet.WriteShort(); //rings

                foreach (int rock in c.Character.TeleportRock)
                {
                    packet.WriteInt(rock);
                }

                packet.WriteLong(64); //padding

                c.Send(packet);
            }
        }
示例#24
0
        private static void MigrateClient(MapleClient client, int characterID)
        {
            ChannelServer destination = MasterServer.Instance.Worlds[client.World].Channels[client.Channel];

            destination.Migrations.Add(client.Host, client.Account.ID, characterID);

            using (OutPacket oPacket = new OutPacket(SendOps.SelectCharacterResult))
            {
                oPacket
                .WriteByte()
                .WriteByte()
                .WriteBytes(new byte[4] {
                    127, 0, 0, 1
                })
                .WriteShort(destination.Port)
                .WriteInt(characterID)
                .WriteInt()
                .WriteByte();

                client.Send(oPacket);
            }
        }
示例#25
0
        public static void OnCheckUserLimit(MapleClient c, InPacket p)
        {
            int current = MasterServer.Instance.Channels.Sum((ch) => ch.Load);

            using (OutPacket packet = new OutPacket(SendOps.CheckUserLimitResult, 2))
            {
                if (current >= Constants.MaxPlayers) //full
                {
                    packet.WriteByte(2);
                }
                else if (current * 2 >= Constants.MaxPlayers) //half full
                {
                    packet.WriteByte(1);
                }
                else //under half full
                {
                    packet.WriteByte();
                }

                c.Send(packet);
            }
        }
示例#26
0
        public static void OnSelectWorld(MapleClient c, InPacket p)
        {
            p.Skip(1); // world id
            c.Channel = p.ReadByte();

            using (OutPacket packet = new OutPacket(SendOps.SelectWorldResult))
            {
                packet.WriteByte(); //some error

                packet.WriteByte((byte)c.Characters.Count);

                foreach (var character in c.Characters)
                {
                    PacketCreator.Helper.AddCharacterData(packet, character);
                    PacketCreator.Helper.AddCharaterLook(packet, character);
                    packet.WriteBool(false); //rank
                }

                packet.WriteZero(64); //padding
                c.Send(packet);
            }
        }
示例#27
0
        public static void OnSelectCharacter(MapleClient c, InPacket p)
        {
            int charId = p.ReadInt();

            Character target = c.Characters.FindOne((chr) => chr.CharId == charId);

            if (target != default(Character))
            {
                using (OutPacket packet = new OutPacket(SendOps.SelectCharacterResult))
                {
                    packet.WriteShort();
                    packet.WriteBytes(127, 0, 0, 1); //TODO : non const ip
                    packet.WriteShort(MasterServer.Instance.Channels[c.Channel].Port);
                    packet.WriteInt(charId);
                    packet.WriteByte();

                    c.Send(packet);
                }
            }
            else
            {
                c.Close();
            }
        }
示例#28
0
        public static void OnDeleteCharacter(MapleClient c, InPacket p)
        {
            p.Skip(4);
            int charId = p.ReadInt();

            Character target = c.Characters.FindOne((chr) => chr.CharId == charId);

            if (target != default(Character))
            {
                Database.Instance.DeleteCharacter(target);
                c.Characters.Remove(target);

                using (OutPacket packet = new OutPacket(SendOps.DeleteCharacterResult))
                {
                    packet.WriteInt(charId);
                    packet.WriteByte();
                    c.Send(packet);
                }
            }
            else
            {
                c.Close();
            }
        }
示例#29
0
        public static void HandleCharacterCreation(MapleClient client, InPacket iPacket)
        {
            string name      = iPacket.ReadMapleString();
            int    jobType   = iPacket.ReadInt();
            int    face      = iPacket.ReadInt();
            int    hair      = iPacket.ReadInt();
            int    hairColor = iPacket.ReadInt();
            byte   skin      = (byte)iPacket.ReadInt();
            int    topID     = iPacket.ReadInt();
            int    bottomID  = iPacket.ReadInt();
            int    shoesID   = iPacket.ReadInt();
            int    weaponID  = iPacket.ReadInt();
            Gender gender    = (Gender)iPacket.ReadByte();

            bool error = false;

            // TODO: Validate name, beauty and equipment before creating the character.

            int id = Database.InsertAndReturnIdentifier("INSERT INTO `characters` (account_id, world_id, name, gender, skin, face, hair) " +
                                                        "VALUES (@account_id, @world_id, @name, @gender, @skin, @face, @hair)",
                                                        new MySqlParameter("account_id", client.Account.ID),
                                                        new MySqlParameter("world_id", client.World),
                                                        new MySqlParameter("name", name),
                                                        new MySqlParameter("gender", gender),
                                                        new MySqlParameter("skin", skin),
                                                        new MySqlParameter("face", face),
                                                        new MySqlParameter("hair", hair));

            // TODO: Validate the default equipment statistics. I'm pretty sure some of them are untradable.

            Database.Execute("INSERT INTO `items` (character_id, inventory, slot, maple_id, weapon_defense) " +
                             "VALUES (@character_id, 0, -5, @maple_id, 3)",
                             new MySqlParameter("character_id", id),
                             new MySqlParameter("maple_id", topID));

            Database.Execute("INSERT INTO `items` (character_id, inventory, slot, maple_id, weapon_defense) " +
                             "VALUES (@character_id, 0, -6, @maple_id, 2)",
                             new MySqlParameter("character_id", id),
                             new MySqlParameter("maple_id", bottomID));

            Database.Execute("INSERT INTO `items` (character_id, inventory, slot, maple_id, slots, weapon_defense) " +
                             "VALUES (@character_id, 0, -7, @maple_id, 5, 3)",
                             new MySqlParameter("character_id", id),
                             new MySqlParameter("maple_id", shoesID));

            Database.Execute("INSERT INTO `items` (character_id, inventory, slot, maple_id, slots, weapon_attack) " +
                             "VALUES (@character_id, 0, -11, @maple_id, 7, 17)",
                             new MySqlParameter("character_id", id),
                             new MySqlParameter("maple_id", weaponID));

            // TODO: Add beginner's guide (based on job).

            using (DatabaseQuery query = Database.Query("SELECT * FROM characters WHERE `character_id` = @character_id", new MySqlParameter("character_id", id)))
            {
                query.NextRow();

                using (OutPacket oPacket = new OutPacket(SendOps.CreateNewCharacterResult))
                {
                    oPacket.WriteBool(error);

                    LoginHandler.AddCharacterEntry(oPacket, query);

                    client.Send(oPacket);
                }
            }
        }
示例#30
0
 public override void HandlePacket(MapleClient client, PacketReader packet)
 {
     Logger.Info("收到 PING 封包");
     client.Send(new Pong());
 }