Esempio n. 1
0
		public GameItemHandler(Room room)
		{
			this.room = room;
			this.rnd = new Random();
			this.banzaiPyramids = new QueuedDictionary<uint, RoomItem>();
			this.banzaiTeleports = new QueuedDictionary<uint, RoomItem>();
		}
Esempio n. 2
0
		internal void UpdateUser(GameClient client)
		{
			this.client = client;
			if (client != null && client.GetHabbo() != null)
			{
				this.currentRoom = client.GetHabbo().CurrentRoom;
			}
		}
Esempio n. 3
0
		internal void Init(uint pBaseId, int pRoomUserId, uint pRoomId, RoomUser user, Room room)
		{
			this.BaseId = pBaseId;
			this.RoomUserId = pRoomUserId;
			this.RoomId = pRoomId;
			this.roomUser = user;
			this.room = room;
		}
Esempio n. 4
0
		internal static bool IsTeleLinked(uint TeleId, Room pRoom)
		{
			uint linkedTele = TeleHandler.GetLinkedTele(TeleId, pRoom);
			if (linkedTele == 0u)
			{
				return false;
			}
			RoomItem item = pRoom.GetRoomItemHandler().GetItem(linkedTele);
			return (item != null && item.GetBaseItem().InteractionType == InteractionType.teleport) || TeleHandler.GetTeleRoomId(linkedTele, pRoom) != 0u;
		}
Esempio n. 5
0
		internal DynamicRoomModel(RoomModel pModel, Room room)
		{
			this.staticModel = pModel;
			this.DoorX = this.staticModel.DoorX;
			this.DoorY = this.staticModel.DoorY;
			this.DoorZ = this.staticModel.DoorZ;
			this.DoorOrientation = this.staticModel.DoorOrientation;
			this.Heightmap = this.staticModel.Heightmap;
			this.MapSizeX = this.staticModel.MapSizeX;
			this.MapSizeY = this.staticModel.MapSizeY;
			this.ClubOnly = this.staticModel.ClubOnly;
            this.mRoom = room;
			this.Generate();
		}
Esempio n. 6
0
 public RoomUserManager(Room room)
 {
     this.room = room;
     this.userlist = new QueuedDictionary<int, RoomUser>(new EventHandler(this.OnUserAdd), null, new EventHandler(this.onRemove), null);
     this.pets = new HybridDictionary();
     this.bots = new HybridDictionary();
     this.usersByUsername = new HybridDictionary();
     this.usersByUserID = new HybridDictionary();
     this.primaryPrivateUserID = 0;
     this.secondaryPrivateUserID = 0;
     this.ToRemove = new List<RoomUser>(room.UsersMax);
     this.ToSet = new Dictionary<Point, RoomUser>();
     this.petCount = 0;
     this.userCount = 0;
 }
Esempio n. 7
0
 public Gamemap(Room room)
 {
     this.room = room;
     this.DiagonalEnabled = true;
     this.mStaticModel = CyberEnvironment.GetGame().GetRoomManager().GetModel(room.ModelName);
     if (this.mStaticModel == null)
     {
         throw new Exception("No modeldata found for roomID " + room.RoomId);
     }
     this.mDynamicModel = new DynamicRoomModel(this.mStaticModel, room);
     this.mCoordinatedItems = new HybridDictionary();
     this.gotPublicPool = room.RoomData.Model.gotPublicPool;
     this.mGameMap = new byte[this.Model.MapSizeX, this.Model.MapSizeY];
     this.mItemHeightMap = new double[this.Model.MapSizeX, this.Model.MapSizeY];
     this.userMap = new HybridDictionary();
     this.walkableList = this.GetWalkablePoints();
 }
Esempio n. 8
0
		internal static uint GetLinkedTele(uint TeleId, Room pRoom)
		{
			uint result;
			using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
			{
				queryreactor.setQuery("SELECT tele_two_id FROM tele_links WHERE tele_one_id = " + TeleId);
				DataRow row = queryreactor.getRow();
				if (row == null)
				{
					result = 0u;
				}
				else
				{
					result = Convert.ToUInt32(row[0]);
				}
			}
			return result;
		}
Esempio n. 9
0
		public RoomItemHandling(Room room)
		{
			this.room = room;
			this.mRemovedItems = new HybridDictionary();
			this.mMovedItems = new HybridDictionary();
			this.mAddedItems = new HybridDictionary();
			this.mRollers = new QueuedDictionary<uint, RoomItem>();
			this.mWallItems = new QueuedDictionary<uint, RoomItem>();
			this.mFloorItems = new QueuedDictionary<uint, RoomItem>();
			this.roomItemUpdateQueue = new Queue();
			this.mGotRollers = false;
			this.mRoolerCycle = 0;
			this.mRollerSpeed = 4;
			this.HopperCount = 0;
			this.rollerItemsMoved = new List<uint>();
			this.rollerUsersMoved = new List<uint>();
			this.rollerMessages = new List<ServerMessage>();
		}
Esempio n. 10
0
		internal static uint GetTeleRoomId(uint TeleId, Room pRoom)
		{
			if (pRoom.GetRoomItemHandler().GetItem(TeleId) != null)
			{
				return pRoom.RoomId;
			}
			uint result;
			using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
			{
				queryreactor.setQuery("SELECT room_id FROM items WHERE id = " + TeleId + " LIMIT 1");
				DataRow row = queryreactor.getRow();
				if (row == null)
				{
					result = 0u;
				}
				else
				{
					result = Convert.ToUInt32(row[0]);
				}
			}
			return result;
		}
Esempio n. 11
0
		internal void DeliverRandomPinataItem(RoomUser User, Room Room, RoomItem Item)
		{
			if (Room == null || Item == null || Item.GetBaseItem().InteractionType != InteractionType.pinata || !this.Pinatas.ContainsKey(Item.GetBaseItem().ItemId))
			{
				return;
			}
			PinataItem pinataItem;
			this.Pinatas.TryGetValue(Item.GetBaseItem().ItemId, out pinataItem);
			if (pinataItem == null || pinataItem.Rewards.Count < 1)
			{
				return;
			}
			int getX = Item.GetX;
			int getY = Item.GetY;
			double getZ = Item.GetZ;
			Thread.Sleep(900);
			Item.refreshItem();
			Item.BaseItem = pinataItem.Rewards[new Random().Next(checked(pinataItem.Rewards.Count - 1))];
			Item.ExtraData = "";
			Room.GetRoomItemHandler().RemoveFurniture(User.GetClient(), Item.Id, false);
			using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
			{
				queryreactor.runFastQuery(string.Concat(new object[]
				{
					"UPDATE items SET base_item = '",
					Item.BaseItem,
					"', extra_data = '' WHERE id = ",
					Item.Id
				}));
				queryreactor.runQuery();
			}
			Room.GetRoomItemHandler().SetFloorItem(Item, getX, getY, getZ, 0, false);
			ServerMessage serverMessage = new ServerMessage(Outgoing.AddFloorItemMessageComposer);
			Item.Serialize(serverMessage);
			serverMessage.AppendString(Room.Owner);
			Room.SendMessage(serverMessage);
			Room.GetRoomItemHandler().SetFloorItem(User.GetClient(), Item, Item.GetX, Item.GetY, 0, true, false, true);
		}
Esempio n. 12
0
		internal void Fill(Room Room)
		{
			this.Id = Room.RoomId;
			this.Name = Room.Name;
			this.Description = Room.Description;
			this.Type = Room.Type;
			this.Owner = Room.Owner;
			this.Category = Room.Category;
			this.State = Room.State;
			this.UsersNow = Room.UsersNow;
			this.UsersMax = Room.UsersMax;
			this.ModelName = Room.ModelName;
            this.WallHeight = Room.WallHeight;
			this.Score = Room.Score;
			this.Tags = new List<string>();
			object[] array = Room.Tags.ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				string item = (string)array[i];
				this.Tags.Add(item);
			}
			this.AllowPets = Room.AllowPets;
			this.AllowPetsEating = Room.AllowPetsEating;
			this.AllowWalkthrough = Room.AllowWalkthrough;
			this.Hidewall = Room.Hidewall;
			this.Password = Room.Password;
			this.Wallpaper = Room.Wallpaper;
			this.Floor = Room.Floor;
			this.Landscape = Room.Landscape;
			this.FloorThickness = Room.FloorThickness;
			this.WallThickness = Room.WallThickness;
			this.Group = Room.Group;
			this.Event = Room.Event;
			this.ChatType = Room.ChatType;
			this.ChatBalloon = Room.ChatBalloon;
			this.ChatSpeed = Room.ChatSpeed;
			this.ChatMaxDistance = Room.ChatMaxDistance;
			this.ChatFloodProtection = Room.ChatFloodProtection;
			this.WhoCanMute = Room.WhoCanMute;
			this.WhoCanKick = Room.WhoCanKick;
			this.WhoCanBan = Room.WhoCanBan;
			this.RoomChat = Room.RoomChat;
			this.WordFilter = Room.WordFilter;
			this.mModel = CyberEnvironment.GetGame().GetRoomManager().GetModel(this.ModelName);
		}
Esempio n. 13
0
		internal void SerializeGroupInfo(Guild Group, ServerMessage Response, GameClient Session, Room Room, bool NewWindow = false)
		{
            if (Room == null) { return; }
			DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
			DateTime dateTime2 = dateTime.AddSeconds((double)Group.CreateTime);
			Response.Init(Outgoing.GroupDataMessageComposer);
			Response.AppendUInt(Group.Id);
			Response.AppendBoolean(true);
			Response.AppendUInt(Group.State);
			Response.AppendString(Group.Name);
			Response.AppendString(Group.Description);
			Response.AppendString(Group.Badge);
			Response.AppendUInt(Group.RoomId);
			Response.AppendString((CyberEnvironment.GetGame().GetRoomManager().GenerateRoomData(Group.RoomId) == null) ? "No room found.." : CyberEnvironment.GetGame().GetRoomManager().GenerateRoomData(Group.RoomId).Name);
			Response.AppendInt32((Group.CreatorId == Session.GetHabbo().Id) ? 3 : (Group.Requests.Contains(Session.GetHabbo().Id) ? 2 : (Group.Members.ContainsKey(Session.GetHabbo().Id) ? 1 : 0)));
			Response.AppendInt32(Group.Members.Count);
			Response.AppendBoolean(Session.GetHabbo().FavouriteGroup == Group.Id);
			Response.AppendString(string.Concat(new object[]
			{
				dateTime2.Day,
				"-",
				dateTime2.Month,
				"-",
				dateTime2.Year
			}));
			Response.AppendBoolean(Group.CreatorId == Session.GetHabbo().Id);
			Response.AppendBoolean(Group.Admins.ContainsKey(Session.GetHabbo().Id));
			Response.AppendString((CyberEnvironment.getHabboForId(Group.CreatorId) == null) ? "" : CyberEnvironment.getHabboForId(Group.CreatorId).Username);
			Response.AppendBoolean(NewWindow);
			Response.AppendBoolean(Group.AdminOnlyDeco == 0u);
			Response.AppendInt32(Group.Requests.Count);
			Response.AppendBoolean(Group.HasForum);
			if (Room != null)
			{
				Room.SendMessage(Response);
				return;
			}
			if (Session != null)
			{
				Session.SendMessage(Response);
			}
		}
Esempio n. 14
0
		internal void BroadcastCurrentSongData(Room Instance)
		{
            if (mSong != null)
                Instance.SendMessage(JukeboxComposer.ComposePlayingComposer(mSong.SongData.Id, mSongQueuePosition, 0));
            else
                Instance.SendMessage(JukeboxComposer.ComposePlayingComposer(0, 0, 0));
		}
Esempio n. 15
0
		public void Update(Room Instance)
		{
			if (this.mIsPlaying && (this.mSong == null || this.TimePlaying >= this.mSong.SongData.LengthSeconds + 1.0))
			{
				if (this.mPlaylist.Count == 0)
				{
					this.Stop();
					this.mRoomOutputItem.ExtraData = "0";
					this.mRoomOutputItem.UpdateState();
				}
				else
				{
					this.SetNextSong();
				}
				RoomMusicController.mBroadcastNeeded = true;
			}
			if (RoomMusicController.mBroadcastNeeded)
			{
				this.BroadcastCurrentSongData(Instance);
				RoomMusicController.mBroadcastNeeded = false;
			}
		}
		internal void SerializeRoomInformation(Room Room, bool show)
		{
			if (Room == null)
			{
				return;
			}

			this.GetResponse().Init(Outgoing.RoomDataMessageComposer);
			this.GetResponse().AppendBoolean(show);
			this.GetResponse().AppendUInt(Room.RoomId);
			this.GetResponse().AppendString(Room.Name);
			this.GetResponse().AppendBoolean(Room.Type == "private");
			this.GetResponse().AppendInt32(Room.OwnerId);
			this.GetResponse().AppendString(Room.Owner);
			this.GetResponse().AppendInt32(Room.State);
			this.GetResponse().AppendInt32(Room.UsersNow);
			this.GetResponse().AppendInt32(Room.UsersMax);
			this.GetResponse().AppendString(Room.Description);
			this.GetResponse().AppendInt32(Room.TradeState);
			this.GetResponse().AppendInt32(Room.Score);
			this.GetResponse().AppendInt32(0);
            this.GetResponse().AppendInt32(0);
			this.GetResponse().AppendInt32(Room.Category);

			if (Room.GroupId > 0 && Room.Group != null)
			{
				this.GetResponse().AppendUInt(Room.Group.Id);
				this.GetResponse().AppendString(Room.Group.Name);
				this.GetResponse().AppendString(Room.Group.Badge);
				this.Response.AppendString("");
			}
			else
			{
				this.GetResponse().AppendInt32(0);
				this.GetResponse().AppendString("");
				this.GetResponse().AppendString("");
				this.GetResponse().AppendString("");
			}
			this.GetResponse().AppendInt32(Room.TagCount);
			object[] array = Room.Tags.ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				string s = (string)array[i];
				this.GetResponse().AppendString(s);
			}
			this.GetResponse().AppendInt32(0);
			this.GetResponse().AppendInt32(0);
			this.GetResponse().AppendInt32(0);
			this.GetResponse().AppendBoolean(Room.AllowPets == 1);
			this.GetResponse().AppendBoolean(Room.AllowPetsEating == 1);
			this.GetResponse().AppendString("");
			this.GetResponse().AppendString("");
			this.GetResponse().AppendInt32(0);
			this.GetResponse().AppendBoolean(Room.RoomId != this.Session.GetHabbo().CurrentRoomId);
            this.GetResponse().AppendBoolean(false);
			this.GetResponse().AppendBoolean(false);
			this.GetResponse().AppendBoolean(false);
			this.GetResponse().AppendInt32(Room.WhoCanMute);
			this.GetResponse().AppendInt32(Room.WhoCanKick);
			this.GetResponse().AppendInt32(Room.WhoCanBan);
			this.GetResponse().AppendBoolean(Room.CheckRights(this.Session, true, false));
			this.GetResponse().AppendInt32(Room.ChatType);
			this.GetResponse().AppendInt32(Room.ChatBalloon);
			this.GetResponse().AppendInt32(Room.ChatSpeed);
			this.GetResponse().AppendInt32(Room.ChatMaxDistance);
			this.GetResponse().AppendInt32(Room.ChatFloodProtection);
			this.SendResponse();
			if (Room.Group == null)
			{
				DataTable table;
				using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
				{
					queryreactor.setQuery("SELECT user_id FROM room_rights WHERE room_id=" + Room.RoomId);
					table = queryreactor.getTable();
				}
				this.Response.Init(Outgoing.LoadRoomRightsListMessageComposer);
				this.GetResponse().AppendUInt(Room.RoomData.Id);
				this.GetResponse().AppendInt32(table.Rows.Count);
				foreach (DataRow dataRow in table.Rows)
				{
					Habbo habboForId = CyberEnvironment.getHabboForId((uint)dataRow[0]);
					if (habboForId != null)
					{
						this.GetResponse().AppendUInt(habboForId.Id);
						this.GetResponse().AppendString(habboForId.Username);
					}
				}
				this.SendResponse();
			}
		}
		internal ServerMessage SerializeRoomChatOption(Room room)
		{
			ServerMessage serverMessage = new ServerMessage(Outgoing.RoomChatOptionsMessageComposer);
			serverMessage.AppendInt32(room.ChatType);
			serverMessage.AppendInt32(room.ChatBalloon);
			serverMessage.AppendInt32(room.ChatSpeed);
			serverMessage.AppendInt32(room.ChatMaxDistance);
			serverMessage.AppendInt32(room.ChatFloodProtection);
			return serverMessage;
		}
		internal ServerMessage RoomFloorAndWallComposer(Room room)
		{
			ServerMessage serverMessage = new ServerMessage(Outgoing.RoomFloorWallLevelsMessageComposer);
			serverMessage.AppendBoolean(room.Hidewall == 1);
			serverMessage.AppendInt32(room.WallThickness);
			serverMessage.AppendInt32(room.FloorThickness);
			return serverMessage;
		}
		internal void PrepareRoomForUser(uint Id, string Password)
		{
			this.ClearRoomLoading();
			QueuedServerMessage queuedServerMessage = new QueuedServerMessage(this.Session.GetConnection());
			if (this.Session == null)
			{
				return;
			}
			if (CyberEnvironment.ShutdownStarted)
			{
				this.Session.SendNotif("The server is shutting down. What are you doing?");
				return;
			}
			if (this.Session.GetHabbo().InRoom)
			{
				Room room = CyberEnvironment.GetGame().GetRoomManager().GetRoom(this.Session.GetHabbo().CurrentRoomId);
				if (room != null && room.GetRoomUserManager() != null)
				{
					room.GetRoomUserManager().RemoveUserFromRoom(this.Session, false, false);
				}
			}
			Room room2 = CyberEnvironment.GetGame().GetRoomManager().LoadRoom(Id);
			if (room2 == null)
			{
				return;
			}

			if (room2.UserCount >= room2.UsersMax && !this.Session.GetHabbo().HasFuse("fuse_enter_full_rooms") && (ulong)this.Session.GetHabbo().Id != (ulong)((long)room2.OwnerId))
			{
				ServerMessage serverMessage = new ServerMessage(Outgoing.RoomEnterErrorMessageComposer);
				serverMessage.AppendInt32(1);
				this.Session.SendMessage(serverMessage);
				ServerMessage message = new ServerMessage(Outgoing.OutOfRoomMessageComposer);
				this.Session.SendMessage(message);
				return;
			}
			if (room2 == null || this.Session == null || this.Session.GetHabbo() == null)
			{
				return;
			}
			if (this.Session.GetHabbo().IsTeleporting && this.Session.GetHabbo().TeleportingRoomID != Id)
			{
				return;
			}
			this.Session.GetHabbo().LoadingRoom = Id;
			this.CurrentLoadingRoom = room2;
			if (!this.Session.GetHabbo().HasFuse("fuse_enter_any_room") && room2.UserIsBanned(this.Session.GetHabbo().Id))
			{
				if (!room2.HasBanExpired(this.Session.GetHabbo().Id))
				{
					ServerMessage serverMessage2 = new ServerMessage(Outgoing.RoomEnterErrorMessageComposer);
					serverMessage2.AppendInt32(4);
					this.Session.SendMessage(serverMessage2);
					this.Response.Init(Outgoing.OutOfRoomMessageComposer);
					queuedServerMessage.appendResponse(this.GetResponse());
					queuedServerMessage.sendResponse();
					return;
				}
				room2.RemoveBan(this.Session.GetHabbo().Id);
			}
			this.Response.Init(Outgoing.PrepareRoomMessageComposer);
			queuedServerMessage.appendResponse(this.GetResponse());
			if (!this.Session.GetHabbo().HasFuse("fuse_enter_any_room") && !room2.CheckRights(this.Session, true, false) && !this.Session.GetHabbo().IsTeleporting && !this.Session.GetHabbo().IsHopping)
			{
				if (room2.State == 1)
				{
					if (room2.UserCount == 0)
					{
						this.Response.Init(Outgoing.DoorbellNoOneMessageComposer);
						queuedServerMessage.appendResponse(this.GetResponse());
					}
					else
					{
						this.Response.Init(Outgoing.DoorbellMessageComposer);
						this.Response.AppendString("");
						queuedServerMessage.appendResponse(this.GetResponse());
						ServerMessage serverMessage3 = new ServerMessage(Outgoing.DoorbellMessageComposer);
						serverMessage3.AppendString(this.Session.GetHabbo().Username);
						room2.SendMessageToUsersWithRights(serverMessage3);
					}
					queuedServerMessage.sendResponse();
					return;
				}
				if (room2.State == 2 && Password.ToLower() != room2.Password.ToLower())
				{
					this.Response.Init(Outgoing.OutOfRoomMessageComposer);
					queuedServerMessage.appendResponse(this.GetResponse());
					queuedServerMessage.sendResponse();
					return;
				}
			}
			this.Session.GetHabbo().LoadingChecksPassed = true;
			queuedServerMessage.addBytes(this.LoadRoomForUser().getPacket);
			queuedServerMessage.sendResponse();
			if (this.Session.GetHabbo().RecentlyVisitedRooms.Contains(room2.RoomId))
			{
                this.Session.GetHabbo().RecentlyVisitedRooms.Remove(room2.RoomId);
			}
            this.Session.GetHabbo().RecentlyVisitedRooms.Add(room2.RoomId);
		}
Esempio n. 20
0
 internal void Destroy()
 {
     this.room = null;
     this.usersByUsername.Clear();
     this.usersByUsername = null;
     this.usersByUserID.Clear();
     this.usersByUserID = null;
     this.OnUserEnter = null;
     this.pets.Clear();
     this.bots.Clear();
     this.pets = null;
     this.bots = null;
     this.userlist.Destroy();
     this.userlist = null;
 }
Esempio n. 21
0
		internal Room LoadRoom(uint Id)
		{
			if (this.IsRoomLoaded(Id))
			{
				return this.GetRoom(Id);
			}
			RoomData roomData = this.GenerateRoomData(Id);
			if (roomData == null)
			{
				return null;
			}
			Room room = new Room(roomData);
            Logging.WriteLine("[RoomMgr] Room #[" + Id + "] was loaded.", ConsoleColor.Blue);
			lock (this.roomsToAddQueue.SyncRoot)
			{
				this.roomsToAddQueue.Enqueue(room);
			}
			room.InitBots();
			room.InitPets();
			return room;
		}
Esempio n. 22
0
		internal void Destroy()
		{
			if (this.banzaiTeleports != null)
			{
				this.banzaiTeleports.Destroy();
			}
			if (this.banzaiPyramids != null)
			{
				this.banzaiPyramids.Clear();
			}
			this.banzaiPyramids = null;
			this.banzaiTeleports = null;
			this.room = null;
			this.rnd = null;
		}
Esempio n. 23
0
 internal void Destroy()
 {
     this.userMap.Clear();
     this.mDynamicModel.Destroy();
     this.mCoordinatedItems.Clear();
     Array.Clear(this.mGameMap, 0, this.mGameMap.Length);
     Array.Clear(this.mUserItemEffect, 0, this.mUserItemEffect.Length);
     Array.Clear(this.mItemHeightMap, 0, this.mItemHeightMap.Length);
     this.userMap = null;
     this.mGameMap = null;
     this.mUserItemEffect = null;
     this.mItemHeightMap = null;
     this.mCoordinatedItems = null;
     this.mDynamicModel = null;
     this.room = null;
     this.mStaticModel = null;
 }
Esempio n. 24
0
		internal void UnloadRoom(Room Room)
		{
			if (Room == null)
			{
				return;
			}

            if (CyberEnvironment.GetGame().GetNavigator().PrivateCategories.Contains(Room.Category))
            {
                ((FlatCat)CyberEnvironment.GetGame().GetNavigator().PrivateCategories[Room.Category]).removeUsers(Room.UserCount);
            }
            Room.UsersNow = 0;
            
			StringBuilder stringBuilder = new StringBuilder();
			checked
			{
				for (int i = 0; i < Room.TagCount; i++)
				{
					if (i > 0)
					{
						stringBuilder.Append(",");
					}
					stringBuilder.Append(Room.Tags[i]);
				}
				string text = "open";
				if (Room.State == 1)
				{
					text = "locked";
				}
				else
				{
					if (Room.State > 1)
					{
						text = "password";
					}
				}
				using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
				{
					queryreactor.setQuery(string.Concat(new object[]
					{
						"UPDATE rooms SET caption = @caption, description = @description, password = @password, category = ",
						Room.Category,
						", state = '",
						text,
						"', tags = @tags, users_now = '0', users_max = ",
						Room.UsersMax,
						", allow_pets = '",
						Room.AllowPets,
						"', allow_pets_eat = '",
						Room.AllowPetsEating,
						"', allow_walkthrough = '",
						Room.AllowWalkthrough,
						"', allow_hidewall = '",
						Room.Hidewall,
						"', floorthick = ",
						Room.FloorThickness,
						", wallthick = ",
						Room.WallThickness,
						", mute_settings='",
						Room.WhoCanMute,
						"', kick_settings='",
						Room.WhoCanKick,
						"',ban_settings='",
						Room.WhoCanBan,
						"', walls_height = '", Room.WallHeight, "', chat_type = @chat_t,chat_balloon = @chat_b,chat_speed = @chat_s,chat_max_distance = @chat_m,chat_flood_protection = @chat_f WHERE id = ",
						Room.RoomId
					}));
					queryreactor.addParameter("caption", Room.Name);
					queryreactor.addParameter("description", Room.Description);
					queryreactor.addParameter("password", Room.Password);
					queryreactor.addParameter("tags", stringBuilder.ToString());
					queryreactor.addParameter("chat_t", Room.ChatType);
					queryreactor.addParameter("chat_b", Room.ChatBalloon);
					queryreactor.addParameter("chat_s", Room.ChatSpeed);
					queryreactor.addParameter("chat_m", Room.ChatMaxDistance);
					queryreactor.addParameter("chat_f", Room.ChatFloodProtection);
					queryreactor.runQuery();
				}
				lock (this.roomsToRemoveQueue.SyncRoot)
				{
					this.roomsToRemoveQueue.Enqueue(Room.RoomId);
				}
                Logging.WriteLine("[RoomMgr] Room #[" + Room.RoomId + "] was unloaded.", ConsoleColor.DarkYellow);
				foreach (RoomUser current in Room.GetRoomUserManager().UserList.Values)
				{
					if (current.IsPet)
					{
						using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
						{
							queryreactor2.setQuery("UPDATE bots SET x=@x, y=@y, z=@z WHERE id=@id LIMIT 1;");
							queryreactor2.addParameter("x", current.X);
							queryreactor2.addParameter("y", current.Y);
							queryreactor2.addParameter("z", current.Z);
							queryreactor2.addParameter("id", current.PetData.PetId);
							queryreactor2.runQuery();
							goto IL_4AA;
						}
					}
					goto IL_38A;
					IL_4AA:
					Room.GetRoomUserManager().RemoveRoomUser(current);
					continue;
					IL_38A:
					if (current.IsBot)
					{
						using (IQueryAdapter queryreactor3 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
						{
							queryreactor3.setQuery("UPDATE bots SET x=@x, y=@y, z=@z, name=@name, motto=@motto, look=@look, rotation=@rotation, dance=@dance WHERE id=@id LIMIT 1;");
							queryreactor3.addParameter("name", current.BotData.Name);
							queryreactor3.addParameter("motto", current.BotData.Motto);
							queryreactor3.addParameter("look", current.BotData.Look);
							queryreactor3.addParameter("rotation", current.BotData.Rot);
							queryreactor3.addParameter("dance", current.BotData.DanceId);
							queryreactor3.addParameter("x", current.X);
							queryreactor3.addParameter("y", current.Y);
							queryreactor3.addParameter("z", current.Z);
							queryreactor3.addParameter("id", current.BotData.BotId);
							queryreactor3.runQuery();
						}
						goto IL_4AA;
					}
					goto IL_4AA;
				}
                lock (Room.RoomChat)
                {
                    foreach (Chatlog current2 in Room.RoomChat)
                    {
                        current2.Save(Room.RoomId);
                    }
                }
				Room.Destroy();
			}
		}
		internal void PlantMonsterplant(RoomItem Mopla, Room Room)
		{
			if (Room == null)
			{
				return;
			}
			if (Mopla == null)
			{
				return;
			}
			if (Mopla.GetBaseItem().InteractionType != InteractionType.moplaseed)
			{
				return;
			}
			int rarity = int.Parse(Mopla.ExtraData);
			int getX = Mopla.GetX;
			int getY = Mopla.GetY;
			Room.GetRoomItemHandler().RemoveFurniture(this.Session, Mopla.Id, false);
			Pet pet = Catalog.CreatePet(this.Session.GetHabbo().Id, "Monsterplant", 16, "0", "0", rarity);
			this.Response.Init(Outgoing.SendMonsterplantIdMessageComposer);
			this.Response.AppendUInt(pet.PetId);
			this.SendResponse();
			using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
			{
				queryreactor.runFastQuery(string.Concat(new object[]
				{
					"UPDATE bots SET room_id = '",
					Room.RoomId,
					"', x = '",
					getX,
					"', y = '",
					getY,
					"' WHERE id = '",
					pet.PetId,
					"'"
				}));
			}
			pet.PlacedInRoom = true;
			pet.RoomId = Room.RoomId;
			List<RandomSpeech> list = new List<RandomSpeech>();
			List<BotResponse> list2 = new List<BotResponse>();
			RoomBot bot = new RoomBot(pet.PetId, pet.OwnerId, pet.RoomId, AIType.Pet, "freeroam", pet.Name, "", pet.Look, getX, getY, 0.0, 4, 0, 0, 0, 0, ref list, ref list2, "", 0, false);
			Room.GetRoomUserManager().DeployBot(bot, pet);

			if (pet.DBState != DatabaseUpdateState.NeedsInsert)
			{
				pet.DBState = DatabaseUpdateState.NeedsUpdate;
			}

			using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
			{
                queryreactor2.runFastQuery("DELETE FROM items WHERE id = " + Mopla.Id);
				Room.GetRoomUserManager().SavePets(queryreactor2);
			}
		}
		internal void PromoteRoom()
		{
			int pageId = this.Request.PopWiredInt32();
			int item = this.Request.PopWiredInt32();

			CatalogPage page2 = CyberEnvironment.GetGame().GetCatalog().GetPage(pageId);
			if (page2 == null)
			{
				return;
			}
            CatalogItem catalogItem = page2.GetItem(item);

			if (catalogItem == null)
			{
				return;
			}

			uint num = this.Request.PopWiredUInt();
			string text = this.Request.PopFixedString();
			this.Request.PopWiredBoolean();

            string text2 = "";
            try
            {
                text2 = this.Request.PopFixedString();
            }
            catch (Exception) { }

			Room room = CyberEnvironment.GetGame().GetRoomManager().GetRoom(num);
			if (room == null)
			{
				RoomData roomData = CyberEnvironment.GetGame().GetRoomManager().GenerateRoomData(num);
				if (roomData == null)
				{
					return;
				}
				room = new Room(roomData);
			}

            if (!room.CheckRights(Session, true))
                return;

			checked
			{
				if (catalogItem.CreditsCost > 0)
				{
					if (catalogItem.CreditsCost > this.Session.GetHabbo().Credits)
					{
						return;
					}
					this.Session.GetHabbo().Credits -= catalogItem.CreditsCost;
					this.Session.GetHabbo().UpdateCreditsBalance();
				}
				if (catalogItem.DucketsCost > 0)
				{
					if (catalogItem.DucketsCost > this.Session.GetHabbo().ActivityPoints)
					{
						return;
					}
					this.Session.GetHabbo().ActivityPoints -= catalogItem.DucketsCost;
					this.Session.GetHabbo().UpdateActivityPointsBalance();
				}
				if (catalogItem.BelCreditsCost > 0 || catalogItem.LoyaltyCost > 0)
				{
					if (catalogItem.BelCreditsCost > this.Session.GetHabbo().BelCredits)
					{
						return;
					}
					this.Session.GetHabbo().BelCredits -= catalogItem.BelCreditsCost;
					this.Session.GetHabbo().UpdateSeasonalCurrencyBalance();
				}
                this.Session.SendMessage(CatalogPacket.PurchaseOK());

				if (room.Event != null && !room.Event.HasExpired)
				{
					room.Event.Time = CyberEnvironment.GetUnixTimestamp();
					CyberEnvironment.GetGame().GetRoomEvents().SerializeEventInfo(room.RoomId);
				}
				else
				{
					CyberEnvironment.GetGame().GetRoomEvents().AddNewEvent(room.RoomId, text, text2, this.Session, 7200);
					CyberEnvironment.GetGame().GetRoomEvents().SerializeEventInfo(room.RoomId);
				}
				this.Session.GetHabbo().GetBadgeComponent().GiveBadge("RADZZ", true, this.Session, false);
			}
		}
Esempio n. 27
0
		internal void Destroy()
		{
			this.mFloorItems.Clear();
			this.mWallItems.Clear();
			this.mRemovedItems.Clear();
			this.mMovedItems.Clear();
			this.mAddedItems.Clear();
			this.roomItemUpdateQueue.Clear();
			this.room = null;
			this.mFloorItems = null;
			this.mWallItems = null;
			this.mRemovedItems = null;
			this.mMovedItems = null;
			this.mAddedItems = null;
			this.mWallItems = null;
			this.roomItemUpdateQueue = null;
		}