Esempio n. 1
0
 public static void Handle(MapleClient c)
 {
     if (ServerConstants.LocalHost) //Kek
     {
         MapleAccount acc = MapleAccount.GetAccountFromDatabase("Nuclear");
         c.Account = acc;
         c.SendPacket(LoginAccountHandler.LoginAccountSuccess(acc));
     }
 }
        public static PacketWriter LoginAccountSuccess(MapleAccount acc)
        {
            PacketWriter pw = new PacketWriter();

            pw.WriteHeader(SendHeader.AccountLoginResponse);

            pw.WriteByte(0);
            pw.WriteByte(0);
            pw.WriteInt(0);
            pw.WriteInt(acc.Id);
            pw.WriteLong(0);
            pw.WriteShort(0);
            pw.WriteByte(0x95);
            pw.WriteMapleString(acc.Name);
            pw.WriteLong(0);
            pw.WriteShort(0);
            pw.WriteHexString("A0 2C D1 09 92 7C C5 01 0A 00 00 00 01 11 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 00 02 00 01 01 00 01 01 00 01 01 00 01 01 00 00 01 00 00 FF FF FF FF 01 01");

            /*pw.WriteHexString("60 AC CC 1F 57 C7 01");
             * pw.WriteInt(0x38);
             * pw.WriteBool(true); //?
             * pw.WriteByte(0xB); //featured job, shows up at the front, 0xA = Zero, 0xB = BeastTamer
             * pw.WriteBool(true); //Resistance
             * pw.WriteBool(true); //Explorer
             * pw.WriteBool(true); //Cygnus
             * pw.WriteBool(true); //Aran
             * pw.WriteBool(true); //Evan
             * pw.WriteBool(true); //Mercedes
             * pw.WriteBool(true); //Demon
             * pw.WriteBool(true); //Phantom
             * pw.WriteBool(true); //DualBlade
             * pw.WriteBool(true); //Mihile
             * pw.WriteBool(true); //Luminous
             * pw.WriteBool(true); //Kaiser
             * pw.WriteBool(true); //Angelic Buster
             * pw.WriteBool(true); //Cannonneer
             * pw.WriteBool(true); //Xenon
             * pw.WriteBool(false); //Zero
             * pw.WriteBool(true); //Jett
             * pw.WriteBool(true); //Hayato
             * pw.WriteBool(true); //Kanna
             * pw.WriteBool(true); //BeastTamer
             */


            MigrationData migration = new MigrationData()
            {
                CharacterId    = 0,
                ConnectionAuth = Functions.RandomLong(),
                AccountName    = acc.Name
            };

            acc.MigrationData = migration;
            pw.WriteLong(migration.ConnectionAuth);
            return(pw);
        }
        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.");
            }
        }
        static PacketWriter ShowCharacters(MapleAccount acc)
        {
            List <MapleCharacter> chars = acc.GetCharsFromDatabase();
            PacketWriter          pw    = new PacketWriter(SendHeader.ShowCharacters);

            pw.WriteZeroBytes(5);
            pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(DateTime.UtcNow));
            pw.WriteByte((byte)chars.Count); //Char count
            foreach (MapleCharacter chr in chars)
            {
                MapleCharacter.AddCharEntry(pw, chr);
            }
            //pw.WriteHexString("00 00 04 00 00 00 00 00 00 00 30 2A F3 A2 FA 33 D0 01 60 42 F9 64 00 00 00 00 00");

            pw.WriteByte(acc.HasPic() ? (byte)1 : (byte)0); //pic state? 4 = refresh, 1 = normal, 0 = create new pic
            pw.WriteByte(0);
            pw.WriteInt(4);                                 //char slots
            pw.WriteInt(0);
            pw.WriteLong(MapleFormatHelper.GetMapleTimeStamp(DateTime.UtcNow));
            pw.WriteHexString("60 42 F9 64");
            pw.WriteInt(0); // 1 = namechange button
            return(pw);
        }
        public static void Handle(MapleClient c, PacketReader pr)
        {
            string accountPassword = pr.ReadMapleString();
            string accountName     = pr.ReadMapleString();

            if (accountName.StartsWith("NP12:auth"))
            {
                c.SendPacket(MapleCharacter.ServerNotice("Please start MapleStory using the leatty launcher.", 1));
                return;
            }
            ServerConsole.Debug("Login account: " + accountName);
            MapleAccount account = MapleAccount.GetAccountFromDatabase(accountName);

            if (account != null)
            {
                if (Program.IsAccountOnline(account.Id))
                {
                    c.SendPacket(LoginAccountFailed(7));
                }
                else
                {
                    if (account.CheckPassword(accountPassword))
                    {
                        c.Account = account;
                        c.SendPacket(LoginAccountSuccess(account));
                    }
                    else
                    {
                        c.SendPacket(LoginAccountFailed(4));
                    }
                }
            }
            else
            {
                c.SendPacket(LoginAccountFailed(5));
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.Title           = "Leatty " + ServerConstants.Version;

            ServerConstants.LoadFromFile();

            InitializeDatabase();
            LoadDataBuffers();
            CustomNpcs = DataProvider.LoadCustomNpcs();
            StartCashShop();
            StartLogin();
            StartChannels();
            PingTimer.Elapsed += (sender, e) => PingClients();


            StartDataApi();

            GC.Collect();
            string line = string.Empty;

            while (!(line = Console.ReadLine().ToLower()).Contains("stop") && !line.Contains("exit"))
            {
                string[] split = line.Split(' ');
                if (split.Length > 0)
                {
                    switch (split[0])
                    {
                    case "login":
                        if (ServerConstants.LocalHost && Program.Clients.Any())
                        {
                            MapleClient  c   = Program.Clients.First().Value;
                            MapleAccount acc = MapleAccount.GetAccountFromDatabase("Nuclear");
                            c.SendPacket(LoginAccountHandler.LoginAccountSuccess(acc));
                        }
                        break;

                    case "mapleshark":
                    case "maplesharkconfig":
                        MapleSharkConfigCreator.GenerateConfigFile();
                        break;

                    case "dumpskills":
                        Functions.DumpSkillConstants();
                        break;

                    case "dumpitems":
                        Functions.DumpItems();
                        break;

                    case "send":
                        if (split.Length > 4)
                        {
                            MapleCharacter chr = GetCharacterByName(split[1]);
                            if (chr == null)
                            {
                                ServerConsole.Info("Player " + split[1] + "not found");
                            }
                            else
                            {
                                PacketWriter pw = new PacketWriter();
                                pw.WriteHexString(split.Fuse(2));
                                chr.Client.SendPacket(pw);
                            }
                        }
                        break;

                    case "notice":
                        if (split.Length > 1)
                        {
                            string message = "[Notice] " + split.Fuse(1);
                            BroadCastWorldPacket(MapleCharacter.ServerNotice(message, 6));
                        }
                        break;

                    default:
                        ServerConsole.Info("Unknown command: " + line);
                        break;
                    }
                }
            }
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Shutting down...");
            Quit();
        }