internal void GenerateMaps(bool checkLines = true) { var maxX = 0; var maxY = 0; mCoordinatedItems = new ConcurrentDictionary <Point, List <int> >(); if (checkLines) { var items = _room.GetRoomItemHandler().GetFloor.ToArray(); foreach (var item in items.ToList()) { if (item == null) { continue; } if (item.GetX > Model.MapSizeX && item.GetX > maxX) { maxX = item.GetX; } if (item.GetY > Model.MapSizeY && item.GetY > maxY) { maxY = item.GetY; } } Array.Clear(items, 0, items.Length); } if (maxY > Model.MapSizeY - 1 || maxX > Model.MapSizeX - 1) { if (maxX < Model.MapSizeX) { maxX = Model.MapSizeX; } if (maxY < Model.MapSizeY) { maxY = Model.MapSizeY; } Model.SetMapsize(maxX + 7, maxY + 7); GenerateMaps(false); return; } if (maxX != StaticModel.MapSizeX || maxY != StaticModel.MapSizeY) { EffectMap = new byte[Model.MapSizeX, Model.MapSizeY]; GameMap = new byte[Model.MapSizeX, Model.MapSizeY]; mItemHeightMap = new double[Model.MapSizeX, Model.MapSizeY]; //if (modelRemap) // Model.Generate(); //Clears model for (var line = 0; line < Model.MapSizeY; line++) { for (var chr = 0; chr < Model.MapSizeX; chr++) { GameMap[chr, line] = 0; EffectMap[chr, line] = 0; if (chr == Model.DoorX && line == Model.DoorY) { GameMap[chr, line] = 3; } else if (Model.SqState[chr, line] == SquareState.OPEN) { GameMap[chr, line] = 1; } else if (Model.SqState[chr, line] == SquareState.SEAT) { GameMap[chr, line] = 2; } else if (Model.SqState[chr, line] == SquareState.POOL) { EffectMap[chr, line] = 6; } } } if (gotPublicPool) { for (var y = 0; y < StaticModel.MapSizeY; y++) { for (var x = 0; x < StaticModel.MapSizeX; x++) { if (StaticModel.mRoomModelfx[x, y] != 0) { EffectMap[x, y] = StaticModel.mRoomModelfx[x, y]; } } } } /** COMENTADO YA QUE SALAS PUBLICAS NUEVA CRYPTO NO NECESARIO * if (!string.IsNullOrEmpty(StaticModel.StaticFurniMap)) * { * foreach (PublicRoomSquare square in StaticModel.Furnis) * { * if (square.Content.Contains("chair") || square.Content.Contains("sofa")) * { * mGameMap[square.X, square.Y] = 1; * } else { * mGameMap[square.X, square.Y] = 0; * } * } * }*/ } else { //mGameMap //mUserItemEffect EffectMap = new byte[Model.MapSizeX, Model.MapSizeY]; GameMap = new byte[Model.MapSizeX, Model.MapSizeY]; mItemHeightMap = new double[Model.MapSizeX, Model.MapSizeY]; //if (modelRemap) // Model.Generate(); //Clears model for (var line = 0; line < Model.MapSizeY; line++) { for (var chr = 0; chr < Model.MapSizeX; chr++) { GameMap[chr, line] = 0; EffectMap[chr, line] = 0; if (chr == Model.DoorX && line == Model.DoorY) { GameMap[chr, line] = 3; } else if (Model.SqState[chr, line] == SquareState.OPEN) { GameMap[chr, line] = 1; } else if (Model.SqState[chr, line] == SquareState.SEAT) { GameMap[chr, line] = 2; } else if (Model.SqState[chr, line] == SquareState.POOL) { EffectMap[chr, line] = 6; } } } if (gotPublicPool) { for (var y = 0; y < StaticModel.MapSizeY; y++) { for (var x = 0; x < StaticModel.MapSizeX; x++) { if (StaticModel.mRoomModelfx[x, y] != 0) { EffectMap[x, y] = StaticModel.mRoomModelfx[x, y]; } } } } } var tmpItems = _room.GetRoomItemHandler().GetFloor.ToArray(); foreach (var Item in tmpItems.ToList()) { if (Item == null) { continue; } if (!AddItemToMap(Item)) { } } Array.Clear(tmpItems, 0, tmpItems.Length); tmpItems = null; if (_room.RoomBlockingEnabled == 0) { foreach (var user in _room.GetRoomUserManager().GetUserList().ToList()) { if (user == null) { continue; } user.SqState = GameMap[user.X, user.Y]; GameMap[user.X, user.Y] = 0; } } try { GameMap[Model.DoorX, Model.DoorY] = 3; } catch { } }
public void GenerateMaps(bool checkLines = true) { int MaxX = 0; int MaxY = 0; _coordinatedItems = new ConcurrentDictionary <Point, List <int> >(); if (checkLines) { Item[] items = _room.GetRoomItemHandler().GetFloor.ToArray(); foreach (Item item in items.ToList()) { if (item == null) { continue; } if (item.GetX > Model.MapSizeX && item.GetX > MaxX) { MaxX = item.GetX; } if (item.GetY > Model.MapSizeY && item.GetY > MaxY) { MaxY = item.GetY; } } Array.Clear(items, 0, items.Length); items = null; } if (MaxY > (Model.MapSizeY - 1) || MaxX > (Model.MapSizeX - 1)) { if (MaxX < Model.MapSizeX) { MaxX = Model.MapSizeX; } if (MaxY < Model.MapSizeY) { MaxY = Model.MapSizeY; } Model.SetMapsize(MaxX + 7, MaxY + 7); GenerateMaps(false); return; } if (MaxX != StaticModel.MapSizeX || MaxY != StaticModel.MapSizeY) { _userItemEffect = new byte[Model.MapSizeX, Model.MapSizeY]; _gameMap = new byte[Model.MapSizeX, Model.MapSizeY]; _itemHeightMap = new double[Model.MapSizeX, Model.MapSizeY]; //if (modelRemap) // Model.Generate(); //Clears model for (int line = 0; line < Model.MapSizeY; line++) { for (int chr = 0; chr < Model.MapSizeX; chr++) { _gameMap[chr, line] = 0; _userItemEffect[chr, line] = 0; if (chr == Model.DoorX && line == Model.DoorY) { _gameMap[chr, line] = 3; } else if (Model.SqState[chr, line] == SquareState.Open) { _gameMap[chr, line] = 1; } else if (Model.SqState[chr, line] == SquareState.Seat) { _gameMap[chr, line] = 2; } else if (Model.SqState[chr, line] == SquareState.Pool) { _userItemEffect[chr, line] = 6; } } } } else { _userItemEffect = new byte[Model.MapSizeX, Model.MapSizeY]; _gameMap = new byte[Model.MapSizeX, Model.MapSizeY]; _itemHeightMap = new double[Model.MapSizeX, Model.MapSizeY]; for (int line = 0; line < Model.MapSizeY; line++) { for (int chr = 0; chr < Model.MapSizeX; chr++) { _gameMap[chr, line] = 0; _userItemEffect[chr, line] = 0; if (chr == Model.DoorX && line == Model.DoorY) { _gameMap[chr, line] = 3; } else if (Model.SqState[chr, line] == SquareState.Open) { _gameMap[chr, line] = 1; } else if (Model.SqState[chr, line] == SquareState.Seat) { _gameMap[chr, line] = 2; } else if (Model.SqState[chr, line] == SquareState.Pool) { _userItemEffect[chr, line] = 6; } } } } Item[] tmpItems = _room.GetRoomItemHandler().GetFloor.ToArray(); foreach (Item Item in tmpItems.ToList()) { if (Item == null) { continue; } if (!AddItemToMap(Item)) { continue; } } Array.Clear(tmpItems, 0, tmpItems.Length); tmpItems = null; if (_room.RoomBlockingEnabled == 0) { foreach (RoomUser user in _room.GetRoomUserManager().GetUserList().ToList()) { if (user == null) { continue; } user.SqState = _gameMap[user.X, user.Y]; _gameMap[user.X, user.Y] = 0; } } try { _gameMap[Model.DoorX, Model.DoorY] = 3; } catch { } }
public void OnChat(int Colour, string Message, bool Shout) { if (GetClient() == null || GetClient().GetHabbo() == null || mRoom == null) { return; } if (mRoom.GetWired().TriggerEvent(Items.Wired.WiredBoxType.TriggerUserSays, GetClient().GetHabbo(), Message)) { return; } GetClient().GetHabbo().HasSpoken = true; if (mRoom.WordFilterList.Count > 0 && !GetClient().GetHabbo().GetPermissions().HasRight("word_filter_override")) { Message = mRoom.GetFilter().CheckMessage(Message); } ServerPacket Packet = null; if (Shout) { Packet = new ShoutComposer(VirtualId, Message, PlusEnvironment.GetGame().GetChatManager().GetEmotions().GetEmotionsForText(Message), Colour); } else { Packet = new ChatComposer(VirtualId, Message, PlusEnvironment.GetGame().GetChatManager().GetEmotions().GetEmotionsForText(Message), Colour); } if (GetClient().GetHabbo().TentId > 0) { mRoom.SendToTent(GetClient().GetHabbo().Id, GetClient().GetHabbo().TentId, Packet); Packet = new WhisperComposer(this.VirtualId, "[Tent Chat] " + Message, 0, Colour); List <RoomUser> ToNotify = mRoom.GetRoomUserManager().GetRoomUserByRank(2); if (ToNotify.Count > 0) { foreach (RoomUser user in ToNotify) { if (user == null || user.GetClient() == null || user.GetClient().GetHabbo() == null || user.GetClient().GetHabbo().TentId == GetClient().GetHabbo().TentId) { continue; } user.GetClient().SendPacket(Packet); } } } else { foreach (RoomUser User in mRoom.GetRoomUserManager().GetRoomUsers().ToList()) { if (User == null || User.GetClient() == null || User.GetClient().GetHabbo() == null || User.GetClient().GetHabbo().GetIgnores().IgnoredUserIds().Contains(mClient.GetHabbo().Id)) { continue; } if (mRoom.ChatDistance > 0 && Gamemap.TileDistance(this.X, this.Y, User.X, User.Y) > mRoom.ChatDistance) { continue; } User.GetClient().SendPacket(Packet); } } #region Pets/Bots responces if (Shout) { foreach (RoomUser User in mRoom.GetRoomUserManager().GetUserList().ToList()) { if (!User.IsBot) { continue; } if (User.IsBot) { User.BotAI.OnUserShout(this, Message); } } } else { foreach (RoomUser User in mRoom.GetRoomUserManager().GetUserList().ToList()) { if (!User.IsBot) { continue; } if (User.IsBot) { User.BotAI.OnUserSay(this, Message); } } } #endregion }
/// <summary> /// Unloads the room. /// </summary> /// <param name="room">The room.</param> /// <param name="reason">The reason.</param> internal void UnloadRoom(Room room, string reason) { if (room == null || room.RoomData == null) { return; } if (room.RoomData.Description.Contains("SPACE")) { spaceManager.initiated = false; } if (room.RoomData.Description.Contains("TREES")) { woodManager.initiated = false; } if (room.RoomData.Description.Contains("FARM")) { farmingManager.initiated = false; } if (room.RoomData.Description.Contains("CASINO")) { SlotsManager.initiated = false; } if (Plus.GetGame().MafiaWars.Started) { if (room.RoomData.Description.Contains("MAFIAWARS")) { return; } } if (room.RoomId == ColourManager.GameLobby && ColourManager.LobbyLoop != null) { ColourManager.LobbyLoop.On = false; ColourManager.LobbyLoop = null; } if (room.RoomData.Description.Contains("MAFIAWARLOBBY") && Plus.GetGame().MafiaWars.LobbyLoop != null) { Plus.GetGame().MafiaWars.LobbyLoop.On = false; Plus.GetGame().MafiaWars.LobbyLoop = null; } if (Plus.GetGame().GetNavigator().PrivateCategories.Contains(room.RoomData.Category)) { ((FlatCat)Plus.GetGame().GetNavigator().PrivateCategories[room.RoomData.Category]).UsersNow -= room.UserCount; } room.RoomData.UsersNow = 0; var state = "open"; if (room.RoomData.State == 1) { state = "locked"; } else if (room.RoomData.State > 1) { state = "password"; } using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery( "UPDATE rooms_data SET caption = @caption, description = @description, password = @password, category = " + room.RoomData.Category + ", state = '" + state + "', tags = @tags, users_now = '0', users_max = " + room.RoomData.UsersMax + ", allow_pets = '" + Plus.BoolToEnum(room.RoomData.AllowPets) + "', allow_pets_eat = '" + Plus.BoolToEnum(room.RoomData.AllowPetsEating) + "', allow_walkthrough = '" + Plus.BoolToEnum(room.RoomData.AllowWalkThrough) + "', hidewall = '" + Plus.BoolToEnum(room.RoomData.HideWall) + "', floorthick = " + room.RoomData.FloorThickness + ", wallthick = " + room.RoomData.WallThickness + ", mute_settings='" + room.RoomData.WhoCanMute + "', kick_settings='" + room.RoomData.WhoCanKick + "',ban_settings='" + room.RoomData.WhoCanBan + "', walls_height = '" + room.RoomData.WallHeight + "', chat_type = @chat_t,chat_balloon = @chat_b,chat_speed = @chat_s,chat_max_distance = @chat_m,chat_flood_protection = @chat_f, trade_state = '" + room.RoomData.TradeState + "' WHERE id = " + room.RoomId); queryReactor.AddParameter("caption", room.RoomData.Name); queryReactor.AddParameter("description", room.RoomData.Description); queryReactor.AddParameter("password", room.RoomData.PassWord); queryReactor.AddParameter("tags", string.Join(",", room.RoomData.Tags)); queryReactor.AddParameter("chat_t", room.RoomData.ChatType); queryReactor.AddParameter("chat_b", room.RoomData.ChatBalloon); queryReactor.AddParameter("chat_s", room.RoomData.ChatSpeed); queryReactor.AddParameter("chat_m", room.RoomData.ChatMaxDistance); queryReactor.AddParameter("chat_f", room.RoomData.ChatFloodProtection); queryReactor.RunQuery(); } Room junkRoom; if (!LoadedRooms.TryRemove(room.RoomId, out junkRoom)) { return; } Out.WriteLine(string.Format("Room '{0}' [{1}] was unloaded! Reason: " + reason, room.RoomData.Name, room.RoomId), "", ConsoleColor.DarkGray); foreach (var current in room.GetRoomUserManager().UserList.Values.Where(current => current != null)) { if (current.IsPet) { using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.SetQuery("UPDATE bots SET x=@x, y=@y, z=@z WHERE id=@id LIMIT 1;"); queryReactor.AddParameter("x", current.X); queryReactor.AddParameter("y", current.Y); queryReactor.AddParameter("z", current.Z); queryReactor.AddParameter("id", current.PetData.PetId); queryReactor.RunQuery(); current.BotAI.Dispose(); } } else if (current.IsBot) { using (var queryReactor = Plus.GetDatabaseManager().GetQueryReactor()) { queryReactor.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;"); queryReactor.AddParameter("name", current.BotData.Name); queryReactor.AddParameter("motto", current.BotData.Motto); queryReactor.AddParameter("look", current.BotData.Look); queryReactor.AddParameter("rotation", current.BotData.Rot); queryReactor.AddParameter("dance", current.BotData.DanceId); queryReactor.AddParameter("x", current.X); queryReactor.AddParameter("y", current.Y); queryReactor.AddParameter("z", current.Z); queryReactor.AddParameter("id", current.BotData.BotId); queryReactor.RunQuery(); } current.BotAI.Dispose(); } else { if (current.GetClient() == null) { continue; } room.GetRoomUserManager().RemoveUserFromRoom(current.GetClient(), true, false); current.GetClient().CurrentRoomUserId = -1; } } lock (room.RoomData.RoomChat) { foreach (Chatlog Chat in room.RoomData.RoomChat) { Chat.Save(room.RoomId); } } room.Destroy(); }