Fixes null propogation

This commit is contained in:
Kamron Batman 2018-09-14 13:49:23 -07:00
parent 22ab83ea9e
commit 3c9842ee5a
218 changed files with 799 additions and 1458 deletions

View file

@ -110,8 +110,8 @@ namespace Server.Misc
if (Settings.KickOnFailure)
m.Send(new BeginHandshake());
if (m_Dictionary.TryGetValue(m, out Timer t) && t != null)
t.Stop();
if (m_Dictionary.TryGetValue(m, out Timer t))
t?.Stop();
m_Dictionary[m] = t = Timer.DelayCall(Settings.HandshakeTimeout, OnHandshakeTimeout_Callback, m);
t.Start();

View file

@ -513,11 +513,9 @@ namespace Server
}
else
{
if ( first != null )
first.Delete();
first?.Delete();
if ( second != null )
second.Delete();
second?.Delete();
}
}
}
@ -539,11 +537,9 @@ namespace Server
}
else
{
if ( first != null )
first.Delete();
first?.Delete();
if ( second != null )
second.Delete();
second?.Delete();
}
}
}

View file

@ -257,10 +257,7 @@ namespace Server.Misc
{
Mobile mob = acc[i];
if ( mob == null )
continue;
string lang = mob.Language;
string lang = mob?.Language;
if ( lang != null )
{

View file

@ -25,8 +25,7 @@ namespace Server
NetState ns = NetState.Instances[i];
Mobile m = ns.Mobile;
if ( m != null )
m.CheckLightLevels( false );
m?.CheckLightLevels( false );
}
}
}
@ -113,8 +112,7 @@ namespace Server
NetState ns = NetState.Instances[i];
Mobile m = ns.Mobile;
if ( m != null )
m.CheckLightLevels( false );
m?.CheckLightLevels( false );
}
}
}

View file

@ -35,8 +35,7 @@ namespace Server.Misc
{
NetState ns = from.NetState;
if ( ns != null )
ns.Dispose();
ns?.Dispose();
return false;
}

View file

@ -131,10 +131,7 @@ namespace Server
public static implicit operator string( TextDefinition m )
{
if ( m == null )
return null;
return m.m_String;
return m?.m_String;
}
public static void AddHtmlText( Gump g, int x, int y, int width, int height, TextDefinition def, bool back, bool scroll, int numberColor, int stringColor )

View file

@ -12,8 +12,7 @@ namespace Server
public static void Initialize()
{
if ( StartValidation != null )
StartValidation();
StartValidation?.Invoke();
StartValidation = null;
}

View file

@ -198,8 +198,7 @@ namespace Server.Misc
List<Weather> list = GetWeatherList( facet );
if ( list != null )
list.Add( this );
list?.Add( this );
Timer.DelayCall( TimeSpan.FromSeconds( (0.2+(Utility.RandomDouble()*0.8)) * interval.TotalSeconds ), interval, new TimerCallback( OnTick ) );
}