From b54bf2c8bb6f8d7d8c37bdfe62dec776200d9fcf Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 27 Oct 2009 04:32:03 +0000 Subject: [PATCH] Resolve: Damage can potentially modify the collection during the enumeration. --- Scripts/Items/Misc/AcidSlime.cs | 13 +++++++++---- Scripts/Items/Misc/PoolOfAcid.cs | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Scripts/Items/Misc/AcidSlime.cs b/Scripts/Items/Misc/AcidSlime.cs index 2aa47f712..0fd456c81 100644 --- a/Scripts/Items/Misc/AcidSlime.cs +++ b/Scripts/Items/Misc/AcidSlime.cs @@ -47,23 +47,28 @@ namespace Server.Items DateTime now = DateTime.Now; TimeSpan age = now - m_Created; - if( age > m_Duration ) + if( age > m_Duration ) { Delete(); - else - { + } else { if( !m_Drying && age > (m_Duration - age) ) { m_Drying = true; ItemID = 0x122B; } + + List toDamage = new List(); + foreach( Mobile m in GetMobilesInRange( 0 ) ) { BaseCreature bc = m as BaseCreature; if( m.Alive && !m.IsDeadBondedPet && (bc == null || bc.Controlled || bc.Summoned) ) { - Damage ( m ); + toDamage.Add( m ); } } + + for ( int i = 0; i < toDamage.Count; i++ ) + Damage( toDamage[i] ); } } diff --git a/Scripts/Items/Misc/PoolOfAcid.cs b/Scripts/Items/Misc/PoolOfAcid.cs index b385d100b..2bd3f8dab 100644 --- a/Scripts/Items/Misc/PoolOfAcid.cs +++ b/Scripts/Items/Misc/PoolOfAcid.cs @@ -49,24 +49,29 @@ namespace Server.Items DateTime now = DateTime.Now; TimeSpan age = now - m_Created; - if( age > m_Duration ) + if( age > m_Duration ) { Delete(); - else - { + } else { if( !m_Drying && age > (m_Duration - age) ) { m_Drying = true; ItemID = 0x122B; } + + List toDamage = new List(); + foreach( Mobile m in GetMobilesInRange( 0 ) ) { BaseCreature bc = m as BaseCreature; if( m.Alive && !m.IsDeadBondedPet && (bc == null || bc.Controlled || bc.Summoned) ) { - Damage ( m ); + toDamage.Add( m ); } } + + for ( int i = 0; i < toDamage.Count; i++ ) + Damage( toDamage[i] ); } } public override bool OnMoveOver( Mobile m )