Exemplo n.º 1
0
        public static void Handle(MapleClient c, PacketReader pr)
        {
            if (c.Account.MigrationData == null)
            {
                c.Disconnect("Account was found to have no migration data");
                return;
            }
            pr.Skip(1);
            pr.Skip(1);
            int    characterId = pr.ReadInt();
            string mac         = pr.ReadMapleString();
            string mac_hdd     = pr.ReadMapleString();
            string newpic      = pr.ReadMapleString();

            if (!c.Account.HasPic() && newpic.Length >= 6 && newpic.Length <= 16 && c.Account.HasCharacter(characterId) && Program.ChannelServers.Keys.Contains(c.Channel))
            {
                ushort port = Program.ChannelServers[c.Channel].Port;
                c.Account.MigrationData.CharacterId      = characterId;
                c.Account.MigrationData.Character        = MapleCharacter.LoadFromDatabase(characterId, false);
                c.Account.MigrationData.Character.Hidden = c.Account.IsGM;
                c.Account.SetPic(newpic);

                Program.EnqueueMigration(characterId, c.Account.MigrationData);

                c.SendPacket(ChooseCharWithPicHandler.ChannelIpPacket(port, characterId));
            }
        }
        public static void Handle(MapleClient c, PacketReader pr)
        {
            //[00 00 00 00] [F2 07 00 00] 00 00 00 00 00 00 64 11 A0 D8 00 00 00 00 B8 54 00 00 38 9A FE 92 98 EB F3 B2
            pr.Skip(4); //v143
            int characterId = pr.ReadInt();

            pr.Skip(18);
            long          ConnectionAuth = pr.ReadLong();
            MigrationData migration      = Program.TryDequeueMigration(characterId, ConnectionAuth, c.Channel);

            if (migration != null || migration.Character == null)
            {
                MapleClient oldClient = Program.GetClientByCharacterId(migration.CharacterId);
                if (oldClient != null)
                {
                    oldClient.SClient.Dispose();
                }

                MapleAccount   account = MapleAccount.GetAccountFromDatabase(migration.AccountName);
                MapleCharacter chr     = migration.Character;

                account.Character = chr;
                c.Account         = account;
                chr.Bind(c);
                account.MigrationData = migration;
                account.Character     = chr;
                if (!migration.ToCashShop)
                {
                    MapleMap map = Program.GetChannelServer(c.Channel).GetMap(chr.MapId);
                    if (map != null)
                    {
                        chr.Map = map;
                        MapleCharacter.EnterChannel(c);
                        c.Account.Character.LoggedIn();

                        chr.Stats.Recalculate(chr);
                        chr.Position = map.GetStartpoint(0).Position;
                        map.AddCharacter(chr);
                    }
                }
                else
                {
                    CashShop.StartShowing(c);
                }
            }
            else
            {
                c.Disconnect("No migration data found.");
            }
        }
Exemplo n.º 3
0
        public static void Disconnect(string[] split, MapleClient c)
        {
            string      playerName   = split[1];
            MapleClient targetClient = Program.GetClientByCharacterName(playerName);

            if (targetClient != null)
            {
                targetClient.Disconnect("Disconnected by chat command from {0}", c.Account.Character.Name);
                c.Account.Character.SendBlueMessage("Succesfully disconnected " + playerName);
            }
            else
            {
                c.Account.Character.SendBlueMessage("Player " + playerName + " is not online");
            }
        }
Exemplo n.º 4
0
        public static void Handle(MapleClient c, PacketReader pr)
        {
            try
            {
                if (c.Account == null)
                {
                    c.Disconnect("Client is not logged in to an account");
                    return;
                }

                string pic         = pr.ReadMapleString();
                int    characterId = pr.ReadInt();
                pr.Skip(1);
                string macs     = pr.ReadMapleString();
                string clientid = pr.ReadMapleString();
                if (c.Account.CheckPic(pic) && c.Account.HasCharacter(characterId) && Program.ChannelServers.ContainsKey(c.Channel))
                {
                    ushort port = Program.ChannelServers[c.Channel].Port;
                    c.Account.MigrationData.CharacterId      = characterId;
                    c.Account.MigrationData.Character        = MapleCharacter.LoadFromDatabase(characterId, false);
                    c.Account.MigrationData.Character.Hidden = c.Account.IsGM;

                    Program.EnqueueMigration(characterId, c.Account.MigrationData);

                    c.SendPacket(ChannelIpPacket(port, characterId));
                }
                else
                {
                    //Incorrect Pic
                    PacketWriter pw = new PacketWriter();
                    pw.WriteHeader(SendHeader.PICResponse);
                    pw.WriteByte(0x14);
                    c.SendPacket(pw);
                }
            }
            catch (Exception ex)
            {
                ServerConsole.Error(ex.ToString());
                FileLogging.Log("Character loading", ex.ToString());
                c.SendPacket(MapleCharacter.ServerNotice("Error loading character", 1));

                /*PacketWriter pw = new PacketWriter();
                 * pw.WriteHeader(SendHeaders.PICResponse);
                 * pw.WriteByte(0x15);
                 * c.SendPacket(pw);*/
            }
        }
        //opcode  ?    serv chan  network ip
        //[43 00] [02] [00] [00] [0A 00 00 03]
        public static void Handle(MapleClient c, PacketReader pr)
        {
            if (c.Account == null)
            {
                c.Disconnect("Account is not logged in"); //something's wrong, isnt logged in
                return;
            }

            pr.Skip(1);
            pr.Skip(1); //server, we only have 1 atm anyway
            byte channel = (byte)(pr.ReadByte());

            c.Account.MigrationData.ToChannel = channel;
            c.Channel = channel;
            //last 4 bytes = network IP

            /*PacketWriter pw = new PacketWriter();
             * pw.WriteHeader(SendHeader.LoginSuccess);
             * pw.WriteByte(0);
             * pw.WriteInt(c.Account.Id); //Accid
             * pw.WriteZeroBytes(10);
             * pw.WriteByte(0x95);
             * pw.WriteMapleString(c.Account.Name);
             * pw.WriteZeroBytes(10);
             * pw.WriteMapleString(c.Account.Name);
             * pw.WriteHexString("00 6E E5 D6 A3 2C C7 01"); //account creation date?
             * pw.WriteInt(10); //no idea
             * pw.WriteHexString("E4 A4 AE E1 C5 54 E9 93"); //no idea
             * pw.WriteShort(0);
             *
             * pw.WriteHexString(options);
             *
             * pw.WriteInt(-1);
             * pw.WriteByte(0);
             * pw.WriteByte(1);
             * pw.WriteByte(1);
             * c.SendPacket(pw);
             *
             * pw = new PacketWriter(SendHeader.WorldId);
             * pw.WriteInt(0); //world 1 = scania
             * c.SendPacket(pw);
             */

            c.SendPacket(ShowCharacters(c.Account));
            c.SendPacket(CreateCharacterOptions());
        }
Exemplo n.º 6
0
        private static void MapleClientConnect(Socket client)
        {
            String ip = ((IPEndPoint)client.RemoteEndPoint).Address.ToString();

            if (!AllowConnection(ip))
            {
                client.Shutdown(SocketShutdown.Both);
                client.Close();
                return;
            }

            MapleClient Client = new MapleClient(client);

            try
            {
                ushort channelStartPort = ServerConstants.ChannelStartPort;
                byte   channelCount     = ServerConstants.Channels;
                byte   channelID        = 0;
                for (byte i = 0; i < ChannelServers.Count; i++)
                {
                    if (ChannelServers[i].Port == ((IPEndPoint)client.LocalEndPoint).Port)
                    {
                        channelID = (byte)(i);
                    }
                }
                if (((IPEndPoint)client.LocalEndPoint).Port == ServerConstants.CashShopPort)
                {
                    channelID = 0xFF;
                }
                Client.Channel = channelID;
                Client.SendHandshake();
                Clients.Add(ip + Functions.Random(), Client);
            }
            catch (Exception e)
            {
                Client.Disconnect(e.ToString());
            }
        }