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

@ -228,13 +228,11 @@ namespace Server.Engines.ConPVP
get => m_Tournament;
set
{
if ( m_Tournament != null )
m_Tournament.Tournament.Arenas.Remove( this );
m_Tournament?.Tournament.Arenas.Remove( this );
m_Tournament = value;
if ( m_Tournament != null )
m_Tournament.Tournament.Arenas.Add( this );
m_Tournament?.Tournament.Arenas.Add( this );
}
}
@ -263,8 +261,7 @@ namespace Server.Engines.ConPVP
if ( m_Teleporter != null )
m_Teleporter.Map = value;
if ( m_Region != null )
m_Region.Unregister();
m_Region?.Unregister();
if ( m_Zone.Start != Point2D.Zero && m_Zone.End != Point2D.Zero && m_Facet != null )
m_Region = new SafeZone( m_Zone, m_Outside, m_Facet, m_IsGuarded );
@ -306,15 +303,13 @@ namespace Server.Engines.ConPVP
if ( m_Zone.Start != Point2D.Zero && m_Zone.End != Point2D.Zero && m_Facet != null )
{
if ( m_Region != null )
m_Region.Unregister();
m_Region?.Unregister();
m_Region = new SafeZone( m_Zone, m_Outside, m_Facet, m_IsGuarded );
}
else
{
if ( m_Region != null )
m_Region.Unregister();
m_Region?.Unregister();
m_Region = null;
}
@ -380,10 +375,9 @@ namespace Server.Engines.ConPVP
{
Active = false;
if ( m_Region != null )
m_Region.Unregister();
m_Region?.Unregister();
m_Region = null;
m_Region = null;
}
public override string ToString()
@ -589,8 +583,7 @@ namespace Server.Engines.ConPVP
private void AttachToTournament_Sandbox()
{
if ( m_Tournament != null )
m_Tournament.Tournament.Arenas.Add( this );
m_Tournament?.Tournament.Arenas.Add( this );
}
[CommandProperty( AccessLevel.Administrator, AccessLevel.Administrator )]

View file

@ -641,8 +641,8 @@ namespace Server.Engines.ConPVP
{
loser.Broadcast( 0x22, null, loser.Players.Length == 1 ? "{0} has lost the duel." : "{0} and {1} team have lost the duel.", loser.Players.Length == 1 ? "You have lost the duel." : "Your team has lost the duel." );
if ( m_Tournament != null && loser.TournyPart != null )
loser.TournyPart.LostMatch( m_Match );
if ( m_Tournament != null )
loser.TournyPart?.LostMatch( m_Match );
}
for ( int j = 0; j < loser.Players.Length; ++j )
@ -671,8 +671,7 @@ namespace Server.Engines.ConPVP
}
}
if ( m_EventGame != null )
m_EventGame.OnStop();
m_EventGame?.OnStop();
Timer.DelayCall( TimeSpan.FromSeconds( 9.0 ), new TimerCallback( UnregisterRematch ) );
}
@ -739,8 +738,7 @@ namespace Server.Engines.ConPVP
m_Registered = false;
if ( m_Arena != null )
m_Arena.Evict();
m_Arena?.Evict();
StopSDTimers();
@ -868,8 +866,7 @@ namespace Server.Engines.ConPVP
public void StopCountdown()
{
if ( m_Countdown != null )
m_Countdown.Stop();
m_Countdown?.Stop();
m_Countdown = null;
}
@ -883,8 +880,7 @@ namespace Server.Engines.ConPVP
if ( count==0 )
{
if ( m_Countdown != null )
m_Countdown.Stop();
m_Countdown?.Stop();
m_Countdown=null;
}
@ -909,26 +905,22 @@ namespace Server.Engines.ConPVP
public void StopSDTimers()
{
if ( m_SDWarnTimer != null )
m_SDWarnTimer.Stop();
m_SDWarnTimer?.Stop();
m_SDWarnTimer = null;
if ( m_SDActivateTimer != null )
m_SDActivateTimer.Stop();
m_SDActivateTimer?.Stop();
m_SDActivateTimer = null;
}
public void StartSuddenDeath( TimeSpan timeUntilActive )
{
if ( m_SDWarnTimer != null )
m_SDWarnTimer.Stop();
m_SDWarnTimer?.Stop();
m_SDWarnTimer = Timer.DelayCall( TimeSpan.FromMinutes( timeUntilActive.TotalMinutes * 0.9 ), new TimerCallback( WarnSuddenDeath ) );
if ( m_SDActivateTimer != null )
m_SDActivateTimer.Stop();
m_SDActivateTimer?.Stop();
m_SDActivateTimer = Timer.DelayCall( timeUntilActive, new TimerCallback( ActivateSuddenDeath ) );
}
@ -952,11 +944,9 @@ namespace Server.Engines.ConPVP
}
}
if ( m_Tournament != null )
m_Tournament.Alert( m_Arena, "Sudden death will be active soon!" );
m_Tournament?.Alert( m_Arena, "Sudden death will be active soon!" );
if ( m_SDWarnTimer != null )
m_SDWarnTimer.Stop();
m_SDWarnTimer?.Stop();
m_SDWarnTimer = null;
}
@ -985,21 +975,18 @@ namespace Server.Engines.ConPVP
}
}
if ( m_Tournament != null )
m_Tournament.Alert( m_Arena, "Sudden death has been activated!" );
m_Tournament?.Alert( m_Arena, "Sudden death has been activated!" );
m_IsSuddenDeath = true;
if ( m_SDActivateTimer != null )
m_SDActivateTimer.Stop();
m_SDActivateTimer?.Stop();
m_SDActivateTimer = null;
}
public void BeginAutoTie()
{
if ( m_AutoTieTimer != null )
m_AutoTieTimer.Stop();
m_AutoTieTimer?.Stop();
TimeSpan ts = ( m_Tournament == null || m_Tournament.TournyType == TournyType.Standard )
? AutoTieDelay
@ -1010,8 +997,7 @@ namespace Server.Engines.ConPVP
public void EndAutoTie()
{
if ( m_AutoTieTimer != null )
m_AutoTieTimer.Stop();
m_AutoTieTimer?.Stop();
m_AutoTieTimer = null;
}
@ -1066,8 +1052,7 @@ namespace Server.Engines.ConPVP
}
}
if ( m_Tournament != null )
m_Tournament.HandleTie( m_Arena, m_Match, remaining );
m_Tournament?.HandleTie( m_Arena, m_Match, remaining );
Timer.DelayCall( TimeSpan.FromSeconds( 10.0 ), new TimerCallback( Unregister ) );
}
@ -2297,10 +2282,7 @@ namespace Server.Engines.ConPVP
{
DuelPlayer pl = p.Players[j];
if ( pl == null )
continue;
Mobile mob = pl.Mobile;
Mobile mob = pl?.Mobile;
if ( mob != null )
{
@ -2390,8 +2372,7 @@ namespace Server.Engines.ConPVP
{
DuelPlayer dp = p.Players[j];
if ( dp != null )
dp.Mobile.SendMessage( "The duel could not be started because {0}.", error );
dp?.Mobile.SendMessage( "The duel could not be started because {0}.", error );
}
}
@ -2432,8 +2413,7 @@ namespace Server.Engines.ConPVP
{
DuelPlayer dp = p.Players[j];
if ( dp != null )
dp.Mobile.SendMessage( "The duel could not be started because there are no arenas. If you want to stop waiting for a free arena, yield the duel." );
dp?.Mobile.SendMessage( "The duel could not be started because there are no arenas. If you want to stop waiting for a free arena, yield the duel." );
}
}
@ -2491,8 +2471,7 @@ namespace Server.Engines.ConPVP
arena.MoveInside( p.Players, i );
}
if ( m_EventGame != null )
m_EventGame.OnStart();
m_EventGame?.OnStart();
StartCountdown( 10, new CountdownCallback( SendBeginGump ) );
@ -2508,8 +2487,7 @@ namespace Server.Engines.ConPVP
{
DuelPlayer dp = p.Players[j];
if ( dp != null )
dp.Mobile.SendMessage( "The duel could not be started because all arenas are full. If you want to stop waiting for a free arena, yield the duel." );
dp?.Mobile.SendMessage( "The duel could not be started because all arenas are full. If you want to stop waiting for a free arena, yield the duel." );
}
}
@ -2561,16 +2539,14 @@ namespace Server.Engines.ConPVP
public static void CloseAndSendGump( NetState ns, Gump g, params Type[] types )
{
if ( ns != null ) {
Mobile mob = ns.Mobile;
Mobile mob = ns?.Mobile;
if ( mob != null ) {
foreach ( Type type in types ) {
mob.CloseGump( type );
}
mob.SendGump( g );
if ( mob != null ) {
foreach ( Type type in types ) {
mob.CloseGump( type );
}
mob.SendGump( g );
}
/*if ( ns == null )

View file

@ -149,8 +149,10 @@ namespace Server.Engines.ConPVP
MoveToWorld( mob.Location, mob.Map );
else if ( killer != null && !killer.Deleted )
MoveToWorld( killer.Location, killer.Map );
else if ( m_Game != null )
m_Game.ReturnBomb();
else
{
m_Game?.ReturnBomb();
}
}
public override bool OnMoveOver( Mobile m )
@ -1564,8 +1566,7 @@ namespace Server.Engines.ConPVP
public void Alert( string text )
{
if ( m_Context.m_Tournament != null )
m_Context.m_Tournament.Alert( text );
m_Context.m_Tournament?.Alert( text );
for ( int i = 0; i < m_Context.Participants.Count; ++i )
{
@ -1734,8 +1735,7 @@ namespace Server.Engines.ConPVP
for ( int i = 0; i < m_Context.Participants.Count; ++i )
ApplyHues( m_Context.Participants[i] as Participant, m_Controller.TeamInfo[i % m_Controller.TeamInfo.Length].Color );
if ( m_FinishTimer != null )
m_FinishTimer.Stop();
m_FinishTimer?.Stop();
m_Bomb = new BRBomb( this );
ReturnBomb();

View file

@ -334,8 +334,7 @@ namespace Server.Engines.ConPVP
private void StopCountdown()
{
if ( m_ReturnTimer != null )
m_ReturnTimer.Stop();
m_ReturnTimer?.Stop();
m_ReturnTimer = null;
}
@ -364,8 +363,7 @@ namespace Server.Engines.ConPVP
case 2:
case 1:
{
if ( owner != null )
owner.SendMessage( 0x26, "You have {0} {1} to capture the cookies!", m_ReturnCount, m_ReturnCount == 1 ? "second" : "seconds" );
owner?.SendMessage( 0x26, "You have {0} {1} to capture the cookies!", m_ReturnCount, m_ReturnCount == 1 ? "second" : "seconds" );
break;
}
@ -380,8 +378,7 @@ namespace Server.Engines.ConPVP
SendHome();
if ( m_TeamInfo?.Game != null )
m_TeamInfo.Game.Alert( "The {0} cookies have been returned.", m_TeamInfo.Name );
m_TeamInfo?.Game?.Alert( "The {0} cookies have been returned.", m_TeamInfo.Name );
return;
}
@ -908,8 +905,7 @@ namespace Server.Engines.ConPVP
public void Alert( string text )
{
if ( m_Context.m_Tournament != null )
m_Context.m_Tournament.Alert( text );
m_Context.m_Tournament?.Alert( text );
for ( int i = 0; i < m_Context.Participants.Count; ++i )
{
@ -1112,8 +1108,7 @@ namespace Server.Engines.ConPVP
for ( int i = 0; i < m_Context.Participants.Count; ++i )
ApplyHues( m_Context.Participants[i] as Participant, m_Controller.TeamInfo[i % 8].Color );
if ( m_FinishTimer != null )
m_FinishTimer.Stop();
m_FinishTimer?.Stop();
m_FinishTimer = Timer.DelayCall( m_Controller.Duration, new TimerCallback( Finish_Callback ) );
}
@ -1304,8 +1299,7 @@ namespace Server.Engines.ConPVP
for ( int i = 0; i < m_Context.Participants.Count; ++i )
ApplyHues( m_Context.Participants[i] as Participant, -1 );
if ( m_FinishTimer != null )
m_FinishTimer.Stop();
m_FinishTimer?.Stop();
m_FinishTimer = null;
}

View file

@ -542,8 +542,7 @@ namespace Server.Engines.ConPVP
public void Alert( string text )
{
if ( m_Context.m_Tournament != null )
m_Context.m_Tournament.Alert( text );
m_Context.m_Tournament?.Alert( text );
for ( int i = 0; i < m_Context.Participants.Count; ++i )
{

View file

@ -67,9 +67,8 @@ namespace Server.Engines.ConPVP
{
if (m_Game != value)
{
if (m_KingTimer != null)
m_KingTimer.Stop();
m_Game = value;
m_KingTimer?.Stop();
m_Game = value;
m_King = null;
}
}
@ -171,10 +170,9 @@ namespace Server.Engines.ConPVP
{
PublicOverheadMessage(MessageType.Regular, 0x0481, false, "Free!");
if (m_KingTimer != null)
m_KingTimer.Stop();
m_KingTimer?.Stop();
m_King = null;
m_King = null;
}
private void ReKingify(Mobile m)
@ -308,11 +306,9 @@ namespace Server.Engines.ConPVP
{
if (m_Controller != value)
{
if (m_Controller != null)
m_Controller.RemoveBoard(this);
m_Controller = value;
if (m_Controller != null)
m_Controller.AddBoard(this);
m_Controller?.RemoveBoard(this);
m_Controller = value;
m_Controller?.AddBoard(this);
}
}
}
@ -930,10 +926,9 @@ namespace Server.Engines.ConPVP
public void Alert(string text)
{
if (m_Context.m_Tournament != null)
m_Context.m_Tournament.Alert(text);
m_Context.m_Tournament?.Alert(text);
for (int i = 0; i < m_Context.Participants.Count; ++i)
for (int i = 0; i < m_Context.Participants.Count; ++i)
{
Participant p = m_Context.Participants[i] as Participant;
@ -1097,10 +1092,9 @@ namespace Server.Engines.ConPVP
for (int i = 0; i < m_Context.Participants.Count; ++i)
ApplyHues(m_Context.Participants[i] as Participant, m_Controller.TeamInfo[i % m_Controller.TeamInfo.Length].Color);
if (m_FinishTimer != null)
m_FinishTimer.Stop();
m_FinishTimer?.Stop();
for (int i = 0; i < m_Controller.Hills.Length; i++)
for (int i = 0; i < m_Controller.Hills.Length; i++)
{
if (m_Controller.Hills[i] != null)
m_Controller.Hills[i].Game = this;

View file

@ -75,13 +75,10 @@ namespace Server.Engines.ConPVP
{
Ladder ladder = Ladder.Instance;
if ( ladder != null )
{
LadderEntry entry = ladder.Find( m );
LadderEntry entry = ladder?.Find( m );
if ( entry != null && Ladder.GetLevel( entry.Experience ) < tourny.LevelRequirement )
return;
}
if ( entry != null && Ladder.GetLevel( entry.Experience ) < tourny.LevelRequirement )
return;
if ( tourny.IsFactionRestricted && Faction.Find( m ) == null )
{
@ -603,9 +600,8 @@ namespace Server.Engines.ConPVP
}
case TournamentStage.Inactive:
{
if ( m_Registrar != null )
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "The tournament is closed.", from.NetState );
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "The tournament is closed.", @from.NetState );
break;
}
@ -613,11 +609,8 @@ namespace Server.Engines.ConPVP
{
if ( m_Players.Count != tourny.PlayersPerParticipant )
{
if ( m_Registrar != null )
{
m_Registrar.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "You have not yet chosen your team.", from.NetState );
}
m_Registrar?.PrivateOverheadMessage( MessageType.Regular,
0x35, false, "You have not yet chosen your team.", @from.NetState );
m_From.SendGump( new ConfirmSignupGump( m_From, m_Registrar, m_Tournament, m_Players ) );
break;
@ -2253,8 +2246,7 @@ namespace Server.Engines.ConPVP
{
object[] states = (object[])state;
if ( states[0] != null )
((Mobile)states[0]).PublicOverheadMessage( MessageType.Regular, 0x35, false, (string)states[1] );
((Mobile) states[0])?.PublicOverheadMessage( MessageType.Regular, 0x35, false, (string)states[1] );
}
}