public RoomInstance(int roomID)
        {
            mRoomID = roomID;
            mRoomInfo = InstanceManager.Game.Rooms.GetRoom(roomID);
            LoadReactor(mRoomInfo.ReactorType);
            mMemberSessions = new Dictionary<long, int>();
            mRoomUsers = new Dictionary<long, RoomUser>();
            mRoomUserIDs = new List<int>();
            mRoomInteractor = new RoomInteractor(mRoomID, this);
            mDoorEntries = new Dictionary<long, int>();

            if (RoomInfo.ReactorType == "LidoReactor" || RoomInfo.ReactorType == "RooftopReactor") Interactor.mHasPoolCam = true;
        }
        public void CallForHelp(RoomUser user, RoomInfo room, string callBody)
        {
            CallForHelpInfo cfh = new CallForHelpInfo();
            cfh.CallId = callCurrentID++;
            cfh.Caller = user.UserInfo.sUsername;
            cfh.CallerId = user.UserInfo.userId;
            cfh.Message = callBody;
            cfh.PickedUpBy = "";
            cfh.Priority = 2;
            cfh.RoomId = room.RoomID;
            cfh.RoomName = room.RoomName;

            mCalls.Add(cfh.CallId, cfh);

            SendCFH(cfh);
        }
        //57 - "TRYFLAT": "@y"
        public void Listener57()
        {
            int    roomId       = 0;
            bool   result       = false;
            string roomPassword = null;

            if (mPacketBody.Contains('/'))
            {
                roomId       = int.Parse(mPacketBody.Split('/')[0]);
                roomPassword = mPacketBody.Split('/')[1];
            }
            else
            {
                roomId = int.Parse(mPacketBody);
            }



            if (!InstanceManager.Game.Roles.HasRight(mUserInfo.iRole, "fuse_enter_locked_rooms"))
            {
                if (InstanceManager.Sessions.GetSession(mSessionID).authenticatedDoor > 0 && InstanceManager.Sessions.GetSession(mSessionID).authenticatedFlat == roomId) //Entering via door
                {
                    InstanceManager.Sessions.GetSession(mSessionID).authenticatedDoor = 0;
                    result = true;
                }
                else
                {
                    RoomInfo roomInfo = InstanceManager.Game.Rooms.GetRoom(roomId);

                    if (mUserInfo.userId == roomInfo.RoomOwner)
                    {
                        result = true;
                    }
                    else
                    {
                        if (roomInfo.RoomStatus == "open") // Open
                        {
                            result = true;
                        }
                        else if (roomInfo.RoomStatus == "closed") //Doorbell
                        {
                            if (InstanceManager.Game.Rooms.InstanceExists(roomId))
                            {
                                if (InstanceManager.Game.Rooms.GetRoomInstance(roomId).BroadcastRingingUser(mUserInfo.sUsername))
                                {
                                    InstanceManager.Sessions.GetSession(mSessionID).waitingFlat = roomId;
                                }
                                else
                                {
                                    mMessage.Init(131); //BC
                                    SendMessage(mMessage);
                                }
                            }
                            else
                            {
                                mMessage.Init(131); //BC
                                SendMessage(mMessage);
                            }
                        }
                        else if (roomInfo.RoomStatus == "password") //Password
                        {
                            if (roomInfo.Password == roomPassword)
                            {
                                result = true;
                            }
                            else
                            {
                                ReportError("Incorrect flat password", false);
                            }
                        }
                    }
                }
            }
            else
            {
                result = true;
            }


            if (result)
            {
                InstanceManager.Sessions.GetSession(mSessionID).authenticatedFlat = roomId;
                mMessage.Init(41); // @i
                SendMessage(mMessage);
            }
        }
        //25 - "SETFLATINFO": "@Y"
        public void Listener25()
        {
            string rId    = "";
            int    roomId = 0;

            if (mPacketBody.Substring(0, 1) == "/")
            {
                rId = mPacketBody.Split('/')[1];
            }
            else
            {
                rId = mPacketBody.Split('/')[0];
            }

            if (int.TryParse(rId, out roomId))
            {
                RoomInfo roomInfo = InstanceManager.Game.Rooms.GetRoom(roomId);
                if (roomInfo.RoomOwner == mUserInfo.userId)
                {
                    string[] payLoad = mPacketBody.Split(Convert.ToChar(13));

                    for (int i = 1; i < payLoad.Length; i++)
                    {
                        string updateHeader = payLoad[i].Split('=')[0];
                        string updateBody   = "";
                        if (payLoad[i].Length > updateHeader.Length + 1)
                        {
                            updateBody = payLoad[i].Substring(updateHeader.Length + 1);
                        }

                        switch (updateHeader)
                        {
                        case "description":
                            roomInfo.RoomDescription = SpecialFiltering.FilterChars("2,9,13,47", updateBody);
                            break;

                        case "maxvisitors":
                            int maxvis = 0;
                            if (int.TryParse(updateBody, out maxvis))
                            {
                                roomInfo.MaxUsers = maxvis;
                            }
                            break;

                        case "allsuperuser":
                            int allsuper = 0;
                            if (int.TryParse(updateBody, out allsuper))
                            {
                                if (allsuper == 1 || allsuper == 0)
                                {
                                    roomInfo.SuperUsers = allsuper;
                                }
                            }
                            break;

                        case "password":
                            roomInfo.Password = SpecialFiltering.FilterChars("2,9,13,47", updateBody);
                            break;
                        }
                    }

                    InstanceManager.Game.Rooms.UpdateRoom(roomInfo);
                }
            }
        }
Exemple #5
0
        private string formSpecialRoomDefinition(RoomInfo roomInfo, UserInfo user)
        {
            StringBuilder sb = new StringBuilder();

            char tab = Convert.ToChar(9);

            sb.Append(roomInfo.RoomID.ToString());
            sb.Append(tab);
            sb.Append(roomInfo.RoomName);
            sb.Append(tab);
            if (roomInfo.ShowOwner == 1 || InstanceManager.Game.Roles.HasRight(user.iRole, "fuse_see_all_roomowners"))
            {
                sb.Append(InstanceManager.Game.Users.GetUser(roomInfo.RoomOwner).sUsername);
            }
            else
            {
                sb.Append("-");
            }
            sb.Append(tab);
            sb.Append(roomInfo.RoomStatus);
            sb.Append(tab);
            sb.Append("x");
            sb.Append(tab);
            sb.Append(roomInfo.CurrentUsers.ToString());
            sb.Append(tab);
            sb.Append(roomInfo.MaxUsers.ToString());
            sb.Append(tab);
            sb.Append("null");
            sb.Append(tab);
            sb.Append(roomInfo.RoomDescription);
            sb.Append(tab);
            sb.Append(roomInfo.RoomDescription);
            sb.Append(tab);
            sb.Append(Convert.ToChar(13));

            return sb.ToString();
        }
Exemple #6
0
        private string BuildRoomResponse(RoomInfo room, UserInfo user, int hideFull)
        {
            int categoryType = InstanceManager.Game.Rooms.GetCategory(room.RoomCategory).RoomCategoryType;

            StringBuilder sb = new StringBuilder();

            if (hideFull == 1 && room.CurrentUsers >= room.MaxUsers)
            {
                return "";
            }

            if (categoryType == 2) // Guest
            {
                sb.Append(ArgumentEncoding.encodeInt(room.RoomID));
                sb.Append(room.RoomName);
                sb.Append(Convert.ToChar(2));
                if (room.ShowOwner == 1 || InstanceManager.Game.Roles.HasRight(user.iRole, "fuse_see_all_roomowners"))
                {
                    sb.Append(InstanceManager.Game.Users.GetUser(room.RoomOwner).sUsername);
                }
                else
                {
                    sb.Append("-");
                }
                sb.Append(Convert.ToChar(2));
                sb.Append(room.RoomStatus);
                sb.Append(Convert.ToChar(2));
                sb.Append(ArgumentEncoding.encodeInt(room.CurrentUsers));
                sb.Append(ArgumentEncoding.encodeInt(room.MaxUsers));
                sb.Append(room.RoomDescription);
                sb.Append(Convert.ToChar(2));
            }

            if (categoryType == 0) //Public
            {
                sb.Append(ArgumentEncoding.encodeInt(room.RoomID));
                sb.Append(ArgumentEncoding.encodeInt(1));
                sb.Append(room.RoomName);
                sb.Append(Convert.ToChar(2));
                sb.Append(ArgumentEncoding.encodeInt(room.CurrentUsers));
                sb.Append(ArgumentEncoding.encodeInt(room.MaxUsers));
                sb.Append(ArgumentEncoding.encodeInt(room.RoomCategory));
                sb.Append(room.RoomDescription);
                sb.Append(Convert.ToChar(2));
                sb.Append(ArgumentEncoding.encodeInt(room.RoomID));
                sb.Append(ArgumentEncoding.encodeInt(0));
                sb.Append(room.CCTs);
                sb.Append(Convert.ToChar(2));
                sb.Append(ArgumentEncoding.encodeInt(0));
                sb.Append(ArgumentEncoding.encodeInt(1));
            }
            return sb.ToString();
        }
        private RoomInfo ProduceRoomFromRow(DataRow dRow)
        {
            RoomInfo roomInfo = new RoomInfo();

            roomInfo.RoomID = int.Parse(dRow["RoomID"].ToString());
            roomInfo.RoomName = dRow["RoomName"].ToString();
            roomInfo.RoomDescription = dRow["RoomDescription"].ToString();
            roomInfo.RoomStatus = dRow["RoomStatus"].ToString();
            roomInfo.RoomOwner = int.Parse(dRow["RoomOwner"].ToString());
            roomInfo.RoomType = int.Parse(dRow["RoomType"].ToString());
            roomInfo.RoomCategory = int.Parse(dRow["CategoryID"].ToString());
            roomInfo.TypeName = dRow["FriendlyName"].ToString();
            roomInfo.RoomModel = dRow["RoomModel"].ToString();
            roomInfo.DefaultHeightmap = dRow["DefaultHeightmap"].ToString().Replace('|', Convert.ToChar(13));
            roomInfo.StartX = int.Parse(dRow["StartX"].ToString());
            roomInfo.StartY = int.Parse(dRow["StartY"].ToString());
            roomInfo.StartZ = int.Parse(dRow["StartZ"].ToString());
            roomInfo.MaxUsers = int.Parse(dRow["MaxUsers"].ToString());
            roomInfo.Wallpaper = int.Parse(dRow["Wallpaper"].ToString());
            roomInfo.Floor = int.Parse(dRow["Floor"].ToString());
            roomInfo.ReactorType = dRow["ReactorType"].ToString();
            roomInfo.CCTs = dRow["CCTs"].ToString();
            roomInfo.IsGuestRoom = bool.Parse(dRow["Guest"].ToString());
            roomInfo.SuperUsers = int.Parse(dRow["SuperUsers"].ToString());
            roomInfo.ShowOwner = int.Parse(dRow["ShowOwner"].ToString());
            roomInfo.UserType = int.Parse(dRow["UserType"].ToString());
            roomInfo.Password = dRow["Password"].ToString();
            roomInfo.CurrentUsers = int.Parse(dRow["CurrentUsers"].ToString());
            roomInfo.UserType = int.Parse(dRow["UserType"].ToString());
            roomInfo.MaxAscend = float.Parse(dRow["MaxAscend"].ToString());
            roomInfo.MaxDescend  = float.Parse(dRow["MaxDescend"].ToString());

            return roomInfo;
        }
        public void UpdateRoom(RoomInfo room)
        {
            Database db = new Database();
            db.sqlexecute.Parameters.AddWithValue("@roomid", room.RoomID);
            db.sqlexecute.Parameters.AddWithValue("@roomname", room.RoomName);
            db.sqlexecute.Parameters.AddWithValue("@roomtype", room.RoomType);
            db.sqlexecute.Parameters.AddWithValue("@roomstate", room.RoomStatus);
            db.sqlexecute.Parameters.AddWithValue("@showowner", room.ShowOwner);
            db.sqlexecute.Parameters.AddWithValue("@owner", room.RoomOwner);
            db.sqlexecute.Parameters.AddWithValue("@description", room.RoomDescription);
            db.sqlexecute.Parameters.AddWithValue("@password", room.Password);
            db.sqlexecute.Parameters.AddWithValue("@superusers", room.SuperUsers);
            db.sqlexecute.Parameters.AddWithValue("@wallpaper", room.Wallpaper);
            db.sqlexecute.Parameters.AddWithValue("@floor", room.Floor);
            db.sqlexecute.Parameters.AddWithValue("@category", room.RoomCategory);
            db.sqlexecute.Parameters.AddWithValue("@maxusers", room.MaxUsers);

            db.ExecuteSQL("UPDATE Rooms SET RoomName = @roomname, RoomType = @roomtype, RoomStatus = @roomstate, ShowOwner = @showowner, RoomOwner = @owner, RoomDescription = @description, Password = @password, SuperUsers = @superusers,Wallpaper = @wallpaper, Floor = @floor, CategoryID = @category, MaxUsers = @maxusers WHERE RoomID = @roomid;");

            db.sqlexecute.Parameters.Clear();

            if (InstanceExists(room.RoomID))
            {
                GetRoomInstance(room.RoomID).RoomInfo = GetRoom(room.RoomID);
            }
        }