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

@ -24,9 +24,8 @@ namespace Server.Commands
if ( m.Player && !(m is PlayerMobile ) )
{
count++;
if ( m.NetState != null )
m.NetState.Dispose();
m.NetState?.Dispose();
PlayerMobile pm = new PlayerMobile( m.Serial );
pm.DefaultMobileInit();

View file

@ -1018,8 +1018,7 @@ namespace Server.Commands
}
}
if ( item != null )
item.Delete();
item?.Delete();
return count;
}

View file

@ -1015,8 +1015,7 @@ namespace Server.Commands
}
}
if ( item != null )
item.Delete();
item?.Delete();
return count;
}

View file

@ -16,10 +16,7 @@ namespace Server.Commands.Generic
{
RangeCommandImplementor impl = RangeCommandImplementor.Instance;
if ( impl == null )
return;
impl.Process( 18, from, command, args );
impl?.Process( 18, @from, command, args );
}
}
}

View file

@ -13,7 +13,9 @@ namespace Server.Engines.BulkOrders
set => m_Owner = value;
}
public int Amount{ get => m_Amount;
set{ m_Amount = value; if ( m_Owner != null ) m_Owner.InvalidateProperties(); } }
set{ m_Amount = value;
m_Owner?.InvalidateProperties();
} }
public SmallBulkEntry Details => m_Details;
public static SmallBulkEntry[] LargeRing => GetEntries( "Blacksmith", "largering" );

View file

@ -101,13 +101,10 @@ namespace Server.Engines.BulkOrders
{
RewardItem rewardItem = rewardGroup.AcquireItem();
if ( rewardItem != null )
{
Item item = rewardItem.Construct();
Item item = rewardItem?.Construct();
if ( item != null )
list.Add( item );
}
if ( item != null )
list.Add( item );
}
}

View file

@ -96,13 +96,10 @@ namespace Server.Engines.BulkOrders
{
RewardItem rewardItem = rewardGroup.AcquireItem();
if ( rewardItem != null )
{
Item item = rewardItem.Construct();
Item item = rewardItem?.Construct();
if ( item != null )
list.Add( item );
}
if ( item != null )
list.Add( item );
}
}

View file

@ -52,13 +52,10 @@ namespace Server.Engines.BulkOrders
{
RewardItem rewardItem = rewardGroup.AcquireItem();
if ( rewardItem != null )
{
Item item = rewardItem.Construct();
Item item = rewardItem?.Construct();
if ( item != null )
list.Add( item );
}
if ( item != null )
list.Add( item );
}
}

View file

@ -45,13 +45,10 @@ namespace Server.Engines.BulkOrders
{
RewardItem rewardItem = rewardGroup.AcquireItem();
if ( rewardItem != null )
{
Item item = rewardItem.Construct();
Item item = rewardItem?.Construct();
if ( item != null )
list.Add( item );
}
if ( item != null )
list.Add( item );
}
}

View file

@ -15,8 +15,7 @@ namespace Server.Engines.CannedEvil
{
base.OnAfterDelete();
if ( m_Spawn != null )
m_Spawn.Delete();
m_Spawn?.Delete();
}
public ChampionAltar( Serial serial ) : base( serial )

View file

@ -46,8 +46,7 @@ namespace Server.Engines.CannedEvil
{
base.OnAfterDelete();
if ( m_Spawn != null )
m_Spawn.Delete();
m_Spawn?.Delete();
}
public ChampionPlatform( Serial serial ) : base( serial )

View file

@ -19,7 +19,9 @@ namespace Server.Engines.CannedEvil
[CommandProperty( AccessLevel.GameMaster )]
public Item Skull{ get => m_Skull;
set{ m_Skull = value; if ( m_Platform != null ) m_Platform.Validate(); } }
set{ m_Skull = value;
m_Platform?.Validate();
} }
public override int LabelNumber => 1049489 + (int)m_Type;
@ -38,8 +40,7 @@ namespace Server.Engines.CannedEvil
public override void OnDoubleClick( Mobile from )
{
if ( m_Platform != null )
m_Platform.Validate();
m_Platform?.Validate();
BeginSacrifice( from );
}

View file

@ -75,8 +75,7 @@ namespace Server.Engines.CannedEvil
{
Effects.SendBoltEffect( brazier );
if ( brazier.Skull != null )
brazier.Skull.Delete();
brazier.Skull?.Delete();
}
}

View file

@ -91,8 +91,7 @@ namespace Server.Engines.CannedEvil
public void UpdateRegion()
{
if ( m_Region != null )
m_Region.Unregister();
m_Region?.Unregister();
if ( !Deleted && Map != Map.Internal )
{
@ -274,8 +273,7 @@ namespace Server.Engines.CannedEvil
m_Timer = new SliceTimer( this );
m_Timer.Start();
if ( m_RestartTimer != null )
m_RestartTimer.Stop();
m_RestartTimer?.Stop();
m_RestartTimer = null;
@ -303,8 +301,7 @@ namespace Server.Engines.CannedEvil
m_Timer = null;
if ( m_RestartTimer != null )
m_RestartTimer.Stop();
m_RestartTimer?.Stop();
m_RestartTimer = null;
@ -317,8 +314,7 @@ namespace Server.Engines.CannedEvil
public void BeginRestart( TimeSpan ts )
{
if ( m_RestartTimer != null )
m_RestartTimer.Stop();
m_RestartTimer?.Stop();
m_RestartTime = DateTime.UtcNow + ts;
@ -596,8 +592,7 @@ namespace Server.Engines.CannedEvil
}
catch { }
if ( m_Champion != null )
m_Champion.MoveToWorld( new Point3D( X, Y, Z - 15 ), Map );
m_Champion?.MoveToWorld( new Point3D( X, Y, Z - 15 ), Map );
}
public void Respawn()
@ -905,14 +900,11 @@ namespace Server.Engines.CannedEvil
{
base.OnAfterDelete();
if ( m_Platform != null )
m_Platform.Delete();
m_Platform?.Delete();
if ( m_Altar != null )
m_Altar.Delete();
m_Altar?.Delete();
if ( m_Idol != null )
m_Idol.Delete();
m_Idol?.Delete();
if ( m_RedSkulls != null )
{
@ -1235,8 +1227,7 @@ namespace Server.Engines.CannedEvil
{
base.OnAfterDelete();
if ( m_Spawn != null )
m_Spawn.Delete();
m_Spawn?.Delete();
}
public IdolOfTheChampion( Serial serial ) : base( serial )

View file

@ -133,8 +133,7 @@ namespace Server.Engines.Chat
}
else
{
if ( user.CurrentChannel != null )
user.CurrentChannel.RemoveUser( user ); // Remove them from their current channel first
user.CurrentChannel?.RemoveUser( user ); // Remove them from their current channel first
ChatSystem.SendCommandTo( user.Mobile, ChatCommand.JoinedChannel, m_Name );
@ -226,8 +225,8 @@ namespace Server.Engines.Chat
SendMessage( 44, user.Username ) ; // %1 has been kicked out of the conference.
}
if ( wasBanned && moderator != null )
moderator.SendMessage( 62, user.Username ); // You are banning %1 from this conference.
if ( wasBanned )
moderator?.SendMessage( 62, user.Username ); // You are banning %1 from this conference.
}
public bool VoiceRestricted

View file

@ -33,8 +33,7 @@ namespace Server.Engines.Chat
public static void SendCommandTo( Mobile to, ChatCommand type, string param1, string param2 )
{
if ( to != null )
to.Send( new ChatMessagePacket( null, (int)type + 20, param1, param2 ) );
to?.Send( new ChatMessagePacket( null, (int)type + 20, param1, param2 ) );
}
public static void OpenChatWindowRequest( NetState state, PacketReader pvSrc )
@ -57,8 +56,7 @@ namespace Server.Engines.Chat
if ( acct != null )
accountChatName = acct.GetTag( "ChatName" );
if ( accountChatName != null )
accountChatName = accountChatName.Trim();
accountChatName = accountChatName?.Trim();
if ( accountChatName != null && accountChatName.Length > 0 )
{
@ -96,8 +94,7 @@ namespace Server.Engines.Chat
accountChatName = chatName;
if ( acct != null )
acct.AddTag( "ChatName", chatName );
acct?.AddTag( "ChatName", chatName );
}
else
{

View file

@ -175,8 +175,7 @@ namespace Server.Engines.Chat
}
}
if ( password != null )
password = password.Trim();
password = password?.Trim();
if ( password != null && password.Length == 0 )
password = null;
@ -213,8 +212,7 @@ namespace Server.Engines.Chat
name = param;
}
if ( password != null )
password = password.Trim();
password = password?.Trim();
if ( password != null && password.Length == 0 )
password = null;

View file

@ -190,8 +190,7 @@ namespace Server.Engines.Chat
{
ChatSystem.SendCommandTo( user.Mobile, ChatCommand.CloseChatWindow );
if ( user.m_Channel != null )
user.m_Channel.RemoveUser( user );
user.m_Channel?.RemoveUser( user );
m_Users.Remove( user );
m_Table.Remove( user.m_Mobile );

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] );
}
}

View file

@ -780,8 +780,9 @@ namespace Server.Engines.Craft
if ( index == -1 )
{
if ( consumeType != ConsumeType.None )
if ( consumeExtra != null )
consumeExtra.Delete();
{
consumeExtra?.Delete();
}
return true;
}
@ -948,8 +949,7 @@ namespace Server.Engines.Craft
{
CraftContext context = craftSystem.GetContext( from );
if ( context != null )
context.OnMade( this );
context?.OnMade( this );
int iMin = craftSystem.MinCraftEffect;
int iMax = (craftSystem.MaxCraftEffect - iMin) + 1;
@ -1286,8 +1286,7 @@ namespace Server.Engines.Craft
try{ cc = Activator.CreateInstance( m_CraftItem.ItemType, new object[] { m_From, m_CraftItem, m_CraftSystem, m_TypeRes, m_Tool, quality } ) as CustomCraft; }
catch{}
if ( cc != null )
cc.EndCraftAction();
cc?.EndCraftAction();
return;
}

View file

@ -77,8 +77,7 @@ namespace Server.Engines.Craft
{
CraftContext c = GetContext( m );
if ( c != null )
c.OnMade( item );
c?.OnMade( item );
}
public bool Resmelt

View file

@ -151,8 +151,7 @@ namespace Server.Engines.Doom
ClearTraps();
DestroyRegion();
if ( m_Timer != null )
m_Timer.Stop();
m_Timer?.Stop();
m_Timer = null;
}
@ -194,8 +193,7 @@ namespace Server.Engines.Doom
public virtual void DestroyRegion()
{
if ( m_Region != null )
m_Region.Unregister();
m_Region?.Unregister();
m_Region = null;
}

View file

@ -146,10 +146,7 @@ namespace Server.Engines.Doom
NukeItemList( m_Statues );
NukeItemList( m_Levers );
if ( m_LampRoom != null )
{
m_LampRoom.Unregister();
}
m_LampRoom?.Unregister();
if ( m_Tiles != null )
{
foreach( Region region in m_Tiles )
@ -181,12 +178,9 @@ namespace Server.Engines.Doom
{
LeverPuzzleRegion region = (LeverPuzzleRegion)m_Tiles[index];
if ( region != null )
if ( region?.Occupant != null && region.Occupant.Alive )
{
if ( region.Occupant != null && region.Occupant.Alive )
{
return (PlayerMobile)region.Occupant;
}
return (PlayerMobile)region.Occupant;
}
return null;
}

View file

@ -267,8 +267,7 @@ namespace Server.Factions
{
if ( m_Faction.Election != this )
{
if ( m_Timer != null )
m_Timer.Stop();
m_Timer?.Stop();
m_Timer = null;

View file

@ -105,8 +105,7 @@ namespace Server.Factions
get => m_Commander;
set
{
if ( m_Commander != null )
m_Commander.InvalidateProperties();
m_Commander?.InvalidateProperties();
m_Commander = value;

View file

@ -15,8 +15,7 @@ namespace Server.Factions
{
PlayerState pl = (PlayerState)state;
if ( pl != null )
pl.Mobile.PublicOverheadMessage( MessageType.Regular, pl.Mobile.SpeechHue, true, pl.KillPoints.ToString( "N0" ) ); // NOTE: Added 'N0'
pl?.Mobile.PublicOverheadMessage( MessageType.Regular, pl.Mobile.SpeechHue, true, pl.KillPoints.ToString( "N0" ) ); // NOTE: Added 'N0'
}
private static void EventSink_Speech( SpeechEventArgs e )
@ -144,8 +143,7 @@ namespace Server.Factions
{
Faction faction = Faction.Find( from );
if ( faction != null )
faction.BeginHonorLeadership( from );
faction?.BeginHonorLeadership( @from );
break;
}

View file

@ -172,13 +172,9 @@ namespace Server.Factions
public void PrivateOverheadLocalizedMessage( Mobile to, int number, int hue, string name, string args )
{
if ( to == null )
return;
NetState ns = to?.NetState;
NetState ns = to.NetState;
if ( ns != null )
ns.Send( new MessageLocalized( Serial, ItemID, MessageType.Regular, hue, 3, number, name, args ) );
ns?.Send( new MessageLocalized( Serial, ItemID, MessageType.Regular, hue, 3, number, name, args ) );
}
public BaseFactionTrap( Faction f, Mobile m, int itemID ) : base( itemID )
@ -212,16 +208,14 @@ namespace Server.Factions
public virtual void BeginConceal()
{
if ( m_Concealing != null )
m_Concealing.Stop();
m_Concealing?.Stop();
m_Concealing = Timer.DelayCall( ConcealPeriod, new TimerCallback( Conceal ) );
}
public virtual void Conceal()
{
if ( m_Concealing != null )
m_Concealing.Stop();
m_Concealing?.Stop();
m_Concealing = null;

View file

@ -28,8 +28,7 @@ namespace Server.Factions
{
Delete();
if ( consumer != null )
consumer.SendLocalizedMessage( 1042531 ); // You have used all of the parts in your trap removal kit.
consumer?.SendLocalizedMessage( 1042531 ); // You have used all of the parts in your trap removal kit.
}
}

View file

@ -39,8 +39,7 @@ namespace Server.Factions
public void Unregister()
{
if ( m_Town != null )
m_Town.UnregisterGuard( this );
m_Town?.UnregisterGuard( this );
}
public abstract GuardAI GuardAI{ get; }

View file

@ -38,8 +38,7 @@ namespace Server.Factions
public void Unregister()
{
if ( m_Town != null )
m_Town.UnregisterVendor( this );
m_Town?.UnregisterVendor( this );
}
private List<SBInfo> m_SBInfos = new List<SBInfo>();

View file

@ -95,8 +95,7 @@ namespace Server.Mobiles
if ( !base.OnBeforeDeath() )
return false;
if ( Backpack != null )
Backpack.Destroy();
Backpack?.Destroy();
if ( Utility.Random( 3 ) == 0 )
{

View file

@ -54,8 +54,7 @@ namespace Server.Engines.MLQuests.Gumps
{
case 0: // Cancel
{
if ( m_Owner != null )
m_Owner.OnCancel( m_From );
m_Owner?.OnCancel( m_From );
break;
}

View file

@ -63,8 +63,7 @@ namespace Server.Engines.MLQuests
private void Register()
{
if ( m_Quest?.Instances != null )
m_Quest.Instances.Add( this );
m_Quest?.Instances?.Add( this );
if ( m_Player != null )
PlayerContext.QuestInstances.Add( this );
@ -72,8 +71,7 @@ namespace Server.Engines.MLQuests
private void Unregister()
{
if ( m_Quest?.Instances != null )
m_Quest.Instances.Remove( this );
m_Quest?.Instances?.Remove( this );
if ( m_Player != null )
PlayerContext.QuestInstances.Remove( this );
@ -255,8 +253,7 @@ namespace Server.Engines.MLQuests
{
MLQuest nextQuest = MLQuestSystem.FindQuest( nextQuestType );
if ( nextQuest != null )
nextQuest.SendOffer( m_Quester, m_Player );
nextQuest?.SendOffer( m_Quester, m_Player );
}
}
else
@ -514,8 +511,7 @@ namespace Server.Engines.MLQuests
for ( int i = 0; i < objectives; ++i )
BaseObjectiveInstance.Deserialize( reader, version, ( instance != null && i < instance.Objectives.Length ) ? instance.Objectives[i] : null );
if ( instance != null )
instance.Slice();
instance?.Slice();
return instance;
}

View file

@ -578,8 +578,7 @@ namespace Server.Engines.MLQuests
{
MLQuestContext context = GetContext( pm );
if ( context != null )
context.HandleDeath();
context?.HandleDeath();
}
public static void HandleDeletion( PlayerMobile pm )

View file

@ -136,16 +136,28 @@ namespace Server.Engines.MyRunUO
}
catch ( Exception e )
{
try{ if ( transact != null ) transact.Rollback(); }
try
{
transact?.Rollback();
}
catch{}
try{ if ( connection != null ) connection.Close(); }
try
{
connection?.Close();
}
catch{}
try{ if ( connection != null ) connection.Dispose(); }
try
{
connection?.Dispose();
}
catch{}
try{ if ( command != null ) command.Dispose(); }
try
{
command?.Dispose();
}
catch{}
try{ m_Sync.Close(); }

View file

@ -66,8 +66,7 @@ namespace Server.Engines.MyRunUO
Console.WriteLine( e );
}
if ( m_Command != null )
m_Command.Enqueue( null );
m_Command?.Enqueue( null );
}
}
}

View file

@ -13,8 +13,7 @@ namespace Server.Engines.PartySystem
{
DeclineTimer t = (DeclineTimer)m_Table[m];
if ( t != null )
t.Stop();
t?.Stop();
m_Table[m] = t = new DeclineTimer( m, leader );
t.Start();

View file

@ -129,18 +129,14 @@ namespace Server.Engines.PartySystem
Mobile from = e.Mobile;
Party p = Get( from );
if ( p != null )
p.Remove( from );
p?.Remove( @from );
from.Party = null;
}
public static Party Get( Mobile m )
{
if ( m == null )
return null;
return m.Party as Party;
return m?.Party as Party;
}
public Party( Mobile leader )

View file

@ -702,10 +702,7 @@ namespace Server.Movement
public static void ClearMoveCache(ref List<Item> cache, bool free)
{
if (cache != null)
{
cache.Clear();
}
cache?.Clear();
if (!free)
{

View file

@ -83,8 +83,7 @@ namespace Server.Engines.Quests.Collector
if ( obj != null && !obj.Completed )
{
if ( player.Backpack != null )
player.Backpack.ConsumeUpTo( typeof( EnchantedPaints ), 1 );
player.Backpack?.ConsumeUpTo( typeof( EnchantedPaints ), 1 );
obj.Complete();
}

View file

@ -17,8 +17,7 @@ namespace Server.Engines.Quests
public override void OnClick()
{
if ( m_Callback != null )
m_Callback();
m_Callback?.Invoke();
}
}
}

View file

@ -88,8 +88,7 @@ namespace Server.Engines.Quests
QuestSystem qs = Construct( type ) as QuestSystem;
if ( qs != null )
qs.BaseDeserialize( reader );
qs?.BaseDeserialize( reader );
return qs;
}
@ -129,8 +128,7 @@ namespace Server.Engines.Quests
QuestObjective obj = Construct( type ) as QuestObjective;
if ( obj != null )
obj.BaseDeserialize( reader );
obj?.BaseDeserialize( reader );
return obj;
}
@ -170,8 +168,7 @@ namespace Server.Engines.Quests
QuestConversation conv = Construct( type ) as QuestConversation;
if ( conv != null )
conv.BaseDeserialize( reader );
conv?.BaseDeserialize( reader );
return conv;
}

View file

@ -114,20 +114,17 @@ namespace Server.Engines.Quests.Samurai
if ( obj != null && !obj.Completed )
{
Container pack = player.Backpack;
if ( pack != null )
Item katana = pack?.FindItemByType( typeof( HaochisKatana ) );
if ( katana != null )
{
Item katana = pack.FindItemByType( typeof( HaochisKatana ) );
if ( katana != null )
{
katana.Delete();
obj.Complete();
katana.Delete();
obj.Complete();
obj = qs.FindObjective( typeof( FifthTrialIntroObjective ) );
if ( obj != null && ((FifthTrialIntroObjective)obj).StolenTreasure )
qs.AddConversation( new SixthTrialIntroConversation( true ) );
else
qs.AddConversation( new SixthTrialIntroConversation( false ) );
}
obj = qs.FindObjective( typeof( FifthTrialIntroObjective ) );
if ( obj != null && ((FifthTrialIntroObjective)obj).StolenTreasure )
qs.AddConversation( new SixthTrialIntroConversation( true ) );
else
qs.AddConversation( new SixthTrialIntroConversation( false ) );
}
return;

View file

@ -59,8 +59,7 @@ namespace Server.Engines.Quests.Naturalist
{
base.Accept();
if ( m_Naturalist != null )
m_Naturalist.PlaySound( 0x431 );
m_Naturalist?.PlaySound( 0x431 );
AddConversation( new AcceptConversation() );
}

View file

@ -127,8 +127,7 @@ namespace Server.Engines.Quests.Doom
m_Chyloth = reader.ReadMobile() as Chyloth;
m_Dragon = reader.ReadMobile() as SkeletalDragon;
if ( m_Chyloth != null )
m_Chyloth.Delete();
m_Chyloth?.Delete();
}
}
}

View file

@ -102,13 +102,9 @@ namespace Server.Engines.Quests.Doom
{
Victoria victoria = ((TheSummoningQuest)System).Victoria;
if ( victoria != null )
{
SummoningAltar altar = victoria.Altar;
SummoningAltar altar = victoria?.Altar;
if ( altar != null )
altar.CheckDaemon();
}
altar?.CheckDaemon();
PlayerMobile from = System.From;

View file

@ -263,20 +263,17 @@ namespace Server.RemoteAdmin
public override void Write( char ch )
{
if ( m_OnChar != null )
m_OnChar( ch );
m_OnChar?.Invoke( ch );
}
public override void Write( string str )
{
if ( m_OnStr != null )
m_OnStr( str );
m_OnStr?.Invoke( str );
}
public override void WriteLine( string line )
{
if ( m_OnLine != null )
m_OnLine( line );
m_OnLine?.Invoke( line );
}
public override Encoding Encoding => Encoding.ASCII;

View file

@ -40,13 +40,11 @@ namespace Server.Engines.Reports
lock ( StaffHistory.RenderLock )
{
if ( m_Resolver != null )
m_Resolver.Unregister( this );
m_Resolver?.Unregister( this );
m_Resolver = value;
if ( m_Resolver != null )
m_Resolver.Register( this );
m_Resolver?.Register( this );
}
}
}
@ -61,13 +59,11 @@ namespace Server.Engines.Reports
lock ( StaffHistory.RenderLock )
{
if ( m_Sender != null )
m_Sender.Unregister( this );
m_Sender?.Unregister( this );
m_Sender = value;
if ( m_Sender != null )
m_Sender.Register( this );
m_Sender?.Register( this );
}
}
}

View file

@ -460,9 +460,9 @@ namespace Server.Engines.Reports
}
finally
{
if (brsFont != null) brsFont.Dispose();
if (valFont != null) valFont.Dispose();
if (sfFormat != null) sfFormat.Dispose();
brsFont?.Dispose();
valFont?.Dispose();
sfFormat?.Dispose();
}
}
@ -536,11 +536,11 @@ namespace Server.Engines.Reports
}
finally
{
if (lblFont != null) lblFont.Dispose();
if (brs != null) brs.Dispose();
if (lblFormat != null) lblFormat.Dispose();
if (pen != null) pen.Dispose();
if (sfVLabel != null) sfVLabel.Dispose();
lblFont?.Dispose();
brs?.Dispose();
lblFormat?.Dispose();
pen?.Dispose();
sfVLabel?.Dispose();
}
}
@ -571,10 +571,10 @@ namespace Server.Engines.Reports
}
finally
{
if (lblFont != null) lblFont.Dispose();
if (brs != null) brs.Dispose();
if (lblFormat != null) lblFormat.Dispose();
if (pen != null) pen.Dispose();
lblFont?.Dispose();
brs?.Dispose();
lblFormat?.Dispose();
pen?.Dispose();
}
}
@ -642,10 +642,10 @@ namespace Server.Engines.Reports
}
finally
{
if (lblFont != null) lblFont.Dispose();
if (brs != null) brs.Dispose();
if (lblFormat != null) lblFormat.Dispose();
if (pen != null) pen.Dispose();
lblFont?.Dispose();
brs?.Dispose();
lblFormat?.Dispose();
pen?.Dispose();
}
}
@ -698,10 +698,10 @@ namespace Server.Engines.Reports
}
finally
{
if (lblFont != null) lblFont.Dispose();
if (brs != null) brs.Dispose();
if (lblFormat != null) lblFormat.Dispose();
if (pen != null) pen.Dispose();
lblFont?.Dispose();
brs?.Dispose();
lblFormat?.Dispose();
pen?.Dispose();
}
}
@ -805,9 +805,9 @@ namespace Server.Engines.Reports
}
finally
{
if (graph != null) graph.Dispose();
if (bmp != null) bmp.Dispose();
if (font != null) font.Dispose();
graph?.Dispose();
bmp?.Dispose();
font?.Dispose();
}
}

View file

@ -183,8 +183,7 @@ namespace Server.Engines.Reports
}
finally
{
if (brs !=null)
brs.Dispose();
brs?.Dispose();
}
}
@ -198,8 +197,7 @@ namespace Server.Engines.Reports
}
finally
{
if (brs !=null)
brs.Dispose();
brs?.Dispose();
}
}
@ -224,11 +222,11 @@ namespace Server.Engines.Reports
}
finally
{
if (sf != null) sf.Dispose();
if (grp != null) grp.Dispose();
if (sfp != null) sfp.Dispose();
if (fnt != null) fnt.Dispose();
if (pen != null) pen.Dispose();
sf?.Dispose();
grp?.Dispose();
sfp?.Dispose();
fnt?.Dispose();
pen?.Dispose();
}
return bmp;
}

View file

@ -250,8 +250,7 @@ namespace Server.Mobiles
{
if ( m_Running )
{
if ( m_Timer != null )
m_Timer.Stop();
m_Timer?.Stop();
m_Running = false;
}
}
@ -714,8 +713,7 @@ namespace Server.Mobiles
{
ISpawnable e = entry.Spawned[i];
entry.Spawned.RemoveAt( i );
if ( e != null )
e.Delete();
e?.Delete();
}
m_Entries.Remove( entry );
@ -734,8 +732,7 @@ namespace Server.Mobiles
{
m_Spawned.TryGetValue( spawn, out SpawnerEntry entry );
if ( entry != null )
entry.Spawned.Remove( spawn );
entry?.Spawned.Remove( spawn );
m_Spawned.Remove( spawn );
}
@ -798,8 +795,9 @@ namespace Server.Mobiles
Defrag();
foreach( ISpawnable e in m_Spawned.Keys )
if ( e != null )
e.MoveToWorld( Location, Map );
{
e?.MoveToWorld( Location, Map );
}
}
public override void OnDelete()

View file

@ -257,8 +257,7 @@ namespace Server.Mobiles
deed.StatueType = m_Type;
deed.IsRewardItem = m_IsRewardItem;
if ( m_Plinth != null )
m_Plinth.Delete();
m_Plinth?.Delete();
return true;
}
@ -332,8 +331,7 @@ namespace Server.Mobiles
for ( int i = Items.Count - 1; i >= 0; i -- )
Items[ i ].Hue = Hue;
if ( m_Plinth != null )
m_Plinth.InvalidateHue();
m_Plinth?.InvalidateHue();
}
private int m_Animation;
@ -526,8 +524,7 @@ namespace Server.Mobiles
{
base.OnDelete();
if ( m_Statue != null )
m_Statue.Delete();
m_Statue?.Delete();
}
public override void Serialize( GenericWriter writer )

View file

@ -134,12 +134,10 @@ namespace Server.Gumps
{
CharacterStatue backup = deed.Statue;
if ( backup != null )
backup.Delete();
backup?.Delete();
}
if ( m_Maker != null )
m_Maker.Delete();
m_Maker?.Delete();
m_Statue.Sculpt( state.Mobile );
}

View file

@ -22,8 +22,7 @@ namespace Server.Gumps
{
m_Option = option;
if ( m_Option != null )
m_Option.GetOptions( m_Options );
m_Option?.GetOptions( m_Options );
AddPage( 0 );

View file

@ -168,8 +168,7 @@ namespace Server.Gumps
{
GuildTeleporter item = new GuildTeleporter( m_Guild.Guildstone );
if ( m_Guild.Teleporter != null )
m_Guild.Teleporter.Delete();
m_Guild.Teleporter?.Delete();
m_Mobile.SendLocalizedMessage( 501133 ); // Use the teleporting object placed in your backpack to move this guildstone.

View file

@ -516,8 +516,7 @@ namespace Server.Gumps
{
if ( isOwner )
{
if ( m_House.CoOwners != null )
m_House.CoOwners.Clear();
m_House.CoOwners?.Clear();
from.SendLocalizedMessage( 501333 ); // All co-owners have been removed from this house.
}
@ -571,8 +570,7 @@ namespace Server.Gumps
{
if ( isCoOwner )
{
if ( m_House.Friends != null )
m_House.Friends.Clear();
m_House.Friends?.Clear();
from.SendLocalizedMessage( 501332 ); // All friends have been removed from this house.
}

View file

@ -617,8 +617,7 @@ namespace Server.Gumps
if ( okay && house.IsOwner( from ) )
{
if ( house.CoOwners != null )
house.CoOwners.Clear();
house.CoOwners?.Clear();
from.SendLocalizedMessage( 501333 ); // All co-owners have been removed from this house.
}
@ -635,8 +634,7 @@ namespace Server.Gumps
if ( okay && house.IsCoOwner( from ) )
{
if ( house.Friends != null )
house.Friends.Clear();
house.Friends?.Clear();
from.SendLocalizedMessage( 501332 ); // All friends have been removed from this house.
}
@ -653,8 +651,7 @@ namespace Server.Gumps
if ( okay && house.IsFriend( from ) )
{
if ( house.Bans != null )
house.Bans.Clear();
house.Bans?.Clear();
from.SendLocalizedMessage( 1060754 ); // All bans for this house have been lifted.
}
@ -673,8 +670,7 @@ namespace Server.Gumps
{
ArrayList list = new ArrayList( house.Access );
if ( house.Access != null )
house.Access.Clear();
house.Access?.Clear();
for ( int i = 0; i < list.Count; ++i )
{

View file

@ -568,8 +568,7 @@ namespace Server.Gumps
{
Item item = m_Vendor.FindItemOnLayer( Categories[cat].Layer );
if ( item != null )
item.Delete();
item?.Delete();
List<Item> items = m_Vendor.Items;
@ -585,8 +584,7 @@ namespace Server.Gumps
}
}
if ( item != null )
item.Delete();
item?.Delete();
if ( Categories[cat].Layer == Layer.FacialHair )
{
@ -706,8 +704,7 @@ namespace Server.Gumps
}
}
if ( item != null )
item.Delete();
item?.Delete();
}
from.SendGump( new PlayerVendorCustomizeGump( m_Vendor, from ) );

View file

@ -151,8 +151,7 @@ namespace Server.Items
public override void OnDoubleClick( Mobile from )
{
if ( m_Addon != null )
m_Addon.OnComponentUsed( this, from );
m_Addon?.OnComponentUsed( this, @from );
}
public void OnChop( Mobile from )
@ -179,8 +178,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Addon != null )
m_Addon.Delete();
m_Addon?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -207,8 +205,7 @@ namespace Server.Items
m_Addon = reader.ReadItem() as BaseAddon;
m_Offset = reader.ReadPoint3D();
if ( m_Addon != null )
m_Addon.OnComponentLoaded( this );
m_Addon?.OnComponentLoaded( this );
ApplyLightTo( this );

View file

@ -60,8 +60,7 @@ namespace Server.Items
public override void OnDoubleClick( Mobile from )
{
if ( m_Addon != null )
m_Addon.OnComponentUsed( this, from );
m_Addon?.OnComponentUsed( this, @from );
}
public override void OnLocationChange( Point3D old )
@ -72,8 +71,7 @@ namespace Server.Items
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
{
if ( m_Addon != null )
m_Addon.GetContextMenuEntries( from, list );
m_Addon?.GetContextMenuEntries( @from, list );
}
public override void OnMapChange()
@ -86,8 +84,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Addon != null )
m_Addon.Delete();
m_Addon?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -109,8 +106,7 @@ namespace Server.Items
m_Addon = reader.ReadItem() as BaseAddonContainer;
m_Offset = reader.ReadPoint3D();
if ( m_Addon != null )
m_Addon.OnComponentLoaded( this );
m_Addon?.OnComponentLoaded( this );
AddonComponent.ApplyLightTo( this );
}

View file

@ -96,8 +96,7 @@ namespace Server.Items
{
BaseHouse house = BaseHouse.FindHouseAt( this );
if ( house != null )
house.Addons.Remove( this );
house?.Addons.Remove( this );
base.OnDelete();
}

View file

@ -77,8 +77,7 @@ namespace Server.Items
}
}
if ( callback != null )
callback( this, from, hue );
callback?.Invoke( this, @from, hue );
}
private class SpinTimer : Timer

View file

@ -79,8 +79,7 @@ namespace Server.Items
}
}
if ( callback != null )
callback( this, from, hue );
callback?.Invoke( this, @from, hue );
}
private class SpinTimer : Timer

View file

@ -87,8 +87,7 @@ namespace Server.Items
}
}
if ( callback != null )
callback( this, from, hue );
callback?.Invoke( this, @from, hue );
}
private class SpinTimer : Timer

View file

@ -79,8 +79,7 @@ namespace Server.Items
}
}
if ( callback != null )
callback( this, from, hue );
callback?.Invoke( this, @from, hue );
}
private class SpinTimer : Timer

View file

@ -822,8 +822,7 @@ namespace Server.Items
if ( IsFull || m_LiveCreatures >= MaxLiveCreatures || fish.Dead )
{
if ( from != null )
from.SendLocalizedMessage( 1073633 ); // The aquarium can not hold the creature.
@from?.SendLocalizedMessage( 1073633 ); // The aquarium can not hold the creature.
return false;
}
@ -833,8 +832,7 @@ namespace Server.Items
m_LiveCreatures += 1;
if ( from != null )
from.SendLocalizedMessage( 1073632, $"#{fish.LabelNumber}"); // You add the following creature to your aquarium: ~1_FISH~
@from?.SendLocalizedMessage( 1073632, $"#{fish.LabelNumber}"); // You add the following creature to your aquarium: ~1_FISH~
InvalidateProperties();
return true;

View file

@ -620,13 +620,10 @@ namespace Server.Items
CraftResourceInfo info = CraftResources.GetInfo( m_Resource );
if ( info != null )
{
CraftAttributeInfo attrInfo = info.AttributeInfo;
CraftAttributeInfo attrInfo = info?.AttributeInfo;
if ( attrInfo != null )
v += attrInfo.ArmorLowerRequirements;
}
if ( attrInfo != null )
v += attrInfo.ArmorLowerRequirements;
if ( v > 100 )
v = 100;
@ -1382,10 +1379,7 @@ namespace Server.Items
{
CraftResourceInfo resInfo = CraftResources.GetInfo( m_Resource );
if ( resInfo == null )
return 0;
CraftAttributeInfo attrInfo = resInfo.AttributeInfo;
CraftAttributeInfo attrInfo = resInfo?.AttributeInfo;
if ( attrInfo == null )
return 0;

View file

@ -558,8 +558,7 @@ namespace Server.Items
if ( RequiredRace == Race.Elf )
list.Add( 1075086 ); // Elves Only
if ( m_AosSkillBonuses != null )
m_AosSkillBonuses.GetProperties( list );
m_AosSkillBonuses?.GetProperties( list );
int prop;

View file

@ -128,8 +128,7 @@ namespace Server.Items
private void BeginDecay( TimeSpan delay )
{
if ( m_DecayTimer != null )
m_DecayTimer.Stop();
m_DecayTimer?.Stop();
m_DecayTime = DateTime.UtcNow + delay;
@ -157,8 +156,7 @@ namespace Server.Items
public override void OnAfterDelete()
{
if ( m_DecayTimer != null )
m_DecayTimer.Stop();
m_DecayTimer?.Stop();
m_DecayTimer = null;
}

View file

@ -159,8 +159,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -212,8 +211,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override bool HandlesOnMovement => true; // Tell the core that we implement OnMovement
@ -327,8 +325,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -382,8 +379,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override bool HandlesOnMovement => true; // Tell the core that we implement OnMovement

View file

@ -144,8 +144,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -196,8 +195,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -251,8 +249,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -303,8 +300,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -358,8 +354,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -410,8 +405,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -465,8 +459,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -517,8 +510,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )

View file

@ -32,8 +32,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -84,8 +83,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -140,8 +138,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -192,8 +189,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -247,8 +243,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -299,8 +294,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -355,8 +349,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -407,8 +400,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -463,8 +455,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -515,8 +506,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -571,8 +561,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -623,8 +612,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -678,8 +666,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -731,8 +718,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -787,8 +773,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -839,8 +824,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -894,8 +878,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -947,8 +930,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -1003,8 +985,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -1055,8 +1036,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -1110,8 +1090,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -1163,8 +1142,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )

View file

@ -157,8 +157,7 @@ namespace Server.Items
public void StopTimer()
{
if ( m_RelockTimer != null )
m_RelockTimer.Stop();
m_RelockTimer?.Stop();
m_RelockTimer = null;
}

View file

@ -240,10 +240,7 @@ namespace Server.Items
public static StealableInstance GetStealableInstance( Item item )
{
if ( Instance == null )
return null;
return (StealableInstance) Instance.m_Table[item];
return (StealableInstance) Instance?.m_Table[item];
}
@ -341,8 +338,7 @@ namespace Server.Items
foreach ( StealableInstance si in m_Artifacts )
{
if ( si.Item != null )
si.Item.Delete();
si.Item?.Delete();
}
m_Instance = null;

View file

@ -83,8 +83,7 @@ namespace Server.Items
public override void OnDelete()
{
if ( m_Commodity != null )
m_Commodity.Delete();
m_Commodity?.Delete();
base.OnDelete();
}

View file

@ -139,10 +139,7 @@ namespace Server.Items
{
BaseHouse house = BaseHouse.FindHouseAt( this );
if ( house != null )
{
house.VendorRentalContracts.Remove( this );
}
house?.VendorRentalContracts.Remove( this );
}
}

View file

@ -35,8 +35,7 @@ namespace Server.Items
Item spawn = GetCropObject();
if ( spawn != null )
spawn.MoveToWorld( loc, map );
spawn?.MoveToWorld( loc, map );
m_Picked = true;

View file

@ -47,8 +47,7 @@ namespace Server.Engines.Mahjong
{
MahjongGame game = World.FindItem( pvSrc.ReadInt32() ) as MahjongGame;
if ( game != null )
game.Players.CheckPlayers();
game?.Players.CheckPlayers();
pvSrc.ReadByte();

View file

@ -470,8 +470,7 @@ namespace Server.Items
Stop();
m_From.EndAction( typeof( TreasureMap ) );
if ( m_Chest != null )
m_Chest.Delete();
m_Chest?.Delete();
if ( m_Dirt1 != null )
{

View file

@ -368,8 +368,7 @@ namespace Server.Items
public void BeginDecay( TimeSpan delay )
{
if ( m_DecayTimer != null )
m_DecayTimer.Stop();
m_DecayTimer?.Stop();
m_DecayTime = DateTime.UtcNow + delay;
@ -379,8 +378,7 @@ namespace Server.Items
public override void OnAfterDelete()
{
if ( m_DecayTimer != null )
m_DecayTimer.Stop();
m_DecayTimer?.Stop();
m_DecayTimer = null;
}

View file

@ -19,8 +19,7 @@ namespace Server.Items
public void BeginDecay( TimeSpan delay )
{
if ( m_DecayTimer != null )
m_DecayTimer.Stop();
m_DecayTimer?.Stop();
m_DecayTime = DateTime.UtcNow + delay;
@ -30,8 +29,7 @@ namespace Server.Items
public override void OnAfterDelete()
{
if ( m_DecayTimer != null )
m_DecayTimer.Stop();
m_DecayTimer?.Stop();
m_DecayTimer = null;
}

View file

@ -62,8 +62,7 @@ namespace Server.Items
if ( !Active )
{
if ( boat.TillerMan != null )
boat.TillerMan.Say( 502507 ); // Ar, Legend has it that these pillars are inactive! No man knows how it might be undone!
boat.TillerMan?.Say( 502507 ); // Ar, Legend has it that these pillars are inactive! No man knows how it might be undone!
return;
}
@ -90,8 +89,7 @@ namespace Server.Items
}
}
if ( boat.TillerMan != null )
boat.TillerMan.Say( 502508 ); // Ar, I refuse to take that matey through here!
boat.TillerMan?.Say( 502508 ); // Ar, I refuse to take that matey through here!
}
}

View file

@ -862,8 +862,7 @@ namespace Server.Items
public override bool OnMoveOver(Mobile m)
{
if (m_Teleporter != null)
m_Teleporter.StopTimer(m);
m_Teleporter?.StopTimer(m);
return true;
}

View file

@ -39,10 +39,8 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
if ( m_Item2 != null )
m_Item2.Delete();
m_Item?.Delete();
m_Item2?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -97,8 +95,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -152,8 +149,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -215,10 +211,8 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
if ( m_Item2 != null )
m_Item2.Delete();
m_Item?.Delete();
m_Item2?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -273,8 +267,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )
@ -328,8 +321,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Item != null )
m_Item.Delete();
m_Item?.Delete();
}
public override void Serialize( GenericWriter writer )

View file

@ -206,8 +206,7 @@ namespace Server.Items
{
base.OnAfterDelete();
if ( m_Timer != null )
m_Timer.Stop();
m_Timer?.Stop();
}
public InternalItem( Serial serial ) : base( serial )
@ -316,8 +315,7 @@ namespace Server.Items
if ( (m.Z + 16) > m_Item.Z && (m_Item.Z + 12) > m.Z && (!Core.AOS || m != from) && SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false ) )
{
if ( from != null )
from.DoHarmful( m );
@from?.DoHarmful( m );
AOS.Damage( m, from, m_Item.GetDamage(), 0, 100, 0, 0, 0 );
m.PlaySound( 0x208 );

View file

@ -104,8 +104,7 @@ namespace Server.Items
Spellbook book = Find( from, -1, type );
if ( book != null )
book.DisplayTo( from );
book?.DisplayTo( @from );
}
private static void EventSink_CastSpellRequest( CastSpellRequestEventArgs e )

View file

@ -153,8 +153,7 @@ namespace Server.Items
}
else
{
if ( from != null )
from.SendLocalizedMessage( 502079 ); // The instrument played its last tune.
@from?.SendLocalizedMessage( 502079 ); // The instrument played its last tune.
Delete();
}
@ -187,8 +186,7 @@ namespace Server.Items
if ( instrument != null )
{
if ( callback != null )
callback( from, instrument );
callback?.Invoke( @from, instrument );
}
else
{
@ -233,10 +231,7 @@ namespace Server.Items
public static int GetPoisonLevel( BaseCreature bc )
{
if ( bc == null )
return 0;
Poison p = bc.HitPoison;
Poison p = bc?.HitPoison;
if ( p == null )
return 0;

View file

@ -309,8 +309,7 @@ namespace Server.Items
{
m_Timers.TryGetValue( m, out Timer t );
if ( t != null )
t.Start();
t?.Start();
}
public static bool IsDisguised( Mobile m )

View file

@ -239,10 +239,7 @@ namespace Server.Items
{
CraftResourceInfo resInfo = CraftResources.GetInfo( m_Resource );
if ( resInfo == null )
return;
CraftAttributeInfo attrs = resInfo.AttributeInfo;
CraftAttributeInfo attrs = resInfo?.AttributeInfo;
if ( attrs == null )
return;
@ -438,10 +435,7 @@ namespace Server.Items
{
CraftResourceInfo resInfo = CraftResources.GetInfo( m_Resource );
if ( resInfo == null )
return;
CraftAttributeInfo attrs = resInfo.AttributeInfo;
CraftAttributeInfo attrs = resInfo?.AttributeInfo;
if ( attrs == null )
return;

View file

@ -39,8 +39,7 @@ namespace Server.Items
{
SendLocalizedMessageTo( from, 1010442 ); // The item will be deleted in three minutes
if ( m_Timer != null )
m_Timer.Stop();
m_Timer?.Stop();
m_Timer = Timer.DelayCall( TimeSpan.FromMinutes( 3 ), new TimerCallback( Empty ) );
}
@ -62,8 +61,7 @@ namespace Server.Items
{
SendLocalizedMessageTo( from, 1010442 ); // The item will be deleted in three minutes
if ( m_Timer != null )
m_Timer.Stop();
m_Timer?.Stop();
m_Timer = Timer.DelayCall( TimeSpan.FromMinutes( 3 ), new TimerCallback( Empty ) );
}

View file

@ -47,17 +47,14 @@ namespace Server.Items
ItemID = 0x1765;
if ( Owner != null )
{
Container pack = Owner.Backpack;
Container pack = Owner?.Backpack;
if ( pack != null )
if ( pack != null )
{
for ( int i = 0; i < pack.Items.Count; i++ )
{
for ( int i = 0; i < pack.Items.Count; i++ )
{
if ( pack.Items[ i ] is PlagueBeastMainOrgan main && main.Complete )
main.FinishOpening( from );
}
if ( pack.Items[ i ] is PlagueBeastMainOrgan main && main.Complete )
main.FinishOpening( @from );
}
}
@ -74,8 +71,7 @@ namespace Server.Items
if ( Patched )
return;
if ( Owner != null )
Owner.PlaySound( 0x25 );
Owner?.PlaySound( 0x25 );
if ( ItemID == 0x122A )
{

View file

@ -98,8 +98,7 @@ namespace Server.Items
{
m_Opened = true;
if ( Owner != null )
Owner.PlaySound( 0x50 );
Owner?.PlaySound( 0x50 );
}
public PlagueBeastOrgan( Serial serial ) : base( serial )
@ -145,8 +144,7 @@ namespace Server.Items
{
ItemID = 0x1249;
if ( Owner != null )
Owner.PlaySound( 0x187 );
Owner?.PlaySound( 0x187 );
AddComponent( new PlagueBeastComponent( 0x1D0D, 0x0 ), 22, 3 );
AddComponent( new PlagueBeastComponent( 0x1D12, 0x0 ), 15, 18 );
@ -398,8 +396,7 @@ namespace Server.Items
from.SendAsciiMessage( 0x3B2, "* You place the healthy gland inside the organ sac *" );
item.Movable = false;
if ( Owner != null )
Owner.PlaySound( 0x20 );
Owner?.PlaySound( 0x20 );
return true;
}

View file

@ -48,8 +48,7 @@ namespace Server.Items
else
ItemID = 0x1B1C;
if ( Owner != null )
Owner.PlaySound( 0x199 );
Owner?.PlaySound( 0x199 );
if ( Organ is PlagueBeastRubbleOrgan organ )
organ.OnVeinCut( from, this );

View file

@ -92,8 +92,7 @@ namespace Server.Items
public override void OnLocationChange( Point3D old )
{
if ( m_Fire != null )
m_Fire.MoveToWorld( new Point3D( X, Y, Z + ItemData.Height ), Map );
m_Fire?.MoveToWorld( new Point3D( X, Y, Z + ItemData.Height ), Map );
}
public override void GetProperties( ObjectPropertyList list )

Some files were not shown because too many files have changed in this diff Show more