internal void SerializeFloor(ServerMessage Message, Boolean Inventory) { Message.AppendUInt(Id); Message.AppendString(mBaseItem.Type.ToString().ToUpper()); Message.AppendUInt(Id); Message.AppendInt32(GetBaseItem().SpriteId); Message.AppendInt32(Extra); // extra Message.AppendInt32(Data.GetTypeID()); Data.AppendToMessage(Message); Message.AppendBoolean(GetBaseItem().AllowRecycle); Message.AppendBoolean(GetBaseItem().AllowTrade); Message.AppendBoolean(GetBaseItem().AllowInventoryStack); Message.AppendBoolean(Marketplace.CanSellItem(this)); Message.AppendInt32(-1); Message.AppendString(""); Message.AppendInt32(0); }
internal void Serialize(ServerMessage Message, int UserId) { // int // int // int // int // int // string // int (extra) // int data type (0,1,2,3,4) ( // 0 = (StringData?) - string // 1 = (MapStuffData) - int i, foreach i { string, string } // 2 = (StringArrayStuffData) - int i, foreach i { string } // 3 = (?) - string, int // 4 = not implemented? // ---data // int // int // int // int // if type < 0, string if (IsFloorItem) { Message.AppendUInt(Id); Message.AppendInt32(GetBaseItem().SpriteId); // type Message.AppendInt32(mX); // x Message.AppendInt32(mY); // y Message.AppendInt32(Rot); // dir Message.AppendString(String.Format("{0:0.00}", TextHandling.GetString(mZ))); // z Message.AppendInt32(Extra); // extra Message.AppendInt32(data.GetTypeID()); // data type data.AppendToMessage(Message); //if (this.GetBaseItem().InteractionType == InteractionType.gift) //{ // int result = 0; // if (ExtraData.Contains(Convert.ToChar(5).ToString())) // { // int color = int.Parse(ExtraData.Split((char)5)[1]); // int lazo = int.Parse(ExtraData.Split((char)5)[2]); // result = color * 1000 + lazo; // } // Message.AppendInt32(result); // if (this.ExtraData.Contains(Convert.ToChar(5).ToString())) // { // uint PurchaserId = (uint)int.Parse(ExtraData.Split(';')[0]); // Habbo Purchaser = FirewindEnvironment.getHabboForId(PurchaserId); // if (Purchaser != null) // { // // "MESSAGE", "PRODUCT_CODE", "EXTRA_PARAM", "PURCHASER_NAME", "PURCHASER_FIGURE"; // Message.AppendInt32(1); // Message.AppendInt32(6); // Message.AppendString("EXTRA_PARAM"); // Message.AppendString(""); // Message.AppendString("MESSAGE"); // Message.AppendString(ExtraData.Split(';')[1].Split((char)5)[0]); // Message.AppendString("PURCHASER_NAME"); // Message.AppendString(Purchaser.Username); // Message.AppendString("PURCHASER_FIGURE"); // Message.AppendString(Purchaser.Look); // Message.AppendString("PRODUCT_CODE"); // Message.AppendString(""); // Message.AppendString("state"); // Message.AppendString(MagicRemove ? "1" : "0"); // } // else // { // Message.AppendInt32(0); // } // } // // this.ExtraData.Contains(Convert.ToChar(5).ToString()) ? ExtraData.Split((char)5)[1] : "0" // else // Message.AppendInt32(0); //} //else //{ // Message.AppendInt32(0); // Message.AppendInt32(0); // if (GetBaseItem().InteractionType != InteractionType.fbgate) // Message.AppendString(ExtraData); // else // Message.AppendString(string.Empty); //} Message.AppendInt32(-1); Message.AppendInt32(1); // Type New R63 ('use bottom') Message.AppendInt32(UserId); } else if (IsWallItem) { Message.AppendString(Id + String.Empty); Message.AppendInt32(GetBaseItem().SpriteId); Message.AppendString(wallCoord.ToString()); switch (GetBaseItem().InteractionType) { case InteractionType.postit: Message.AppendString(data.GetData().ToString().Split(' ')[0]); break; default: Message.AppendString(data.ToString()); break; } Message.AppendInt32(1); // Type New R63 ('use bottom') Message.AppendInt32(UserId); if (data.GetType() != typeof(StringData)) { Logging.LogException(string.Format("Strange wallitem, {2}, {3}, {0}, \"{1}\"", Id, data.ToString(), GetBaseItem().Name, GetBaseItem().Type)); using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) dbClient.runFastQuery(string.Format("DELETE FROM items_extradata WHERE item_id = {0}", Id)); } } }
internal UserItem AddNewItem(UInt32 Id, UInt32 BaseItem, IRoomItemData data, int extra, bool insert, bool fromRoom, UInt32 songID = 0) { isUpdated = false; if (insert) { if (fromRoom) { using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("REPLACE INTO items_users VALUES (" + Id + "," + UserId + ")"); //dbClient.setQuery("REPLACE INTO user_items (id, user_id,base_item,extra_data) VALUES ('" + Id + "','" + UserId + "','" + BaseItem + "',@extra_data)"); //dbClient.addParameter("extra_data", ExtraData); //dbClient.runQuery(); } Item baseItem = FirewindEnvironment.GetGame().GetItemManager().GetItem(BaseItem); if (baseItem != null && baseItem.InteractionType == InteractionType.musicdisc) { using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("DELETE FROM items_rooms_songs WHERE item_id = " + Id); //dbClient.runFastQuery("REPLACE INTO user_items_songs (item_id,user_id,song_id) VALUES (" + Id + "," + UserId + "," + songID + ")"); } } } else { using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("INSERT INTO items (base_id) VALUES (" + BaseItem + ")"); Id = (uint)dbClient.insertQuery(); //if (!string.IsNullOrEmpty(ExtraData)) { dbClient.setQuery("INSERT INTO items_extradata VALUES (" + Id + ",@datatype,@data,@extra)"); dbClient.addParameter("datatype", data.GetTypeID()); dbClient.addParameter("data", data); dbClient.addParameter("extra", extra); dbClient.runQuery(); } dbClient.runFastQuery("INSERT INTO items_users VALUES (" + Id + "," + UserId + ")"); //dbClient.setQuery("INSERT INTO user_items (user_id,base_item,extra_data) VALUES ('" + UserId + "','" + BaseItem + "',@extra_data)"); //dbClient.addParameter("extra_data", ExtraData); //Id = (uint)dbClient.insertQuery(); } } } UserItem ItemToAdd = new UserItem(Id, BaseItem, data, extra); if (UserHoldsItem(Id)) { RemoveItem(Id, false); } if (ItemToAdd.GetBaseItem().InteractionType == InteractionType.musicdisc) discs.Add(ItemToAdd.Id, ItemToAdd); if (ItemToAdd.isWallItem) wallItems.Add(ItemToAdd.Id, ItemToAdd); else floorItems.Add(ItemToAdd.Id, ItemToAdd); if (mRemovedItems.Contains(Id)) mRemovedItems.Remove(Id); if (!mAddedItems.ContainsKey(Id)) mAddedItems.Add(Id, ItemToAdd); return ItemToAdd; //Logging.WriteLine("Item added: " + BaseItem); }
internal UserItem AddNewItem(UInt32 Id, UInt32 BaseItem, IRoomItemData data, int extra, bool insert, bool fromRoom, UInt32 songID = 0) { isUpdated = false; if (insert) { if (fromRoom) { using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("REPLACE INTO items_users VALUES (" + Id + "," + UserId + ")"); //dbClient.setQuery("REPLACE INTO user_items (id, user_id,base_item,extra_data) VALUES ('" + Id + "','" + UserId + "','" + BaseItem + "',@extra_data)"); //dbClient.addParameter("extra_data", ExtraData); //dbClient.runQuery(); } Item baseItem = FirewindEnvironment.GetGame().GetItemManager().GetItem(BaseItem); if (baseItem != null && baseItem.InteractionType == InteractionType.musicdisc) { using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.runFastQuery("DELETE FROM items_rooms_songs WHERE item_id = " + Id); //dbClient.runFastQuery("REPLACE INTO user_items_songs (item_id,user_id,song_id) VALUES (" + Id + "," + UserId + "," + songID + ")"); } } } else { using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("INSERT INTO items (base_id) VALUES (" + BaseItem + ")"); Id = (uint)dbClient.insertQuery(); //if (!string.IsNullOrEmpty(ExtraData)) { dbClient.setQuery("INSERT INTO items_extradata VALUES (" + Id + ",@datatype,@data,@extra)"); dbClient.addParameter("datatype", data.GetTypeID()); dbClient.addParameter("data", data.ToString()); dbClient.addParameter("extra", extra); dbClient.runQuery(); } dbClient.runFastQuery("INSERT INTO items_users VALUES (" + Id + "," + UserId + ")"); //dbClient.setQuery("INSERT INTO user_items (user_id,base_item,extra_data) VALUES ('" + UserId + "','" + BaseItem + "',@extra_data)"); //dbClient.addParameter("extra_data", ExtraData); //Id = (uint)dbClient.insertQuery(); } } } UserItem ItemToAdd = new UserItem(Id, BaseItem, data, extra); if (UserHoldsItem(Id)) { RemoveItem(Id, false); } if (ItemToAdd.GetBaseItem().InteractionType == InteractionType.musicdisc) { discs.Add(ItemToAdd.Id, ItemToAdd); } if (ItemToAdd.isWallItem) { wallItems.Add(ItemToAdd.Id, ItemToAdd); } else { floorItems.Add(ItemToAdd.Id, ItemToAdd); } if (mRemovedItems.Contains(Id)) { mRemovedItems.Remove(Id); } if (!mAddedItems.ContainsKey(Id)) { mAddedItems.Add(Id, ItemToAdd); } return(ItemToAdd); //Logging.WriteLine("Item added: " + BaseItem); }