Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -66,6 +66,7 @@ namespace Server.Engines.MLQuests
}
catch
{
// ignored
}
if (quest == null)
@ -128,7 +129,7 @@ namespace Server.Engines.MLQuests
if (AutoGenerateNew)
foreach (MLQuest quest in Quests.Values)
if (quest != null && !quest.Deserialized)
if (quest?.Deserialized == false)
quest.Generate();
MLQuestPersistence.EnsureExistence();
@ -555,7 +556,7 @@ namespace Server.Engines.MLQuests
foreach (MLQuest quest in quests)
{
if (quest.IsChainTriggered || context != null && context.IsDoingQuest(quest))
if (quest.IsChainTriggered || context?.IsDoingQuest(quest) == true)
continue;
/*
@ -569,10 +570,7 @@ namespace Server.Engines.MLQuests
m_EligiblePool.Add(quest);
}
if (m_EligiblePool.Count == 0)
return fallback;
return m_EligiblePool[Utility.Random(m_EligiblePool.Count)];
return m_EligiblePool.Count == 0 ? fallback : m_EligiblePool[Utility.Random(m_EligiblePool.Count)];
}
public static void TurnToFace(IQuestGiver quester, Mobile mob)
@ -590,7 +588,7 @@ namespace Server.Engines.MLQuests
else if (quester is Item item)
MessageHelper.SendLocalizedMessageTo(item, pm, cliloc, SpeechColor);
else
pm.SendLocalizedMessage(cliloc, "", SpeechColor);
pm.SendLocalizedMessage(cliloc);
}
public static void Tell(IQuestGiver quester, PlayerMobile pm, int cliloc, string args)
@ -602,7 +600,7 @@ namespace Server.Engines.MLQuests
else if (quester is Item item)
MessageHelper.SendLocalizedMessageTo(item, pm, cliloc, args, SpeechColor);
else
pm.SendLocalizedMessage(cliloc, args, SpeechColor);
pm.SendLocalizedMessage(cliloc, args);
}
public static void Tell(IQuestGiver quester, PlayerMobile pm, string message)
@ -630,7 +628,7 @@ namespace Server.Engines.MLQuests
public static void WriteQuestRef(GenericWriter writer, MLQuest quest)
{
writer.Write(quest != null && quest.SaveEnabled ? quest.GetType().FullName : null);
writer.Write(quest?.SaveEnabled == true ? quest.GetType().FullName : null);
}
public static MLQuest ReadQuestRef(GenericReader reader)
@ -709,4 +707,4 @@ namespace Server.Engines.MLQuests
}
}
}
}
}