Fixes BuffIcon is NPE (#259)

- [X] Fixes BuffIconTable accessed while null
This commit is contained in:
Kamron Batman 2020-09-19 15:56:22 -07:00 • committed by GitHub
parent e9c1e4cbba
commit fd9ec089f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 19 deletions

View file

@ -131,26 +131,17 @@ namespace Server
public static void AddBuff(Mobile m, BuffInfo b) public static void AddBuff(Mobile m, BuffInfo b)
{ {
if (m is PlayerMobile pm) (m as PlayerMobile)?.AddBuff(b);
{
pm.AddBuff(b);
}
} }
public static void RemoveBuff(Mobile m, BuffInfo b) public static void RemoveBuff(Mobile m, BuffInfo b)
{ {
if (m is PlayerMobile pm) (m as PlayerMobile)?.RemoveBuff(b);
{
pm.RemoveBuff(b);
}
} }
public static void RemoveBuff(Mobile m, BuffIcon b) public static void RemoveBuff(Mobile m, BuffIcon b)
{ {
if (m is PlayerMobile pm) (m as PlayerMobile)?.RemoveBuff(b);
{
pm.RemoveBuff(b);
}
} }
} }

View file

@ -4640,12 +4640,7 @@ namespace Server.Mobiles
public void ResendBuffs() public void ResendBuffs()
{ {
if (!BuffInfo.Enabled || m_BuffTable == null) if (BuffInfo.Enabled && m_BuffTable != null && NetState?.BuffIcon == true)
{
return;
}
if (NetState?.BuffIcon == true)
{ {
foreach (var info in m_BuffTable.Values) foreach (var info in m_BuffTable.Values)
{ {
@ -4685,7 +4680,7 @@ namespace Server.Mobiles
public void RemoveBuff(BuffIcon b) public void RemoveBuff(BuffIcon b)
{ {
if (!m_BuffTable.Remove(b, out var info)) if (m_BuffTable == null || !m_BuffTable.Remove(b, out var info))
{ {
return; return;
} }