コード例 #1
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 ) );
			}
		}
コード例 #2
0
ファイル: BaseHouse.cs プロジェクト: Ravenwolfe/Origins
        public void AddSecure( Mobile m, Item item )
        {
            if ( m_Secures == null || !IsOwner( m ) || !IsActive )
                return;

            if ( !IsInside( item ) )
            {
                m.SendAsciiMessage( "That is not in your house" ); // That is not in your house
            }
            else if ( IsLockedDown( item ) )
            {
                m.SendAsciiMessage( "This is already locked down and cannot be secured." ); // This is already locked down and cannot be secured.
            }
            else if ( !(item is Container) )
            {
                LockDown( m, item );
            }
            else
            {
                SecureInfo info = null;

                for ( int i = 0; info == null && i < m_Secures.Count; ++i )
                    if ( ((SecureInfo)m_Secures[i]).Item == item )
                        info = (SecureInfo)m_Secures[i];

                if ( info != null )
                {
                    m.SendMenu( new SetSecureLevelMenu( m_Owner, info, this ) );
                }
                else if ( item.Parent != null )
                {
                    m.SendAsciiMessage( "You cannot secure this, place it on the ground first." ); // You cannot secure this, place it on the ground first.
                }
                else if ( !item.Movable )
                {
                    m.SendAsciiMessage( "You cannot secure this." ); // You cannot secure this.
                }
                else if ( !IsAosRules && SecureCount >= MaxSecures )
                {
                    // The maximum number of secure items has been reached :
                    m.SendAsciiMessage( "The maximum number of secure items has been reached : " + MaxSecures.ToString() );
                }
                else if ( IsAosRules ? !CheckAosLockdowns( 1 ) : ((LockDownCount + 125) >= MaxLockDowns) )
                {
                    m.SendAsciiMessage( "That would exceed the maximum lock down limit for this house" ); // That would exceed the maximum lock down limit for this house
                }
                else if ( IsAosRules && !CheckAosStorage( item.TotalItems ) )
                {
                    m.SendAsciiMessage( "This action would exceed the secure storage limit of the house." ); // This action would exceed the secure storage limit of the house.
                }
                else
                {
                    //enable protection
                    if ( this.SecureCount == 0 && this.LockDownCount == 0)
                    {
                        PlayerMobile pm = m as PlayerMobile;
                        Guild guild = pm.Guild as Guild;

                        if ( pm.ProtectedHouse != null )
                        {
                            pm.SendAsciiMessage( "You already have a protected house." );
                            return;
                        }

                        pm.SendAsciiMessage( "This house is now under the protection of " + pm.Guild.Name + "." );
                        pm.ProtectedHouse = this;
                        this.ChangeSignType( guild.GuildHouseSignItemID );

                        if ( m_Sign != null )
                            m_Sign.InvalidateProperties();
                    }

                    info = new SecureInfo( (Container)item, SecureLevel.Owner );

                    item.IsLockedDown = false;
                    item.IsSecure = true;

                    m_Secures.Add( info );
                    m_LockDowns.Remove( item );
                    item.Movable = false;

                    m.SendMenu( new SetSecureLevelMenu( m_Owner, info, this ) );
                }
            }
        }
コード例 #3
0
		public void AddSecure( Mobile m, Item item )
		{
			if ( m_Secures == null || !IsOwner( m ) || !IsActive )
				return;

			if ( !IsInside( item ) )
			{
				m.SendLocalizedMessage( 1005525 ); // That is not in your house
			}
			else if ( IsLockedDown( item ) )
			{
				m.SendLocalizedMessage( 1010550 ); // This is already locked down and cannot be secured.
			}
			else if ( !(item is Container) )
			{
				LockDown( m, item );
			}
			else
			{
				SecureInfo info = null;

				for ( int i = 0; info == null && i < m_Secures.Count; ++i )
					if ( ((SecureInfo)m_Secures[i]).Item == item )
						info = (SecureInfo)m_Secures[i];

				if ( info != null )
				{
					m.SendGump( new Gumps.SetSecureLevelGump( m_Owner, info, this ) );
				}
				else if ( item.Parent != null )
				{
					m.SendLocalizedMessage( 1010423 ); // You cannot secure this, place it on the ground first.
				}
				// Mondain's Legacy mod
				else if ( !( item is BaseAddonContainer ) && !item.Movable )
				{
					m.SendLocalizedMessage( 1010424 ); // You cannot secure this.
				}
				else if ( !IsAosRules && SecureCount >= MaxSecures )
				{
					// The maximum number of secure items has been reached : 
					m.SendLocalizedMessage( 1008142, true, MaxSecures.ToString() );
				}
				else if ( IsAosRules ? !CheckAosLockdowns( 1 ) : ((LockDownCount + 125) >= MaxLockDowns) )
				{
					m.SendLocalizedMessage( 1005379 ); // That would exceed the maximum lock down limit for this house
				}
				else if ( IsAosRules && !CheckAosStorage( item.TotalItems ) )
				{
					m.SendLocalizedMessage( 1061839 ); // This action would exceed the secure storage limit of the house.
				}
				else
				{
					info = new SecureInfo( (Container)item, SecureLevel.CoOwners );

					item.IsLockedDown = false;
					item.IsSecure = true;

					m_Secures.Add( info );
					m_LockDowns.Remove( item );
					item.Movable = false;

					m.SendGump( new Gumps.SetSecureLevelGump( m_Owner, info, this ) );
				}
			}
		}
コード例 #4
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 ) );
            }
        }
コード例 #5
0
ファイル: Tent.cs プロジェクト: zerodowned/angelisland
		public void GenerateTent()
		{
			TentWalls walls = new TentWalls( TentStyle.Newbie );
			TentRoof roof = new TentRoof( m_RoofHue );
			//TentTrim trim = new TentTrim();
			TentFloor floor = new TentFloor();
			            						
			walls.MoveToWorld( this.Location, this.Map );
			roof.MoveToWorld( this.Location, this.Map );
			//trim.MoveToWorld( this.Location, this.Map );
			floor.MoveToWorld( this.Location, this.Map );
			
			Addons.Add( walls );
			Addons.Add( roof );
			//Addons.Add( trim );
			Addons.Add( floor );

			// Create tent bed
			m_Tentbed = new TentBedRoll( this );
			m_Tentbed.MoveToWorld( new Point3D( this.X, this.Y + 1, this.Z ), this.Map );
			m_Tentbed.Movable = false;

			// Create secute tent pack within the tent
			m_Tentpack = new TentBackpack( this );
			m_Tentpack.MoveToWorld( new Point3D( this.X-1, this.Y-1, this.Z), this.Map );
			SecureInfo info = new SecureInfo( (Container) m_Tentpack, SecureLevel.Anyone );
			m_Tentpack.IsSecure = true;
			this.Secures.Add( info );
			m_Tentpack.Movable = false;
			m_Tentpack.Hue = m_RoofHue;
		}
コード例 #6
0
ファイル: BaseHouse.cs プロジェクト: greeduomacro/divinity
        public void AddSecure( Mobile m, Item item )
        {
            if ( m_Secures == null || !IsOwner( m ) || !IsActive )
                return;

            if ( !IsInside( item ) )
            {
                m.SendLocalizedMessage( 1005525 ); // That is not in your house
            }
            else if ( IsLockedDown( item ) )
            {
                m.SendLocalizedMessage( 1010550 ); // This is already locked down and cannot be secured.
            }
            else if ( !(item is Container) )
            {
                LockDown( m, item );
            }
            else
            {
                SecureInfo info = null;

                for ( int i = 0; info == null && i < m_Secures.Count; ++i )
                    if ( ((SecureInfo)m_Secures[i]).Item == item )
                        info = (SecureInfo)m_Secures[i];

                if ( info != null )
                {
                    m.SendGump( new Gumps.SetSecureLevelGump( m_Owner, info, this ) );
                }
                else if ( item.Parent != null )
                {
                    m.SendLocalizedMessage( 1010423 ); // You cannot secure this, place it on the ground first.
                }
                else if ( !item.Movable )
                {
                    m.SendLocalizedMessage( 1010424 ); // You cannot secure this.
                }
                else if ( !IsAosRules && SecureCount >= MaxSecures )
                {
                    // The maximum number of secure items has been reached :
                    m.SendLocalizedMessage( 1008142, true, MaxSecures.ToString() );
                }
                else if ( IsAosRules ? !CheckAosLockdowns( 1 ) : ((LockDownCount + 125) >= MaxLockDowns) )
                {
                    m.SendLocalizedMessage( 1005379 ); // That would exceed the maximum lock down limit for this house
                }
                else if ( IsAosRules && !CheckAosStorage( item.TotalItems ) )
                {
                    m.SendLocalizedMessage( 1061839 ); // This action would exceed the secure storage limit of the house.
                }
                /*else
                {
                    info = new SecureInfo( (Container)item, SecureLevel.CoOwners );

                    item.IsLockedDown = false;
                    item.IsSecure = true;

                    m_Secures.Add( info );
                    m_LockDowns.Remove( item );
                    item.Movable = false;

                    m.SendGump( new Gumps.SetSecureLevelGump( m_Owner, info, this ) );
                }*/
                else
                {
                    Container cont = (Container)item;

                    if ( cont.TotalWeight > cont.MaxWeight )
                    {
                        m.SendMessage( "That container is too heavy to secure." );
                    }
                    else
                    {
                        // TODO: better way of restricting placement near stairs?
                        int range = (this is Tower) ? 2 : 1;
                        for ( int i = 0; m_Doors != null && i < m_Doors.Count; ++i )
                        {
                            BaseDoor door = m_Doors[i] as BaseDoor;
                            Point3D p = door.Location;

                            if ( door.Open )
                                p = new Point3D( p.X - door.Offset.X, p.Y - door.Offset.Y, p.Z - door.Offset.Z );

                            if ( (item.Z + 16) >= p.Z && (p.Z + 16) >= item.Z )
                            {
                                if ( Utility.InRange( item.Location, p, range ) )
                                {
                                    m.SendAsciiMessage( "You cannot secure a container near a door or near stairs." );
                                    return;
                                }
                            }
                        }

                        info = new SecureInfo( cont, SecureLevel.Friends );

                        item.IsLockedDown = false;
                        item.IsSecure = true;

                        m_Secures.Add( info );
                        m_LockDowns.Remove( item );
                        item.Movable = false;
                    }

                    //m.SendGump( new Gumps.SetSecureLevelGump( m_Owner, info ) );
                }
            }
        }
コード例 #7
0
ファイル: BaseHouse.cs プロジェクト: zerodowned/angelisland
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

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

			m_Region = new HouseRegion(this);

			switch (version)
			{
				case 20:
					{
						m_NPCData = reader.ReadUInt32();
						goto case 19;
					}
				case 19:
					{
						m_RestartDecay = reader.ReadTimeSpan();
						goto case 18;
					}
				case 18:
					{
						m_Flags = (ImplFlags)reader.ReadUInt32();
						goto case 17;
					}
				case 17:
					{
						m_UpgradeCosts = reader.ReadUInt32();
						goto case 16;
					}
				case 16:
					{
						m_LockBoxData = reader.ReadUInt32();
						goto case 15;
					}
				case 15:
					{
						m_SecurePremises = reader.ReadBool();
						goto case 14;
					}
				case 14:
					{
						idocannc = reader.ReadBool();
						goto case 13;
					}
				case 13:
					{
						m_DecayMinutesStored = reader.ReadDouble();
						m_NeverDecay = reader.ReadBool();
						goto case 11; //note, this isn't a mistake - we want to skip 12
					}
				case 12:
					{
						DateTime tempDT = reader.ReadDeltaTime();
						//StructureDecayTime = reader.ReadDeltaTime();
						m_DecayMinutesStored = (tempDT - DateTime.Now).TotalMinutes;

						m_NeverDecay = reader.ReadBool();
						goto case 11;
					}
				case 11:
					{
						m_MaxLockBoxes = reader.ReadInt();
						m_LockBoxCount = reader.ReadInt();

						goto case 9;
					}
				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;
								info.Item.CancelFreezeTimer();        // don't initiate for Deserialize
								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 < 16)
						{
							LockBoxCeling = (uint)m_MaxLockBoxes * 2;   // high limit
							LockBoxFloor = (uint)m_MaxLockBoxes;        // low limit
						}

						if (version < 12)
						{
							Refresh();
							m_NeverDecay = false;
						}

						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 item = m_LockDowns[i] as Item;
							if (item != null)
							{
								item.IsLockedDown = true;
								item.CancelFreezeTimer();        // don't initiate for Deserialize
							}
						}

						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;
					}
			}

			// patch m_NPCData to hold the default barkeep count
			if (version < 20)
				MaximumBarkeepCount = 2;		

			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 (idocannc) // idoc announcement was running when we saved, re-create it
			{
				string[] lines = new string[1];
				lines[0] = String.Format("Lord British has condemned the estate of {0} near {1}.", this.Owner.Name, DescribeLocation());
				m_IDOC_Broadcast_TCE = new TownCrierEntry(lines, TimeSpan.FromMinutes(m_DecayMinutesStored), Serial.MinusOne);
				GlobalTownCrierEntryList.Instance.AddEntry(m_IDOC_Broadcast_TCE);
			}
		}
コード例 #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 ) );
		}