Fixes dictionary uses (#7)

This commit is contained in:
Kamron Batman 2018-11-02 08:16:42 -07:00 • committed by GitHub
parent d4a52344f2
commit 916d404c51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
161 changed files with 1211 additions and 1722 deletions

View file

@ -23,27 +23,19 @@ namespace Server.Items
{
}
public static Dictionary<Mobile, CandyCaneTimer> ToothAches{ get; set; }
public static void Initialize()
{
ToothAches = new Dictionary<Mobile, CandyCaneTimer>();
}
private static Dictionary<Mobile, CandyCaneTimer> m_ToothAches = new Dictionary<Mobile, CandyCaneTimer>();
private static CandyCaneTimer EnsureTimer(Mobile from)
{
if (!ToothAches.TryGetValue(from, out CandyCaneTimer timer))
ToothAches[from] = timer = new CandyCaneTimer(from);
if (!m_ToothAches.TryGetValue(from, out CandyCaneTimer timer))
m_ToothAches[from] = timer = new CandyCaneTimer(from);
return timer;
}
public static int GetToothAche(Mobile from)
{
if (ToothAches.TryGetValue(from, out CandyCaneTimer timer))
return timer.Eaten;
return 0;
return m_ToothAches.TryGetValue(from, out CandyCaneTimer timer) ? timer.Eaten : 0;
}
public static void SetToothAche(Mobile from, int value)
@ -92,7 +84,7 @@ namespace Server.Items
if (Eater == null || Eater.Deleted || Eaten <= 0)
{
Stop();
ToothAches.Remove(Eater);
m_ToothAches.Remove(Eater);
}
else if (Eater.Map != Map.Internal && Eater.Alive)
{
@ -171,4 +163,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}