Пример #1
0
        public static void KRoomInfo(Session right, PacketRead rs)
        {
            libcomservice.REQUEST.Room room = new libcomservice.REQUEST.Room();

            ushort m_usRoomID = rs.UShort();

            room.m_strRoomName   = rs.UnicodeString();
            room.m_bPublic       = rs.Bool();
            room.m_bGuild        = rs.Bool();
            room.m_strRoomPasswd = rs.UnicodeString();
            short m_usUsers = rs.Short();

            room.m_usMaxUsers     = rs.Get_Short();
            room.m_bPlaying       = rs.Bool();
            room.m_cGrade         = rs.Byte();
            room.m_cGameCategory  = rs.Byte();
            room.m_iGameMode      = rs.Int();
            room.m_iSubGameMode   = rs.Int();
            room.m_bRandomableMap = rs.Bool();
            room.m_iMapID         = rs.Int();
            room.m_iP2PVersion    = rs.Int();
            byte[] m_abSlotOpen = rs.Buffer_Array_Bytes(6);
            room.m_vecMonsterSlot = rs.Int();
            room.m_cDifficulty    = rs.Int();
            rs.Jump(17);

            ushort index_room = 0;

            for (ushort i = 1; i < GameServer.m_usMaxUsers; i++)
            {
                if (GameServer.List_Rooms.ContainsKey(i))
                {
                    continue;
                }
                index_room = i;
                break;
            }
            room.m_usRoomID = index_room;

            room.m_dwSlots[0].Active = true;
            room.m_dwSlots[0].usr    = right;
            room.m_dwSlots[0].Leader = true;
            room.m_dwSlots[0].Open   = false;
            room.m_dwSlots[0].Status = 0;
            room.m_dwSlots[0].AFK    = false;
            room.m_dwSlots[0].Team   = 0;

            for (int i = 1; i < room.m_usMaxUsers; i++)
            {
                room.m_dwSlots[i].Active = false;
                room.m_dwSlots[i].usr    = null;
                room.m_dwSlots[i].Leader = false;
                room.m_dwSlots[i].Open   = true;
                room.m_dwSlots[i].Status = 0;
                room.m_dwSlots[i].AFK    = false;
                room.m_dwSlots[i].Team   = 0;
            }
            right.PInfo.CurRoom = room;
        }
Пример #2
0
        public void RoomMyInfoDivide(Session p, PacketRead r)
        {
            r.Jump(6);
            ushort roomid    = (ushort)r.Get_Short();
            Room   room      = RoomExists(roomid);
            int    TempCount = -1;

            for (int i = 0; i < room.m_usMaxUsers; i++)
            {
                if (room.m_dwSlots[i].Active == false)
                {
                    continue;
                }
                TempCount++;
                if (room.m_dwSlots[i].usr == p)
                {
                    PacketWrite pw = new PacketWrite();
                    pw.Int(0);
                    pw.Int(room.m_usUsers());
                    pw.Int(TempCount);
                    pw.UnicodeStr(room.m_dwSlots[i].usr.PInfo.m_strLogin);
                    pw.Int(room.m_dwSlots[i].usr.PInfo.m_dwUserUID);
                    pw.UnicodeStr(room.m_dwSlots[i].usr.PInfo.m_strNickName);
                    pw.Int(i);
                    pw.Byte(room.m_dwSlots[i].usr.PInfo.m_ucCharType);
                    pw.Int(0);
                    pw.HexArray("00 FF 00 FF 00 FF 00 00 00 00");
                    pw.Byte((byte)room.GetTeam(room.m_dwSlots[i].usr));
                    pw.HexArray("00 00 00 00 64 00 00");
                    pw.Int(room.m_dwSlots[i].usr.PInfo.m_iGamePoint);
                    pw.Short(0);
                    Serializables.SerializeStages(room.m_dwSlots[i].usr, pw);
                    if (room.m_sSearchLeader() == room.m_dwSlots[i].usr)
                    {
                        pw.Bool(true);
                    }
                    else
                    {
                        pw.Bool(false);
                    }
                    pw.HexArray("01 00 00 00 00 00 00 00 00 00 00 00 00");
                    Serializables.m_roomCharacterInfo(room.m_dwSlots[i].usr, pw);
                    pw.HexArray("00 00 00 02 76 19 A8 C0 10 0C D6 BA 00 00 00 01 7F 39 00 00 00 00 00 00 00 00 00 00 00");
                    pw.Byte(room.m_dwSlots[i].Status);
                    pw.HexArray("00 00 00 00 00 12 C8 F2 00 00 00 00 00 D6 D9 BE 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 42 00 52 00 0B 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 00 00 00 00 00 00 00 D2 F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D2 F0 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 06 11 16 00 00 00 00 00 00 00 00 46 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97 D8 00 00 01 A0 04 7B 00 00 00 00 00 00 00 00");

                    p.SendPacket(pw, 1472);
                    break;
                }
            }
        }
Пример #3
0
        public void EnterRoom(Session p, PacketRead r)
        {
            try
            {
                r.Jump(4);
                ushort roomID   = (ushort)r.Get_Short();
                string Password = r.UnicodeString();
                r.Jump(5);
                string userLogin = r.UnicodeString();
                r.Jump(4);
                string userNick = r.UnicodeString();
                r.Jump(4);
                p.PInfo.m_ucCharType = r.Byte();

                Room room = RoomExists(roomID);

                if (room == null)
                {
                    PacketWrite pw2 = new PacketWrite();
                    pw2.Int(1);
                    p.SendPacket(pw2, 54);
                    return;
                }
                else if (room.m_abTotalSlotsOpen() == 0)
                {
                    PacketWrite pw2 = new PacketWrite();
                    pw2.Int(1);
                    p.SendPacket(pw2, 54);
                    return;
                }
                else if (room.m_bPlaying == true)
                {
                    PacketWrite pw2 = new PacketWrite();
                    pw2.Int(1);
                    p.SendPacket(pw2, 54);
                    return;
                }
                else if (room.m_strRoomPasswd != Password)
                {
                    PacketWrite pw2 = new PacketWrite();
                    pw2.Int(1);
                    p.SendPacket(pw2, 54);
                    return;
                }
                int pos = 0;
                if (room.m_cGameCategory == 2)
                {
                    pos = room.m_abSlotOpen();
                }
                else
                {
                    byte Team1 = 0, Team2 = 0;
                    int  EmptyPos1 = -1, EmptyPos2 = -1;
                    for (int i = 0; i < 3; i++)
                    {
                        if (room.m_dwSlots[i].Active == true)
                        {
                            Team1++;
                        }
                        if (EmptyPos1 == -1 && room.m_dwSlots[i].Open == true)
                        {
                            EmptyPos1 = i;
                        }
                    }
                    for (int i = 3; i < 6; i++)
                    {
                        if (room.m_dwSlots[i].Active == true)
                        {
                            Team2++;
                        }
                        if (EmptyPos2 == -1 && room.m_dwSlots[i].Open == true)
                        {
                            EmptyPos2 = i;
                        }
                    }

                    pos = EmptyPos1;
                    if (Team1 >= Team2)
                    {
                        pos = EmptyPos2;
                    }
                }
                room.m_dwSlots[pos].Active       = true;
                room.m_dwSlots[pos].usr          = p;
                room.m_dwSlots[pos].Open         = false;
                room.m_dwSlots[pos].AFK          = false;
                room.m_dwSlots[pos].Deaths       = 0;
                room.m_dwSlots[pos].Kills        = 0;
                room.m_dwSlots[pos].Win          = 0;
                room.m_dwSlots[pos].PositionSlot = pos;
                room.m_dwSlots[pos].Leader       = false;

                p.PInfo.CurRoom   = room;
                p.PInfo.m_cStatus = "ROOM";
                GameServer.UsersList.Remove(p);

                PacketWrite pw = new PacketWrite();
                pw.UnicodeStr(p.PInfo.m_strLogin);
                pw.Int(p.PInfo.m_dwUserUID);
                pw.UnicodeStr(p.PInfo.m_strNickName);
                pw.Int(pos);
                pw.Byte(p.PInfo.m_ucCharType);
                pw.Int(0);
                pw.HexArray("00 FF 00 FF 00 FF 00 00 00 00");
                pw.Byte((byte)(pos / 3));
                pw.HexArray("01 00 00 00 64 00 00");
                pw.Int(p.PInfo.m_iGamePoint);
                pw.Short(0);
                Serializables.SerializeStages(p, pw);
                if (room.m_sSearchLeader() == p)
                {
                    pw.Bool(true);
                }
                else
                {
                    pw.Bool(false);
                }
                pw.HexArray("01 00 00 00 00 00 00 00 00 00 00 00 00");
                Serializables.m_roomCharacterInfo(p, pw);
                pw.HexArray("00 00 00 02 76 19 A8 C0 10 0C D6 BA 00 00 00 01 7F 39 00 00 00 00 00 00 00 00 00 00 00");
                pw.Byte(room.m_dwSlots[pos].Status);
                pw.HexArray("00 00 00 00 00 12 C8 F2 00 00 00 00 00 D6 D9 BE 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 42 00 52 00 0B 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 00 00 00 00 00 00 00 D2 F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D2 F0 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 06 11 16 00 00 00 00 00 00 00 00 46 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97 D8 00 00 01 A0 04 7B 00 00 00 00 00 00 00 00");

                room.SendForAllPlayersInRoom(pw, 54);
                RoomInfo(p, room);
                RoomInfoDivide(p, room);
            }
            catch (Exception ex)
            {
                Log.Write("{0}", ex.StackTrace);
                PacketWrite pw = new PacketWrite();
                pw.Int(1);
                p.SendPacket(pw, 54);
                p.PInfo.CurRoom   = null;
                p.PInfo.m_cStatus = "LOBBY";
                GameServer.UsersList.Add(p);
            }
        }