Exemple #1
0
        /// <summary>
        /// Moves the Item to a given <paramref name="location" /> and <paramref name="map" />.
        /// </summary>
        public void MoveToWorld( Point3D location, Map map )
        {
            if ( Deleted )
                return;

            Point3D oldLocation = GetWorldLocation();
            Point3D oldRealLocation = m_Location;

            SetLastMoved();

            if ( Parent is Mobile )
                ((Mobile)Parent).RemoveItem( this );
            else if ( Parent is Item )
                ((Item)Parent).RemoveItem( this );

            if ( m_Map != map )
            {
                Map old = m_Map;

                if ( m_Map != null )
                {
                    m_Map.OnLeave( this );

                    if ( oldLocation.m_X != 0 )
                    {
                        Packet remPacket = null;

                        IPooledEnumerable eable = m_Map.GetClientsInRange( oldLocation, GetMaxUpdateRange() );

                        foreach ( NetState state in eable )
                        {
                            Mobile m = state.Mobile;

                            if ( m.InRange( oldLocation, GetUpdateRange( m ) ) )
                            {
                                if ( remPacket == null )
                                    remPacket = this.RemovePacket;

                                state.Send( remPacket );
                            }
                        }

                        eable.Free();
                    }
                }

                if ( m_Items != null )
                {
                    for ( int i = 0; i < m_Items.Count; ++i )
                        ((Item)m_Items[i]).Map = map;
                }

                m_Location = location;
                this.OnLocationChange( oldRealLocation );
                m_WorldPacket = null;

                m_Map = map;

                if ( m_Map != null )
                    m_Map.OnEnter( this );

                OnMapChange();

                if ( m_Map != null )
                {
                    IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location, GetMaxUpdateRange() );

                    foreach ( NetState state in eable )
                    {
                        Mobile m = state.Mobile;

                        if ( m.CanSee( this ) && m.InRange( m_Location, GetUpdateRange( m ) ) )
                            SendInfoTo( state );
                    }

                    eable.Free();
                }

                RemDelta( ItemDelta.Update );

                if ( old == null || old == Map.Internal )
                    InvalidateProperties();
            }
            else if ( m_Map != null )
            {
                IPooledEnumerable eable;

                if ( oldLocation.m_X != 0 )
                {
                    Packet removeThis = null;

                    eable = m_Map.GetClientsInRange( oldLocation, GetMaxUpdateRange() );

                    foreach ( NetState state in eable )
                    {
                        Mobile m = state.Mobile;

                        if ( !m.InRange( location, GetUpdateRange( m ) ) )
                        {
                            if ( removeThis == null )
                                removeThis = this.RemovePacket;

                            state.Send( removeThis );
                        }
                    }

                    eable.Free();
                }

                Point3D oldInternalLocation = m_Location;

                m_Location = location;
                this.OnLocationChange( oldRealLocation );
                m_WorldPacket = null;

                eable = m_Map.GetClientsInRange( m_Location, GetMaxUpdateRange() );

                foreach ( NetState state in eable )
                {
                    Mobile m = state.Mobile;

                    if ( m.CanSee( this ) && m.InRange( m_Location, GetUpdateRange( m ) ) )
                        SendInfoTo( state );
                }

                eable.Free();

                m_Map.OnMove( oldInternalLocation, this );

                RemDelta( ItemDelta.Update );
            }
            else
            {
                Map = map;
                Location = location;
            }
        }
Exemple #2
0
        public virtual void Deserialize( GenericReader reader )
        {
            int version = reader.ReadInt();

            SetLastMoved();

            switch ( version )
            {
                case 7:
                case 6:
                {
                    SaveFlag flags = (SaveFlag)reader.ReadInt();

                    if ( version < 7 )
                    {
                        LastMoved = reader.ReadDeltaTime();
                    }
                    else
                    {
                        int minutes = reader.ReadEncodedInt();

                        try{ LastMoved = Core.Now - TimeSpan.FromMinutes( minutes ); }
                        catch{ LastMoved = Core.Now; }
                    }

                    if ( GetSaveFlag( flags, SaveFlag.Direction ) )
                        m_Direction = (Direction)reader.ReadByte();

                    if ( GetSaveFlag( flags, SaveFlag.Bounce ) )
                        m_Bounce = BounceInfo.Deserialize( reader );

                    if ( GetSaveFlag( flags, SaveFlag.LootType ) )
                        m_LootType = (LootType)reader.ReadByte();

                    int x = 0, y = 0, z = 0;

                    if ( GetSaveFlag( flags, SaveFlag.LocationFull ) )
                    {
                        x = reader.ReadEncodedInt();
                        y = reader.ReadEncodedInt();
                        z = reader.ReadEncodedInt();
                    }
                    else
                    {
                        if ( GetSaveFlag( flags, SaveFlag.LocationByteXY ) )
                        {
                            x = reader.ReadByte();
                            y = reader.ReadByte();
                        }
                        else if ( GetSaveFlag( flags, SaveFlag.LocationShortXY ) )
                        {
                            x = reader.ReadShort();
                            y = reader.ReadShort();
                        }

                        if ( GetSaveFlag( flags, SaveFlag.LocationSByteZ ) )
                            z = reader.ReadSByte();
                    }

                    m_Location = new Point3D( x, y, z );

                    if ( GetSaveFlag( flags, SaveFlag.ItemID ) )
                        m_ItemID = reader.ReadEncodedInt();

                    if ( GetSaveFlag( flags, SaveFlag.Hue ) )
                        m_Hue = reader.ReadEncodedInt();

                    if ( GetSaveFlag( flags, SaveFlag.Amount ) )
                        m_Amount = reader.ReadEncodedInt();
                    else
                        m_Amount = 1;

                    if ( GetSaveFlag( flags, SaveFlag.Layer ) )
                        m_Layer = (Layer)reader.ReadByte();

                    if ( GetSaveFlag( flags, SaveFlag.Name ) )
                        m_Name = string.Intern(reader.ReadString());

                    if ( GetSaveFlag( flags, SaveFlag.Parent ) )
                    {
                        Serial parent = reader.ReadInt();

                        if ( parent.IsMobile )
                            m_Parent = World.FindMobile( parent );
                        else if ( parent.IsItem )
                            m_Parent = World.FindItem( parent );
                        else
                            m_Parent = null;

                        if ( m_Parent == null && (parent.IsMobile || parent.IsItem) )
                            Delete();
                    }

                    if ( GetSaveFlag( flags, SaveFlag.Items ) )
                        m_Items = reader.ReadItemList();
                    //else
                    //	m_Items = new ArrayList( 1 );

                    if ( GetSaveFlag( flags, SaveFlag.IntWeight ) )
                        m_Weight = reader.ReadEncodedInt();
                    else if ( GetSaveFlag( flags, SaveFlag.WeightNot1or0 ) )
                        m_Weight = reader.ReadDouble();
                    else if ( GetSaveFlag( flags, SaveFlag.WeightIs0 ) )
                        m_Weight = 0.0;
                    else
                        m_Weight = 1.0;

                    if ( GetSaveFlag( flags, SaveFlag.Map ) )
                        m_Map = reader.ReadMap();
                    else
                        m_Map = Map.Internal;

                    if ( GetSaveFlag( flags, SaveFlag.Visible ) )
                        SetFlag( ImplFlag.Visible, reader.ReadBool() );
                    else
                        SetFlag( ImplFlag.Visible, true );

                    if ( GetSaveFlag( flags, SaveFlag.Movable ) )
                        SetFlag( ImplFlag.Movable, reader.ReadBool() );
                    else
                        SetFlag( ImplFlag.Movable, true );

                    if ( GetSaveFlag( flags, SaveFlag.Stackable ) )
                        SetFlag( ImplFlag.Stackable, reader.ReadBool() );

                    if ( GetSaveFlag( flags, SaveFlag.ImplFlags ) )
                        m_Flags = (ImplFlag)reader.ReadEncodedInt();

                    if ( GetSaveFlag( flags, SaveFlag.InsuredFor ) )
                        /*m_InsuredFor = */reader.ReadMobile();

                    if ( GetSaveFlag( flags, SaveFlag.BlessedFor ) )
                        m_BlessedFor = reader.ReadMobile();

                    if ( GetSaveFlag( flags, SaveFlag.HeldBy ) )
                        m_HeldBy = reader.ReadMobile();

                    if ( GetSaveFlag( flags, SaveFlag.SavedFlags ) )
                        m_SavedFlags = reader.ReadEncodedInt();

                    if ( m_Map != null && m_Parent == null )
                        m_Map.OnEnter( this );

                    break;
                }
                case 5:
                {
                    SaveFlag flags = (SaveFlag)reader.ReadInt();

                    LastMoved = reader.ReadDeltaTime();

                    if ( GetSaveFlag( flags, SaveFlag.Direction ) )
                        m_Direction = (Direction)reader.ReadByte();

                    if ( GetSaveFlag( flags, SaveFlag.Bounce ) )
                        m_Bounce = BounceInfo.Deserialize( reader );

                    if ( GetSaveFlag( flags, SaveFlag.LootType ) )
                        m_LootType = (LootType)reader.ReadByte();

                    if ( GetSaveFlag( flags, SaveFlag.LocationFull ) )
                        m_Location = reader.ReadPoint3D();

                    if ( GetSaveFlag( flags, SaveFlag.ItemID ) )
                        m_ItemID = reader.ReadInt();

                    if ( GetSaveFlag( flags, SaveFlag.Hue ) )
                        m_Hue = reader.ReadInt();

                    if ( GetSaveFlag( flags, SaveFlag.Amount ) )
                        m_Amount = reader.ReadInt();
                    else
                        m_Amount = 1;

                    if ( GetSaveFlag( flags, SaveFlag.Layer ) )
                        m_Layer = (Layer)reader.ReadByte();

                    if ( GetSaveFlag( flags, SaveFlag.Name ) )
                        m_Name = string.Intern(reader.ReadString());

                    if ( GetSaveFlag( flags, SaveFlag.Parent ) )
                    {
                        Serial parent = reader.ReadInt();

                        if ( parent.IsMobile )
                            m_Parent = World.FindMobile( parent );
                        else if ( parent.IsItem )
                            m_Parent = World.FindItem( parent );
                        else
                            m_Parent = null;

                        if ( m_Parent == null && (parent.IsMobile || parent.IsItem) )
                            Delete();
                    }

                    if ( GetSaveFlag( flags, SaveFlag.Items ) )
                        m_Items = reader.ReadItemList();
                    //else
                    //	m_Items = new ArrayList( 1 );

                    if ( GetSaveFlag( flags, SaveFlag.IntWeight ) )
                        m_Weight = reader.ReadEncodedInt();
                    else if ( GetSaveFlag( flags, SaveFlag.WeightNot1or0 ) )
                        m_Weight = reader.ReadDouble();
                    else if ( GetSaveFlag( flags, SaveFlag.WeightIs0 ) )
                        m_Weight = 0.0;
                    else
                        m_Weight = 1.0;

                    if ( GetSaveFlag( flags, SaveFlag.Map ) )
                        m_Map = reader.ReadMap();
                    else
                        m_Map = Map.Internal;

                    if ( GetSaveFlag( flags, SaveFlag.Visible ) )
                        SetFlag( ImplFlag.Visible, reader.ReadBool() );
                    else
                        SetFlag( ImplFlag.Visible, true );

                    if ( GetSaveFlag( flags, SaveFlag.Movable ) )
                        SetFlag( ImplFlag.Movable, reader.ReadBool() );
                    else
                        SetFlag( ImplFlag.Movable, true );

                    if ( GetSaveFlag( flags, SaveFlag.Stackable ) )
                        SetFlag( ImplFlag.Stackable, reader.ReadBool() );

                    if ( m_Map != null && m_Parent == null )
                        m_Map.OnEnter( this );

                    break;
                }
                case 4: // Just removed variables
                case 3:
                {
                    m_Direction = (Direction)reader.ReadInt();

                    goto case 2;
                }
                case 2:
                {
                    m_Bounce = BounceInfo.Deserialize( reader );
                    LastMoved = reader.ReadDeltaTime();

                    goto case 1;
                }
                case 1:
                {
                    m_LootType = (LootType) reader.ReadByte();//m_Newbied = reader.ReadBool();

                    goto case 0;
                }
                case 0:
                {
                    m_Location = reader.ReadPoint3D();
                    m_ItemID = reader.ReadInt();
                    m_Hue = reader.ReadInt();
                    m_Amount = reader.ReadInt();
                    m_Layer = (Layer) reader.ReadByte();
                    m_Name = reader.ReadString();
                    if (m_Name != null)
                        m_Name = string.Intern(m_Name);

                    Serial parent = reader.ReadInt();

                    if ( parent.IsMobile )
                        m_Parent = World.FindMobile( parent );
                    else if ( parent.IsItem )
                        m_Parent = World.FindItem( parent );
                    else
                        m_Parent = null;

                    if ( m_Parent == null && (parent.IsMobile || parent.IsItem) )
                        Delete();

                    int count = reader.ReadInt();

                    if ( count > 0 )
                    {
                        m_Items = new ArrayList( count );

                        for ( int i = 0; i < count; ++i )
                        {
                            Item item = reader.ReadItem();

                            if ( item != null )
                                m_Items.Add( item );
                        }
                    }

                    m_Weight = reader.ReadDouble();

                    if ( version <= 3 )
                    {
                        /*m_TotalItems =*/ reader.ReadInt();
                        /*m_TotalWeight =*/ reader.ReadInt();
                        /*m_TotalGold =*/ reader.ReadInt();
                    }

                    m_Map = reader.ReadMap();
                    SetFlag( ImplFlag.Visible, reader.ReadBool() );
                    SetFlag( ImplFlag.Movable, reader.ReadBool() );

                    if ( version <= 3 )
                        /*m_Deleted =*/ reader.ReadBool();

                    Stackable = reader.ReadBool();

                    if ( m_Map != null && m_Parent == null )
                        m_Map.OnEnter( this );

                    break;
                }
            }

            if ( m_HeldBy != null )
                Timer.DelayCall( TimeSpan.Zero, new TimerCallback( FixHolding_Sandbox ) );
        }
Exemple #3
0
        public virtual void MoveToWorld( Point3D newLocation, Map map )
        {
            if ( m_Map == map )
            {
                SetLocation( newLocation, true );
                return;
            }

            BankBox box = FindBankNoCreate();

            if ( box != null && box.Opened )
                box.Close();

            Point3D oldLocation = m_Location;
            Map oldMap = m_Map;

            Region oldRegion = m_Region;

            if ( oldMap != null )
            {
                oldMap.OnLeave( this );

                ClearScreen();
                SendRemovePacket();
            }

            for ( int i = 0; i < m_Items.Count; ++i )
                ((Item)m_Items[i]).Map = map;

            m_Map = map;

            m_Region.InternalExit( this );

            m_Location = newLocation;

            NetState ns = m_NetState;

            if ( m_Map != null )
            {
                m_Map.OnEnter( this );

                m_Region = Region.Find( m_Location, m_Map );
                OnRegionChange( oldRegion, m_Region );

                m_Region.InternalEnter( this );

                if ( ns != null && m_Map != null )
                {
                    ns.Sequence = 0;
                    ns.Send( new MapChange( this ) );
                    ns.Send( new MapPatches() );
                    ns.Send( SeasonChange.Instantiate( GetSeason(), true ) );
                    ns.Send( new MobileUpdate( this ) );
                    ClearFastwalkStack();
                }
            }

            if ( ns != null )
            {
                if ( m_Map != null )
                    Send( new ServerChange( this, m_Map ) );

                ns.Sequence = 0;
                ClearFastwalkStack();

                Send( new MobileIncoming( this, this ) );
                Send( new MobileUpdate( this ) );
                CheckLightLevels( true );
                Send( new MobileUpdate( this ) );
            }

            SendEverything();
            SendIncomingPacket();

            if ( ns != null )
            {
                m_NetState.Sequence = 0;
                ClearFastwalkStack();

                Send( new MobileIncoming( this, this ) );
                Send( SupportedFeatures.Instantiate( ns.Account ) );
                Send( new MobileUpdate( this ) );
                Send( new MobileAttributes( this ) );
            }

            OnMapChange( oldMap );
            OnLocationChange( oldLocation );

            m_Region.OnLocationChanged( this, oldLocation );
        }
Exemple #4
0
        public virtual void MoveToWorld( Point3D newLocation, Map map )
        {
            if ( m_Deleted )
                return;

            if ( m_Map == map )
            {
                SetLocation( newLocation, true );
                return;
            }

            BankBox box = FindBankNoCreate();

            if ( box != null && box.Opened )
                box.Close();

            Point3D oldLocation = m_Location;
            Map oldMap = m_Map;

            //Region oldRegion = m_Region;

            if ( oldMap != null )
            {
                oldMap.OnLeave( this );

                this.ClearScreen();
                this.SendRemovePacket();
            }

            for ( int i = 0; i < m_EquippedItems.Count; ++i )
                ( (Item) m_EquippedItems[i] ).Map = map;

            m_Map = map;

            m_Location = newLocation;

            GameClient ns = m_Client;

            if ( m_Map != null )
            {
                m_Map.OnEnter( this );

                UpdateRegion();

                if ( ns != null && m_Map != null )
                {
                    ns.Sequence = 0;
                    ns.Send( new MapChange( this ) );
                    ns.Send( SeasonChange.Instantiate( GetSeason(), true ) );
                    ns.Send( new MobileUpdate( this ) );
                    ClearFastwalkStack();
                }
            }
            else
            {
                UpdateRegion();
            }

            if ( ns != null )
            {
                if ( m_Map != null )
                    Send( new ServerChange( this, m_Map ) );

                ns.Sequence = 0;
                ClearFastwalkStack();

                Send( new MobileIncoming( this, this ) );
                Send( new MobileUpdate( this ) );
                CheckLightLevels( true );
                Send( new MobileUpdate( this ) );
            }

            this.SendEverything();
            this.SendIncomingPacket();

            if ( ns != null )
            {
                m_Client.Sequence = 0;
                ClearFastwalkStack();

                Send( new MobileIncoming( this, this ) );
                Send( SupportedFeatures.Instantiate( ns ) );
                Send( new MobileUpdate( this ) );
                Send( new MobileAttributes( this ) );
            }

            EventSink.Instance.InvokeMapChanged( new MapChangedEventArgs( this, oldMap ) );

            OnMapChange( oldMap );
            OnLocationChange( oldLocation );

            if ( m_Region != null )
                m_Region.OnLocationChanged( this, oldLocation );
        }
Exemple #5
0
        /// <summary>
        /// Moves the Item to a given <paramref name="location" /> and <paramref name="map" />.
        /// </summary>
        public void MoveToWorld( Point3D location, Map map )
        {
            if ( Deleted )
                return;

            Point3D oldLocation = GetWorldLocation();
            Point3D oldRealLocation = m_Location;

            SetLastMoved();

            if ( Parent is Mobile )
                ( (Mobile) Parent ).RemoveItem( this );
            else if ( Parent is Item )
                ( (Item) Parent ).RemoveItem( this );

            if ( m_Map != map )
            {
                Map old = m_Map;

                if ( m_Map != null )
                {
                    m_Map.OnLeave( this );

                    if ( oldLocation.X != 0 )
                    {
                        Packet remPacket = null;

                        foreach ( GameClient state in m_Map.GetClientsInRange( oldLocation, GetMaxUpdateRange() ) )
                        {
                            Mobile m = state.Mobile;

                            if ( m.InRange( oldLocation, GetUpdateRange( m ) ) )
                            {
                                if ( remPacket == null )
                                    remPacket = this.RemovePacket;

                                state.Send( remPacket );
                            }
                        }
                    }
                }

                m_Location = location;
                this.OnLocationChange( oldRealLocation );

                ReleaseWorldPackets();

                if ( m_Items != null )
                {
                    for ( int i = 0; i < m_Items.Count; ++i )
                        ( (Item) m_Items[i] ).Map = map;
                }

                m_Map = map;

                if ( m_Map != null )
                    m_Map.OnEnter( this );

                OnMapChange();

                EventSink.Instance.InvokeMapChanged( new MapChangedEventArgs( this, old ) );

                if ( m_Map != null )
                {
                    foreach ( GameClient state in m_Map.GetClientsInRange( m_Location, GetMaxUpdateRange() ) )
                    {
                        Mobile m = state.Mobile;

                        if ( m.CanSee( this ) && m.InRange( m_Location, GetUpdateRange( m ) ) )
                            SendInfoTo( state );
                    }
                }

                RemDelta( ItemDelta.Update );

                if ( old == null || old == Map.Internal )
                    InvalidateProperties();
            }
            else if ( m_Map != null )
            {
                if ( oldLocation.X != 0 )
                {
                    Packet removeThis = null;

                    foreach ( GameClient state in m_Map.GetClientsInRange( oldLocation, GetMaxUpdateRange() ) )
                    {
                        Mobile m = state.Mobile;

                        if ( !m.InRange( location, GetUpdateRange( m ) ) )
                        {
                            if ( removeThis == null )
                                removeThis = this.RemovePacket;

                            state.Send( removeThis );
                        }
                    }
                }

                Point3D oldInternalLocation = m_Location;

                m_Location = location;
                this.OnLocationChange( oldRealLocation );

                ReleaseWorldPackets();

                foreach ( GameClient state in m_Map.GetClientsInRange( m_Location, GetMaxUpdateRange() ) )
                {
                    Mobile m = state.Mobile;

                    if ( m.CanSee( this ) && m.InRange( m_Location, GetUpdateRange( m ) ) )
                        SendInfoTo( state );
                }

                m_Map.OnMove( oldInternalLocation, this );

                RemDelta( ItemDelta.Update );
            }
            else
            {
                Map = map;
                Location = location;
            }
        }
Exemple #6
0
		public virtual void Deserialize(GenericReader reader)
		{
			int version = reader.ReadInt();

			SetLastMoved();

			// must always read this first
			SaveFlag flags = 0;
			if (version >= 5)
				flags = (SaveFlag)reader.ReadInt32();

			switch (version)
			{
				case 10:
					{	// get the per item custom drop rate
						if (GetSaveFlag(flags, SaveFlag.DropRate))
							m_DropRate = reader.ReadDouble();
					}
					goto case 9;
				case 9:
					goto case 8;
				case 8:
					goto case 7;// change is at bottom of file after ImplFlags are read
				case 7:
					goto case 6;
				case 6:
					{
						if (version < 7)
						{
							LastMoved = reader.ReadDeltaTime();
						}
						else
						{
							int minutes = reader.ReadEncodedInt();

							try { LastMoved = DateTime.Now - TimeSpan.FromMinutes(minutes); }
							catch { LastMoved = DateTime.Now; }
						}

						if (GetSaveFlag(flags, SaveFlag.Direction))
							m_Direction = (Direction)reader.ReadByte();

						if (GetSaveFlag(flags, SaveFlag.Bounce))
							m_Bounce = BounceInfo.Deserialize(reader);

						if (GetSaveFlag(flags, SaveFlag.LootType))
							m_LootType = (LootType)reader.ReadByte();

						int x = 0, y = 0, z = 0;

						if (GetSaveFlag(flags, SaveFlag.LocationFull))
						{
							x = reader.ReadEncodedInt();
							y = reader.ReadEncodedInt();
							z = reader.ReadEncodedInt();
						}
						else
						{
							if (GetSaveFlag(flags, SaveFlag.LocationByteXY))
							{
								x = reader.ReadByte();
								y = reader.ReadByte();
							}
							else if (GetSaveFlag(flags, SaveFlag.LocationShortXY))
							{
								x = reader.ReadShort();
								y = reader.ReadShort();
							}

							if (GetSaveFlag(flags, SaveFlag.LocationSByteZ))
								z = reader.ReadSByte();
						}

						m_Location = new Point3D(x, y, z);

						if (GetSaveFlag(flags, SaveFlag.ItemID))
							m_ItemID = reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.Hue))
							m_Hue = reader.ReadEncodedInt();

						if (GetSaveFlag(flags, SaveFlag.Amount))
							m_Amount = reader.ReadEncodedInt();
						else
							m_Amount = 1;

						if (GetSaveFlag(flags, SaveFlag.Layer))
							m_Layer = (Layer)reader.ReadByte();

						if (GetSaveFlag(flags, SaveFlag.Name))
							m_Name = reader.ReadString();

						if (GetSaveFlag(flags, SaveFlag.Parent))
						{
							Serial parent = reader.ReadInt32();

							if (parent.IsMobile)
								m_Parent = World.FindMobile(parent);
							else if (parent.IsItem)
								m_Parent = World.FindItem(parent);
							else
								m_Parent = null;

							if (m_Parent == null && (parent.IsMobile || parent.IsItem))
								Delete();
						}

						if (GetSaveFlag(flags, SaveFlag.Items))
							m_Items = reader.ReadItemList();
						//else
						//	m_Items = new ArrayList( 1 );

						if (GetSaveFlag(flags, SaveFlag.IntWeight))
							m_Weight = reader.ReadEncodedInt();
						else if (GetSaveFlag(flags, SaveFlag.WeightNot1or0))
							m_Weight = reader.ReadDouble();
						else if (GetSaveFlag(flags, SaveFlag.WeightIs0))
							m_Weight = 0.0;
						else
							m_Weight = 1.0;

						if (GetSaveFlag(flags, SaveFlag.Map))
							m_Map = reader.ReadMap();
						else
							m_Map = Map.Internal;

						if (GetSaveFlag(flags, SaveFlag.Visible))
							SetFlag(ImplFlag.Visible, reader.ReadBool());
						else
							SetFlag(ImplFlag.Visible, true);

						if (GetSaveFlag(flags, SaveFlag.Movable))
							SetFlag(ImplFlag.Movable, reader.ReadBool());
						else
							SetFlag(ImplFlag.Movable, true);

						if (GetSaveFlag(flags, SaveFlag.Stackable))
							SetFlag(ImplFlag.Stackable, reader.ReadBool());

						if (GetSaveFlag(flags, SaveFlag.ImplFlags))
						{
							m_Flags = (ImplFlag)reader.ReadEncodedInt();
						}

						// don't confuse ImplFlag.FreezeDried with SaveFlag.FreezeDried
						// we check different flags because of a version quirk - ask Taran
						if (GetFlag(ImplFlag.FreezeDried))
						{
							TotalWeight = reader.ReadInt32();
							TotalItems = reader.ReadInt32();
							TotalGold = reader.ReadInt32();
						}

						if (GetSaveFlag(flags, SaveFlag.FreezeDried))
						{
							int count = reader.ReadInt();
							m_SerializedContentsIdx = new byte[count];
							for (int i = 0; i < count; i++)
								m_SerializedContentsIdx[i] = reader.ReadByte();
							count = reader.ReadInt();
							m_SerializedContentsBin = new byte[count];
							for (int i = 0; i < count; i++)
								m_SerializedContentsBin[i] = reader.ReadByte();
						}

						if (GetSaveFlag(flags, SaveFlag.InsuredFor))
							/*m_InsuredFor = */
							reader.ReadMobile();

						if (GetSaveFlag(flags, SaveFlag.BlessedFor))
							m_BlessedFor = reader.ReadMobile();

						if (GetSaveFlag(flags, SaveFlag.HeldBy))
							m_HeldBy = reader.ReadMobile();

						if (GetSaveFlag(flags, SaveFlag.SavedFlags))
							m_SavedFlags = reader.ReadEncodedInt();

						//wea: 13/Mar/2007 Rare Factory
						if (GetSaveFlag(flags, SaveFlag.RareData))
							m_RareData = (UInt32)reader.ReadInt();

						if (m_Map != null && m_Parent == null)
							m_Map.OnEnter(this);

						break;
					}
				case 5:
					{
						//SaveFlag flags = (SaveFlag)reader.ReadInt();

						LastMoved = reader.ReadDeltaTime();

						if (GetSaveFlag(flags, SaveFlag.Direction))
							m_Direction = (Direction)reader.ReadByte();

						if (GetSaveFlag(flags, SaveFlag.Bounce))
							m_Bounce = BounceInfo.Deserialize(reader);

						if (GetSaveFlag(flags, SaveFlag.LootType))
							m_LootType = (LootType)reader.ReadByte();

						if (GetSaveFlag(flags, SaveFlag.LocationFull))
							m_Location = reader.ReadPoint3D();

						if (GetSaveFlag(flags, SaveFlag.ItemID))
							m_ItemID = reader.ReadInt();

						if (GetSaveFlag(flags, SaveFlag.Hue))
							m_Hue = reader.ReadInt();

						if (GetSaveFlag(flags, SaveFlag.Amount))
							m_Amount = reader.ReadInt();
						else
							m_Amount = 1;

						if (GetSaveFlag(flags, SaveFlag.Layer))
							m_Layer = (Layer)reader.ReadByte();

						if (GetSaveFlag(flags, SaveFlag.Name))
							m_Name = reader.ReadString();

						if (GetSaveFlag(flags, SaveFlag.Parent))
						{
							Serial parent = reader.ReadInt();

							if (parent.IsMobile)
								m_Parent = World.FindMobile(parent);
							else if (parent.IsItem)
								m_Parent = World.FindItem(parent);
							else
								m_Parent = null;

							if (m_Parent == null && (parent.IsMobile || parent.IsItem))
								Delete();
						}

						if (GetSaveFlag(flags, SaveFlag.Items))
							m_Items = reader.ReadItemList();
						//else
						//	m_Items = new ArrayList( 1 );

						if (GetSaveFlag(flags, SaveFlag.IntWeight))
							m_Weight = reader.ReadEncodedInt();
						else if (GetSaveFlag(flags, SaveFlag.WeightNot1or0))
							m_Weight = reader.ReadDouble();
						else if (GetSaveFlag(flags, SaveFlag.WeightIs0))
							m_Weight = 0.0;
						else
							m_Weight = 1.0;

						if (GetSaveFlag(flags, SaveFlag.Map))
							m_Map = reader.ReadMap();
						else
							m_Map = Map.Internal;

						if (GetSaveFlag(flags, SaveFlag.Visible))
							SetFlag(ImplFlag.Visible, reader.ReadBool());
						else
							SetFlag(ImplFlag.Visible, true);

						if (GetSaveFlag(flags, SaveFlag.Movable))
							SetFlag(ImplFlag.Movable, reader.ReadBool());
						else
							SetFlag(ImplFlag.Movable, true);

						if (GetSaveFlag(flags, SaveFlag.Stackable))
							SetFlag(ImplFlag.Stackable, reader.ReadBool());

						if (m_Map != null && m_Parent == null)
							m_Map.OnEnter(this);


						break;
					}
				case 4: // Just removed variables
				case 3:
					{
						m_Direction = (Direction)reader.ReadInt();

						goto case 2;
					}
				case 2:
					{
						m_Bounce = BounceInfo.Deserialize(reader);
						LastMoved = reader.ReadDeltaTime();

						goto case 1;
					}
				case 1:
					{
						m_LootType = (LootType)reader.ReadByte();//m_Newbied = reader.ReadBool();

						goto case 0;
					}
				case 0:
					{
						m_Location = reader.ReadPoint3D();
						m_ItemID = reader.ReadInt();
						m_Hue = reader.ReadInt();
						m_Amount = reader.ReadInt();
						m_Layer = (Layer)reader.ReadByte();
						m_Name = reader.ReadString();

						Serial parent = reader.ReadInt();

						if (parent.IsMobile)
							m_Parent = World.FindMobile(parent);
						else if (parent.IsItem)
							m_Parent = World.FindItem(parent);
						else
							m_Parent = null;

						if (m_Parent == null && (parent.IsMobile || parent.IsItem))
							Delete();

						int count = reader.ReadInt();

						if (count > 0)
						{
							m_Items = new ArrayList(count);

							for (int i = 0; i < count; ++i)
							{
								Item item = reader.ReadItem();

								if (item != null)
									m_Items.Add(item);
							}
						}

						m_Weight = reader.ReadDouble();

						if (version <= 3)
						{
							/*m_TotalItems =*/
							reader.ReadInt();
							/*m_TotalWeight =*/
							reader.ReadInt();
							/*m_TotalGold =*/
							reader.ReadInt();
						}

						m_Map = reader.ReadMap();
						SetFlag(ImplFlag.Visible, reader.ReadBool());
						SetFlag(ImplFlag.Movable, reader.ReadBool());

						if (version <= 3)
							/*m_Deleted =*/
							reader.ReadBool();

						Stackable = reader.ReadBool();

						if (m_Map != null && m_Parent == null)
							m_Map.OnEnter(this);

						break;
					}
			}

			if (m_HeldBy != null)
				Timer.DelayCall(TimeSpan.Zero, new TimerCallback(FixHolding_Sandbox));
		}