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

@ -12,7 +12,7 @@ namespace Server.SkillHandlers
{
public class AnimalTaming
{
private static Dictionary<Mobile, Mobile> m_BeingTamed = new Dictionary<Mobile, Mobile>();
private static HashSet<Mobile> m_BeingTamed = new HashSet<Mobile>();
public static bool DisableMessage{ get; set; }
@ -36,12 +36,10 @@ namespace Server.SkillHandlers
public static bool CheckMastery(Mobile tamer, BaseCreature creature)
{
if (SummonFamiliarSpell.Table[tamer] is DarkWolfFamiliar familiar && !familiar.Deleted)
if (creature is DireWolf || creature is GreyWolf || creature is TimberWolf || creature is WhiteWolf ||
creature is BakeKitsune)
return true;
return false;
return SummonFamiliarSpell.Table.TryGetValue(tamer, out BaseCreature bc) && bc is DarkWolfFamiliar familiar &&
!familiar.Deleted && (creature is DireWolf || creature is GreyWolf || creature is TimberWolf ||
creature is WhiteWolf ||
creature is BakeKitsune);
}
public static bool MustBeSubdued(BaseCreature bc)
@ -194,7 +192,7 @@ namespace Server.SkillHandlers
}
}
if (m_BeingTamed.ContainsKey(creature))
if (m_BeingTamed.Contains(creature))
{
creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502802,
from.NetState); // Someone else is already taming this.
@ -222,7 +220,7 @@ namespace Server.SkillHandlers
}
else
{
m_BeingTamed[creature] = from;
m_BeingTamed.Add(creature);
from.LocalOverheadMessage(MessageType.Emote, 0x59,
1010597); // You start to tame the creature.

View file

@ -35,9 +35,7 @@ namespace Server.SkillHandlers
public static bool GetEffect(Mobile targ, ref int effect)
{
DiscordanceInfo info = m_Table[targ];
if (info == null)
if (!m_Table.TryGetValue(targ, out DiscordanceInfo info))
return false;
effect = info.m_Effect;

View file

@ -43,9 +43,9 @@ namespace Server.SkillHandlers
public static bool IsEmpty(BaseBook book)
{
foreach (BookPageInfo page in book.Pages)
foreach (string line in page.Lines)
if (line.Trim().Length != 0)
return false;
foreach (string line in page.Lines)
if (line.Trim().Length != 0)
return false;
return true;
}
@ -170,4 +170,4 @@ namespace Server.SkillHandlers
}
}
}
}
}

View file

@ -35,9 +35,9 @@ namespace Server.SkillHandlers
public static double GetStalkingBonus(Mobile tracker, Mobile target)
{
m_Table.TryGetValue(tracker, out TrackingInfo info);
;
if (info == null || info.m_Target != target || info.m_Map != target.Map)
if (!m_Table.TryGetValue(tracker, out TrackingInfo info) || info.m_Target != target || info.m_Map != target.Map)
return 0.0;
int xDelta = info.m_Location.X - target.X;
@ -47,10 +47,7 @@ namespace Server.SkillHandlers
m_Table.Remove(tracker); //Reset as of Pub 40, counting it as bug for Core.SE.
if (Core.ML)
return Math.Min(bonus, 10 + tracker.Skills.Tracking.Value / 10);
return bonus;
return Core.ML ? Math.Min(bonus, 10 + tracker.Skills.Tracking.Value / 10) : bonus;
}
@ -399,4 +396,4 @@ namespace Server.SkillHandlers
}
}
}
}
}