Code:
internal void LoadFurniture() {
//this.Items.Clear();
this.mFloorItems.Clear();
this.mWallItems.Clear();
DataTable Data;
using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
{
dbClient.setQuery("SELECT `items`.* , COALESCE(`items_groups`.`group_id`, 0) AS group_id FROM `items` LEFT OUTER JOIN `items_groups` ON `items`.`id` = `items_groups`.`id` WHERE items.room_id=@roomid LIMIT 2000");
dbClient.addParameter("roomid", room.RoomId);
Data = dbClient.getTable();
if (Data.Rows.Count == 2000)
{
GameClient Client = SilverwaveEnvironment.GetGame().GetClientManager().GetClientByUserID((uint)room.OwnerId);
if (Client != null)
Client.SendNotif("Your room has more than 2000 items in it. The current limit of items per room is 2000.\n" +
"To view the rest, pick some of these items up!");
}
uint itemID;
int x;
int y;
Double z;
sbyte n;
uint baseID;
string extradata;
string wallposs;
uint UserId;
uint groupid;
int limitedNo;
int limitedTot;
foreach (DataRow dRow in Data.Rows)
{
try
{
itemID = Convert.ToUInt32(dRow[0]);
x = Convert.ToInt32(dRow[5]);
y = Convert.ToInt32(dRow[6]);
z = Convert.ToDouble(dRow[7]);
n = Convert.ToSByte(dRow[8]);
groupid = Convert.ToUInt32(dRow[13]);
limitedNo = Convert.ToInt32(dRow[11]);
limitedTot = Convert.ToInt32(dRow[12]);
UserId = Convert.ToUInt32(dRow[1]);
if (UserId == 0)
{
dbClient.setQuery("UPDATE items SET user_id=@userid WHERE id=@itemID LIMIT 1");
dbClient.addParameter("itemID", itemID);
dbClient.addParameter("userid", room.OwnerId);
dbClient.runQuery();
}
if (string.IsNullOrWhiteSpace(dRow[9].ToString()))
{
dbClient.setQuery("SELECT type FROM furniture WHERE id=" + dRow[3] + " LIMIT 1");
string thing = dbClient.getString();
if (thing == "i")
{
wallposs = ":w=0,2 l=11,53 l";
dbClient.runFastQuery("UPDATE items SET wall_pos='" + wallposs + "' WHERE id=" + itemID + " LIMIT 1");
}
}
//if (Item.IsWallItem && string.IsNullOrWhiteSpace(dRow[9].ToString()))
//{
// wallposs = ":w=0,2 l=11,53 l";
//}
//else
{
wallposs = Convert.ToString(dRow[9]);
}
baseID = Convert.ToUInt32(dRow[3]);
if (DBNull.Value.Equals(dRow[4]))
extradata = string.Empty;
else
extradata = (string)dRow[4];
//groupid = Convert.ToUInt32(dRow[11]);
//if ((room.GetRoomItemHandler().mFloorItems.Values.Count + room.GetRoomItemHandler().mWallItems.Values.Count) < 3000)
{
if (!string.IsNullOrWhiteSpace(wallposs) && wallposs != "0") // Is wallitem
{
string WallPossition = WallPositionCheck(":" + wallposs.Split(':')[1]);
RoomItem item = new RoomItem(itemID, room.RoomId, baseID, extradata, WallPossition, room, UserId, groupid, SilverwaveEnvironment.GetGame().GetItemManager().GetItem(baseID).FlatId, limitedNo, limitedTot);
if (!mWallItems.ContainsKey(itemID))
mWallItems.Inner.Add(itemID, item);
}
else //Is flooritem
{
RoomItem item = new RoomItem(itemID, room.RoomId, baseID, extradata, x, y, (double)z, n, room, UserId, groupid, SilverwaveEnvironment.GetGame().GetItemManager().GetItem(baseID).FlatId, limitedNo, limitedTot);
if (!room.GetGameMap().ValidTile(x, y))
{
GameClient Client = SilverwaveEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
if (Client != null)
{
Client.GetHabbo().GetInventoryComponent().AddNewItem(item.Id, item.BaseItem, item.ExtraData, groupid, true, true, 0, 0, 0);
dbClient.runFastQuery("UPDATE items SET room_id='0' WHERE id='" + item.Id + "' LIMIT 1");
Client.GetHabbo().GetInventoryComponent().UpdateItems(true);
}
else
{
dbClient.runFastQuery("UPDATE items SET room_id='0' WHERE id='" + item.Id + "' LIMIT 1");
}
continue;
}
if (item.GetBaseItem().InteractionType == InteractionType.jukebox)
JukeBoxCount++;
if (item.GetBaseItem().InteractionType == InteractionType.hopper)
HopperCount++;
if (!mFloorItems.ContainsKey(itemID))
mFloorItems.Inner.Add(itemID, item);
if (item.IsWired)
{
room.GetWiredHandler().LoadWired(room.GetWiredHandler().GenerateNewItem(item));
}
}
}
/*else
{
RoomItem Item;
GameClient Client = SilverwaveEnvironment.GetGame().GetClientManager().GetClientByUserID(UserId);
if (Client != null)
{
if (!string.IsNullOrWhiteSpace(wallposs)) // Is wallitem
{
string WallPossition = WallPositionCheck(":" + wallposs.Split(':')[1]);
Item = new RoomItem(itemID, room.RoomId, baseID, extradata, WallPossition, room, UserId);
}
else
Item = new RoomItem(itemID, room.RoomId, baseID, extradata, x, y, (double)z, n, room, UserId);
Client.GetHabbo().GetInventoryComponent().AddNewItem(Item.Id, Item.BaseItem, Item.ExtraData, true, true, 0);
dbClient.runFastQuery("UPDATE items SET room_id='' WHERE id='" + Item.Id + "' LIMIT 1");
Client.GetHabbo().GetInventoryComponent().UpdateItems(true);
}
else
{
if (!string.IsNullOrWhiteSpace(wallposs)) // Is wallitem
{
string WallPossition = WallPositionCheck(":" + wallposs.Split(':')[1]);
Item = new RoomItem(itemID, room.RoomId, baseID, extradata, WallPossition, room, UserId);
}
else
Item = new RoomItem(itemID, room.RoomId, baseID, extradata, x, y, (double)z, n, room, UserId);
dbClient.runFastQuery("UPDATE items SET room_id='' WHERE id='" + Item.Id + "' LIMIT 1");
}
continue;
}*/
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
foreach (RoomItem Item in mFloorItems.Values)
{
if (Item.IsRoller)
mGotRollers = true;
else if (Item.GetBaseItem().InteractionType == Silverwave.HabboHotel.Items.InteractionType.dimmer)
{
if (room.MoodlightData == null)
room.MoodlightData = new MoodlightData(Item.Id);
}
else if (Item.GetBaseItem().InteractionType == Silverwave.HabboHotel.Items.InteractionType.roombg)
{
if (room.TonerData == null)
room.TonerData = new TonerData(Item.Id);
}
}
}
room.GetWiredHandler().ReloadTimers();
}