Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
 public static OutPacket AddNewCharEntry(MapleCharacter chr, bool worked)
 {
     using (var packet = new OutPacket(SendOpcodes.AddNewCharEntry))
     {
         packet.WriteBool(!worked);
         AddCharEntry(packet, chr);
         return(packet);
     }
 }
Exemplo n.º 4
0
 public static OutPacket CharNameResponse(string name, bool nameUsed)
 {
     using (var packet = new OutPacket(SendOpcodes.CharNameResponse))
     {
         packet.WriteMapleString(name);
         packet.WriteBool(nameUsed);
         return(packet);
     }
 }
Exemplo n.º 5
0
        public OutPacket GetControlCancelPacket()
        {
            OutPacket oPacket = new OutPacket(SendOps.NpcChangeController);

            oPacket
            .WriteBool()
            .WriteInt(this.ObjectID);

            return(oPacket);
        }
Exemplo n.º 6
0
        /* NetCafe
         * 會員於特約網咖連線
         */
        public static void Login_Ack(Client c, ServerState.LoginState state, short encryptKey = 0, bool netCafe = false)
        {
            using (var plew = new OutPacket(LoginServerOpcode.LOGIN_ACK))
            {
                plew.WriteByte((byte)state);
                plew.WriteBool(netCafe);
                plew.WriteShort(encryptKey);

                c.Send(plew);
            }
        }
Exemplo n.º 7
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);
            }
        }
Exemplo n.º 8
0
        public List <byte[]> GetCharacters(int accountId, byte worldId, bool fromViewAll)
        {
            using (OutPacket outPacket = new OutPacket(InteroperabilityMessage.CharacterEntriesRequest))
            {
                outPacket.WriteInt(accountId);
                outPacket.WriteByte(worldId);
                outPacket.WriteBool(fromViewAll);

                this.RandomChannel.Send(outPacket);
            }

            return(this.CharacterListPool.Dequeue(accountId));
        }
Exemplo n.º 9
0
        public byte[] CreateCharacter(int accountId, byte worldId, bool isMaster, byte[] data)
        {
            using (OutPacket outPacket = new OutPacket(InteroperabilityMessage.CharacterCreationRequest))
            {
                outPacket.WriteInt(accountId);
                outPacket.WriteByte(worldId);
                outPacket.WriteBool(isMaster);
                outPacket.WriteBytes(data);

                this.RandomChannel.Send(outPacket);
            }

            return(this.CharacterCreationPool.Dequeue(accountId));
        }
Exemplo n.º 10
0
        public void Migrate(bool valid, short port)
        {
            using (OutPacket oPacket = new OutPacket(SendOps.MigrateCommand))
            {
                oPacket
                .WriteBool(valid)
                .WriteBytes(new byte[4] {
                    127, 0, 0, 1
                })
                .WriteShort(port);

                this.Send(oPacket);
            }
        }
Exemplo n.º 11
0
        public void Notify(string message, NoticeType type = NoticeType.Pink)
        {
            using (OutPacket oPacket = new OutPacket(SendOps.BroadcastMsg))
            {
                oPacket.WriteByte((byte)type);

                if (type == NoticeType.Ticker)
                {
                    oPacket.WriteBool(!string.IsNullOrEmpty(message));
                }

                oPacket.WriteMapleString(message);

                this.Client.Send(oPacket);
            }
        }
Exemplo n.º 12
0
 public static OutPacket AuthSuccess(string username, int accountId, bool gender)
 {
     using (var packet = new OutPacket(SendOpcodes.LoginStatus))
     {
         packet.WriteByte(0x00);
         packet.WriteInt(accountId);
         packet.WriteBool(gender);
         packet.WriteShort(0);
         packet.WriteMapleString(username);
         packet.WriteBytes(new byte[]
                           { 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00, 0xE2, 0xED, 0xA3, 0x7A, 0xFA, 0xC9, 0x01 });
         packet.WriteInt(0);
         packet.WriteLong(0);
         packet.WriteMapleString(accountId.ToString());
         packet.WriteMapleString(username);
         packet.WriteByte(0x01);
         return(packet);
     }
 }
Exemplo n.º 13
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);
            }
        }
Exemplo n.º 14
0
        private OutPacket GetInternalPacket(bool requestControl)
        {
            OutPacket oPacket = new OutPacket(requestControl ? SendOps.NpcChangeController : SendOps.NpcEnterField);

            if (requestControl)
            {
                oPacket.WriteBool(true);
            }

            oPacket
            .WriteInt(this.ObjectID)
            .WriteInt(this.MapleID)
            .WritePoint(this.Position)
            .WriteBool(!this.Spawn.Flip)
            .WriteShort(this.Spawn.Foothold)
            .WriteShort(this.Spawn.MinimumClickX)
            .WriteShort(this.Spawn.MaximumClickX)
            .WriteBool(!this.Spawn.Hide);

            return(oPacket);
        }
Exemplo n.º 15
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);
            }
        }
Exemplo n.º 16
0
        public static void AddCharStats(OutPacket p, MapleCharacter chr)
        {
            p.WriteInt(chr.Id); // character id
            p.WriteString(chr.Name);
            // 填充名字字符
            // p.WriteZero(13 - Encoding.Default.GetByteCount(chr.CharacterName));
            for (var x = Encoding.Default.GetByteCount(chr.Name); x < 13; x++)
            {
                // fill to maximum name length
                p.WriteByte(0);
            }

            p.WriteBool(chr.Gender);       // gender (0 = male, 1 = female)
            p.WriteByte(chr.Skin.ColorId); // skin color
            p.WriteInt(chr.Face);          // face
            p.WriteInt(chr.Hair);          // hair
            p.WriteLong(0);
            p.WriteLong(0);
            p.WriteLong(0);
            p.WriteByte(chr.Level);        // level
            p.WriteShort(chr.Job.JobId);   // job
            p.WriteShort(chr.Str);         // str
            p.WriteShort(chr.Dex);         // dex
            p.WriteShort(chr.Int);         // int
            p.WriteShort(chr.Luk);         // luk
            p.WriteShort(chr.Hp);          // hp (?)
            p.WriteShort(chr.MaxHp);       // maxhp
            p.WriteShort(chr.Mp);          // mp (?)
            p.WriteShort(chr.MaxMp);       // maxmp
            p.WriteShort(chr.RemainingAp); // remaining ap
            p.WriteShort(chr.RemainingSp); // remaining sp
            p.WriteInt(chr.Exp.Value);     // current exp
            p.WriteShort(chr.Fame);        // fame
            p.WriteInt(0);
            p.WriteLong(DateUtiliy.GetFileTimestamp(DateTime.Now.GetTimeMilliseconds()));
            p.WriteInt(chr.Map?.MapId ?? 10000); // current map id
            p.WriteByte(chr.InitialSpawnPoint);  // spawnpoint
        }
Exemplo n.º 17
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);
                }
            }
        }
Exemplo n.º 18
0
        public void OnRoomList(ClientSession cs, InPacket ip)
        {
            byte RoomType = ip.ReadByte();

            //LogFactory.GetLog("Main").LogInfo("RoomTYPE: " + RoomType);

            // 그 뒤로
            // FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00
            // 어딘가에 페이지가 있겠다.

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_ROOM_LIST_ACK))
            {
                int roomcount = 0;//default is 0
                //LogFactory.GetLog("Main").LogInfo("HUEHUE ROOMS Count: " + roomcount);
                foreach (Room room in RoomsList)
                {
                    // 대기방만 보여주는 것이라면...
                    if (RoomType == 1)
                    {
                        // 게임시작이거나, 남는자리가 없다면 생략
                        if (room.Playing == true || room.GetFreeSlot() == 0)
                        {
                            continue;
                        }
                    }
                    roomcount++;
                }
                oPacket.WriteInt(roomcount);
                for (int j = 0; j < roomcount; j++)
                {
                    /*ushort roomid = 38;//00 26
                    *  string nameRoom = "test";
                    *  string passRoom = "";//01
                    *  ushort fresslots = 4;
                    *  ushort players = 1;
                    *  bool playing = false;
                    *  string nick = "[ADM]Hiro";*/

                    //Room room = new Room();

                    /*
                     * oPacket.WriteUShort(1);//00 26
                     * oPacket.WriteInt("Vamos jogar!".Length * 2);//00 00 00 0C
                     * oPacket.WriteUnicodeString("Vamos jogar!");//68 BE AC B9 68 BE AC B9 21 00 21 00
                     * oPacket.WriteByte(1);
                     * oPacket.WriteByte(0);//00
                     * oPacket.WriteInt("".Length * 2);//00 00 00 00
                     * oPacket.WriteUnicodeString("");
                     * oPacket.WriteUShort(4);//00 04
                     * oPacket.WriteUShort(1);//00 01
                     * oPacket.WriteBool(false);//00
                     * oPacket.WriteHexString("28 5C DA F2 02 02 00 00 00 08 32 25 A5 77 00 00 00 03 00 00 00 00 00 00 00 01");
                     * oPacket.WriteInt("[ADM]SkelletonX".Length * 2);
                     * oPacket.WriteUnicodeString("[ADM]SkelletonX");
                     * oPacket.WriteHexString("02 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 04 5A 00 5A 00 01");
                     */
                    foreach (Room room in RoomsList)
                    {
                        ushort roomid    = room.ID;       //00 26
                        string nameRoom  = room.RoomName;
                        string passRoom  = room.RoomPass; //01
                        ushort fresslots = 4;
                        ushort players   = (ushort)room.GetPlayerCount();
                        bool   playing   = room.Playing;
                        string nick      = room.GetRoomLeaderCS().Nick;

                        //LogFactory.GetLog("Main").LogInfo("roomID: " + roomid);
                        //LogFactory.GetLog("Main").LogInfo("Name Room: " + nameRoom);
                        //LogFactory.GetLog("Main").LogInfo("Pass Room: " + passRoom);
                        //LogFactory.GetLog("Main").LogInfo("Slots: " + fresslots);
                        //LogFactory.GetLog("Main").LogInfo("players: " + players);
                        //LogFactory.GetLog("Main").LogInfo("Playing: " + playing);

                        if (RoomType == 1)
                        {
                            if (room.Playing == true || room.GetFreeSlot() == 0)
                            {
                                continue;
                            }
                        }
                        oPacket.WriteUShort(roomid);           //00 26
                        oPacket.WriteInt(nameRoom.Length * 2); //00 00 00 0C
                        oPacket.WriteUnicodeString(nameRoom);  //68 BE AC B9 68 BE AC B9 21 00 21 00
                        if (passRoom.Length > 0)               //01
                        {
                            oPacket.WriteByte(0);
                        }
                        else
                        {
                            oPacket.WriteByte(1);
                        }
                        oPacket.WriteByte(0);                  //00
                        oPacket.WriteInt(passRoom.Length * 2); //00 00 00 00
                        oPacket.WriteUnicodeString(passRoom);
                        oPacket.WriteUShort(fresslots);        //00 04
                        oPacket.WriteUShort(players);          //00 01
                        oPacket.WriteBool(playing);            //00
                        oPacket.WriteHexString("28 5C DA F2 02 02 00 00 00 08 32 25 A5 77 00 00 00 03 00 00 00 00 00 00 00 01");
                        oPacket.WriteInt(nick.Length * 2);
                        oPacket.WriteUnicodeString(nick);
                        oPacket.WriteHexString("02 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 04 5A 00 5A 00 01");
                    }
                }
                //}

                /* 방 정보 조합
                 * foreach (Room room in RoomsList)
                 * {
                 *  // 대기방만 보여주는 것이라면...
                 *  if( RoomType == 1 )
                 *  {
                 *      // 게임시작이거나, 남는자리가 없다면 생략
                 *      if (room.Playing == true || room.GetFreeSlot() == 0)
                 *          continue;
                 *  }
                 *
                 *  oPacket.WriteUShort(1);
                 *  oPacket.WriteInt("kkk".Length * 2);
                 *  oPacket.WriteUnicodeString("kkk");
                 *
                 *  if (room.RoomPass.Length > 0)
                 *      oPacket.WriteByte(0); // 비밀방
                 *  else
                 *      oPacket.WriteByte(1); // 공개방
                 *  oPacket.WriteByte(0);
                 *  oPacket.WriteInt("hue".Length * 2);
                 *  oPacket.WriteUnicodeString("hue");
                 *  //LogFactory.GetLog("Main").LogInfo("PasswdRoom: " + room.RoomPass);
                 *
                 *  // 빈자리 + 유저수 = 총 자리 개수
                 *  oPacket.WriteShort(3 + 1);
                 *  //LogFactory.GetLog("Main").LogInfo(3);
                 *  oPacket.WriteShort(1);
                 *  //LogFactory.GetLog("Main").LogInfo(1);
                 *  oPacket.WriteBool(false);
                 *  //LogFactory.GetLog("Main").LogInfo("Playing: " + room.Playing);
                 *
                 *  oPacket.WriteHexString("2E 02 1B 25 01 00 00 00 00 01 6B F9 38 77 00 00 00 0C 00 00 00 00 00 00 00 01");
                 *
                 *  oPacket.WriteInt("[ADM]SkelletonX".Length * 2);
                 *  //LogFactory.GetLog("Main").LogInfo("LEADER NICK: " + room.GetRoomLeaderCS().Nick);
                 *  oPacket.WriteUnicodeString("[ADM]SkelletonX");
                 *
                 *  oPacket.WriteHexString("0B 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01");
                 * }*/

                // 여태껏 조합된 방 정보를 압축한다.
                int RoomInfoSize = oPacket.ToArray().Length; // 압축하기 전 사이즈
                oPacket.CompressBuffer();
                byte[] RoomInfo = oPacket.getBuffer();

                oPacket.InitBuffer(); // 초기화

                // 실제 패킷 작성
                oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 01");
                oPacket.WriteInt(4 + RoomInfo.Length);                   // 압축된 정보크기 + 4(실제 크기버퍼)
                oPacket.WriteByte(1);                                    // 압축된 데이터다.
                oPacket.WriteBytes(BitConverter.GetBytes(RoomInfoSize)); // 압축전 사이즈를 일반적으로 넣는다.
                oPacket.WriteBytes(RoomInfo);                            // 압축된 방 정보

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(oPacket);
                //LogFactory.GetLog("Main").LogHex("ROOMLIST: ", oPacket.getBuffer());
            }
        }
Exemplo n.º 19
0
        public void OnJoinRoom(ClientSession cs, InPacket ip)
        {
            ip.ReadByte(); // 0
            ip.ReadByte(); // 0
            ip.ReadByte(); // 0
            ip.ReadByte(); // 0
            ushort RoomID  = ip.ReadUShort();
            int    PassLen = ip.ReadInt();
            string Pass    = "";

            if (PassLen > 0)
            {
                Pass = ip.ReadUnicodeString(PassLen);
            }
            //LogFactory.GetLog("ROOM INFO:").LogInfo("ROOM ID: "+RoomID);
            //LogFactory.GetLog("ROOM INFO:").LogInfo("ROOM Length Password: "******"ROOM INFO:").LogInfo("ROOM Password: "******"Main").LogInfo(" Sergio Dean {0} metade Kana {1} {2} uma determinada ranhura ({3}, {4})", Team1, Team2, pos, EmptyPos1, EmptyPos2);

            // 방 슬롯에 정보 입력
            room.Slot[pos].Active = true;
            room.Slot[pos].cs     = cs;
            room.Slot[pos].Open   = false;
            room.Slot[pos].Spree  = 0;
            room.Slot[pos].Leader = false;
            room.Slot[pos].AFK    = false;

            // 유저한테 방 입력
            cs.CurrentRoom = room;

            // 방에 있는 사람들한테 입장했다고 알려준다. (입장하는놈은 제외)
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_JOIN_ROOM_BROAD))
            {
                oPacket.WriteInt(cs.Login.Length * 2);
                oPacket.WriteUnicodeString(cs.Login);
                oPacket.WriteInt(cs.LoginUID);
                oPacket.WriteInt(cs.Nick.Length * 2);
                oPacket.WriteUnicodeString(cs.Nick);
                oPacket.WriteInt(pos);
                oPacket.WriteByte((byte)cs.CurrentChar);
                oPacket.WriteHexString("00 FF 00 FF 00 FF 00 00 00 00");
                oPacket.WriteByte((byte)(pos / 3)); // 팀을 구하면 됨. 빠르게 처리하기 위해서
                oPacket.WriteHexString("01 00 00 00 0D 00 00 00 00 10 F4 00 00 00 00 00 4E 00 00 00 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 19 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5F 00 00 00 00 00 00 00 00 00 00 00");
                if (room.GetRoomLeaderCS() == cs)
                {
                    oPacket.WriteByte(1);
                }
                else
                {
                    oPacket.WriteByte(0);
                }
                oPacket.WriteHexString("01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");

                oPacket.WriteByte((byte)cs.MyCharacter.MyChar.Length);
                for (int i = 0; i < cs.MyCharacter.MyChar.Length; i++)
                {
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].CharType);
                    //LogFactory.GetLog("ROOM INFO:").LogInfo("ROOM Chartype: " + cs.MyCharacter.MyChar[i].CharType);
                    oPacket.WriteInt(0);
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].Promotion);
                    //LogFactory.GetLog("ROOM INFO:").LogInfo("ROOM Chartype: " + cs.MyCharacter.MyChar[i].Promotion);
                    oPacket.WriteInt(0);
                    oPacket.WriteByte(0);
                    oPacket.WriteInt(cs.MyCharacter.MyChar[i].Exp);
                    //LogFactory.GetLog("ROOM INFO:").LogInfo("ROOM Chartype: " + cs.MyCharacter.MyChar[i].Exp);
                    oPacket.WriteByte(0);
                    oPacket.WriteByte(0);
                    oPacket.WriteByte(0);
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].Level);
                    //LogFactory.GetLog("ROOM INFO:").LogInfo("ROOM Chartype: " + cs.MyCharacter.MyChar[i].Level);
                    oPacket.WriteInt(0);
                    oPacket.WriteInt(0);

                    oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip.Length);
                    for (int j = 0; j < cs.MyCharacter.MyChar[i].Equip.Length; j++)
                    {
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemID);
                        oPacket.WriteInt(1);
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemUID);
                        oPacket.WriteInt(0);
                        oPacket.WriteInt(0);
                        oPacket.WriteInt(0);
                        oPacket.WriteInt(0);
                        oPacket.WriteByte(0);
                        oPacket.WriteByte(0);
                        oPacket.WriteByte(0);
                    }

                    //oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 01 00 00 00 00 00 00 00 00 02 00 00 00 A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 01 FF 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 2C 00 00 01 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07");
                    // 이 패킷이 아래 끝까지 분리됐음. ▼▼
                    oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 01 00");

                    // 장착한 스킬

                    /*
                     * oPacket.WriteInt(cs.MyCharacter.MyChar[i].EquipSkill.Length);
                     * for (int j = 0; j < cs.MyCharacter.MyChar[i].EquipSkill.Length; j++)
                     * {
                     *  oPacket.WriteInt(0);
                     *  oPacket.WriteInt(cs.MyCharacter.MyChar[i].EquipSkill[j].SkillGroup);
                     *  oPacket.WriteInt(cs.MyCharacter.MyChar[i].EquipSkill[j].SkillID);
                     * }*/
                    oPacket.WriteInt(0);

                    // FF가 스킬포인트일지도
                    oPacket.WriteHexString("00 00 00 FF 00 00 00 A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 FF 00 00 00 00 00 00");

                    // 배운 스킬

                    /*oPacket.WriteInt(cs.MyCharacter.MyChar[i].MySkill.Length);
                     * for (int j = 0; j < cs.MyCharacter.MyChar[i].MySkill.Length; j++)
                     * {
                     *  oPacket.WriteInt(cs.MyCharacter.MyChar[i].MySkill[j].SkillID);
                     * }*/
                    oPacket.WriteInt(0);

                    oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 2C 00 00 01 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07");
                    // ▲▲
                }
                oPacket.WriteHexString("00 00 00 04 13 00 A8 C0 01 EC A8 C0 9B BA FE A9");
                oPacket.WriteIPFromString(cs.GetIP(), false);
                oPacket.WriteHexString("00 00 00 01 7E F6 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 E5 6A 00 00 00 01 2C BD 52 5A 00 00 00 00 01 00 00 E5 88 00 00 00 01 2C BD 52 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 56 86 32 00 56 87 6E D4 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");

                // 방에 있는 모든 유저에게 전송해야함.
                for (int i = 0; i < 6; i++)
                {
                    // 나 자신은 제외한 나머지한테 전송
                    if (room.Slot[i].Active == true && room.Slot[i].cs != cs)
                    {
                        oPacket.Assemble(room.Slot[i].cs.CRYPT_KEY, room.Slot[i].cs.CRYPT_HMAC, room.Slot[i].cs.CRYPT_PREFIX, room.Slot[i].cs.CRYPT_COUNT);
                        room.Slot[i].cs.Send(oPacket); // 패킷 보내고
                        oPacket.CancelAssemble();      // 다시 패킷 복구
                    }
                }
            }

            // 방에 접속했다고 알려준다.
            using (OutPacket op = new OutPacket(GameOpcodes.EVENT_JOIN_ROOM_INFO_ACK))
            {
                op.WriteUShort(RoomID);
                op.WriteInt(room.RoomName.Length * 2);
                op.WriteUnicodeString(room.RoomName);
                op.WriteByte(0);
                if (room.RoomPass.Length > 0)
                {
                    op.WriteByte(1); // 비밀방
                }
                else
                {
                    op.WriteByte(0); // 공개방
                }
                op.WriteInt(room.RoomPass.Length * 2);
                op.WriteUnicodeString(room.RoomPass);
                op.WriteShort((short)room.GetPlayerCount());
                op.WriteShort((short)room.GetFreeSlot());
                op.WriteHexString("00 0B");
                op.WriteByte((byte)room.GameCategory);
                op.WriteInt(room.GameMode);
                op.WriteInt(room.ItemMode);
                op.WriteBool(room.RandomMap);
                op.WriteInt(room.GameMap);
                op.WriteHexString("00 00 00 0C");
                for (int i = 0; i < 6; i++)
                {
                    op.WriteBool(room.Slot[i].Open);
                }
                op.WriteHexString("FF FF FF FF 00 00 00 00 00 00 00 00 01");
                op.WriteIPFromString(Server.UDPRelayIP, true);
                op.WriteShort(Server.UDPRelayPort);
                op.WriteIPFromString(Server.TCPRelayIP, true);
                op.WriteShort(Server.TCPRelayPort);

                op.WriteHexString("01 00 01 00 00 01 2C 00 00 00 14 00 02 4B 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 01 00 00 00 00");

                op.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(op);
            }

            room.SendJoinRoomInfoDivide(cs);
            //return;

            // 방에 입장할 수 없다.
cantjoin:
            using (OutPacket op = new OutPacket(GameOpcodes.EVENT_JOIN_ROOM_INFO_DIVIDE_ACK))
            {
                op.WriteInt(6);
                op.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 30 00 00 00 F9 00 00 09 0D 00 00 00 00 00 00 00 00 F2 04 00 00 00 00 00 00 13 49 F4 FC 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 09 13 F2 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");

                op.CompressAndAssemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(op);
            }
            //return;
        }
Exemplo n.º 20
0
        public void OnRoomList2(ClientSession cs, InPacket ip)
        {
            byte RoomType = ip.ReadByte(); // 1 = 대기방보기, 0 = 모든방보기

            //LogFactory.GetLog("Main").LogInfo("RoomTYPE: " + RoomType);

            // 그 뒤로
            // FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00
            // 어딘가에 페이지가 있겠다.

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_ROOM_LIST_ACK))
            {
                // 방 정보를 조합한 다음에 압축하고, 실제 패킷을 작성한다.

                // 방 개수 구하기
                int roomcount = 0;

                //LogFactory.GetLog("Main").LogInfo("ROOMS Count: " + roomcount);

                foreach (Room room in RoomsList)
                {
                    //LogFactory.GetLog("Main").LogInfo("PasswdRoom: " + room.RoomPass);
                    //LogFactory.GetLog("Main").LogInfo("Slots: " + room.GetFreeSlot());
                    //LogFactory.GetLog("Main").LogInfo("Players: " + room.GetPlayerCount());
                    //LogFactory.GetLog("Main").LogInfo("Playing: " + room.Playing);
                    // 대기방만 보여주는 것이라면...
                    if (RoomType == 1)
                    {
                        // 게임시작이거나, 남는자리가 없다면 생략
                        if (room.Playing == true || room.GetFreeSlot() == 0)
                        {
                            continue;
                        }
                    }
                    roomcount++;
                    //LogFactory.GetLog("Main").LogInfo("Rooms: " + roomcount);
                }
                oPacket.WriteInt(roomcount);

                // 방 정보 조합
                foreach (Room room in RoomsList)
                {
                    // 대기방만 보여주는 것이라면...

                    /*if (RoomType == 1)
                     * {
                     *  // 게임시작이거나, 남는자리가 없다면 생략
                     *  if (room.Playing == true || room.GetFreeSlot() == 0)
                     *      continue;
                     * }
                     */
                    oPacket.WriteUShort(room.ID);
                    oPacket.WriteInt(room.RoomName.Length * 2);
                    oPacket.WriteUnicodeString(room.RoomName);

                    if (room.RoomPass.Length > 0)
                    {
                        oPacket.WriteByte(0); // 비밀방
                    }
                    else
                    {
                        oPacket.WriteByte(1); // 공개방
                    }
                    oPacket.WriteByte(0);
                    oPacket.WriteInt(room.RoomPass.Length * 2);
                    oPacket.WriteUnicodeString(room.RoomPass);
                    //LogFactory.GetLog("Main").LogInfo("PasswdRoom: " + room.RoomPass);

                    // 빈자리 + 유저수 = 총 자리 개수
                    oPacket.WriteShort((short)(room.GetFreeSlot() + room.GetPlayerCount()));
                    //LogFactory.GetLog("Main").LogInfo("Slots: " + room.GetFreeSlot());
                    oPacket.WriteShort((short)room.GetPlayerCount());
                    //LogFactory.GetLog("Main").LogInfo("Players: " + room.GetPlayerCount());
                    oPacket.WriteBool(room.Playing);
                    //LogFactory.GetLog("Main").LogInfo("Playing: " + room.Playing);

                    oPacket.WriteHexString("2E 02 1B 25 01 00 00 00 00 01 6B F9 38 77 00 00 00 0C 00 00 00 00 00 00 00 01");

                    oPacket.WriteInt(room.GetRoomLeaderCS().Nick.Length * 2);
                    //LogFactory.GetLog("Main").LogInfo("LEADER NICK: " + room.GetRoomLeaderCS().Nick);
                    oPacket.WriteUnicodeString(room.GetRoomLeaderCS().Nick);

                    oPacket.WriteHexString("0B 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01");
                }

                // 여태껏 조합된 방 정보를 압축한다.
                int RoomInfoSize = oPacket.ToArray().Length; // 압축하기 전 사이즈
                oPacket.CompressBuffer();
                byte[] RoomInfo = oPacket.getBuffer();

                oPacket.InitBuffer(); // 초기화

                // 실제 패킷 작성
                oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 01");
                oPacket.WriteInt(4 + RoomInfo.Length);                   // 압축된 정보크기 + 4(실제 크기버퍼)
                oPacket.WriteByte(1);                                    // 압축된 데이터다.
                oPacket.WriteBytes(BitConverter.GetBytes(RoomInfoSize)); // 압축전 사이즈를 일반적으로 넣는다.
                oPacket.WriteBytes(RoomInfo);                            // 압축된 방 정보

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(oPacket);
                //LogFactory.GetLog("Main").LogHex("ROOMLIST: ", oPacket.getBuffer());
            }
        }
Exemplo n.º 21
0
        public void OnJoinRoom(ClientSession cs, InPacket ip)
        {
            ip.ReadByte(); // 0
            ip.ReadByte(); // 0
            ip.ReadByte(); // 0
            ushort RoomID  = ip.ReadUShort();
            int    PassLen = ip.ReadInt();
            string Pass    = "";

            if (PassLen > 0)
            {
                Pass = ip.ReadUnicodeString(PassLen);
            }


            Room room = GetRoom(RoomID);


            if (room == null)
            {
                goto cantjoin;
            }


            if (room.GetFreeSlot() == 0 || room.Playing == true || cs.CurrentRoom != null)
            {
                goto cantjoin;
            }


            if (room.RoomPass != Pass)
            {
                goto cantjoin;
            }


            byte Team1 = 0, Team2 = 0;
            int  EmptyPos1 = -1, EmptyPos2 = -1;

            for (int i = 0; i < 3; i++)
            {
                if (room.Slot[i].Active == true)
                {
                    Team1++;
                }
                if (EmptyPos1 == -1 && room.Slot[i].Open == true)
                {
                    EmptyPos1 = i;
                }
            }
            for (int i = 3; i < 6; i++)
            {
                if (room.Slot[i].Active == true)
                {
                    Team2++;
                }
                if (EmptyPos2 == -1 && room.Slot[i].Open == true)
                {
                    EmptyPos2 = i;
                }
            }


            int pos = EmptyPos1;

            if (Team1 >= Team2)
            {
                pos = EmptyPos2;
            }

            room.Slot[pos].Active = true;
            room.Slot[pos].cs     = cs;
            room.Slot[pos].Open   = false;
            room.Slot[pos].Spree  = 0;
            room.Slot[pos].Leader = false;
            room.Slot[pos].AFK    = false;


            cs.CurrentRoom = room;


            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_JOIN_ROOM_BROAD))
            {
                oPacket.WriteInt(cs.Login.Length * 2);
                oPacket.WriteUnicodeString(cs.Login);
                oPacket.WriteInt(cs.LoginUID);
                oPacket.WriteInt(cs.Nick.Length * 2);
                oPacket.WriteUnicodeString(cs.Nick);
                oPacket.WriteInt(pos);
                oPacket.WriteByte((byte)cs.CurrentChar);
                oPacket.WriteHexString("00 FF 00 FF 00 FF 00 00 00 00");
                oPacket.WriteByte((byte)(pos / 3));
                oPacket.WriteHexString("01 00 00 00 0D 00 00 00 00 10 F4 00 00 00 00 00 4E 00 00 00 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 19 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 2F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 34 00 00 00 00 00 00 00 00 00 00 00 00 00 00 35 00 00 00 00 00 00 00 00 00 00 00 00 00 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 39 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 43 00 00 00 00 00 00 00 00 00 00 00 00 00 00 44 00 00 00 00 00 00 00 00 00 00 00 00 00 00 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 47 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 53 00 00 00 00 00 00 00 00 00 00 00 00 00 00 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 57 00 00 00 00 00 00 00 00 00 00 00 00 00 00 58 00 00 00 00 00 00 00 00 00 00 00 00 00 00 59 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5F 00 00 00 00 00 00 00 00 00 00 00");
                if (room.GetRoomLeaderCS() == cs)
                {
                    oPacket.WriteByte(1);
                }
                else
                {
                    oPacket.WriteByte(0);
                }
                oPacket.WriteHexString("01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");

                oPacket.WriteByte((byte)cs.MyCharacter.MyChar.Length);
                for (int i = 0; i < cs.MyCharacter.MyChar.Length; i++)
                {
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].CharType);
                    oPacket.WriteInt(0);
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].Promotion);
                    oPacket.WriteInt(0);
                    oPacket.WriteByte(0);
                    oPacket.WriteInt(cs.MyCharacter.MyChar[i].Exp);
                    oPacket.WriteByte(0);
                    oPacket.WriteByte(0);
                    oPacket.WriteByte(0);
                    oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].Level);
                    oPacket.WriteInt(0);
                    oPacket.WriteInt(0);

                    oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip.Length);
                    for (int j = 0; j < cs.MyCharacter.MyChar[i].Equip.Length; j++)
                    {
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemID);
                        oPacket.WriteInt(1);
                        oPacket.WriteInt(cs.MyCharacter.MyChar[i].Equip[j].ItemUID);
                        oPacket.WriteInt(0);
                        oPacket.WriteInt(0);
                        oPacket.WriteInt(0);
                        oPacket.WriteInt(0);
                        oPacket.WriteByte(0);
                        oPacket.WriteByte(0);
                        oPacket.WriteByte(0);
                    }

                    //oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 01 00 00 00 00 00 00 00 00 02 00 00 00 A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 01 FF 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 2C 00 00 01 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07");

                    oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00 00 00 01 00");


                    /*
                     * oPacket.WriteInt(cs.MyCharacter.MyChar[i].EquipSkill.Length);
                     * for (int j = 0; j < cs.MyCharacter.MyChar[i].EquipSkill.Length; j++)
                     * {
                     *  oPacket.WriteInt(0);
                     *  oPacket.WriteInt(cs.MyCharacter.MyChar[i].EquipSkill[j].SkillGroup);
                     *  oPacket.WriteInt(cs.MyCharacter.MyChar[i].EquipSkill[j].SkillID);
                     * }*/
                    oPacket.WriteInt(0);


                    oPacket.WriteHexString("00 00 00 FF 00 00 00 A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 FF 00 00 00 00 00 00");


                    /*oPacket.WriteInt(cs.MyCharacter.MyChar[i].MySkill.Length);
                     * for (int j = 0; j < cs.MyCharacter.MyChar[i].MySkill.Length; j++)
                     * {
                     *  oPacket.WriteInt(cs.MyCharacter.MyChar[i].MySkill[j].SkillID);
                     * }*/
                    oPacket.WriteInt(0);

                    oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 2C 00 00 01 2C 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07");
                }
                oPacket.WriteHexString("00 00 00 04 13 00 A8 C0 01 EC A8 C0 9B BA FE A9");
                oPacket.WriteIPFromString(cs.GetIP(), false);
                oPacket.WriteHexString("00 00 00 01 7E F6 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 E5 6A 00 00 00 01 2C BD 52 5A 00 00 00 00 01 00 00 E5 88 00 00 00 01 2C BD 52 5B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 56 86 32 00 56 87 6E D4 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");


                for (int i = 0; i < 6; i++)
                {
                    if (room.Slot[i].Active == true && room.Slot[i].cs != cs)
                    {
                        oPacket.Assemble(room.Slot[i].cs.CRYPT_KEY, room.Slot[i].cs.CRYPT_HMAC, room.Slot[i].cs.CRYPT_PREFIX, room.Slot[i].cs.CRYPT_COUNT);
                        room.Slot[i].cs.Send(oPacket);
                        oPacket.CancelAssemble();
                    }
                }
            }


            using (OutPacket op = new OutPacket(GameOpcodes.EVENT_JOIN_ROOM_INFO_ACK))
            {
                op.WriteUShort(RoomID);
                op.WriteInt(room.RoomName.Length * 2);
                op.WriteUnicodeString(room.RoomName);
                op.WriteByte(0);
                if (room.RoomPass.Length > 0)
                {
                    op.WriteByte(1);
                }
                else
                {
                    op.WriteByte(0);
                }
                op.WriteInt(room.RoomPass.Length * 2);
                op.WriteUnicodeString(room.RoomPass);
                op.WriteShort((short)room.GetPlayerCount());
                op.WriteShort((short)room.GetFreeSlot());
                op.WriteHexString("00 0B");
                op.WriteByte((byte)room.GameCategory);
                op.WriteInt(room.GameMode);
                op.WriteInt(room.ItemMode);
                op.WriteBool(room.RandomMap);
                op.WriteInt(room.GameMap);
                op.WriteHexString("00 00 00 0C");
                for (int i = 0; i < 6; i++)
                {
                    op.WriteBool(room.Slot[i].Open);
                }
                op.WriteHexString("FF FF FF FF 00 00 00 00 00 00 00 00 01");
                op.WriteIPFromString(Server.UDPRelayIP, true);
                op.WriteShort(Server.UDPRelayPort);
                op.WriteIPFromString(Server.TCPRelayIP, true);
                op.WriteShort(Server.TCPRelayPort);

                op.WriteHexString("01 00 01 00 00 01 2C 00 00 00 14 00 02 4B 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 01 00 00 00 00");

                op.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(op);
            }

            room.SendJoinRoomInfoDivide(cs);
            return;


cantjoin:
            using (OutPacket op = new OutPacket(GameOpcodes.EVENT_JOIN_ROOM_INFO_DIVIDE_ACK))
            {
                op.WriteInt(6);
                op.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 30 00 00 00 F9 00 00 09 0D 00 00 00 00 00 00 00 00 F2 04 00 00 00 00 00 00 13 49 F4 FC 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 09 13 F2 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");

                op.CompressAndAssemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(op);
            }
            return;
        }
Exemplo n.º 22
0
        public static void AddCharLook(OutPacket p, MapleCharacter chr, bool mega)
        {
            p.WriteBool(chr.Gender);
            p.WriteByte(chr.Skin.ColorId); // skin color
            p.WriteInt(chr.Face);          // face
            p.WriteBool(!mega);
            p.WriteInt(chr.Hair);          // hair

            var equip       = chr.Inventorys[MapleInventoryType.Equipped.Value];
            var myEquip     = new Dictionary <byte, int>();
            var maskedEquip = new Dictionary <byte, int>();

            lock (equip)
            {
                foreach (var item in equip.Inventory.Values)
                {
                    var pos = item.Position;
                    if (pos > 0x9C && !myEquip.ContainsKey(pos))
                    {
                        if (myEquip.ContainsKey(pos))
                        {
                            myEquip[pos] = item.ItemId;
                        }
                        else
                        {
                            myEquip.Add(pos, item.ItemId);
                        }
                    }
                    else if ((pos < 0x9C || pos == 128) && pos != 0x91)
                    {
                        pos -= 100;
                        if (myEquip.ContainsKey(pos))
                        {
                            if (maskedEquip.ContainsKey(pos))
                            {
                                maskedEquip[pos] = myEquip[pos];
                            }
                            else
                            {
                                maskedEquip.Add(pos, myEquip[pos]);
                            }

                            myEquip[pos] = item.ItemId;
                        }
                        else
                        {
                            myEquip.Add(pos, item.ItemId);
                        }
                    }
                    else if (myEquip.ContainsKey(pos))
                    {
                        if (maskedEquip.ContainsKey(pos))
                        {
                            maskedEquip[pos] = myEquip[pos];
                        }
                        else
                        {
                            maskedEquip.Add(pos, myEquip[pos]);
                        }
                    }
                }

                foreach (var entry in myEquip)
                {
                    p.WriteByte((byte)(256 - entry.Key));
                    p.WriteInt(entry.Value);
                }
                p.WriteByte(0xFF);

                foreach (var entry in maskedEquip)
                {
                    p.WriteByte((byte)(256 - entry.Key));
                    p.WriteInt(entry.Value);
                }
                p.WriteByte(0xFF);

                IMapleItem cWeapon;
                p.WriteInt(equip.Inventory.TryGetValue(145, out cWeapon) ? cWeapon.ItemId : 0);
            }
            p.WriteInt(0);
            p.WriteLong(0);
        }
Exemplo n.º 23
0
        public void OnRoomList(ClientSession cs, InPacket ip)
        {
            byte RoomType = ip.ReadByte();


            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_ROOM_LIST_ACK))
            {
                int roomcount = 0;
                foreach (Room room in RoomsList)
                {
                    if (RoomType == 1)
                    {
                        if (room.Playing == true || room.GetFreeSlot() == 0)
                        {
                            continue;
                        }
                    }
                    roomcount++;
                }
                oPacket.WriteInt(roomcount);

                foreach (Room room in RoomsList)
                {
                    if (RoomType == 1)
                    {
                        if (room.Playing == true || room.GetFreeSlot() == 0)
                        {
                            continue;
                        }
                    }

                    oPacket.WriteUShort(room.ID);
                    oPacket.WriteInt(room.RoomName.Length * 2);
                    oPacket.WriteUnicodeString(room.RoomName);

                    if (room.RoomPass.Length > 0)
                    {
                        oPacket.WriteByte(0);
                    }
                    else
                    {
                        oPacket.WriteByte(1);
                    }
                    oPacket.WriteByte(0);
                    oPacket.WriteInt(room.RoomPass.Length * 2);
                    oPacket.WriteUnicodeString(room.RoomPass);

                    oPacket.WriteShort((short)(room.GetFreeSlot() + room.GetPlayerCount()));
                    oPacket.WriteShort((short)room.GetPlayerCount());
                    oPacket.WriteBool(room.Playing);

                    oPacket.WriteHexString("2E 02 1B 25 01 00 00 00 00 01 6B F9 38 77 00 00 00 0C 00 00 00 00 00 00 00 01");

                    oPacket.WriteInt(room.GetRoomLeaderCS().Nick.Length * 2);
                    oPacket.WriteUnicodeString(room.GetRoomLeaderCS().Nick);

                    oPacket.WriteHexString("0B 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01");
                }


                int RoomInfoSize = oPacket.ToArray().Length;
                oPacket.CompressBuffer();
                byte[] RoomInfo = oPacket.getBuffer();

                oPacket.InitBuffer();

                oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 01");
                oPacket.WriteInt(4 + RoomInfo.Length);
                oPacket.WriteByte(1);
                oPacket.WriteBytes(BitConverter.GetBytes(RoomInfoSize));
                oPacket.WriteBytes(RoomInfo);

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
Exemplo n.º 24
0
        public void OnLogin(ClientSession cs, InPacket ip)
        {
            int    IDLength = ip.ReadInt();
            string ID       = ip.ReadString(IDLength);
            int    PWLength = ip.ReadInt();
            string PW       = ip.ReadString(PWLength);

            ip.Skip(21);
            int    crc32len = ip.ReadInt();
            string crc32    = ip.ReadString(crc32len);

            LogFactory.GetLog("CRC").LogInfo("LENGTH: " + crc32len + " CRC: " + crc32);

            DataSet ds = new DataSet();

            Database.Query(ref ds, "SELECT * FROM account WHERE Login = '******' AND Passwd = '{1}'", ID, PW);


            if (ds.Tables[0].Rows.Count == 0)
            {
                // 로그인 실패
                LogFactory.GetLog("MAIN").LogInfo("{0}의 로그인이 실패하였습니다.", ID);

                using (OutPacket oPacket = new OutPacket(CenterOpcodes.ENU_VERIFY_ACCOUNT_ACK))
                {
                    oPacket.WriteHexString("00 00 00 14");
                    oPacket.WriteInt(IDLength * 2);
                    oPacket.WriteUnicodeString(ID);
                    oPacket.WriteHexString("00 00 00 00 00");

                    oPacket.CompressAndAssemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                    cs.Send(oPacket);
                }
            }
            else
            {
                SendServerList(cs);
                SendChannelNews(cs);
                //SendShop(cs);
                SendClientContentOpen(cs);
                SendSocketTableInfo(cs);
                SendCashbackRatio(cs);

                using (OutPacket oPacket = new OutPacket(CenterOpcodes.ENU_VERIFY_ACCOUNT_ACK))
                {
                    oPacket.WriteHexString("00 00 00 00");
                    oPacket.WriteInt(IDLength * 2);
                    oPacket.WriteUnicodeString(ID);
                    oPacket.WriteInt(PWLength);
                    oPacket.WriteString(PW);

                    oPacket.WriteHexString("00 00 00 00 14 00 8E A7 C5 01 00 00 00 00 00 00 02 4B 52 00 05 A3 BD 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00");

                    oPacket.WriteInt(cs.MyLoading.GuildMarkURL.Length * 2);
                    oPacket.WriteUnicodeString(cs.MyLoading.GuildMarkURL);
                    oPacket.WriteHexString("00 00 00 00 00 00 00 00");

                    //checklist
                    int SHAi = cs.MyLoading.checklist.Length;
                    oPacket.WriteInt(SHAi);
                    for (int i = 0; i <= cs.MyLoading.checklist.Length - 1; i++)
                    {
                        oPacket.WriteInt(cs.MyLoading.checklist[i].nFile.Length * 2);
                        oPacket.WriteUnicodeString(cs.MyLoading.checklist[i].nFile);
                        oPacket.WriteBool(true);
                    }
                    oPacket.WriteHexString("00 00 00 01 00 00 00 03 00 00 00 00 00 00 00 00 64 01 00 00 00 00 00 00 00 64 02 00 00 00 00 00 00 00 64 01 BF 80 00 00 FC 04 97 FF 00 00 00 00 00 00 00 00 00 00 00 00");

                    oPacket.CompressAndAssemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT);
                    cs.Send(oPacket);
                }
            }
        }
Exemplo n.º 25
0
        public static void OnCheckPassword(MapleClient c, InPacket p)
        {
            string user = p.ReadMapleString().Trim();
            string pass = p.ReadMapleString();

            //byte[] machineId = p.ReadBytes(0x10);
            //int gameRoomCode = p.ReadInt();
            //byte gameStartMode = p.ReadByte();
            //bool adminClient = p.ReadBool();

            byte loginResult = MasterServer.Instance.LoginClient(c, user, pass);

            using (OutPacket packet = new OutPacket(SendOps.CheckPasswordResult))
            {
                packet.WriteByte(loginResult);
                packet.WriteZero(5); //v11 (1) + v12 (4)

                if (loginResult == 0)
                {
                    packet.WriteInt(c.Account.AccountId);
                    packet.WriteByte();
                    packet.WriteBool(c.Account.GM);
                    packet.WriteByte(1);
                    packet.WriteMapleString(c.Account.Username);
                    packet.WriteZero(12);
                }
                else if (loginResult == 2) //TODO : Add packet for this
                {
                    c.Close();
                    return;
                }

                packet.WriteZero(24); //padding
                c.Send(packet);
            }

            if (loginResult != 0)
            {
                return;
            }

            using (OutPacket packet = new OutPacket(SendOps.CheckUserLimitResult, 3))
            {
                packet.WriteByte(4);
                c.Send(packet);
            }

            using (OutPacket packet = new OutPacket(SendOps.WorldInformation))
            {
                byte   worldId = 0;
                string name    = Constants.WorldName;

                packet.WriteByte(worldId);
                packet.WriteMapleString(name);

                packet.WriteByte((byte)MasterServer.Instance.Channels.Length);

                int id = 1;

                foreach (var ch in MasterServer.Instance.Channels)
                {
                    packet.WriteMapleString("{0}-{1}", name, id++);
                    packet.WriteInt(ch.Load);
                    packet.WriteByte(worldId);
                    packet.WriteByte((byte)(id - 1));
                    packet.WriteByte(0x00);
                }

                c.Send(packet);
            }

            using (OutPacket packet = new OutPacket(SendOps.WorldInformation, 3))
            {
                packet.WriteByte(0xff);
                c.Send(packet);
            }
        }
Exemplo n.º 26
0
        public void Update(params StatisticType[] statistics)
        {
            using (OutPacket oPacket = new OutPacket(SendOps.StatChanged))
            {
                oPacket.WriteBool(); // TODO: bOnExclRequest.

                int flag = 0;

                foreach (StatisticType statistic in statistics)
                {
                    flag |= (int)statistic;
                }

                oPacket.WriteInt(flag);

                Array.Sort(statistics);

                foreach (StatisticType statistic in statistics)
                {
                    switch (statistic)
                    {
                    case StatisticType.Skin:
                        oPacket.WriteByte(this.Skin);
                        break;

                    case StatisticType.Face:
                        oPacket.WriteInt(this.Face);
                        break;

                    case StatisticType.Hair:
                        oPacket.WriteInt(this.Hair);
                        break;

                    case StatisticType.Level:
                        oPacket.WriteByte(this.Level);
                        break;

                    case StatisticType.Job:
                        oPacket.WriteShort((short)this.Job);
                        break;

                    case StatisticType.Strength:
                        oPacket.WriteShort(this.Strength);
                        break;

                    case StatisticType.Dexterity:
                        oPacket.WriteShort(this.Dexterity);
                        break;

                    case StatisticType.Intelligence:
                        oPacket.WriteShort(this.Intelligence);
                        break;

                    case StatisticType.Luck:
                        oPacket.WriteShort(this.Luck);
                        break;

                    case StatisticType.Health:
                        oPacket.WriteShort(this.Health);
                        break;

                    case StatisticType.MaxHealth:
                        oPacket.WriteShort(this.MaxHealth);
                        break;

                    case StatisticType.Mana:
                        oPacket.WriteShort(this.Mana);
                        break;

                    case StatisticType.MaxMana:
                        oPacket.WriteShort(this.MaxMana);
                        break;

                    case StatisticType.AbilityPoints:
                        oPacket.WriteShort(this.AbilityPoints);
                        break;

                    case StatisticType.SkillPoints:
                        oPacket.WriteShort(this.SkillPoints);
                        break;

                    case StatisticType.Experience:
                        oPacket.WriteInt(this.Experience);
                        break;

                    case StatisticType.Fame:
                        oPacket.WriteShort(this.Fame);
                        break;

                    case StatisticType.Mesos:
                        oPacket.WriteInt(this.Mesos);
                        break;
                    }
                }

                this.Parent.Client.Send(oPacket);
            }
        }
Exemplo n.º 27
0
        private void Operate(bool unk, params InventoryOperation[] operations)
        {
            using (OutPacket oPacket = new OutPacket(SendOps.InventoryOperation))
            {
                oPacket
                .WriteBool(unk)
                .WriteByte((byte)operations.Length);

                sbyte addedByte = -1;

                foreach (InventoryOperation operation in operations)
                {
                    oPacket
                    .WriteByte((byte)operation.Type)
                    .WriteByte((byte)Item.GetInventory(operation.Item.MapleID));

                    switch (operation.Type)
                    {
                    case InventoryOperationType.AddItem:
                    {
                        oPacket.WriteShort(operation.CurrentSlot);
                        operation.Item.Encode(oPacket);
                    }
                    break;

                    case InventoryOperationType.ModifyQuantity:
                    {
                        oPacket
                        .WriteShort(operation.CurrentSlot)
                        .WriteShort(operation.Item.Quantity);
                    }
                    break;

                    case InventoryOperationType.ModifySlot:
                    {
                        oPacket
                        .WriteShort(operation.OldSlot)
                        .WriteShort(operation.CurrentSlot);

                        if (addedByte == -1)
                        {
                            if (operation.OldSlot < 0)
                            {
                                addedByte = 1;
                            }
                            else if (operation.CurrentSlot < 0)
                            {
                                addedByte = 2;
                            }
                        }
                    }
                    break;

                    case InventoryOperationType.RemoveItem:
                    {
                        oPacket.WriteShort(operation.CurrentSlot);
                    }
                    break;
                    }
                }

                if (addedByte != -1)
                {
                    oPacket.WriteSByte(addedByte);
                }

                this.Parent.Client.Send(oPacket);
            }
        }