Exemplo n.º 1
0
		public SongItem(UserItem item)
		{
			this.itemID = item.Id;
			this.songID = SongManager.GetSongId(item.SongCode);
			this.baseItem = item.GetBaseItem();
			this.extraData = item.ExtraData;
			this.songCode = item.SongCode;
		}
Exemplo n.º 2
0
		internal UserItem AddNewItem(uint Id, uint BaseItem, string ExtraData, uint Group, bool insert, bool fromRoom, int limno, int limtot, string SongCode = "")
		{
			this.isUpdated = false;
			if (insert)
			{
				if (fromRoom)
				{
					using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
					{
						queryreactor.runFastQuery("UPDATE items SET room_id='0' WHERE id=" + Id + " LIMIT 1");
						goto IL_1C9;
					}
				}
				using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
				{
					queryreactor2.setQuery(string.Concat(new object[]
					{
						"INSERT INTO items (base_item, user_id, group_id) VALUES (",
						BaseItem,
						", ",
						this.UserId,
                        ", ",
                        Group,
						")"
					}));
					Id = checked((uint)queryreactor2.insertQuery());
					this.SendNewItems(Id);

					if (!string.IsNullOrEmpty(ExtraData))
					{
						queryreactor2.setQuery("UPDATE items SET extra_data=@extradata WHERE id=" + Id + " LIMIT 1");
						queryreactor2.addParameter("extradata", ExtraData);
						queryreactor2.runQuery();
					}
					if (limno > 0)
					{
						queryreactor2.runFastQuery(string.Concat(new object[]
						{
							"INSERT INTO items_limited VALUES (",
							Id,
							", ",
							limno,
							", ",
							limtot,
							")"
						}));
					}
					if (!string.IsNullOrEmpty(SongCode))
					{
						queryreactor2.setQuery("UPDATE items SET songcode=@song_code WHERE id=" + Id + " LIMIT 1");
						queryreactor2.addParameter("song_code", SongCode);
						queryreactor2.runQuery();
					}
				}
			}
			IL_1C9:
			UserItem userItem = new UserItem(Id, BaseItem, ExtraData, Group, SongCode);
			if (this.UserHoldsItem(Id))
			{
				this.RemoveItem(Id, false);
			}
			if (userItem.GetBaseItem().InteractionType == InteractionType.musicdisc)
			{
				this.discs.Add(userItem.Id, userItem);
			}
			if (userItem.isWallItem)
			{
				this.wallItems.Add(userItem.Id, userItem);
			}
			else
			{
				this.floorItems.Add(userItem.Id, userItem);
			}
			if (this.mRemovedItems.Contains(Id))
			{
				this.mRemovedItems.Remove(Id);
			}
            if (!this.mAddedItems.Contains(Id))
			{
				this.mAddedItems.Add(Id, userItem);
			}
			return userItem;
		}
Exemplo n.º 3
0
		internal void LoadInventory()
		{
			this.floorItems.Clear();
			this.wallItems.Clear();
			DataTable table;
			using (IQueryAdapter queryreactor = CyberEnvironment.GetDatabaseManager().getQueryReactor())
			{
				queryreactor.setQuery("SELECT * FROM ITEMS WHERE user_id=@userid AND room_id='0' LIMIT 8000;");
				queryreactor.addParameter("userid", checked((int)this.UserId));
				table = queryreactor.getTable();
			}
			foreach (DataRow dataRow in table.Rows)
			{
				uint num = Convert.ToUInt32(dataRow[0]);
				uint baseItem = Convert.ToUInt32(dataRow[3]);
				string extraData;
				if (!DBNull.Value.Equals(dataRow[4]))
				{
					extraData = (string)dataRow[4];
				}
				else
				{
					extraData = string.Empty;
				}
				uint group = Convert.ToUInt32(dataRow[10]);
				string songCode;
				if (!DBNull.Value.Equals(dataRow["songcode"]))
				{
					songCode = (string)dataRow["songcode"];
				}
				else
				{
					songCode = string.Empty;
				}
				UserItem userItem = new UserItem(num, baseItem, extraData, group, songCode);
                if (userItem.GetBaseItem().InteractionType == InteractionType.musicdisc && !this.discs.Contains(num))
				{
					this.discs.Add(num, userItem);
				}
				if (userItem.isWallItem)
				{
					if (!this.wallItems.Contains(num))
					{
						this.wallItems.Add(num, userItem);
					}
				}
				else
				{
                    if (!this.floorItems.Contains(num))
					{
						this.floorItems.Add(num, userItem);
					}
				}
			}
			this.discs.Clear();
			this.InventoryPets.Clear();
			using (IQueryAdapter queryreactor2 = CyberEnvironment.GetDatabaseManager().getQueryReactor())
			{
				queryreactor2.setQuery("SELECT * FROM bots WHERE user_id = " + this.UserId + " AND room_id = 0 AND ai_type='pet'");
				DataTable table2 = queryreactor2.getTable();
				if (table2 != null)
				{
					foreach (DataRow dataRow2 in table2.Rows)
					{
						queryreactor2.setQuery("SELECT * FROM bots_petdata WHERE id=" + dataRow2[0] + " LIMIT 1");
						DataRow row = queryreactor2.getRow();
						if (row != null)
						{
							Pet pet = Catalog.GeneratePetFromRow(dataRow2, row);
							if (this.InventoryPets.ContainsKey(pet.PetId))
							{
								this.InventoryPets.Remove(pet.PetId);
							}
							this.InventoryPets.Add(pet.PetId, pet);
						}
					}
				}
			}
		}
Exemplo n.º 4
0
		internal void OfferItem(uint UserId, UserItem Item)
		{
			TradeUser tradeUser = this.GetTradeUser(UserId);
			if (tradeUser == null || Item == null || !Item.GetBaseItem().AllowTrade || tradeUser.HasAccepted || this.TradeStage != 1)
			{
				return;
			}
			this.ClearAccepted();
			if (!tradeUser.OfferedItems.Contains(Item))
			{
				tradeUser.OfferedItems.Add(Item);
			}
			this.UpdateTradeWindow();
		}
Exemplo n.º 5
0
		internal void TakeBackItem(uint UserId, UserItem Item)
		{
			TradeUser tradeUser = this.GetTradeUser(UserId);
			if (tradeUser == null || Item == null || tradeUser.HasAccepted || this.TradeStage != 1)
			{
				return;
			}
			this.ClearAccepted();
			tradeUser.OfferedItems.Remove(Item);
			this.UpdateTradeWindow();
		}