コード例 #1
0
ファイル: VendorInventory.cs プロジェクト: Argalep/ServUO
            public ExpireTimer(VendorInventory inventory, TimeSpan delay)
                : base(delay)
            {
                m_Inventory = inventory;

                Priority = TimerPriority.OneMinute;
            }
コード例 #2
0
		public virtual void Destroy( bool toBackpack )
		{
			Return();

			if ( !BaseHouse.NewVendorSystem )
				FixDresswear();

			/* Possible cases regarding item return:
			 * 
			 * 1. No item must be returned
			 *       -> do nothing.
			 * 2. ( toBackpack is false OR the vendor is in the internal map ) AND the vendor is associated with a AOS house
			 *       -> put the items into the moving crate or a vendor inventory,
			 *          depending on whether the vendor owner is also the house owner.
			 * 3. ( toBackpack is true OR the vendor isn't associated with any AOS house ) AND the vendor isn't in the internal map
			 *       -> put the items into a backpack.
			 * 4. The vendor isn't associated with any house AND it's in the internal map
			 *       -> do nothing (we can't do anything).
			 */

			ArrayList list = GetItems();

			if ( list.Count > 0 || HoldGold > 0 ) // No case 1
			{
				if ( ( !toBackpack || this.Map == Map.Internal ) && House != null && House.IsAosRules ) // Case 2
				{
					if ( House.IsOwner( Owner ) ) // Move to moving crate
					{
						if ( House.MovingCrate == null )
							House.MovingCrate = new MovingCrate( House );

						if ( HoldGold > 0 )
							Banker.Deposit( House.MovingCrate, HoldGold );

						foreach ( Item item in list )
						{
							House.MovingCrate.DropItem( item );
						}
					}
					else // Move to vendor inventory
					{
						VendorInventory inventory = new VendorInventory( House, Owner, Name, ShopName );
						inventory.Gold = HoldGold;

						foreach ( Item item in list )
						{
							inventory.AddItem( item );
						}

						House.VendorInventories.Add( inventory );
					}
				}
				else if ( ( toBackpack || House == null || !House.IsAosRules ) && this.Map != Map.Internal ) // Case 3 - Move to backpack
				{
					Container backpack = new Backpack();

					if ( HoldGold > 0 )
						Banker.Deposit( backpack, HoldGold );

					foreach ( Item item in list )
					{
						backpack.DropItem( item );
					}

					backpack.MoveToWorld( this.Location, this.Map );
				}
			}

			Delete();
		}
コード例 #3
0
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
			int count;

			switch ( version )
			{
				case 14:
				{
					m_RelativeBanLocation = reader.ReadPoint3D();
					goto case 13;
				}
				case 13: // removed ban location serialization
				case 12:
				{
					m_VendorRentalContracts = reader.ReadItemList();
					m_InternalizedVendors = reader.ReadMobileList();

					int relocatedCount = reader.ReadEncodedInt();
					for ( int i = 0; i < relocatedCount; i++ )
					{
						Point3D relLocation = reader.ReadPoint3D();
						IEntity entity = World.FindEntity( reader.ReadInt() );

						if ( entity != null )
							m_RelocatedEntities.Add( new RelocatedEntity( entity, relLocation ) );
					}

					int inventoryCount = reader.ReadEncodedInt();
					for ( int i = 0; i < inventoryCount; i++ )
					{
						VendorInventory inventory = new VendorInventory( this, reader );
						m_VendorInventories.Add( inventory );
					}

					goto case 11;
				}
				case 11:
				{
					m_LastRefreshed = reader.ReadDateTime();
					m_RestrictDecay = reader.ReadBool();
					goto case 10;
				}
				case 10: // just a signal for updates
				case 9:
				{
					m_Visits = reader.ReadInt();
					goto case 8;
				}
				case 8:
				{
					m_Price = reader.ReadInt();
					goto case 7;
				}
				case 7:
				{
					m_Access = reader.ReadMobileList();
					goto case 6;
				}
				case 6:
				{
					m_BuiltOn = reader.ReadDateTime();
					m_LastTraded = reader.ReadDateTime();
					goto case 5;
				}
				case 5: // just removed fields
				case 4:
				{
					m_Addons = reader.ReadItemList();
					goto case 3;
				}
				case 3:
				{
					count = reader.ReadInt();
					m_Secures = new ArrayList( count );

					for ( int i = 0; i < count; ++i )
					{
						SecureInfo info = new SecureInfo( reader );

						if ( info.Item != null )
						{
							info.Item.IsSecure = true;
							m_Secures.Add( info );
						}
					}

					goto case 2;
				}
				case 2:
				{
					m_Public = reader.ReadBool();
					goto case 1;
				}
				case 1:
				{
					if ( version < 13 )
						reader.ReadPoint3D(); // house ban location
					goto case 0;
				}
				case 0:
				{
					if ( version < 14 )
						m_RelativeBanLocation = this.BaseBanLocation;

					if ( version < 12 )
					{
						m_VendorRentalContracts = new ArrayList();
						m_InternalizedVendors = new ArrayList();
					}

					if ( version < 4 )
						m_Addons = new ArrayList();

					if ( version < 7 )
						m_Access = new ArrayList();

					if ( version < 8 )
						m_Price = DefaultPrice;

					m_Owner = reader.ReadMobile();

					if ( version < 5 )
					{
						count = reader.ReadInt();

						for(int i=0;i<count;i++)
							reader.ReadRect2D();
					}

					UpdateRegion();

					m_CoOwners = reader.ReadMobileList();
					m_Friends = reader.ReadMobileList();
					m_Bans = reader.ReadMobileList();

					m_Sign = reader.ReadItem() as HouseSign;
					m_Trash = reader.ReadItem() as TrashBarrel;

					m_Doors = reader.ReadItemList();
					m_LockDowns = reader.ReadItemList();

					for ( int i = 0; i < m_LockDowns.Count; ++i )
						((Item)m_LockDowns[i]).IsLockedDown = true;

					for ( int i = 0; i < m_VendorRentalContracts.Count; ++i )
						((Item)m_VendorRentalContracts[i]).IsLockedDown = true;

					if ( version < 3 )
					{
						ArrayList items = reader.ReadItemList();
						m_Secures = new ArrayList( items.Count );

						for ( int i = 0; i < items.Count; ++i )
						{
							Container c = items[i] as Container;

							if ( c != null )
							{
								c.IsSecure = true;
								m_Secures.Add( new SecureInfo( c, SecureLevel.CoOwners ) );
							}
						}
					}

					m_MaxLockDowns = reader.ReadInt();
					m_MaxSecures = reader.ReadInt();

					if ( (Map == null || Map == Map.Internal) && Location == Point3D.Zero )
						Delete();

					if ( m_Owner != null )
					{
						List<BaseHouse> list = null;
						m_Table.TryGetValue( m_Owner, out list );

						if ( list == null )
							m_Table[m_Owner] = list = new List<BaseHouse>();

						list.Add( this );
					}
					break;
				}
			}

			if ( version <= 1 )
				ChangeSignType( 0xBD2 );//private house, plain brass sign

			if ( version < 10 )
			{
				/* NOTE: This can exceed the house lockdown limit. It must be this way, because
				 * we do not want players' items to decay without them knowing. Or not even
				 * having a chance to fix it themselves.
				 */

				Timer.DelayCall( TimeSpan.Zero, new TimerCallback( FixLockdowns_Sandbox ) );
			}

			if ( version < 11 )
				m_LastRefreshed = DateTime.Now + TimeSpan.FromHours( 24 * Utility.RandomDouble() );

			if ( !CheckDecay() )
			{
				if ( RelocatedEntities.Count > 0 )
					Timer.DelayCall( TimeSpan.Zero, new TimerCallback( RestoreRelocatedEntities ) );

				if ( m_Owner == null && m_Friends.Count == 0 && m_CoOwners.Count == 0 )
					Timer.DelayCall( TimeSpan.FromSeconds( 10.0 ), new TimerCallback( Delete ) );
			}
		}
コード例 #4
0
ファイル: VendorInventory.cs プロジェクト: nathanvy/runuo
            public ExpireTimer( VendorInventory inventory, TimeSpan delay )
                : base(delay)
            {
                m_Inventory = inventory;

                Priority = TimerPriority.OneMinute;
            }
コード例 #5
0
 public ExpireTimer(VendorInventory inventory, TimeSpan delay)
     : base(delay)
 {
     m_Inventory = inventory;
 }
コード例 #6
0
ファイル: BaseHouse.cs プロジェクト: greeduomacro/UO-Forever
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();
            int count;
            bool loadedDynamicDecay = false;

            switch (version)
            {
                case 16:
                {
                    VendorMultiplier = reader.ReadDouble();
                    StorageMultiplier = reader.ReadDouble();

                    goto case 15;
                }
                case 15:
                {
                    int stage = reader.ReadInt();

                    if (stage != -1)
                    {
                        m_CurrentStage = (DecayLevel) stage;
                        m_NextDecayStage = reader.ReadDateTime();
                        loadedDynamicDecay = true;
                    }

                    goto case 14;
                }
                case 14:
                {
                    m_RelativeBanLocation = reader.ReadPoint3D();
                    goto case 13;
                }
                case 13: // removed ban location serialization
                case 12:
                {
                    m_VendorRentalContracts = reader.ReadStrongItemList();
                    m_InternalizedVendors = reader.ReadStrongMobileList();

                    int relocatedCount = reader.ReadEncodedInt();
                    for (int i = 0; i < relocatedCount; i++)
                    {
                        Point3D relLocation = reader.ReadPoint3D();
                        IEntity entity = World.FindEntity(reader.ReadInt());
                        // DO NOT READ ENTITY DIRECTLY, BECAUSE IF IT ISN'T IN THE WORLD (Item or Mobile)
                        // then it creates a new one, which caused a problem previously
                        //IEntity entity = reader.ReadEntity();

                        if (entity != null)
                        {
                            m_RelocatedEntities.Add(new RelocatedEntity(entity, relLocation));
                        }
                    }

                    int inventoryCount = reader.ReadEncodedInt();
                    for (int i = 0; i < inventoryCount; i++)
                    {
                        var inventory = new VendorInventory(this, reader);
                        m_VendorInventories.Add(inventory);
                    }

                    goto case 11;
                }
                case 11:
                {
                    m_LastRefreshed = reader.ReadDateTime();
                    m_RestrictDecay = reader.ReadBool();
                    goto case 10;
                }
                case 10: // just a signal for updates
                case 9:
                {
                    m_Visits = reader.ReadInt();
                    goto case 8;
                }
                case 8:
                {
                    m_Price = reader.ReadInt();
                    goto case 7;
                }
                case 7:
                {
                    m_Access = reader.ReadStrongMobileList();
                    goto case 6;
                }
                case 6:
                {
                    m_BuiltOn = reader.ReadDateTime();
                    m_LastTraded = reader.ReadDateTime();
                    goto case 5;
                }
                case 5: // just removed fields
                case 4:
                {
                    m_Addons = reader.ReadStrongItemList();
                    goto case 3;
                }
                case 3:
                {
                    count = reader.ReadInt();
                    m_Secures = new List<SecureInfo>(count);

                    for (int i = 0; i < count; ++i)
                    {
                        var info = new SecureInfo(reader);

                        if (info.Item != null)
                        {
                            info.Item.IsSecure = true;
                            m_Secures.Add(info);
                        }
                    }

                    goto case 2;
                }
                case 2:
                {
                    m_Public = reader.ReadBool();
                    goto case 1;
                }
                case 1:
                {
                    if (version < 13)
                    {
                        reader.ReadPoint3D(); // house ban location
                    }
                    goto case 0;
                }
                case 0:
                {
                    if (version < 14)
                    {
                        m_RelativeBanLocation = BaseBanLocation;
                    }

                    if (version < 12)
                    {
                        m_VendorRentalContracts = new List<Item>();
                        m_InternalizedVendors = new List<Mobile>();
                    }

                    if (version < 4)
                    {
                        m_Addons = new List<Item>();
                    }

                    if (version < 7)
                    {
                        m_Access = new List<Mobile>();
                    }

                    if (version < 8)
                    {
                        m_Price = DefaultPrice;
                    }

                    m_Owner = reader.ReadMobile();

                    if (version < 5)
                    {
                        count = reader.ReadInt();

                        for (int i = 0; i < count; i++)
                        {
                            reader.ReadRect2D();
                        }
                    }

                    UpdateRegion();

                    m_CoOwners = reader.ReadStrongMobileList();
                    m_Friends = reader.ReadStrongMobileList();
                    m_Bans = reader.ReadStrongMobileList();

                    m_Sign = reader.ReadItem() as HouseSign;
                    m_Trash = reader.ReadItem() as TrashBarrel;

                    m_Doors = reader.ReadStrongItemList<Item>();
                    m_LockDowns = reader.ReadStrongItemList();

                    for (int i = 0; i < m_LockDowns.Count; ++i)
                    {
                        m_LockDowns[i].IsLockedDown = true;
                    }

                    for (int i = 0; i < m_VendorRentalContracts.Count; ++i)
                    {
                        m_VendorRentalContracts[i].IsLockedDown = true;
                    }

                    if (version < 3)
                    {
                        List<Item> items = reader.ReadStrongItemList();
                        m_Secures = new List<SecureInfo>(items.Count);

                        for (int i = 0; i < items.Count; ++i)
                        {
                            var c = items[i] as Container;

                            if (c != null)
                            {
                                c.IsSecure = true;
                                m_Secures.Add(new SecureInfo(c, SecureLevel.CoOwners));
                            }
                        }
                    }

                    m_MaxLockDowns = reader.ReadInt();
                    m_MaxSecures = reader.ReadInt();

                    if ((Map == null || Map == Map.Internal) && Location == Point3D.Zero)
                    {
                        Delete();
                    }

                    if (m_Owner != null)
                    {
                        List<BaseHouse> list = null;
                        m_Table.TryGetValue(m_Owner, out list);

                        if (list == null)
                        {
                            m_Table[m_Owner] = list = new List<BaseHouse>();
                        }

                        list.Add(this);
                    }
                    break;
                }
            }

            if (version <= 1)
            {
                ChangeSignType(0xBD2); //private house, plain brass sign
            }

            if (version < 10)
            {
                /* NOTE: This can exceed the house lockdown limit. It must be this way, because
				 * we do not want players' items to decay without them knowing. Or not even
				 * having a chance to fix it themselves.
				 */

                Timer.DelayCall(TimeSpan.Zero, FixLockdowns_Sandbox);
            }

            if (version < 11)
            {
                m_LastRefreshed = DateTime.UtcNow + TimeSpan.FromHours(24 * Utility.RandomDouble());
            }

            if (DynamicDecay.Enabled && !loadedDynamicDecay)
            {
                DecayLevel old = GetOldDecayLevel();

                if (old == DecayLevel.DemolitionPending)
                {
                    old = DecayLevel.Collapsed;
                }

                SetDynamicDecay(old);
            }

            if (!CheckDecay())
            {
                if (RelocatedEntities.Count > 0)
                {
                    Timer.DelayCall(TimeSpan.Zero, RestoreRelocatedEntities);
                }

                //if ( m_Owner == null && m_Friends.Count == 0 && m_CoOwners.Count == 0 )
                //	Timer.DelayCall( TimeSpan.FromSeconds( 10.0 ), new TimerCallback( Delete ) );
            }
        }
コード例 #7
0
        public virtual void Destroy(bool toBackpack)
        {
            Return();

            /* Possible cases regarding item return:
             *
             * 1. No item must be returned
             *       -> do nothing.
             * 2. ( toBackpack is false OR the vendor is in the internal map ) AND the vendor is associated with a AOS house
             *       -> put the items into the moving crate or a vendor inventory,
             *          depending on whether the vendor owner is also the house owner.
             * 3. ( toBackpack is true OR the vendor isn't associated with any AOS house ) AND the vendor isn't in the internal map
             *       -> put the items into a backpack.
             * 4. The vendor isn't associated with any house AND it's in the internal map
             *       -> do nothing (we can't do anything).
             */

            var items = GetAllItems();

            if (items.Any() || HoldGold > 0)                                    // No case 1
            {
                if ((!toBackpack || this.Map == Map.Internal) && House != null) // Case 2
                {
                    if (House.IsOwner(Owner))                                   // Move to moving crate
                    {
                        if (House.MovingCrate == null)
                        {
                            House.MovingCrate = new MovingCrate(House);
                        }

                        if (HoldGold > 0)
                        {
                            Banker.Deposit(House.MovingCrate, HoldGold);
                        }

                        foreach (Item item in items)
                        {
                            House.MovingCrate.DropItem(item);
                        }
                    }
                    else                     // Move to vendor inventory
                    {
                        VendorInventory inventory = new VendorInventory(House, Owner, Name, ShopName);
                        inventory.Gold = HoldGold;

                        foreach (var item in items)
                        {
                            inventory.AddItem(item);
                        }

                        House.VendorInventories.Add(inventory);
                    }
                }
                else if ((toBackpack || House == null) && this.Map != Map.Internal)                     // Case 3 - Move to backpack
                {
                    Container backpack = new Backpack();

                    if (HoldGold > 0)
                    {
                        Banker.Deposit(backpack, HoldGold);
                    }

                    foreach (var item in items)
                    {
                        backpack.DropItem(item);
                    }

                    backpack.MoveToWorld(this.Location, this.Map);
                }
            }

            Delete();
        }
コード例 #8
0
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
			int count;

			m_Region = new HouseRegion( this );

			switch ( version )
			{
				case 12:
				{
					m_VendorRentalContracts = reader.ReadItemList();
					m_InternalizedVendors = reader.ReadMobileList();

					int relocatedCount = reader.ReadEncodedInt();
					for ( int i = 0; i < relocatedCount; i++ )
					{
						Point3D relLocation = reader.ReadPoint3D();
						IEntity entity = World.FindEntity( reader.ReadInt() );

						if ( entity != null )
							m_RelocatedEntities.Add( new RelocatedEntity( entity, relLocation ) );
					}

					int inventoryCount = reader.ReadEncodedInt();
					for ( int i = 0; i < inventoryCount; i++ )
					{
						VendorInventory inventory = new VendorInventory( this, reader );
						m_VendorInventories.Add( inventory );
					}

					goto case 11;
				}
				case 11:
				{
					m_LastRefreshed = reader.ReadDateTime();
					m_RestrictDecay = reader.ReadBool();
					goto case 10;
				}
				case 10: // just a signal for updates
				case 9:
				{
					m_Visits = reader.ReadInt();
					goto case 8;
				}
				case 8:
				{
					m_Price = reader.ReadInt();
					goto case 7;
				}
				case 7:
				{
					m_Access = reader.ReadMobileList();
					goto case 6;
				}
				case 6:
				{
					m_BuiltOn = reader.ReadDateTime();
					m_LastTraded = reader.ReadDateTime();
					goto case 5;
				}
				case 5: // just removed fields
				case 4:
				{
					m_Addons = reader.ReadItemList();
					goto case 3;
				}
				case 3:
				{
					count = reader.ReadInt();
					m_Secures = new ArrayList( count );

					for ( int i = 0; i < count; ++i )
					{
						SecureInfo info = new SecureInfo( reader );

						if ( info.Item != null )
						{
							info.Item.IsSecure = true;
							m_Secures.Add( info );
						}
					}

					goto case 2;
				}
				case 2:
				{
					m_Public = reader.ReadBool();
					goto case 1;
				}
				case 1:
				{
					m_Region.GoLocation = reader.ReadPoint3D();
					goto case 0;
				}
				case 0:
				{
					if ( version < 12 )
					{
						m_VendorRentalContracts = new ArrayList();
						m_InternalizedVendors = new ArrayList();
					}

					if ( version < 4 )
						m_Addons = new ArrayList();

					if ( version < 7 )
						m_Access = new ArrayList();

					if ( version < 8 )
						m_Price = DefaultPrice;

					m_Owner = reader.ReadMobile();

					if ( version < 5 )
					{
						count = reader.ReadInt();

						for(int i=0;i<count;i++)
							reader.ReadRect2D();
					}

					UpdateRegionArea();

					Region.AddRegion( m_Region );

					m_CoOwners = reader.ReadMobileList();
					m_Friends = reader.ReadMobileList();
					m_Bans = reader.ReadMobileList();

					m_Sign = reader.ReadItem() as HouseSign;
					m_Trash = reader.ReadItem() as TrashBarrel;

					m_Doors = reader.ReadItemList();
					m_LockDowns = reader.ReadItemList();

					for ( int i = 0; i < m_LockDowns.Count; ++i )
						((Item)m_LockDowns[i]).IsLockedDown = true;

					for ( int i = 0; i < m_VendorRentalContracts.Count; ++i )
						((Item)m_VendorRentalContracts[i]).IsLockedDown = true;

					if ( version < 3 )
					{
						ArrayList items = reader.ReadItemList();
						m_Secures = new ArrayList( items.Count );

						for ( int i = 0; i < items.Count; ++i )
						{
							Container c = items[i] as Container;

							if ( c != null )
							{
								c.IsSecure = true;
								m_Secures.Add( new SecureInfo( c, SecureLevel.CoOwners ) );
							}
						}
					}

					m_MaxLockDowns = reader.ReadInt();
					m_MaxSecures = reader.ReadInt();

					if ( (Map == null || Map == Map.Internal) && Location == Point3D.Zero )
						Delete();

					if ( m_Owner != null )
					{
						ArrayList list = (ArrayList)m_Table[m_Owner];

						if ( list == null )
							m_Table[m_Owner] = list = new ArrayList();

						list.Add( this );
					}
					break;
				}
			}

			if ( version <= 1 )
				ChangeSignType( 0xBD2 );//private house, plain brass sign

			if ( version < 10 )
			{
				/* NOTE: This can exceed the house lockdown limit. It must be this way, because
				 * we do not want players' items to decay without them knowing. Or not even
				 * having a chance to fix it themselves.
				 */

				Timer.DelayCall( TimeSpan.Zero, new TimerCallback( FixLockdowns_Sandbox ) );
			}

			if ( version < 11 )
				m_LastRefreshed = DateTime.Now + TimeSpan.FromHours( 24 * Utility.RandomDouble() );
/*
			PlayerMobile pmowner = m_Owner as PlayerMobile;

			if ( pmowner != null && m_Owner.Account != null && CanDecay )
			{
				if ( pmowner.DonationTimeLeft < TimeSpan.MaxValue && ( pmowner.DonationStart + pmowner.DonationDuration + DecayPeriod ) > DateTime.Now )
					m_LastRefreshed = pmowner.DonationStart + pmowner.DonationDuration + DecayPeriod;
			}
*/
			//Moved to cleanup code because CheckDecay will trigger accounts which have not been initialized yet.
			if ( /*!CheckDecay() &&*/ RelocatedEntities.Count > 0 )
				Timer.DelayCall( TimeSpan.Zero, new TimerCallback( RestoreRelocatedEntities ) );
		}
コード例 #9
0
ファイル: VendorInventory.cs プロジェクト: Ravenwolfe/xrunuo
 public ExpireTimer( VendorInventory inventory, TimeSpan delay )
     : base(delay)
 {
     m_Inventory = inventory;
 }