Пример #1
0
		public bool PutObjectInBackpack( Item it, int n, Slots at, bool refresh )
		{
			bool put = false;
			if ( at == Slots.None || Items[ (int)at ] != null )
			{
				put = true;
				at = FindAFreeSlot();
			}
			if ( at == Slots.None )
			{
				this.InventoryFailed( 27 );
				return false;
			}
			if ( n == 0 && it.Stackable > 1 )
				it.MaxCount = it.Stackable;
			else
				it.MaxCount = n;
			//	on verifi les quetes en cours pour les deliveries
			CheckDeliveries( it );

			if ( put )
			{
				foreach( Item i in Items )
				{
					if ( i != null && i.Id == it.Id && i.MaxCount + it.MaxCount <= i.Stackable )
					{
						i.MaxCount += n;
						if ( refresh && account != null )
							i.SendTinyUpdate( new int[]{14}, new object[]{ i.MaxCount }, this );
						return true;
					}
				}
			}
			Items[ (int)at ] = it;
			if ( refresh && account != null )
			{
				int offset = 0;
				Converter.ToBytes( 1, tempBuff, ref offset );
				Converter.ToBytes( (byte)0, tempBuff, ref offset );

				it.PrepareUpdateData( tempBuff, ref offset, UpdateType.UpdateFull, this );	
				//ItemsUpdate( tempBuff, ref offset );				

				byte []res = Zip.Compress( tempBuff, 0, offset );
				byte []data = new byte[ res.Length + 8 ];
				Buffer.BlockCopy( res, 0, data, 8, res.Length );
				int t = 4;
				Converter.ToBytes( (int)offset, data, ref t );
				account.Handler.Send( 0x1F6, data, res.Length + 6 );
				ItemsUpdate( new int[] { (int)at } );
			}
			return true;
		}