Potential deletion of item outside of main thread issue resolved

Item.Spawner now uses CompactInfo for memory savings.
Empty accounts (No Characters) can now be set to go inactive sooner than accounts with characters.
This commit is contained in:
asayre 2011-12-31 07:50:54 +00:00
parent 6a98ff0965
commit d2f79e93ea
5 changed files with 60 additions and 21 deletions

View file

@ -19,6 +19,8 @@ namespace Server.Accounting
public static readonly TimeSpan YoungDuration = TimeSpan.FromHours( 40.0 );
public static readonly TimeSpan InactiveDuration = TimeSpan.FromDays( 180.0 );
public static readonly TimeSpan EmptyInactiveDuration = TimeSpan.FromDays( 30.0 );
private string m_Username, m_PlainPassword, m_CryptPassword, m_NewCryptPassword;
private AccessLevel m_AccessLevel;
@ -221,11 +223,19 @@ namespace Server.Accounting
}
/// <summary>
/// An account is considered inactive based upon LastLogin and InactiveDuration
/// An account is considered inactive based upon LastLogin and InactiveDuration. If the account is empty, it is based upon EmptyInactiveDuration
/// </summary>
public bool Inactive
{
get { return ( ( m_LastLogin + InactiveDuration ) <= DateTime.Now && AccessLevel == AccessLevel.Player ); }
get
{
if( this.AccessLevel != AccessLevel.Player )
return false;
TimeSpan inactiveLength = DateTime.Now - m_LastLogin;
return (inactiveLength > ((this.Count == 0) ? EmptyInactiveDuration : InactiveDuration));
}
}
/// <summary>

View file

@ -210,7 +210,7 @@ namespace Server.Commands
int[] countTable = typeTable[itemType] as int[];
if ( countTable == null )
typeTable[itemType] = countTable = new int[8];
typeTable[itemType] = countTable = new int[9];
if ( ( flags & ExpandFlag.Name ) != 0 )
++countTable[0];
@ -236,6 +236,9 @@ namespace Server.Commands
if ( ( flags & ExpandFlag.Weight ) != 0 )
++countTable[7];
if ((flags & ExpandFlag.Spawner) != 0)
++countTable[8];
itemType = itemType.BaseType;
} while ( itemType != typeof( object ) );
}
@ -253,7 +256,8 @@ namespace Server.Commands
"Blessed",
"TempFlag",
"SaveFlag",
"Weight"
"Weight",
"Spawner"
};
ArrayList list = new ArrayList( typeTable );

View file

@ -547,16 +547,17 @@ namespace Server
[Flags]
public enum ExpandFlag
{
None = 0x00,
None = 0x000,
Name = 0x01,
Items = 0x02,
Bounce = 0x04,
Holder = 0x08,
Blessed = 0x10,
TempFlag = 0x20,
SaveFlag = 0x40,
Weight = 0x80
Name = 0x001,
Items = 0x002,
Bounce = 0x004,
Holder = 0x008,
Blessed = 0x010,
TempFlag = 0x020,
SaveFlag = 0x040,
Weight = 0x080,
Spawner = 0x100
}
public class Item : IEntity, IHued, IComparable<Item>, ISerializable, ISpawnable
@ -704,6 +705,8 @@ namespace Server
public Mobile m_HeldBy;
public Mobile m_BlessedFor;
public ISpawner m_Spawner;
public int m_TempFlags;
public int m_SavedFlags;
@ -735,6 +738,9 @@ namespace Server
if ( info.m_Name != null )
flags |= ExpandFlag.Name;
if (info.m_Spawner != null)
flags |= ExpandFlag.Spawner;
if ( info.m_SavedFlags != 0 )
flags |= ExpandFlag.SaveFlag;
@ -778,6 +784,7 @@ namespace Server
|| ( info.m_Bounce != null )
|| ( info.m_HeldBy != null )
|| ( info.m_BlessedFor != null )
|| ( info.m_Spawner != null )
|| ( info.m_TempFlags != 0 )
|| ( info.m_SavedFlags != 0 )
|| ( info.m_Weight != -1 );
@ -3263,10 +3270,10 @@ namespace Server
public virtual void OnDelete()
{
if ( m_Spawner != null )
if (this.Spawner != null)
{
m_Spawner.Remove( this );
m_Spawner = null;
this.Spawner.Remove(this);
this.Spawner = null;
}
}
@ -3438,10 +3445,28 @@ namespace Server
return true;
}
//TODO: Move to CompactInfo.
private ISpawner m_Spawner;
public ISpawner Spawner
{
get
{
CompactInfo info = LookupCompactInfo();
public ISpawner Spawner{ get{ return m_Spawner; } set{ m_Spawner = value; } }
if (info != null)
return info.m_Spawner;
return null;
}
set
{
CompactInfo info = AcquireCompactInfo();
info.m_Spawner = value;
if (info.m_Spawner == null)
VerifyCompactInfo();
}
}
public virtual void OnBeforeSpawn( Point3D location, Map m )
{

View file

@ -8094,7 +8094,7 @@ namespace Server
}
}
item.Delete();
Timer.DelayCall( TimeSpan.Zero, delegate { item.Delete(); } );
}
}

View file

@ -70,7 +70,7 @@ namespace Server {
{
if( m_DiskWriteHandle.Set())
{
Console.WriteLine("Closing Save Files...");
Console.WriteLine("Closing Save Files. ");
}
}