Fixed issue with decay erroneously triggering world save warnings.

This commit is contained in:
krrios 2007-04-20 22:35:41 +00:00
parent 0c7efa2419
commit 5be90584b6
4 changed files with 32 additions and 20 deletions

View file

@ -39,6 +39,8 @@ namespace Server {
public ParallelSaveStrategy( int processorCount ) {
this.processorCount = processorCount;
_decayQueue = new Queue<Item>();
}
private int GetThreadCount() {
@ -51,7 +53,7 @@ namespace Server {
private SequentialFileWriter mobileData, mobileIndex;
private SequentialFileWriter guildData, guildIndex;
private List<Item> decaying;
private Queue<Item> _decayQueue;
private Consumer[] consumers;
private int cycle;
@ -95,12 +97,14 @@ namespace Server {
Commit();
CloseFiles();
}
if ( decaying != null ) {
foreach ( Item item in decaying ) {
if ( item.OnDecay() ) {
item.Delete();
}
public override void ProcessDecay() {
while ( _decayQueue.Count > 0 ) {
Item item = _decayQueue.Dequeue();
if ( item.OnDecay() ) {
item.Delete();
}
}
}
@ -192,11 +196,7 @@ namespace Server {
}
if ( item.Decays && item.Parent == null && item.Map != Map.Internal && DateTime.Now > ( item.LastMoved + item.DecayTime ) ) {
if ( decaying == null ) {
decaying = new List<Item>();
}
decaying.Add( item );
_decayQueue.Enqueue( item );
}
}

View file

@ -46,5 +46,7 @@ namespace Server {
public abstract string Name { get; }
public abstract void Save( SaveMetrics metrics );
public abstract void ProcessDecay();
}
}

View file

@ -34,7 +34,10 @@ namespace Server {
get { return "Standard"; }
}
private Queue<Item> _decayQueue;
public StandardSaveStrategy() {
_decayQueue = new Queue<Item>();
}
public override void Save( SaveMetrics metrics ) {
@ -109,8 +112,9 @@ namespace Server {
idx.Write( ( int ) items.Count );
foreach ( Item item in items.Values ) {
if ( item.Decays && item.Parent == null && item.Map != Map.Internal && ( item.LastMoved + item.DecayTime ) <= DateTime.Now )
decaying.Add( item );
if ( item.Decays && item.Parent == null && item.Map != Map.Internal && ( item.LastMoved + item.DecayTime ) <= DateTime.Now ) {
_decayQueue.Enqueue( item );
}
long start = bin.Position;
@ -136,13 +140,6 @@ namespace Server {
idx.Close();
tdb.Close();
bin.Close();
for ( int i = 0; i < decaying.Count; ++i ) {
Item item = decaying[i];
if ( item.OnDecay() )
item.Delete();
}
}
protected void SaveGuilds( SaveMetrics metrics ) {
@ -177,5 +174,15 @@ namespace Server {
idx.Close();
bin.Close();
}
public override void ProcessDecay() {
while ( _decayQueue.Count > 0 ) {
Item item = _decayQueue.Dequeue();
if ( item.OnDecay() ) {
item.Delete();
}
}
}
}
}

View file

@ -787,8 +787,11 @@ namespace Server {
watch.Stop();
m_Saving = false;
ProcessSafetyQueues();
strategy.ProcessDecay();
Console.WriteLine( "done in {0:F2} seconds.", watch.Elapsed.TotalSeconds );
if ( message )