Fixes dictionary uses (#7)
This commit is contained in:
parent
d4a52344f2
commit
916d404c51
161 changed files with 1211 additions and 1722 deletions
|
|
@ -71,9 +71,7 @@ namespace Server.Multis
|
|||
|
||||
if (owner != null)
|
||||
{
|
||||
m_Table.TryGetValue(owner, out List<BaseHouse> list);
|
||||
|
||||
if (list == null)
|
||||
if (!m_Table.TryGetValue(owner, out List<BaseHouse> list))
|
||||
m_Table[owner] = list = new List<BaseHouse>();
|
||||
|
||||
list.Add(this);
|
||||
|
|
@ -276,9 +274,7 @@ namespace Server.Multis
|
|||
{
|
||||
if (m_Owner != null)
|
||||
{
|
||||
m_Table.TryGetValue(m_Owner, out List<BaseHouse> list);
|
||||
|
||||
if (list == null)
|
||||
if (!m_Table.TryGetValue(m_Owner, out List<BaseHouse> list))
|
||||
m_Table[m_Owner] = list = new List<BaseHouse>();
|
||||
|
||||
list.Remove(this);
|
||||
|
|
@ -289,9 +285,7 @@ namespace Server.Multis
|
|||
|
||||
if (m_Owner != null)
|
||||
{
|
||||
m_Table.TryGetValue(m_Owner, out List<BaseHouse> list);
|
||||
|
||||
if (list == null)
|
||||
if (!m_Table.TryGetValue(m_Owner, out List<BaseHouse> list))
|
||||
m_Table[m_Owner] = list = new List<BaseHouse>();
|
||||
|
||||
list.Add(this);
|
||||
|
|
@ -1111,9 +1105,7 @@ namespace Server.Multis
|
|||
|
||||
if (m != null)
|
||||
{
|
||||
m_Table.TryGetValue(m, out List<BaseHouse> exists);
|
||||
|
||||
if (exists != null)
|
||||
if (m_Table.TryGetValue(m, out List<BaseHouse> exists))
|
||||
for (int i = 0; i < exists.Count; ++i)
|
||||
{
|
||||
BaseHouse house = exists[i];
|
||||
|
|
@ -2616,9 +2608,7 @@ namespace Server.Multis
|
|||
|
||||
if (m_Owner != null)
|
||||
{
|
||||
m_Table.TryGetValue(m_Owner, out List<BaseHouse> list);
|
||||
|
||||
if (list == null)
|
||||
if (!m_Table.TryGetValue(m_Owner, out List<BaseHouse> list))
|
||||
m_Table[m_Owner] = list = new List<BaseHouse>();
|
||||
|
||||
list.Add(this);
|
||||
|
|
@ -2745,9 +2735,7 @@ namespace Server.Multis
|
|||
|
||||
if (m_Owner != null)
|
||||
{
|
||||
m_Table.TryGetValue(m_Owner, out List<BaseHouse> list);
|
||||
|
||||
if (list == null)
|
||||
if (!m_Table.TryGetValue(m_Owner, out List<BaseHouse> list))
|
||||
m_Table[m_Owner] = list = new List<BaseHouse>();
|
||||
|
||||
list.Remove(this);
|
||||
|
|
@ -2888,12 +2876,7 @@ namespace Server.Multis
|
|||
|
||||
public static bool HasHouse(Mobile m)
|
||||
{
|
||||
if (m == null)
|
||||
return false;
|
||||
|
||||
m_Table.TryGetValue(m, out List<BaseHouse> list);
|
||||
|
||||
if (list == null)
|
||||
if (m == null || !m_Table.TryGetValue(m, out List<BaseHouse> list))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
|
|
|
|||
|
|
@ -23,12 +23,7 @@ namespace Server.Multis
|
|||
|
||||
public static void Register(DecayLevel level, TimeSpan min, TimeSpan max)
|
||||
{
|
||||
DecayStageInfo info = new DecayStageInfo(min, max);
|
||||
|
||||
if (m_Stages.ContainsKey(level))
|
||||
m_Stages[level] = info;
|
||||
else
|
||||
m_Stages.Add(level, info);
|
||||
m_Stages[level] = new DecayStageInfo(min, max);
|
||||
}
|
||||
|
||||
public static bool Decays(DecayLevel level)
|
||||
|
|
@ -38,10 +33,9 @@ namespace Server.Multis
|
|||
|
||||
public static TimeSpan GetRandomDuration(DecayLevel level)
|
||||
{
|
||||
if (!m_Stages.ContainsKey(level))
|
||||
if (!m_Stages.TryGetValue(level, out DecayStageInfo info))
|
||||
return TimeSpan.Zero;
|
||||
|
||||
DecayStageInfo info = m_Stages[level];
|
||||
long min = info.MinDuration.Ticks;
|
||||
long max = info.MaxDuration.Ticks;
|
||||
|
||||
|
|
@ -61,4 +55,4 @@ namespace Server.Multis
|
|||
|
||||
public TimeSpan MaxDuration{ get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -803,7 +803,7 @@ namespace Server.Items
|
|||
|
||||
public static HousePlacementEntry Find(BaseHouse house)
|
||||
{
|
||||
object obj = m_Table[house.GetType()];
|
||||
m_Table.TryGetValue(house.GetType(), out object obj);
|
||||
|
||||
if (obj is HousePlacementEntry entry)
|
||||
return entry;
|
||||
|
|
@ -825,9 +825,7 @@ namespace Server.Items
|
|||
{
|
||||
HousePlacementEntry e = entries[i];
|
||||
|
||||
object obj = m_Table[e.Type];
|
||||
|
||||
if (obj == null)
|
||||
if (!m_Table.TryGetValue(e.Type, out object obj))
|
||||
{
|
||||
m_Table[e.Type] = e;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue