Esempio n. 1
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());
            }
        }
Esempio n. 2
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());
            }
        }
Esempio n. 3
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);
            }
        }