コード例 #1
0
        public virtual void HandleLoginFromWeb(ClientConnection pConnection, MaplePacket pPacket)
        {
            byte error = pPacket.ReadByte();
            if (error != 0)
            {
                pConnection.Logger_WriteLine("Got Status: {0}", error);
                if (error == 0x07)
                {
                    pConnection.Logger_WriteLine("Already logged in!");
                }
                return;
            }

            int userid = pPacket.ReadInt();
            pPacket.ReadByte(); // Gender or GenderSelect/PinSelect
            pPacket.ReadByte();
            pPacket.ReadShort(); // Admin info!
            pPacket.ReadInt(); // ReadBytes(4)
            pPacket.ReadByte(); // 0x95
            string username = pPacket.ReadString(); // Username

            pPacket.ReadByte(); // 0?


            pPacket.ReadByte(); // Quiet Ban
            pPacket.ReadLong(); // Quiet Ban Time
            pPacket.ReadString(); // Username. Again.
            DateTime creationtime = DateTime.FromFileTime(pPacket.ReadLong()); // creation datetime
            pPacket.ReadInt();
            pPacket.ReadBytes(8); // CC key
            pPacket.ReadString();

            ParseLogin(pConnection, userid, username, creationtime);
        }
コード例 #2
0
        public override void HandleLogin(ClientConnection pConnection, MaplePacket pPacket)
        {
            byte error = pPacket.ReadByte();
            if (error != 0)
            {
                pConnection.Logger_WriteLine("Got Status: {0}", error);
                if (error == 0x07)
                {
                    pConnection.Logger_WriteLine("Already logged in?");
                }
                return;
            }

            int userid = pPacket.ReadInt();
            pPacket.ReadByte(); // Gender or GenderSelect/PinSelect
            pPacket.ReadByte();
            pPacket.ReadByte(); // Admin? Has bitflag 5
            string username = pPacket.ReadString(); // Username
            pPacket.ReadByte();
            pPacket.ReadByte();
            DateTime creationtime = DateTime.FromFileTime(pPacket.ReadLong()); // Incorrect :/. Nowhere to be found

            if (pPacket.ReadBool() == false)
                pPacket.ReadString(); // Username, with astriks as protection: 'd**mondo2*'

            pPacket.ReadString(); // wat.
            if (pPacket.ReadBool())
                pPacket.ReadBytes(15); // Every job that can be chosen

            pPacket.ReadInt(); // YYYYMMDDHH, as in character info -.-?


            ParseLogin(pConnection, userid, username, creationtime);
        }
コード例 #3
0
        public virtual void HandleVersion(ClientConnection pConnection, MaplePacket pPacket)
        {
            byte locale = pPacket.ReadByte();
            ushort version = pPacket.ReadUShort();
            ushort subversion = pPacket.ReadUShort();

            pConnection.Logger_WriteLine("Detected MapleStory version of client: {1}.{2} (locale: {0})", locale, version, subversion);
            pConnection.MapleVersion = version;

            pConnection.CharData = null; // Back to the LoginServer!!!
            if (locale != ServerMapleInfo.LOCALE)
            {
                pConnection.Logger_WriteLine("Incompatible MapleStory locale detected!!!!");
                pConnection.SendInfoText("Unsupported MapleStory client detected. Mapler.me only supports MapleStory Global version {0} at the moment.", ServerMapleInfo.VERSION); // This should _never_ happen XD (different encryption and such)
                pConnection.Disconnect();
            }
            else if (version > ServerMapleInfo.VERSION)
            {
                pConnection.Logger_WriteLine("MapleStory client of user is outdated/incorrect. Disconnect.");
                pConnection.SendInfoText("Your MapleStory client seems outdated. Update your client in order to use the Mapler.me service.\r\nVersion identified: {0}\r\nSupported version: {1}", version, ServerMapleInfo.VERSION);
                pConnection.Disconnect();
            }
            else if (version < ServerMapleInfo.VERSION)
            {
                pConnection.Logger_WriteLine("MapleStory client of user is more up-to-date than Mapler.me service!!!");
                pConnection.SendInfoText("As your client is more up-to-date than the Mapler.me service, you are unable to use the Mapler.me service at this time.\r\nCheck the Mapler.me website and/or Twitter (@maplerme) for updates!\r\n\r\nCurrently supported version: {0}\r\nYour version: {1}", ServerMapleInfo.VERSION, version);
                pConnection.Disconnect();
            }

        }
コード例 #4
0
        public static ItemBase DecodeItemData(ClientConnection pConnection, MaplePacket pPacket)
        {
            byte type = pPacket.ReadByte();
            ItemBase ret = null;
            switch (type)
            {
                case 1:
                    ret = new ItemEquip();
                    ret.Amount = 1;
                    break;
                case 2: ret = new ItemRechargable(); break;
                case 3:
                    ret = new ItemPet();
                    ret.Amount = 1;
                    break;
                default:
                    {
                        Logger.WriteLine("Unkown ItemType: {0}", type);
                        return null;
                    }
            }

            ret.Decode(pConnection, pPacket);

            return ret;
        }
        public void Decode(MaplePacket pPacket)
        {
            pPacket.ReadByte(); // ?


            Running = new Dictionary<ushort, string>();
            Done = new Dictionary<ushort, long>();

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                Running.Add(pPacket.ReadUShort(), pPacket.ReadString());
            }

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadString();
                pPacket.ReadString();
            }

            pPacket.ReadByte(); // ?

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                Done.Add(pPacket.ReadUShort(), pPacket.ReadLong());
            }
        }
コード例 #6
0
ファイル: MESession.cs プロジェクト: diamondo25/mapler.me
        public virtual void SendPacket(MaplePacket pPacket)
        {
            if (_disconnected)
            {
                return;
            }
            try
            {
                byte[] data     = pPacket.ToArray();
                int    checksum = data.CalculateChecksum();
                if (_sendKey != null)
                {
                    data = Crypto.Encrypt(data, _sendKey);
                }

                byte[] completeData = new byte[data.Length + 4 + 4];
                Buffer.BlockCopy(BitConverter.GetBytes(pPacket.Length), 0, completeData, 0, 4);
                Buffer.BlockCopy(BitConverter.GetBytes(checksum), 0, completeData, 4, 4);
                Buffer.BlockCopy(data, 0, completeData, 8, data.Length);

                _socket.Send(completeData, 0, completeData.Length, SocketFlags.None);
            }
            catch (Exception)
            {
                Logger.WriteLine("Internal Packet Sending Exception @ SendPacket");
                Disconnect();
            }
        }
コード例 #7
0
        public virtual void HandleLogin(ClientConnection pConnection, MaplePacket pPacket)
        {
            int error = pPacket.ReadInt();
            pPacket.ReadShort();
            if (error != 0)
            {
                pConnection.Logger_WriteLine("Got Status: {0}", error);
                if (error == 0x07)
                {
                    pConnection.Logger_WriteLine("Already logged in!");
                }
                return;
            }

            int userid = pPacket.ReadInt();
            byte gender = pPacket.ReadByte(); // Gender or GenderSelect/PinSelect
            pPacket.ReadByte();
            short admin = pPacket.ReadShort();
            pPacket.ReadInt(); // ReadBytes(4)
            pPacket.ReadByte(); // 0x95
            string username = pPacket.ReadString(); // Username

            pPacket.ReadByte(); // 0?


            byte qban = pPacket.ReadByte(); // Quiet Ban
            DateTime qban_time = DateTime.FromFileTime(pPacket.ReadLong()); // Quiet Ban Time
            DateTime creationtime = DateTime.FromFileTime(pPacket.ReadLong()); // Creation Time
            pPacket.ReadInt(); // 78?
            pPacket.Skip(2); // 1 1
            pPacket.ReadBytes(8); // CC key

            ParseLogin(pConnection, userid, username, creationtime);
        }
コード例 #8
0
        public ClientConnection(Socket pSocket)
            : base(pSocket)
        {
            uniqueid = Program.Random.Next(0, 10000);

            Pong = true;
            IsFake = false;
            Program.Clients.Add(this);
            Clear();
            _exporter = new MSBExporter();
            Logger_WriteLine("Client Connected!");

            byte[] sendkey = new byte[32], recvkey = new byte[32];
            Program.Random.NextBytes(sendkey);
            Program.Random.NextBytes(recvkey);

            using (MaplePacket pack = new MaplePacket(MaplePacket.CommunicationType.ServerPacket, 0xEEFF))
            {
                pack.WriteString(Logger.Version);

                // Add encryption keys
                pack.WriteBytes(recvkey);
                pack.WriteBytes(sendkey);

                for (byte i = 0; i < (byte)MaplePacket.CommunicationType.AMOUNT; i++)
                {
                    pack.WriteUShort((ushort)Program.ValidHeaders[i].Keys.Count);
                    foreach (var header in Program.ValidHeaders[i].Keys)
                        pack.WriteUShort(header);
                }

                pack.WriteByte((byte)Program.AcceptedIPs.Count);
                foreach (string ip in Program.AcceptedIPs)
                    pack.WriteString(ip);


#if LOCALE_GMS
                pack.WriteBool(true);
                pack.WriteBytes(GMSKeys.GetKeyForVersion());
#elif LOCALE_KMS
                pack.WriteBool(false);
#else
                pack.WriteBool(true);
                pack.WriteBytes(new byte[] { 0x13, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0xB4, 0x00, 0x00, 0x00,
            0x1B, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00 });
#endif


                pack.WriteByte(ServerMapleInfo.LOCALE);
                pack.WriteUShort(ServerMapleInfo.VERSION);

                SendPacket(pack);
            }

            SetKeys(sendkey, recvkey);

            SendInfoText("Welcome! Please open MapleStory.");
        }
 public void DecodeTeleportRocks(MaplePacket pPacket)
 {
     TeleportRocks = new int[NORMAL_ROCKS + VIP_ROCKS + HYPER_ROCKS + HYPER_ROCKS2];
     int i = 0;
     for (; i < TeleportRocks.Length; i++)
     {
         TeleportRocks[i] = pPacket.ReadInt();
     }
 }
コード例 #10
0
ファイル: Alliance.cs プロジェクト: diamondo25/mapler.me
        public static void DecodeGuilds(MaplePacket pPacket, byte pWorldID)
        {
            pWorldID = GameHelper.GetAllianceWorldID(pWorldID);

            int guilds = pPacket.ReadInt();
            for (int i = 0; i < guilds; i++)
            {
                Guild guild = new Guild();
                guild.Decode(pPacket);
                guild.Save(pWorldID);
            }
        }
コード例 #11
0
ファイル: MSBExporter.cs プロジェクト: diamondo25/mapler.me
            public DumpPacket(MaplePacket pPacket)
            {
                pPacket.Reset();
                MaplePacket.CommunicationType type = (MaplePacket.CommunicationType)pPacket.ReadByte();
                Outboud = type == MaplePacket.CommunicationType.ClientPacket;
                Opcode = pPacket.ReadUShort();

                Data = new byte[pPacket.Length - 3];
                Buffer.BlockCopy(pPacket.ToArray(), 3, Data, 0, Data.Length); // byte + short (header)
                ArrivalTime = MasterThread.CurrentDate;
                pPacket.Reset();
            }
コード例 #12
0
        public void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            var v = pPacket.ReadByte(); // ?


            Running = new Dictionary<ushort, string>();
            Done = new Dictionary<ushort, long>();

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                Running.Add(pPacket.ReadUShort(), pPacket.ReadString());
            }

            if (v == 0)
            {
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    pPacket.ReadShort(); // UNK lol
                }
            }

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadString(); // 1NX1702337
                pPacket.ReadString(); // '1' or '0 ' ?!
            }

            var hurr = pPacket.ReadByte(); // ?

            // ADDED IN v.128 !!!!
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                // New method of creating dates...
                var id = pPacket.ReadUShort();
                var date = pPacket.ReadUInt();

                long ft = DecodeTimeFromInt(pConnection, date);

                if (!Done.ContainsKey(id))
                    Done.Add(id, ft);
                else
                    pConnection.Logger_WriteLine("Duplicate Quest (Done): {0}", id);

            }

            if (hurr == 0)
            {
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    Done.Add(pPacket.ReadUShort(), pPacket.ReadLong());
                }
            }
        }
            public void Decode(MaplePacket pPacket)
            {
                Values = new int[AmountOfValues];

                string tmp = "";

                for (int i = 0; i < AmountOfValues; i++)
                {
                    Values[i] = pPacket.ReadInt();
                    tmp += string.Format("{0} |", Values[i]);
                }

                Logger.WriteLine("ULOI: {0}", tmp);
            }
コード例 #14
0
ファイル: AvatarLook.cs プロジェクト: diamondo25/mapler.me
        public void Decode(MaplePacket pPacket)
        {
            this.Gender = pPacket.ReadByte(); // Gender
            this.Skin = pPacket.ReadByte(); // Skin
            this.Face = pPacket.ReadInt(); // Face

            this.JobID = pPacket.ReadInt(); // Job ID

            pPacket.ReadByte(); // First slot; hair
               this.Hair = pPacket.ReadInt(); // Hair ID

            Equips = new Dictionary<byte, int>[3];
            Equips[0] = new Dictionary<byte, int>();
            Equips[1] = new Dictionary<byte, int>();
            Equips[2] = new Dictionary<byte, int>();

            while (true)
            {
                byte slot = pPacket.ReadByte();
                if (slot == 0xFF) break;
                Equips[0].Add(slot, pPacket.ReadInt());
            }
            while (true)
            {
                byte slot = pPacket.ReadByte();
                if (slot == 0xFF) break;
                Equips[1].Add(slot, pPacket.ReadInt());
            }
            while (true)
            {
                byte slot = pPacket.ReadByte();
                if (slot == 0xFF) break;
                Equips[2].Add(slot, pPacket.ReadInt());
            }

            pPacket.ReadInt();
            pPacket.ReadInt();
            pPacket.ReadInt();

            pPacket.ReadByte();
            pPacket.ReadInt();
            pPacket.ReadInt();
            pPacket.ReadInt();

            if (this.JobID / 100 == 31 || this.JobID / 100 == 36 || this.JobID == 3001 || this.JobID == 3002)
            {
                this.Wings = pPacket.ReadInt();
            }
        }
コード例 #15
0
ファイル: frmMain.cs プロジェクト: diamondo25/mapler.me
        void _keyboardHook_KeyPressed(object sender, KeyPressedEventArgs e)
        {
            var procs = System.Diagnostics.Process.GetProcessesByName("MapleStory");
            if (procs.Length == 0 || ServerConnection.Instance == null) return;

            if (e.Modifier == Mapler_Client.ModifierKeys.Alt && e.Key == Keys.R)
            {
                Logger.WriteLine("Requesting report screenshot");
                using (MaplePacket mp = new MaplePacket(MaplePacket.CommunicationType.ClientPacket, 0xEE02))
                {
                    ServerConnection.Instance.SendPacket(mp);
                    Console.Beep(7000, 500);
                }
            }
        }
コード例 #16
0
ファイル: Alliance.cs プロジェクト: diamondo25/mapler.me
        public void Decode(MaplePacket pPacket)
        {
            this.ID = pPacket.ReadInt();
            this.Name = pPacket.ReadString();
            this.Ranks = new string[5];
            for (int i = 0; i < 5; i++)
                this.Ranks[i] = pPacket.ReadString();

            byte guilds = pPacket.ReadByte();
            this.GuildIDs = new int[guilds];
            for (int i = 0; i < guilds; i++)
                this.GuildIDs[i] = pPacket.ReadInt();

            this.Capacity = pPacket.ReadInt();
            this.Notice = pPacket.ReadString();
        }
コード例 #17
0
        public virtual void HandleCharacterLoadRequest(ClientConnection pConnection, MaplePacket pPacket)
        {
            if (!(pConnection.ConnectedToPort >= 8585 && pConnection.ConnectedToPort <= 8600))
            {
                pConnection.Logger_WriteLine("Ignoring Character Load Request; not connected to a channel server");
                return;
            }

            int characterid = pPacket.ReadInt();
            byte[] machineid = pPacket.ReadBytes(16);
            pConnection.MachineID = machineid;

            if (pConnection.UserID == -1)
            {
                SessionRestartCache.Instance.TryRestartSession(pConnection, characterid, machineid);
            }
        }
コード例 #18
0
        public virtual void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            ItemID = pPacket.ReadInt();

            if (pPacket.ReadBool())
            {
                CashID = pPacket.ReadLong();
            }
            else
            {
                CashID = 0;
            }

            Expires = pPacket.ReadLong();

            BagID = pPacket.ReadInt();
        }
コード例 #19
0
ファイル: CharacterData.cs プロジェクト: diamondo25/mapler.me
            public Ring(Ring.Type pType, MaplePacket pPacket, string pOwnName = null)
            {
                RingType = pType;
                if (pType == Type.Marriage)
                {
                    int marriageID = pPacket.ReadInt();

                    int characterID = pPacket.ReadInt();
                    int partnerID = pPacket.ReadInt();
                    pPacket.ReadShort(); // Most likely 3, marriage type?
                    int characterItemID = pPacket.ReadInt();
                    int partnerItemID = pPacket.ReadInt();
                    string characterName = pPacket.ReadString(13);
                    string partnerName = pPacket.ReadString(13);

                    if (pOwnName != FriendName)
                    {
                        FriendID = partnerID;
                        FriendName = partnerName;
                        RingCashID1 = characterItemID;
                        RingCashID2 = partnerItemID;
                    }
                    else
                    {
                        FriendID = characterID;
                        FriendName = characterName;
                        RingCashID1 = partnerItemID;
                        RingCashID2 = characterItemID;
                    }
                }
                else
                {
                    FriendID = pPacket.ReadInt();
                    FriendName = pPacket.ReadString(13);
                    RingCashID1 = pPacket.ReadLong();
                    RingCashID2 = pPacket.ReadLong();

                    if (pType == Type.Friend)
                    {
                        int itemID = pPacket.ReadInt();
                    }

                }
            }
        public void Decode(MaplePacket pPacket)
        {
            InventorySlots = new byte[INVENTORIES];
            for (int i = 0; i < INVENTORIES; i++)
                InventorySlots[i] = pPacket.ReadByte();

            pPacket.ReadLong(); // 94354848000000000 | 1-1-1900



            EquipmentItems = new Dictionary<short, ItemEquip>[EQUIP_INVENTORIES];

            for (byte i = 0; i < EQUIP_INVENTORIES; i++)
            {
                EquipmentItems[i] = new Dictionary<short, ItemEquip>();

                while (true)
                {
                    short slot = pPacket.ReadShort();
                    if (slot == 0) break;

                    ItemEquip equip = (ItemEquip)ItemBase.DecodeItemData(pPacket);

                    EquipmentItems[i].Add(slot, equip);
                }
            }

            InventoryItems = new Dictionary<byte, ItemBase>[NORMAL_INVENTORIES];

            for (byte i = 0; i < NORMAL_INVENTORIES; i++)
            {
                InventoryItems[i] = new Dictionary<byte, ItemBase>();

                while (true)
                {
                    byte slot = pPacket.ReadByte();
                    if (slot == 0) break;

                    ItemBase item = ItemBase.DecodeItemData(pPacket);

                    InventoryItems[i].Add(slot, item);
                }
            }
        }
コード例 #21
0
ファイル: Android.cs プロジェクト: diamondo25/mapler.me
        public void Decode(MaplePacket pPacket)
        {
            this.ID = pPacket.ReadInt();
            this.Type = pPacket.ReadByte();

            pPacket.ReadShort(); // X
            pPacket.ReadShort(); // Y
            pPacket.ReadByte(); // Stance
            pPacket.ReadShort(); // Foothold

            this.Skin = (byte)pPacket.ReadShort();
            this.Hair = pPacket.ReadShort();
            this.Face = pPacket.ReadShort();
            this.Name = pPacket.ReadString();

            this.Equips = new int[7];
            for (int i = 0; i < 7; i++)
                this.Equips[i] = pPacket.ReadInt();
        }
コード例 #22
0
        public static void HandleTokenCheck(ClientConnection pConnection, MaplePacket pPacket)
        {
            string token = pPacket.ReadString();
            bool okay = false;
            int accountid = -1;

            okay = Queries.CheckAccountToken(token, out accountid);

            if (!okay)
            {
                pConnection.Logger_ErrorLog("Kicked client; token was not valid.");
                pConnection.Disconnect();
                return;
            }
            else
            {
                pConnection.Logger_WriteLine("Accepted client. Logged in with account ID {0}", accountid);

                pConnection.AccountID = accountid;
            }
        }
コード例 #23
0
        public void Decode(MaplePacket pPacket)
        {
            ChosenCardID = pPacket.ReadInt();

            if (pPacket.ReadBool() == false)
            {
                for (short cards = pPacket.ReadShort(); cards > 0; cards--)
                {
                    pPacket.ReadShort(); // CardID
                    pPacket.ReadByte(); // Level
                }
            }
            else
            {
                // Unknown stuff...
                pPacket.ReadShort();
                short size = pPacket.ReadShort();
                pPacket.Skip(size); // Card block

                size = pPacket.ReadShort();
                pPacket.Skip(size); // Levels
            }
        }
コード例 #24
0
        public virtual void HandleKeymapUpdate(ClientConnection pConnection, MaplePacket pPacket)
        {
            int mode = pPacket.ReadInt();
            if (mode == 0)
            {
                Dictionary<byte, KeyValuePair<byte, int>> modifieds = new Dictionary<byte, KeyValuePair<byte, int>>();
                int amount = pPacket.ReadInt();
                for (int i = 0; i < amount; i++)
                {
                    int idx = pPacket.ReadInt();
                    byte type = pPacket.ReadByte();
                    int value = pPacket.ReadInt();

                    if (idx < 0 || idx > ServerMapleInfo.KEYMAP_SLOTS)
                    {
                        pConnection.Logger_WriteLine("ERROR: Keymap contained invalid index!");
                        return;
                    }

                    if (modifieds.ContainsKey((byte)idx)) continue; // -.-''

                    modifieds.Add((byte)idx, new KeyValuePair<byte, int>(type, value));
                }

                if (modifieds.Count == 0) return;

                StringBuilder sb = new StringBuilder();
                sb.Append("UPDATE character_keymaps SET ");
                foreach (var kvp in modifieds)
                    sb.AppendFormat("map_{0}_type = {1}, map_{0}_value = {2},", kvp.Key, kvp.Value.Key, kvp.Value.Value);

                sb.Append(" WHERE character_id = " + pConnection.CharacterInternalID);

                MySQL_Connection.Instance.RunQuery(sb.ToString().Replace(", WHERE", " WHERE"));

            }
        }
コード例 #25
0
ファイル: CharacterData.cs プロジェクト: diamondo25/mapler.me
 public void Decode(ClientConnection pConnection, MaplePacket pPacket)
 {
     ID = pPacket.ReadShort();
     ItemID = pPacket.ReadInt();
     Level = (byte)pPacket.ReadInt();
 }
コード例 #26
0
ファイル: CharacterData.cs プロジェクト: diamondo25/mapler.me
        public void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            pPacket.Skip(8); // Flag

#if LOCALE_GMS
            pPacket.Skip(1);
#endif

            {
                // Added GMS V.132 
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
            }

#if LOCALE_EMS
            pPacket.Skip(1);
#endif

            int tmp = pPacket.ReadByte();
            pPacket.Skip(tmp * 4);

            tmp = pPacket.ReadInt();
            pPacket.Skip(tmp * (4 + 8));


#if LOCALE_GMS
            pPacket.Skip(1);
#endif

            if (pPacket.ReadBool())
            {
                tmp = pPacket.ReadInt();
                pPacket.Skip(tmp * 8);
                tmp = pPacket.ReadInt();
                pPacket.Skip(tmp * 8);
            }

            Stats = new GW_CharacterStat();
            Stats.Decode(pPacket);

            this.BuddylistSize = pPacket.ReadByte();
#if LOCALE_EMS
            pPacket.ReadByte();
#endif

            if (pPacket.ReadBool()) BlessingOfTheFairy = pPacket.ReadString();
            else BlessingOfTheFairy = null;
            if (pPacket.ReadBool()) BlessingOfEmpress = pPacket.ReadString();
            else BlessingOfEmpress = null;
            if (pPacket.ReadBool()) UltimateExplorer = pPacket.ReadString();
            else UltimateExplorer = null;

            Stats.DecodeMesos(pPacket); // .-.

#if LOCALE_EMS
            pPacket.ReadByte(); // Bool check
            pPacket.ReadInt();
#endif


            // Unknown stuff here

            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadLong();
            }

#if LOCALE_GMS
            // Magical potion pots!!!
            for (int i = pPacket.ReadInt(); i > 0; i--) // V.126
            {
                pPacket.ReadInt(); // Potion pot ID
                pPacket.ReadInt(); // Max value
                pPacket.ReadInt(); // HP
                pPacket.ReadInt(); // ??? (Not max value of MP)
                pPacket.ReadInt(); // MP

                pPacket.ReadLong(); // Start date O.o?
                pPacket.ReadLong(); // End date O.o?
            }
#endif


#if LOCALE_GMS
            // V.142 - RED stuff?

            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadByte();
                pPacket.ReadInt();
                pPacket.ReadInt();
            }

            {
                pPacket.ReadInt();
                for (int i = 3; i > 0; i--)
                {
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                }
            }


            for (int i = pPacket.ReadInt(); i > 0; i--)
                pPacket.ReadInt();

            if (pPacket.ReadBool())
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadLong();
                pPacket.ReadLong();
                pPacket.ReadLong();
            }

            for (int j = 0; j < 2; j++) // called 2 times under each other!
            {
                for (int i = pPacket.ReadByte(); i > 0; i--)
                {
                    pPacket.ReadByte();
                    pPacket.ReadInt();
                    pPacket.ReadByte();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadString();
                }
            }
#endif

#if LOCALE_EMS
            // REMOVED GMS V.141?!
            for (int i = pPacket.ReadInt(); i > 0; i--) // V.137
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt(); 
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
            }

            pPacket.ReadInt();
            for (int i = 6; i > 0; i--)
            {
                pPacket.ReadInt();
            }


            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
            }


            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadString();
            }


            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadString();
            }

#endif

            Inventory = new CharacterInventory();
            Inventory.Decode(pConnection, pPacket);

            //UnknownIntegerListNumber3 = new Dictionary<int, long>();
            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadLong();
                //UnknownIntegerListNumber3.Add(pPacket.ReadInt(), pPacket.ReadLong());
            }

            //UnknownIntegerListNumber4 = new Dictionary<long, long>();
            for (int i = pPacket.ReadInt(); i > 0; i--)
            {
                pPacket.ReadLong();
                pPacket.ReadLong();
                //UnknownIntegerListNumber4.Add(pPacket.ReadLong(), pPacket.ReadLong());
            }


            while (true)
            {
                byte val = pPacket.ReadByte();
                if (val == 0) break;

                {
                    pPacket.ReadInt();
                    pPacket.ReadByte();
                    pPacket.ReadByte();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadInt();
                    pPacket.ReadByte();
                    pPacket.ReadInt();
                    pPacket.ReadLong();
                    pPacket.ReadLong();
                    pPacket.ReadLong();
                    pPacket.ReadLong();
                }
            }


            Skills = new CharacterSkills();
            Skills.Decode(pConnection, pPacket);

            Quests = new CharacterQuests();
            Quests.Decode(pConnection, pPacket);


            // Match
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
            }


            {

                Rings = new List<Ring>();
                MarriedWith = null;

                // Couple
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    Rings.Add(new Ring(Ring.Type.Couple, pPacket));
                }

                // Friend
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    Rings.Add(new Ring(Ring.Type.Friend, pPacket));
                }

                // Marriage
                for (int i = pPacket.ReadShort(); i > 0; i--)
                {
                    Ring ring = new Ring(Ring.Type.Marriage, pPacket, Stats.Name);
                    Rings.Add(ring);

                    MarriedWith = ring.FriendName;
                }
            }


            Inventory.DecodeTeleportRocks(pPacket);

#if LOCALE_GMS
            Monsterbook = new CharacterMonsterBook();
            Monsterbook.Decode(pPacket);

            pPacket.ReadInt(); // -1?

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadShort();
            }

            {
                // Newyear cards... meh
                // WHAT MEH, SOMEONE HAS THIS FFS D:!!!

                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    pPacket.ReadInt(); // Card ID?
                    pPacket.ReadInt(); // Sender ID
                    pPacket.ReadString(); // Sender name
                    pPacket.ReadByte(); // GENDER..?
                    pPacket.ReadLong(); // Sent at?
                    pPacket.ReadInt(); // Receiver ID
                    pPacket.ReadString(); // Receiver name
                    pPacket.ReadByte();
                    pPacket.ReadByte();
                    pPacket.ReadLong(); // Receive date?
                    pPacket.ReadString(); // Message
                }
            }
#else
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.ReadShort();
                pPacket.ReadString();
            }
#endif

            Quests.DecodePQ(pConnection, pPacket);

            if (GameHelper.IsWildHunter(Stats.JobID))
            {
                pPacket.ReadByte(); // Level

                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt(); // Caught mob
            }

            Quests.DecodePQDone(pConnection, pPacket);

            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                short cnt = pPacket.ReadShort();
                int unk = pPacket.ReadInt(); // 9010040 | Conor (NPC)
                if (cnt > 0 && unk > 0)
                {
                    for (short j = 0; j < cnt; j++)
                    {
                        pPacket.ReadInt(); // 9010040 | Conor (NPC)
                        pPacket.ReadShort();
                        pPacket.ReadInt(); // 4330019 | Pink Coin Purse
                        pPacket.ReadShort();
                    }
                }
            }

            for (int i = 13; i > 0; i--)
            {
                pPacket.ReadInt(); // Stolen Skills
            }

            for (int i = 4; i > 0; i--)
            {
                pPacket.ReadInt(); // Chosen Skills?
            }

            // Inner Stats
            Abilities = new List<Tuple<byte, int, byte>>();
            for (int i = pPacket.ReadShort(); i > 0; i--)
            {
                byte id = pPacket.ReadByte(); // 'ID'
                int skillid = pPacket.ReadInt(); // Skill ID
                byte level = pPacket.ReadByte(); // Level
                pPacket.ReadByte(); // Rank
                Abilities.Add(new Tuple<byte, int, byte>(id, skillid, level));
            }

#if LOCALE_GMS
            {
                // V.134
                for (int i = pPacket.ReadInt(); i > 0; i--)
                {
                    pPacket.ReadString();

                    pPacket.ReadInt();
                    pPacket.ReadString();

                    for (int j = pPacket.ReadInt(); j > 0; j--)
                    {
                        pPacket.ReadByte();
                    }
                }

                pPacket.ReadByte();
            }
#endif

            Stats.HonourLevel = pPacket.ReadInt();
            Stats.HonourExp = pPacket.ReadInt();

            {
                byte unk = pPacket.ReadByte();
                if (unk == 1)
                {
                    while (true)
                    {
                        tmp = pPacket.ReadUShort();
                        if (tmp <= 0) break;

                        while (true)
                        {
                            ushort tmp2 = pPacket.ReadUShort();
                            if (tmp2 <= 0) break;

                            pPacket.ReadInt();
                            pPacket.ReadInt();
                        }
                    }
                }
                else
                {
                    while (true)
                    {
                        tmp = pPacket.ReadUShort();
                        if (tmp <= 0) break;

                        pPacket.ReadUShort();
                        pPacket.ReadInt();
                        pPacket.ReadInt();
                    }
                }
            }

            if (pPacket.ReadBool())
            {
                // Wat.
                ItemBase.DecodeItemData(pConnection, pPacket);
                pPacket.ReadInt();
            }


            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadByte();
            }


            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadLong();
            }

#if LOCALE_EMS
            pPacket.ReadBool();
            pPacket.ReadBool();
#endif
            {
                EvolutionCards = new List<EvolutionCard>();

                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    var card = new EvolutionCard();
                    card.Decode(pConnection, pPacket);
                    card.Block = 1;
                    EvolutionCards.Add(card);
                }

                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    var card = new EvolutionCard();
                    card.Decode(pConnection, pPacket);
                    card.Block = 2;
                    EvolutionCards.Add(card);
                }

            }

#if LOCALE_EMS
            if (pPacket.ReadBool())
            {
                // Wat.
                ItemBase.DecodeItemData(pConnection, pPacket);
                pPacket.ReadInt();
                pPacket.ReadInt();
            }
#endif

#if LOCALE_EMS
            // No farm info

            for (short i = pPacket.ReadShort(); i > 0; i--)
            {
                pPacket.Skip(20);
            }

#else
            {
                // V.134
                for (byte i = pPacket.ReadByte(); i > 0; i--)
                {
                    pPacket.ReadInt();
                    pPacket.ReadLong();
                }
            }

            {
                // V.134
                // FARM INFO. Creating... = not yet created farm. Else: farmname
                pPacket.ReadString(); // Creating...
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadByte();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();

                pPacket.ReadInt();
                pPacket.ReadInt();
            }

#if LOCALE_GMS
            if (pPacket.ReadBool())
            {
                // Wat.
                ItemBase.DecodeItemData(pConnection, pPacket);
                pPacket.ReadInt();
                pPacket.ReadInt();
            }
#endif

            {
                // V.141
                pPacket.ReadInt();
                pPacket.ReadLong(); // A bit off here, should be filetime value
                pPacket.ReadInt();
            }

            pPacket.Skip(84); // I don't even

            pPacket.ReadByte();

            {
                for (short i = pPacket.ReadShort(); i > 0; i--)
                {
                    pPacket.ReadShort();
                    pPacket.ReadShort();
                }
            }

            {
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();
                pPacket.ReadInt();

                pPacket.Skip(32);
            }

            {
                if (pPacket.ReadInt() > 0)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        pPacket.Skip(4 + 4 + 4);
                        pPacket.ReadString();
                        pPacket.Skip(4 * 7);
                        pPacket.Skip(8 * 4);
                        pPacket.Skip(4 * 4);
                        pPacket.Skip(1 * 5);
                        pPacket.Skip(4 * 3);
                        pPacket.ReadString();
                        pPacket.Skip(4 * 2);
                        pPacket.ReadByte();

                        byte tmptmp = pPacket.ReadByte();
                        if ((tmptmp & 0x01) != 0)
                        {
                            pPacket.ReadInt();
                            pPacket.ReadString();
                            pPacket.Skip(24);
                        }

                        for (int j = pPacket.ReadInt(); j > 0; j++)
                        {
                            pPacket.Skip(4 * 9);
                        }
                    }
                }
            }

            // Removed in V.141
            //pPacket.ReadInt(); // I DONT EVEN D:
#endif
        }
コード例 #27
0
ファイル: MESession.cs プロジェクト: diamondo25/mapler.me
        private void EndReceive(IAsyncResult pIAR)
        {
            if (_disconnected)
            {
                return;
            }
            try
            {
                int dataLength = 0;
                try
                {
                    dataLength = _socket.EndReceive(pIAR);

                    if (dataLength == 0)
                    {
                        throw new Exception();
                    }
                }
                catch (Exception)
                {
                    Logger.WriteLine("Internal Disconnection. EndReceive");
                    Disconnect();
                    return;
                }

                _receivePosition += dataLength;

                if (_receivePosition == _receiveLength)
                {
                    // Got packet.
                    if (_header)
                    {
                        // Get length
                        int newlen = BitConverter.ToInt32(_receiveBuffer, 0);
                        newlen += 4;
                        _header = false;
                        StartReceive(newlen, false);
                    }
                    else
                    {
                        int checksum = BitConverter.ToInt32(_receiveBuffer, 0);


                        byte[] realdata = new byte[_receiveLength - 4];
                        Buffer.BlockCopy(_receiveBuffer, 4, realdata, 0, realdata.Length);
                        if (_receiveKey != null)
                        {
                            realdata = Crypto.Decrypt(realdata, _receiveKey);
                        }

                        int curchecksum = realdata.CalculateChecksum();

                        if (checksum != curchecksum)
                        {
                            Logger.WriteLine("Invalid Checksum! {0} != {1}", checksum, curchecksum);
                        }
                        else
                        {
                            MaplePacket packet = new MaplePacket(realdata);
                            try
                            {
                                OnPacket(packet);
                            }
                            catch (Exception ex)
                            {
                                Logger.WriteLine("Internal Packet Handling Exception");
                                throw new Exception("Internal Packet Handling Exception", ex);
                            }
                        }

                        _header = true;
                        StartReceive(4, false);
                    }
                }
                else
                {
                    StartReceive(_receiveLength - _receivePosition, true);
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorLog("Error @ Packet Handling:\r\n {0}", ex.ToString());
                Disconnect();
            }
        }
コード例 #28
0
ファイル: MESession.cs プロジェクト: diamondo25/mapler.me
 public virtual void OnPacket(MaplePacket pPacket)
 {
 }
コード例 #29
0
        public void Decode(ClientConnection pConnection, MaplePacket pPacket)
        {
            InventorySlots = new byte[INVENTORIES];
            for (int i = 0; i < INVENTORIES; i++)
                InventorySlots[i] = pPacket.ReadByte();

            pPacket.ReadLong(); // 94354848000000000 | 1-1-1900



            EquipmentItems = new Dictionary<short, ItemEquip>[EQUIP_INVENTORIES];
#if LOCALE_EMS
            for (byte i = 0; i < 3; i++)
            {
                EquipmentItems[i] = new Dictionary<short, ItemEquip>();

                while (true)
                {
                    short slot = pPacket.ReadShort();
                    if (slot == 0) break;
                    slot = CharacterInventory.CorrectEquipSlot(i, slot);

                    ItemEquip equip = (ItemEquip)ItemBase.DecodeItemData(pConnection, pPacket);

                    EquipmentItems[i].Add(slot, equip);
                }
            }

            pPacket.ReadBool(); // EMS only -.-

            for (byte i = 3; i < EQUIP_INVENTORIES; i++)
            {
                EquipmentItems[i] = new Dictionary<short, ItemEquip>();

                while (true)
                {
                    short slot = pPacket.ReadShort();
                    if (slot == 0) break;
                    slot = CharacterInventory.CorrectEquipSlot(i, slot);

                    ItemEquip equip = (ItemEquip)ItemBase.DecodeItemData(pConnection, pPacket);

                    EquipmentItems[i].Add(slot, equip);
                }
            }
#else
            for (byte i = 0; i < EQUIP_INVENTORIES; i++)
            {
                EquipmentItems[i] = new Dictionary<short, ItemEquip>();

                while (true)
                {
                    short slot = pPacket.ReadShort();
                    if (slot == 0) break;
                    slot = CharacterInventory.CorrectEquipSlot(i, slot);

                    ItemEquip equip = (ItemEquip)ItemBase.DecodeItemData(pConnection, pPacket);

                    EquipmentItems[i].Add(slot, equip);
                }
            }
#endif

            InventoryItems = new Dictionary<byte, ItemBase>[NORMAL_INVENTORIES];
            BagItems = new Dictionary<int, BagItem>();

            for (byte i = 0; i < NORMAL_INVENTORIES; i++)
            {
                InventoryItems[i] = new Dictionary<byte, ItemBase>();

                while (true)
                {
                    byte slot = pPacket.ReadByte();
                    if (slot == 0) break;

                    ItemBase item = ItemBase.DecodeItemData(pConnection, pPacket);
                    InventoryItems[i].Add(slot, item);

                    if (item.BagID != -1)
                    {
                        // Update BagID... O.o
                        item.BagID = GameHelper.GetBagID(item.BagID, i);

                        BagItem bi = new BagItem(item);
                        BagItems.Add(item.BagID, bi);
                    }
                }
            }

            // Bagzzz
            for (int inv = 3; inv <= 4; inv++)
            {
                var bags = pPacket.ReadInt();
                for (int i = 0; i < bags; i++)
                {
                    int bagid = pPacket.ReadInt();

                    int bagitemid = pPacket.ReadInt();

                    BagItem bi = BagItems[GameHelper.GetBagID(bagid, inv - 2)]; // No addition to inv...!

                    while (true)
                    {
                        int slotid = pPacket.ReadInt();
                        if (slotid == -1) break;

                        ItemBase item = ItemBase.DecodeItemData(pConnection, pPacket);
                        bi.Items.Add((byte)slotid, item);
                    }
                }
            }
        }
コード例 #30
0
        public static void Initialize()
        {
            Instance = new CommandHandler()
            {
                CommandHandlers = new Dictionary<string,Action<ClientConnection, string[]>>()
            };

            Instance.CommandHandlers.Add("report", (pConnection, pArguments) =>
            {
                return; // Disabled


                if (pArguments.Length == 1)
                {
                    string name = pArguments[0];
                    if (name.Length > 12) return;

                    bool found = false;
                    string query = "SELECT name FROM character_views WHERE name LIKE '" + MySql.Data.MySqlClient.MySqlHelper.EscapeString(name) + "%' AND mapid = " + pConnection.CharData.Stats.MapID;
                    using (var result = MySQL_Connection.Instance.RunQuery(query) as MySql.Data.MySqlClient.MySqlDataReader)
                    {
                        if (result.HasRows && result.Read())
                        {
                            name = result.GetString(0);
                            found = true;
                        }
                        else
                        {
                            pConnection.Logger_WriteLine("Could not find {0} for {1}", name, pConnection.CharData.Stats.Name);
                        }
                    }

                    if (found)
                    {
                        using (InsertQueryBuilder iqb = new InsertQueryBuilder("reports"))
                        {
                            iqb.AddColumns(false, "id", "name", "reported_by", "reported_when", "mapid", "screenshot");
                            iqb.AddRow(null, name, pConnection.CharacterInternalID, new MySQL_Connection.NowType(), pConnection.CharData.Stats.MapID, null);

                            int result = (int)MySQL_Connection.Instance.RunQuery(iqb.ToString());
                            if (result != 0)
                            {
                                pConnection.Logger_WriteLine("Reported {0} (by {1}). Requesting Screenshot...", name, pConnection.CharData.Stats.Name);

                                using (MaplePacket pack = new MaplePacket(MaplePacket.CommunicationType.ServerPacket, (ushort)0xEEFE))
                                {
                                    pack.WriteString("http://mapler.me/actions/upload_report.php");
                                    pack.WriteInt(MySQL_Connection.Instance.GetLastInsertId());
                                    pack.SwitchOver();
                                    pConnection.SendPacket(pack);
                                }
                            }
                            else
                            {
                                pConnection.Logger_WriteLine("Report FAIL {0} (by {1})", name, pConnection.CharData.Stats.Name);
                            }
                        }

                    }
                }
            });
        }
コード例 #31
0
ファイル: Program.cs プロジェクト: diamondo25/mapler.me
        static void StartPinger()
        {
            _timert = new System.Threading.Timer((obj) =>
            {
                MasterThread.Instance.AddCallback(a =>
                {
                    var tmp = new List<ClientConnection>(Clients);
                    foreach (var client in tmp)
                    {
                        if (!client.Pong)
                        {
                            client.Logger_WriteLine("Connection Timeout");
                            client.Disconnect();
                        }
                        else
                        {
                            client.Pong = false;
                            using (MaplePacket mp = new MaplePacket(MaplePacket.CommunicationType.ServerPacket, 0xEE01))
                            {
                                client.SendPacket(mp);
                            }
                        }
                    }
                });

            }, null, 0, 20000);
        }
コード例 #32
0
ファイル: Program.cs プロジェクト: diamondo25/mapler.me
        static void Main(string[] args)
        {
            AppDomain currentDomain = AppDomain.CurrentDomain;
            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnexpectedExHandler);
            Console.CancelKeyPress += Console_CancelKeyPress;

            Logger.SetLogfile(false);

            MasterThread.Load("MPLRServer");

            try
            {
                MySQL_Connection.Initialize();
            }
            catch
            {
                Environment.Exit(12);
            }

            AccountDataCache.Initialize();
#if LOCALE_GMS
            GMSKeys.Initialize();
#endif

            CommandHandler.Initialize();
            Timeline.Init();

            Random = new System.Random();
            {
                InitializeValidHeaders();
                AcceptedIPs = new List<string>();
#if LOCALE_GMS
                AcceptedIPs.Add("8.31.9"); // GMS
#elif LOCALE_EMS
                AcceptedIPs.Add("109.234.77"); // EMS
#endif

                Clients = new List<ClientConnection>();
                StartPinger();
                StartCharacterDeleteQueue();
            }

            EXPTable.Load();

            SessionRestartCache.Start();

            // For clients
            Acceptor accept = new Acceptor(ServerMapleInfo.MAPLER_PORT, sock =>
            {
                new ClientConnection(sock);
            });

            // For online check!
            byte[] OnlineCheckInfo = null;
            {
                MaplePacket packet = new MaplePacket(ServerMapleInfo.VERSION);
                packet.WriteByte(ServerMapleInfo.LOCALE);

                byte[] temp = packet.ToArray();

                OnlineCheckInfo = new byte[temp.Length + 1];
                Buffer.BlockCopy(temp, 0, OnlineCheckInfo, 1, temp.Length);
                OnlineCheckInfo[0] = (byte)(temp.Length + 4);

                packet.Dispose();
                packet = null;
            }
            Acceptor acceptCheck = new Acceptor(ServerMapleInfo.MAPLER_PORT_SERVER_INFO, sock =>
            {
                sock.Send(OnlineCheckInfo);
                sock.Send(BitConverter.GetBytes(Clients.Count));
                sock.Shutdown(System.Net.Sockets.SocketShutdown.Both);
                sock.Close();
            });


            Logger.WriteLine("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
            Logger.WriteLine("|                                             |");
            Logger.WriteLine("|              Mapler.me Server               |");
            Logger.WriteLine("|                                             |");
#if LOCALE_GMS
            Logger.WriteLine("|                   GLOBAL                    |");
#elif LOCALE_EMS
            Logger.WriteLine("|                   EUROPE                    |");
#elif LOCALE_KMS
            Logger.WriteLine("|                   KOREA                     |");
#endif
            Logger.WriteLine("|                                             |");
            Logger.WriteLine("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
            Logger.WriteLine("|           Build For: {0,3} Locale {1,1}           |", ServerMapleInfo.VERSION, ServerMapleInfo.LOCALE);
            Logger.WriteLine("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+");
            Logger.WriteLine("Accepting connections on {0}, and info requests on {1}", ServerMapleInfo.MAPLER_PORT, ServerMapleInfo.MAPLER_PORT_SERVER_INFO);


            while (true)
            {
                string cmd = Console.ReadLine();
                if (cmd == null) break; // CTRL + C
                string[] arguments = cmd.Split(' ');
                if (arguments.Length >= 1)
                {
                    switch (arguments[0])
                    {
#if LOCALE_GMS
                        case "getkeys":
                            {
                                GMSKeys.Initialize();
                                break;
                            }
#endif
                        case "reload_store":
                            {
                                MasterThread.Instance.AddCallback(a =>
                                {
                                    AccountDataCache.Instance.Load();
                                });

                                break;
                            }
                        case "request_screenshots":
                            {
                                MasterThread.Instance.AddCallback(a =>
                                {
                                    var tmp = new List<ClientConnection>(Clients);
                                    foreach (var client in tmp)
                                    {
                                        using (MaplePacket pack = new MaplePacket(MaplePacket.CommunicationType.ServerPacket, 0xEEFE))
                                        {
                                            pack.SwitchOver();
                                            client.SendPacket(pack);
                                        }
                                    }
                                });

                                break;
                            }
                        case "testsession":
                            {
                                int accountid = arguments.Length > 1 ? Int32.Parse(arguments[1]) : -1;
                                bool raw = arguments.Length > 2;
                                var verp = new MSBLoader();
                                var connection = new ClientConnection(verp);
                                connection.AccountID = accountid;
                                verp.Parse("Savefile.msb", raw);

                                break;
                            }
                        case "players":
                            {
                                string names = string.Join(", ", Clients);
                                Console.WriteLine("Players online:\r\n{0}", names);
                                break;
                            }
                        case "close":
                        case "stop":
                        case "exit":
                            {

                                MasterThread.Instance.AddCallback(a =>
                                {
                                    var tmp = new List<ClientConnection>(Clients);
                                    foreach (var client in tmp)
                                    {
                                        // client.Save(true, true);
                                        client.Disconnect();
                                    }

                                    MySQL_Connection.Instance.Stop = true;
                                    MasterThread.Instance.Stop = true;
                                });
                                break;
                            }
                        default:
                            Console.WriteLine("Command not found");
                            break;
                    }
                }
            }
        }
コード例 #33
0
 public void DecodePQ(ClientConnection pConnection, MaplePacket pPacket)
 {
     PartyQuestsRunning = new Dictionary<ushort, string>();
     for (int i = pPacket.ReadShort(); i > 0; i--)
     {
         ushort id = pPacket.ReadUShort();
         string value = pPacket.ReadString();
         if (!PartyQuestsRunning.ContainsKey(id))
             PartyQuestsRunning.Add(id, value);
         else
             pConnection.Logger_WriteLine("Duplicate PQ (Running): {0}", id);
     }
 }