Correct poor design in LampController constructor.
Iteration through World.Items.Values is expensive and unnecessary.
This commit is contained in:
parent
d91adf1abc
commit
0402061b87
1 changed files with 13 additions and 14 deletions
|
|
@ -75,27 +75,18 @@ namespace Server.Items
|
|||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool CanActive { get { return m_CanActive; } set { m_CanActive = value; } }
|
||||
|
||||
private bool Check()
|
||||
{
|
||||
foreach ( Item item in World.Items.Values )
|
||||
{
|
||||
if ( item is LampController && !item.Deleted && item != this )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
private static LampController _Instance = null;
|
||||
|
||||
// Should this even be constructable?
|
||||
[Constructable]
|
||||
public LampController() : base( 0x1BC3 )
|
||||
{
|
||||
if ( Check() )
|
||||
if ( _Instance != null )
|
||||
{
|
||||
World.Broadcast( 0x35, true, "Another Lamp's room controller exists in the world!" );
|
||||
Delete();
|
||||
return;
|
||||
} else {
|
||||
_Instance = this;
|
||||
}
|
||||
|
||||
Visible = false;
|
||||
|
|
@ -104,6 +95,12 @@ namespace Server.Items
|
|||
Setup();
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
_Instance = null;
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
m_CanActive = true;
|
||||
|
|
@ -499,6 +496,8 @@ namespace Server.Items
|
|||
|
||||
m_CanActive = true;
|
||||
m_Box.CanSummon = true;
|
||||
|
||||
_Instance = this;
|
||||
}
|
||||
|
||||
public class PoisonTimer : Timer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue