diff --git a/Scripts/Commands/Generic/Commands/Interface.cs b/Scripts/Commands/Generic/Commands/Interface.cs index 0724a3cbc..2d25aec82 100644 --- a/Scripts/Commands/Generic/Commands/Interface.cs +++ b/Scripts/Commands/Generic/Commands/Interface.cs @@ -351,7 +351,7 @@ namespace Server.Commands.Generic { Mobile owner = m_Item.RootParent as Mobile; - if ( owner != null && (owner.Map != null && owner.Map != Map.Internal) && !BaseCommand.IsAccessible( m_From, owner ) /* !m_From.CanSee( owner )*/ ) + if ( owner?.Map != null && owner.Map != Map.Internal && !BaseCommand.IsAccessible( m_From, owner ) /* !m_From.CanSee( owner )*/ ) { m_From.SendMessage( "You can not get what you can not see." ); } diff --git a/Scripts/Commands/Handlers.cs b/Scripts/Commands/Handlers.cs index 4f15e303e..e194bdb36 100644 --- a/Scripts/Commands/Handlers.cs +++ b/Scripts/Commands/Handlers.cs @@ -629,7 +629,7 @@ namespace Server.Commands Mobile owner = item.RootParent as Mobile; - if ( owner != null && (owner.Map != null && owner.Map != Map.Internal) && !BaseCommand.IsAccessible( from, owner ) /* !from.CanSee( owner )*/ ) + if ( owner?.Map != null && owner.Map != Map.Internal && !BaseCommand.IsAccessible( @from, owner ) /* !from.CanSee( owner )*/ ) { from.SendMessage( "You can not go to what you can not see." ); return; diff --git a/Scripts/Engines/CannedEvil/ChampionSkullPlatform.cs b/Scripts/Engines/CannedEvil/ChampionSkullPlatform.cs index 8f117822a..bafb2ea5b 100644 --- a/Scripts/Engines/CannedEvil/ChampionSkullPlatform.cs +++ b/Scripts/Engines/CannedEvil/ChampionSkullPlatform.cs @@ -82,7 +82,7 @@ namespace Server.Engines.CannedEvil public bool Validate( ChampionSkullBrazier brazier ) { - return ( brazier != null && brazier.Skull != null && !brazier.Skull.Deleted ); + return ( brazier?.Skull != null && !brazier.Skull.Deleted ); } public ChampionSkullPlatform( Serial serial ) : base( serial ) diff --git a/Scripts/Engines/ConPVP/Games/BombingRun.cs b/Scripts/Engines/ConPVP/Games/BombingRun.cs index 894841eb9..b5e06e540 100644 --- a/Scripts/Engines/ConPVP/Games/BombingRun.cs +++ b/Scripts/Engines/ConPVP/Games/BombingRun.cs @@ -59,7 +59,7 @@ namespace Server.Engines.ConPVP protected override void OnTick() { - if ( m_Bomb.Parent == null && m_Bomb.m_Game != null && m_Bomb.m_Game.Controller != null ) + if ( m_Bomb.Parent == null && m_Bomb.m_Game?.Controller != null ) { if ( !m_Bomb.m_Flying && m_Bomb.Map != Map.Internal ) Effects.SendLocationEffect( m_Bomb.GetWorldLocation(), m_Bomb.Map, 0x377A, 16, 10, m_Bomb.Hue, 0 ); @@ -483,7 +483,7 @@ namespace Server.Engines.ConPVP int height; bool found = false; - if ( m_PathIdx < m_Path.Count && Map != null && Map.Tiles != null && Map != Map.Internal ) + if ( m_PathIdx < m_Path.Count && Map?.Tiles != null && Map != Map.Internal ) { int pathCheckEnd = m_PathIdx + 5; @@ -927,7 +927,7 @@ namespace Server.Engines.ConPVP if ( !Visible ) return true; - if ( m == null || !m.Player || !m.Alive || m.Backpack == null || m_Team == null || m_Team.Game == null ) + if ( m == null || !m.Player || !m.Alive || m.Backpack == null || m_Team?.Game == null ) return true; if ( !base.OnMoveOver( m ) ) @@ -960,7 +960,7 @@ namespace Server.Engines.ConPVP public override void OnDoubleClick( Mobile from ) { - if ( m_TeamInfo != null && m_TeamInfo.Game != null ) + if ( m_TeamInfo?.Game != null ) { from.CloseGump( typeof( BRBoardGump ) ); from.SendGump( new BRBoardGump( from, m_TeamInfo.Game ) ); @@ -1522,7 +1522,7 @@ namespace Server.Engines.ConPVP { public override bool CantDoAnything( Mobile mob ) { - if ( mob == null || mob.Backpack == null || GetTeamInfo( mob ) == null ) + if ( mob?.Backpack == null || GetTeamInfo( mob ) == null ) return false; Item bomb = mob.Backpack.FindItemByType( typeof( BRBomb ), true ); @@ -1880,7 +1880,7 @@ namespace Server.Engines.ConPVP { DuelPlayer dp = p.Players[j]; - if ( dp != null && dp.Mobile != null ) + if ( dp?.Mobile != null ) { dp.Mobile.CloseGump( typeof( BRBoardGump ) ); dp.Mobile.SendGump( new BRBoardGump( dp.Mobile, this ) ); diff --git a/Scripts/Engines/ConPVP/Games/CTF.cs b/Scripts/Engines/ConPVP/Games/CTF.cs index e67972244..c865f7c5d 100644 --- a/Scripts/Engines/ConPVP/Games/CTF.cs +++ b/Scripts/Engines/ConPVP/Games/CTF.cs @@ -24,7 +24,7 @@ namespace Server.Engines.ConPVP public override void OnDoubleClick( Mobile from ) { - if ( m_TeamInfo != null && m_TeamInfo.Game != null ) + if ( m_TeamInfo?.Game != null ) { from.CloseGump( typeof( CTFBoardGump ) ); from.SendGump( new CTFBoardGump( from, m_TeamInfo.Game ) ); @@ -105,7 +105,7 @@ namespace Server.Engines.ConPVP { CTFTeamInfo teamInfo = game.Controller.TeamInfo[i % 8]; - if ( teamInfo == null || teamInfo.Flag == null ) + if ( teamInfo?.Flag == null ) continue; entries.Add( teamInfo ); @@ -250,7 +250,7 @@ namespace Server.Engines.ConPVP public override void OnDoubleClick( Mobile from ) { - if ( m_TeamInfo != null && m_TeamInfo.Game != null ) + if ( m_TeamInfo?.Game != null ) { CTFTeamInfo ourTeam = m_TeamInfo; CTFTeamInfo useTeam = m_TeamInfo.Game.GetTeamInfo( from ); @@ -380,7 +380,7 @@ namespace Server.Engines.ConPVP SendHome(); - if ( m_TeamInfo != null && m_TeamInfo.Game != null ) + if ( m_TeamInfo?.Game != null ) m_TeamInfo.Game.Alert( "The {0} cookies have been returned.", m_TeamInfo.Name ); return; @@ -1125,7 +1125,7 @@ namespace Server.Engines.ConPVP { CTFTeamInfo teamInfo = m_Controller.TeamInfo[i % 8]; - if ( teamInfo == null || teamInfo.Flag == null ) + if ( teamInfo?.Flag == null ) continue; teams.Add( teamInfo ); @@ -1262,7 +1262,7 @@ namespace Server.Engines.ConPVP { DuelPlayer dp = p.Players[j]; - if ( dp != null && dp.Mobile != null ) + if ( dp?.Mobile != null ) { dp.Mobile.CloseGump( typeof( CTFBoardGump ) ); dp.Mobile.SendGump( new CTFBoardGump( dp.Mobile, this ) ); diff --git a/Scripts/Engines/ConPVP/Games/DoubleDom.cs b/Scripts/Engines/ConPVP/Games/DoubleDom.cs index 58d8671e8..a2bd93985 100644 --- a/Scripts/Engines/ConPVP/Games/DoubleDom.cs +++ b/Scripts/Engines/ConPVP/Games/DoubleDom.cs @@ -22,7 +22,7 @@ namespace Server.Engines.ConPVP public override void OnDoubleClick( Mobile from ) { - if ( m_TeamInfo != null && m_TeamInfo.Game != null ) + if ( m_TeamInfo?.Game != null ) { from.CloseGump( typeof( DDBoardGump ) ); from.SendGump( new DDBoardGump( from, m_TeamInfo.Game ) ); @@ -971,9 +971,9 @@ namespace Server.Engines.ConPVP { DDTeamInfo team = null; - if ( m_Controller.PointA != null && m_Controller.PointA.TeamOwner != null ) + if ( m_Controller.PointA?.TeamOwner != null ) team = m_Controller.PointA.TeamOwner; - else if ( m_Controller.PointB != null && m_Controller.PointB.TeamOwner != null ) + else if ( m_Controller.PointB?.TeamOwner != null ) team = m_Controller.PointB.TeamOwner; if ( team == null ) diff --git a/Scripts/Engines/ConPVP/Games/KingOfTheHill.cs b/Scripts/Engines/ConPVP/Games/KingOfTheHill.cs index 304ba777f..787428772 100644 --- a/Scripts/Engines/ConPVP/Games/KingOfTheHill.cs +++ b/Scripts/Engines/ConPVP/Games/KingOfTheHill.cs @@ -551,7 +551,7 @@ namespace Server.Engines.ConPVP { get { - if (m_Player == null || m_Player.Name == null) + if (m_Player?.Name == null) return ""; return m_Player.Name; } @@ -960,7 +960,7 @@ namespace Server.Engines.ConPVP { get { - if (m_Context != null && m_Context.Arena != null) + if (m_Context?.Arena != null) return m_Context.Arena.Facet; return m_Controller.Map; diff --git a/Scripts/Engines/ConPVP/Tournament.cs b/Scripts/Engines/ConPVP/Tournament.cs index eb49f07df..444715cca 100644 --- a/Scripts/Engines/ConPVP/Tournament.cs +++ b/Scripts/Engines/ConPVP/Tournament.cs @@ -2227,7 +2227,7 @@ namespace Server.Engines.ConPVP public void Alert( Arena arena, params string[] alerts ) { - if ( arena != null && arena.Announcer != null ) + if ( arena?.Announcer != null ) { for ( int j = 0; j < alerts.Length; ++j ) Timer.DelayCall( TimeSpan.FromSeconds( Math.Max( j-0.5, 0.0 ) ), new TimerStateCallback( Alert_Callback ), new object[]{ arena.Announcer, alerts[j] } ); diff --git a/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs index f3f04271b..7f54410ed 100644 --- a/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs +++ b/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs @@ -161,7 +161,7 @@ namespace Server.Engines.Doom public override bool HandlesOnMovement => true; public override bool OnMoveOver( Mobile m ) { - if ( m != null && m is PlayerMobile ) + if ( m is PlayerMobile ) { if ( SpellHelper.CheckCombat( m ) ) { diff --git a/Scripts/Engines/Factions/Core/Faction.cs b/Scripts/Engines/Factions/Core/Faction.cs index 17e2e67a8..04d858577 100644 --- a/Scripts/Engines/Factions/Core/Faction.cs +++ b/Scripts/Engines/Factions/Core/Faction.cs @@ -830,7 +830,7 @@ namespace Server.Factions sigil.GraceStart = DateTime.MinValue; } - if ( sigil.LastMonolith == null || sigil.LastMonolith.Sigil == null ) + if ( sigil.LastMonolith?.Sigil == null ) { if ( (sigil.LastStolen + Sigil.ReturnPeriod) < DateTime.UtcNow ) sigil.ReturnHome(); diff --git a/Scripts/Engines/Factions/Core/FactionState.cs b/Scripts/Engines/Factions/Core/FactionState.cs index 2c9f6f16d..afdb81e99 100644 --- a/Scripts/Engines/Factions/Core/FactionState.cs +++ b/Scripts/Engines/Factions/Core/FactionState.cs @@ -118,10 +118,10 @@ namespace Server.Factions PlayerState pl = PlayerState.Find( m_Commander ); - if ( pl != null && pl.Finance != null ) + if ( pl?.Finance != null ) pl.Finance.Finance = null; - if ( pl != null && pl.Sheriff != null ) + if ( pl?.Sheriff != null ) pl.Sheriff.Sheriff = null; } } diff --git a/Scripts/Engines/Factions/Gumps/FactionGump.cs b/Scripts/Engines/Factions/Gumps/FactionGump.cs index 21071222b..e89acb3db 100644 --- a/Scripts/Engines/Factions/Gumps/FactionGump.cs +++ b/Scripts/Engines/Factions/Gumps/FactionGump.cs @@ -37,7 +37,7 @@ namespace Server.Factions { if ( text != null && text.Number > 0 ) AddHtmlLocalized( x, y, width, height, text.Number, back, scroll ); - else if ( text != null && text.String != null ) + else if ( text?.String != null ) AddHtml( x, y, width, height, text.String, back, scroll ); } diff --git a/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs b/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs index dbe7f3fd2..0f8bb59c5 100644 --- a/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs +++ b/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs @@ -104,7 +104,7 @@ namespace Server.Factions BaseMonolith monolith = town.Monolith; - AddImage( 20, 60 + (i * 30), ( monolith != null && monolith.Sigil != null && monolith.Sigil.IsPurifying ) ? 0x938 : 0x939 ); + AddImage( 20, 60 + (i * 30), ( monolith?.Sigil != null && monolith.Sigil.IsPurifying ) ? 0x938 : 0x939 ); } } diff --git a/Scripts/Engines/Factions/Items/BaseMonolith.cs b/Scripts/Engines/Factions/Items/BaseMonolith.cs index 77f481db9..e9ba53e5c 100644 --- a/Scripts/Engines/Factions/Items/BaseMonolith.cs +++ b/Scripts/Engines/Factions/Items/BaseMonolith.cs @@ -19,7 +19,7 @@ namespace Server.Factions m_Sigil = value; - if ( m_Sigil != null && m_Sigil.LastMonolith != null && m_Sigil.LastMonolith != this && m_Sigil.LastMonolith.Sigil == m_Sigil ) + if ( m_Sigil?.LastMonolith != null && m_Sigil.LastMonolith != this && m_Sigil.LastMonolith.Sigil == m_Sigil ) m_Sigil.LastMonolith.Sigil = null; if ( m_Sigil != null ) diff --git a/Scripts/Engines/Factions/Items/BaseSystemController.cs b/Scripts/Engines/Factions/Items/BaseSystemController.cs index 70d9aacfd..29dbfe819 100644 --- a/Scripts/Engines/Factions/Items/BaseSystemController.cs +++ b/Scripts/Engines/Factions/Items/BaseSystemController.cs @@ -25,7 +25,7 @@ namespace Server.Factions m_LabelNumber = name.Number; Name = null; } - else if ( name != null && name.String != null ) + else if ( name?.String != null ) { m_LabelNumber = 0; Name = name.String; diff --git a/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs b/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs index e218fc47d..d05611f61 100644 --- a/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs +++ b/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs @@ -138,7 +138,7 @@ namespace Server.Factions if ( def != null && def.Number > 0 ) Say( def.Number ); - else if ( def != null && def.String != null ) + else if ( def?.String != null ) Say( def.String ); } diff --git a/Scripts/Engines/MLQuests/MLQuestEntry.cs b/Scripts/Engines/MLQuests/MLQuestEntry.cs index ac12f5c32..0ba2e1221 100644 --- a/Scripts/Engines/MLQuests/MLQuestEntry.cs +++ b/Scripts/Engines/MLQuests/MLQuestEntry.cs @@ -63,7 +63,7 @@ namespace Server.Engines.MLQuests private void Register() { - if ( m_Quest != null && m_Quest.Instances != null ) + if ( m_Quest?.Instances != null ) m_Quest.Instances.Add( this ); if ( m_Player != null ) @@ -72,7 +72,7 @@ namespace Server.Engines.MLQuests private void Unregister() { - if ( m_Quest != null && m_Quest.Instances != null ) + if ( m_Quest?.Instances != null ) m_Quest.Instances.Remove( this ); if ( m_Player != null ) diff --git a/Scripts/Engines/Reports/Objects/Staffing/Info.cs b/Scripts/Engines/Reports/Objects/Staffing/Info.cs index 113f07dfd..f2b3db3b8 100644 --- a/Scripts/Engines/Reports/Objects/Staffing/Info.cs +++ b/Scripts/Engines/Reports/Objects/Staffing/Info.cs @@ -45,7 +45,7 @@ namespace Server.Engines.Reports mob = check; } - if ( mob != null && mob.Name != null && mob.Name.Length > 0 ) + if ( mob?.Name != null && mob.Name.Length > 0 ) return ( m_Display = mob.Name ); } } diff --git a/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs b/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs index 4915af869..d717603b0 100644 --- a/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs +++ b/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatuePlinth.cs @@ -66,7 +66,7 @@ namespace Server.Items m_Statue = reader.ReadMobile() as CharacterStatue; - if ( m_Statue == null || m_Statue.SculptedBy == null || Map == Map.Internal ) + if ( m_Statue?.SculptedBy == null || Map == Map.Internal ) { Timer.DelayCall( TimeSpan.Zero, new TimerCallback( Delete ) ); } diff --git a/Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs b/Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs index 0f5ba8a41..009d19cac 100644 --- a/Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs +++ b/Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs @@ -130,7 +130,7 @@ namespace Server.Guilds { if ( text != null && text.Number > 0 ) AddHtmlLocalized( x, y, width, height, text.Number, back, scroll ); - else if ( text != null && text.String != null ) + else if ( text?.String != null ) AddHtml( x, y, width, height, text.String, back, scroll ); } diff --git a/Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs b/Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs index 1c080fa6c..a86dda0fc 100644 --- a/Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs +++ b/Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs @@ -204,7 +204,7 @@ namespace Server.Guilds if ( m_LowerText != null && m_LowerText.Number > 0 ) AddHtmlLocalized( 66, 153 + itemNumber * 28, 280, 26, m_LowerText.Number, 0xF, false, false ); - else if ( m_LowerText != null && m_LowerText.String != null ) + else if ( m_LowerText?.String != null ) AddHtml( 66, 153 + itemNumber * 28, 280, 26, Color( m_LowerText.String, 0x99 ), false, false ); if ( AllowAdvancedSearch ) diff --git a/Scripts/Gumps/SetSecureLevelGump.cs b/Scripts/Gumps/SetSecureLevelGump.cs index 42f35bc4e..c24513dd3 100644 --- a/Scripts/Gumps/SetSecureLevelGump.cs +++ b/Scripts/Gumps/SetSecureLevelGump.cs @@ -44,7 +44,7 @@ namespace Server.Gumps AddHtmlLocalized( 45, 110, 150, 20, 1061279, GetColor( SecureLevel.Friends ), false, false ); // Friends Mobile houseOwner = house.Owner; - if ( Guild.NewGuildSystem && house != null && houseOwner != null && houseOwner.Guild != null && ((Guild)houseOwner.Guild).Leader == houseOwner ) //Only the actual House owner AND guild master can set guild secures + if ( Guild.NewGuildSystem && house != null && houseOwner?.Guild != null && ((Guild)houseOwner.Guild).Leader == houseOwner ) //Only the actual House owner AND guild master can set guild secures { AddButton( 10, 130, GetFirstID( SecureLevel.Guild ), 4007, 5, GumpButtonType.Reply, 0 ); AddHtmlLocalized( 45, 130, 150, 20, 1063455, GetColor( SecureLevel.Guild ), false, false ); // Guild Members diff --git a/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs b/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs index b8b06d89b..359614aa7 100644 --- a/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs +++ b/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs @@ -218,7 +218,7 @@ namespace Server.Engines.Events public static bool CheckMobile( Mobile mobile ) { - return ( mobile != null && mobile.Map != null && !mobile.Deleted && mobile.Alive && mobile.Map != Map.Internal ); + return ( mobile?.Map != null && !mobile.Deleted && mobile.Alive && mobile.Map != Map.Internal ); } } diff --git a/Scripts/Holiday Stuff/Halloween/2011/Mobiles/PumpkinHead.cs b/Scripts/Holiday Stuff/Halloween/2011/Mobiles/PumpkinHead.cs index cbe6419ab..0638610ef 100644 --- a/Scripts/Holiday Stuff/Halloween/2011/Mobiles/PumpkinHead.cs +++ b/Scripts/Holiday Stuff/Halloween/2011/Mobiles/PumpkinHead.cs @@ -100,7 +100,7 @@ namespace Server.Mobiles { if ( Utility.RandomBool() ) { - if ( from != null && from.Map != null && Map != Map.Internal && Map == from.Map && from.InRange( this, 12 ) ) + if ( @from?.Map != null && Map != Map.Internal && Map == @from.Map && @from.InRange( this, 12 ) ) { SpillAcid( ( willKill ) ? this : from, ( willKill ) ? 3 : 1 ); } diff --git a/Scripts/Items/Addons/SHTeleporter.cs b/Scripts/Items/Addons/SHTeleporter.cs index 14f91086c..1109f47f2 100644 --- a/Scripts/Items/Addons/SHTeleporter.cs +++ b/Scripts/Items/Addons/SHTeleporter.cs @@ -370,7 +370,7 @@ namespace Server.Items m_Changing = true; - if ( dest == null || !(dest.Addon is SHTeleporter) ) + if ( !(dest?.Addon is SHTeleporter) ) { m_UpTele.TeleDest = dest; m_RightTele.TeleDest = dest; diff --git a/Scripts/Items/Aquarium/Aquarium.cs b/Scripts/Items/Aquarium/Aquarium.cs index 8ce891932..f1a021ff0 100644 --- a/Scripts/Items/Aquarium/Aquarium.cs +++ b/Scripts/Items/Aquarium/Aquarium.cs @@ -876,7 +876,7 @@ namespace Server.Items #region Static members public static FishBowl GetEmptyBowl( Mobile from ) { - if ( from == null || from.Backpack == null ) + if ( @from?.Backpack == null ) return null; Item[] items = from.Backpack.FindItemsByType( typeof( FishBowl ) ); diff --git a/Scripts/Items/Misc/Gold.cs b/Scripts/Items/Misc/Gold.cs index ccb06e69a..80305ff78 100644 --- a/Scripts/Items/Misc/Gold.cs +++ b/Scripts/Items/Misc/Gold.cs @@ -64,7 +64,7 @@ namespace Server.Items Container root = parent as Container; - while (root != null && root.Parent is Container) + while (root?.Parent is Container) { root = (Container)root.Parent; } diff --git a/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs b/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs index e3ef5ee83..e09feab8d 100644 --- a/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs +++ b/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs @@ -228,7 +228,7 @@ namespace Server.Items public static bool IsPoisonImmune( BaseCreature bc ) { - return ( bc != null && bc.PoisonImmune != null ); + return ( bc?.PoisonImmune != null ); } public static int GetPoisonLevel( BaseCreature bc ) diff --git a/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs b/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs index 18d6f908b..bfce25415 100644 --- a/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs +++ b/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs @@ -124,7 +124,7 @@ namespace Server.Items protected override void OnTick() { - if ( m_Mobile == null || m_Mobile.Map == null || m_Mobile.Deleted || !m_Mobile.Alive || m_Mobile.Map == Map.Internal ) + if ( m_Mobile?.Map == null || m_Mobile.Deleted || !m_Mobile.Alive || m_Mobile.Map == Map.Internal ) { Stop(); } diff --git a/Scripts/Items/Special/House Raffle/HouseRaffleManagementGump.cs b/Scripts/Items/Special/House Raffle/HouseRaffleManagementGump.cs index 24899a073..17080f856 100644 --- a/Scripts/Items/Special/House Raffle/HouseRaffleManagementGump.cs +++ b/Scripts/Items/Special/House Raffle/HouseRaffleManagementGump.cs @@ -236,8 +236,8 @@ namespace Server.Gumps public int Compare( RaffleEntry x, RaffleEntry y ) { - bool xIsNull = ( x == null || x.From == null ); - bool yIsNull = ( y == null || y.From == null ); + bool xIsNull = ( x?.From == null ); + bool yIsNull = ( y?.From == null ); if ( xIsNull && yIsNull ) return 0; @@ -265,8 +265,8 @@ namespace Server.Gumps public int Compare( RaffleEntry x, RaffleEntry y ) { - bool xIsNull = ( x == null || x.From == null ); - bool yIsNull = ( y == null || y.From == null ); + bool xIsNull = ( x?.From == null ); + bool yIsNull = ( y?.From == null ); if ( xIsNull && yIsNull ) return 0; @@ -304,8 +304,8 @@ namespace Server.Gumps public int Compare( RaffleEntry x, RaffleEntry y ) { - bool xIsNull = ( x == null || x.Address == null ); - bool yIsNull = ( y == null || y.Address == null ); + bool xIsNull = ( x?.Address == null ); + bool yIsNull = ( y?.Address == null ); if ( xIsNull && yIsNull ) return 0; diff --git a/Scripts/Items/Special/House Raffle/HouseRaffleRegion.cs b/Scripts/Items/Special/House Raffle/HouseRaffleRegion.cs index 9d87cb8f8..d4d1a5de2 100644 --- a/Scripts/Items/Special/House Raffle/HouseRaffleRegion.cs +++ b/Scripts/Items/Special/House Raffle/HouseRaffleRegion.cs @@ -54,7 +54,7 @@ namespace Server.Regions public override bool OnTarget( Mobile m, Target t, object o ) { - if ( m.Spell != null && m.Spell is MarkSpell && m.AccessLevel == AccessLevel.Player ) + if ( m.Spell is MarkSpell && m.AccessLevel == AccessLevel.Player ) { m.SendLocalizedMessage( 501800 ); // You cannot mark an object at that location. return false; diff --git a/Scripts/Items/Special/Mutation Core/PlagueBeastOrgans.cs b/Scripts/Items/Special/Mutation Core/PlagueBeastOrgans.cs index 74bbcb474..3da6780e4 100644 --- a/Scripts/Items/Special/Mutation Core/PlagueBeastOrgans.cs +++ b/Scripts/Items/Special/Mutation Core/PlagueBeastOrgans.cs @@ -536,7 +536,7 @@ namespace Server.Items AddComponent( new PlagueBeastComponent( 0x1363, 0x1 ), 0, 22 ); AddComponent( new PlagueBeastComponent( 0x1D04, 0xD ), 0, 22 ); - if ( Owner != null && Owner.Backpack != null ) + if ( Owner?.Backpack != null ) { PlagueBeastMutationCore core = new PlagueBeastMutationCore(); Owner.Backpack.AddItem( core ); diff --git a/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs b/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs index 717c5f651..21fc7d71c 100644 --- a/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs +++ b/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs @@ -32,7 +32,7 @@ { IEntity rootParent = RootParent; - if ( rootParent != null && rootParent.Map != null && rootParent.Map != Map.Internal ) + if ( rootParent?.Map != null && rootParent.Map != Map.Internal ) MoveToWorld( rootParent.Location, rootParent.Map ); } diff --git a/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs b/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs index ac9b9fd63..e2b1565e6 100644 --- a/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs +++ b/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs @@ -252,7 +252,7 @@ namespace Server.Items from.SendLocalizedMessage( 1054004 ); // You must equip the bracelet in order to use its power. return false; } - else if ( boundRoot == null || boundRoot.NetState == null || boundRoot.FindItemOnLayer( Layer.Bracelet ) != bound ) + else if ( boundRoot?.NetState == null || boundRoot.FindItemOnLayer( Layer.Bracelet ) != bound ) { from.SendLocalizedMessage( 1054006 ); // The bracelet emits a red glow. The bracelet's twin is not available for transport. return false; diff --git a/Scripts/Items/Weapons/Ranged/BaseRanged.cs b/Scripts/Items/Weapons/Ranged/BaseRanged.cs index 132ec1517..546ef8e58 100644 --- a/Scripts/Items/Weapons/Ranged/BaseRanged.cs +++ b/Scripts/Items/Weapons/Ranged/BaseRanged.cs @@ -170,7 +170,7 @@ namespace Server.Items else if ( pack == null || !pack.ConsumeTotal( AmmoType, 1 ) ) return false; } - else if ( quiver.FindItemByType( AmmoType ) == null && ( pack == null || pack.FindItemByType( AmmoType ) == null ) ) + else if ( quiver.FindItemByType( AmmoType ) == null && ( pack?.FindItemByType( AmmoType ) == null ) ) { // lower ammo cost should not work when we have no ammo at all return false; diff --git a/Scripts/Misc/Assistants.cs b/Scripts/Misc/Assistants.cs index 453bfec02..2dc8ed2b7 100644 --- a/Scripts/Misc/Assistants.cs +++ b/Scripts/Misc/Assistants.cs @@ -103,7 +103,7 @@ namespace Server.Misc { Mobile m = e.Mobile; - if (m != null && m.NetState != null && m.NetState.Running) + if (m?.NetState != null && m.NetState.Running) { m.Send(new BeginHandshake()); @@ -122,7 +122,7 @@ namespace Server.Misc { pvSrc.Trace(state); - if (state == null || state.Mobile == null || !state.Running) + if (state?.Mobile == null || !state.Running) return; Mobile m = state.Mobile; diff --git a/Scripts/Misc/Gifts/Winter2004/PileOfGlacialSnow.cs b/Scripts/Misc/Gifts/Winter2004/PileOfGlacialSnow.cs index 9d8d8ebcd..c77e63106 100644 --- a/Scripts/Misc/Gifts/Winter2004/PileOfGlacialSnow.cs +++ b/Scripts/Misc/Gifts/Winter2004/PileOfGlacialSnow.cs @@ -113,7 +113,7 @@ namespace Server.Items { from.SendMessage( "You may not throw snow here." ); } - else if ( pack != null && pack.FindItemByType( new[]{ typeof( SnowPile ), typeof( PileOfGlacialSnow ) } ) != null ) + else if ( pack?.FindItemByType( new[]{ typeof( SnowPile ), typeof( PileOfGlacialSnow ) } ) != null ) { if ( from.BeginAction( typeof( SnowPile ) ) ) { diff --git a/Scripts/Mobiles/AI/ArcherAI.cs b/Scripts/Mobiles/AI/ArcherAI.cs index 765891a91..21a61f0f8 100644 --- a/Scripts/Mobiles/AI/ArcherAI.cs +++ b/Scripts/Mobiles/AI/ArcherAI.cs @@ -67,7 +67,7 @@ namespace Server.Mobiles // When we have no ammo, we flee Container pack = m_Mobile.Backpack; - if ( pack == null || pack.FindItemByType( typeof( Arrow ) ) == null ) + if ( pack?.FindItemByType( typeof( Arrow ) ) == null ) { Action = ActionType.Flee; return true; diff --git a/Scripts/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs b/Scripts/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs index dbf895160..3656317f7 100644 --- a/Scripts/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs +++ b/Scripts/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs @@ -48,7 +48,7 @@ namespace Server.Mobiles public static bool IsInsideKhaldun( Mobile from ) { - return from != null && from.Region != null && from.Region.IsPartOf( "Khaldun" ); + return @from?.Region != null && @from.Region.IsPartOf( "Khaldun" ); } private Mobile m_Target; diff --git a/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs b/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs index 663fc4282..7974d452b 100644 --- a/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs +++ b/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs @@ -196,7 +196,7 @@ namespace Server.Mobiles public bool Devour( Corpse corpse ) { - if ( corpse == null || corpse.Owner == null ) // sorry we can't devour because the corpse's owner is null + if ( corpse?.Owner == null ) // sorry we can't devour because the corpse's owner is null return false; if ( corpse.Owner.Body.IsHuman ) diff --git a/Scripts/Mobiles/Monsters/SE/Kappa.cs b/Scripts/Mobiles/Monsters/SE/Kappa.cs index b6c362de3..b40ec67fd 100644 --- a/Scripts/Mobiles/Monsters/SE/Kappa.cs +++ b/Scripts/Mobiles/Monsters/SE/Kappa.cs @@ -146,7 +146,7 @@ namespace Server.Mobiles public override void OnDamage( int amount, Mobile from, bool willKill ) { - if ( from != null && from.Map != null ) + if ( @from?.Map != null ) { int amt=0; Mobile target = this; diff --git a/Scripts/Mobiles/Special/BaseShieldGuard.cs b/Scripts/Mobiles/Special/BaseShieldGuard.cs index 2ba5e0296..53686e3af 100644 --- a/Scripts/Mobiles/Special/BaseShieldGuard.cs +++ b/Scripts/Mobiles/Special/BaseShieldGuard.cs @@ -105,7 +105,7 @@ namespace Server.Mobiles BaseShield shield = Shield; Item twoHanded = from.FindItemOnLayer( Layer.TwoHanded ); - if ( (pack != null && pack.FindItemByType( shield.GetType() ) != null) || ( twoHanded != null && shield.GetType().IsAssignableFrom( twoHanded.GetType() ) ) ) + if ( (pack?.FindItemByType( shield.GetType() ) != null) || ( twoHanded != null && shield.GetType().IsAssignableFrom( twoHanded.GetType() ) ) ) { Say( 1007110 ); // Why dost thou ask about virtue guards when thou art one? shield.Delete(); diff --git a/Scripts/Mobiles/Vendors/PlayerVendor.cs b/Scripts/Mobiles/Vendors/PlayerVendor.cs index a7dd28c49..5ccd3b9e8 100644 --- a/Scripts/Mobiles/Vendors/PlayerVendor.cs +++ b/Scripts/Mobiles/Vendors/PlayerVendor.cs @@ -220,7 +220,7 @@ namespace Server.Mobiles VendorItem vi = pv.GetVendorItem( item ); - if ( vi != null && vi.Description != null && vi.Description.Length > 0 ) + if ( vi?.Description != null && vi.Description.Length > 0 ) list.Add( 1043305, vi.Description ); //
Seller's Description:
"~1_DESC~" } diff --git a/Scripts/Multis/BaseHouse.cs b/Scripts/Multis/BaseHouse.cs index e6fb77572..cf450f64a 100644 --- a/Scripts/Multis/BaseHouse.cs +++ b/Scripts/Multis/BaseHouse.cs @@ -3266,7 +3266,7 @@ namespace Server.Multis public bool IsGuildMember( Mobile m ) { - if ( m == null || Owner == null || Owner.Guild == null ) + if ( m == null || Owner?.Guild == null ) return false; return ( m.Guild == Owner.Guild ); diff --git a/Scripts/Multis/Boats/TillerMan.cs b/Scripts/Multis/Boats/TillerMan.cs index 5e16f072d..1172893da 100644 --- a/Scripts/Multis/Boats/TillerMan.cs +++ b/Scripts/Multis/Boats/TillerMan.cs @@ -47,7 +47,7 @@ namespace Server.Items public override void AddNameProperty( ObjectPropertyList list ) { - if ( m_Boat != null && m_Boat.ShipName != null ) + if ( m_Boat?.ShipName != null ) list.Add( 1042884, m_Boat.ShipName ); // the tiller man of the ~1_SHIP_NAME~ else base.AddNameProperty( list ); @@ -55,7 +55,7 @@ namespace Server.Items public override void OnSingleClick( Mobile from ) { - if ( m_Boat != null && m_Boat.ShipName != null ) + if ( m_Boat?.ShipName != null ) LabelTo( from, 1042884, m_Boat.ShipName ); // the tiller man of the ~1_SHIP_NAME~ else base.OnSingleClick( from ); diff --git a/Scripts/Multis/HousePlacementTool.cs b/Scripts/Multis/HousePlacementTool.cs index 4d815e47a..986fb83d8 100644 --- a/Scripts/Multis/HousePlacementTool.cs +++ b/Scripts/Multis/HousePlacementTool.cs @@ -87,7 +87,7 @@ namespace Server.Items public override void OnResponse( Network.NetState sender, RelayInfo info ) { - if ( !m_From.CheckAlive() || m_From.Backpack == null || m_From.Backpack.FindItemByType( typeof( HousePlacementTool ) ) == null ) + if ( !m_From.CheckAlive() || m_From.Backpack?.FindItemByType( typeof( HousePlacementTool ) ) == null ) return; switch ( info.ButtonID ) @@ -195,7 +195,7 @@ namespace Server.Items public override void OnResponse( Network.NetState sender, RelayInfo info ) { - if ( !m_From.CheckAlive() || m_From.Backpack == null || m_From.Backpack.FindItemByType( typeof( HousePlacementTool ) ) == null ) + if ( !m_From.CheckAlive() || m_From.Backpack?.FindItemByType( typeof( HousePlacementTool ) ) == null ) return; int index = info.ButtonID - 1; @@ -231,7 +231,7 @@ namespace Server.Items protected override void OnTarget( Mobile from, object o ) { - if ( !from.CheckAlive() || from.Backpack == null || from.Backpack.FindItemByType( typeof( HousePlacementTool ) ) == null ) + if ( !@from.CheckAlive() || @from.Backpack?.FindItemByType( typeof( HousePlacementTool ) ) == null ) return; IPoint3D ip = o as IPoint3D; @@ -260,7 +260,7 @@ namespace Server.Items protected override void OnTargetFinish( Mobile from ) { - if ( !from.CheckAlive() || from.Backpack == null || from.Backpack.FindItemByType( typeof( HousePlacementTool ) ) == null ) + if ( !@from.CheckAlive() || @from.Backpack?.FindItemByType( typeof( HousePlacementTool ) ) == null ) return; if ( !m_Placed ) @@ -332,7 +332,7 @@ namespace Server.Items public void PlacementWarning_Callback( Mobile from, bool okay, object state ) { - if ( !from.CheckAlive() || from.Backpack == null || from.Backpack.FindItemByType( typeof( HousePlacementTool ) ) == null ) + if ( !@from.CheckAlive() || @from.Backpack?.FindItemByType( typeof( HousePlacementTool ) ) == null ) return; PreviewHouse prevHouse = (PreviewHouse)state; @@ -447,7 +447,7 @@ namespace Server.Items public bool OnPlacement( Mobile from, Point3D p ) { - if ( !from.CheckAlive() || from.Backpack == null || from.Backpack.FindItemByType( typeof( HousePlacementTool ) ) == null ) + if ( !@from.CheckAlive() || @from.Backpack?.FindItemByType( typeof( HousePlacementTool ) ) == null ) return false; ArrayList toMove; diff --git a/Scripts/Multis/HouseSign.cs b/Scripts/Multis/HouseSign.cs index 81fc06af8..423431a21 100644 --- a/Scripts/Multis/HouseSign.cs +++ b/Scripts/Multis/HouseSign.cs @@ -65,7 +65,7 @@ namespace Server.Multis base.GetProperties( list ); list.Add( 1061639, Utility.FixHtml( GetName() ) ); // Name: ~1_NAME~ - list.Add( 1061640, (m_Owner == null || m_Owner.Owner == null) ? "nobody" : m_Owner.Owner.Name ); // Owner: ~1_OWNER~ + list.Add( 1061640, (m_Owner?.Owner == null) ? "nobody" : m_Owner.Owner.Name ); // Owner: ~1_OWNER~ if ( m_Owner != null ) { diff --git a/Scripts/Regions/BaseRegion.cs b/Scripts/Regions/BaseRegion.cs index a23d447d4..ac3c1722f 100644 --- a/Scripts/Regions/BaseRegion.cs +++ b/Scripts/Regions/BaseRegion.cs @@ -79,7 +79,7 @@ namespace Server.Regions { BaseRegion br = region as BaseRegion; - if ( br != null && br.m_RuneName != null ) + if ( br?.m_RuneName != null ) return br.m_RuneName; region = region.Parent; diff --git a/Scripts/Regions/Spawning/SpawnEntry.cs b/Scripts/Regions/Spawning/SpawnEntry.cs index 2b05f27f2..ab9145074 100644 --- a/Scripts/Regions/Spawning/SpawnEntry.cs +++ b/Scripts/Regions/Spawning/SpawnEntry.cs @@ -343,7 +343,7 @@ namespace Server.Regions BaseRegion br = reg as BaseRegion; - if ( br == null || br.Spawns == null ) + if ( br?.Spawns == null ) { from.SendMessage( "There are no spawners in region '{0}'.", reg ); return null; diff --git a/Scripts/Skills/Stealing.cs b/Scripts/Skills/Stealing.cs index c2656bc96..548d58703 100644 --- a/Scripts/Skills/Stealing.cs +++ b/Scripts/Skills/Stealing.cs @@ -152,7 +152,7 @@ namespace Server.SkillHandlers m_Thief.SendLocalizedMessage( 1010586 ); // YOU STOLE THE SIGIL!!! (woah, calm down now) - if ( sig.LastMonolith != null && sig.LastMonolith.Sigil != null ) { + if ( sig.LastMonolith?.Sigil != null ) { sig.LastMonolith.Sigil = null; sig.LastStolen = DateTime.UtcNow; } diff --git a/Scripts/SpecialSystems/Engines/PreventInaccess.cs b/Scripts/SpecialSystems/Engines/PreventInaccess.cs index 853ef08c9..685739b0d 100644 --- a/Scripts/SpecialSystems/Engines/PreventInaccess.cs +++ b/Scripts/SpecialSystems/Engines/PreventInaccess.cs @@ -65,7 +65,7 @@ namespace Server.Misc private static bool HasDisconnected( Mobile m ) { - return ( m.NetState == null || m.NetState.Socket == null ); + return ( m.NetState?.Socket == null ); } private static LocationInfo GetRandomDestination() diff --git a/Scripts/Spells/Base/Spell.cs b/Scripts/Spells/Base/Spell.cs index fed73426b..041f3a907 100644 --- a/Scripts/Spells/Base/Spell.cs +++ b/Scripts/Spells/Base/Spell.cs @@ -145,7 +145,7 @@ namespace Server.Spells TransformContext context = TransformationSpellHelper.GetContext( Caster ); - if ( context != null && context.Spell is ReaperFormSpell ) + if ( context?.Spell is ReaperFormSpell ) damageBonus += ((ReaperFormSpell)context.Spell).SpellDamageBonus; damage = AOS.Scale( damage, 100 + damageBonus ); @@ -173,7 +173,7 @@ namespace Server.Spells object o = ProtectionSpell.Registry[m_Caster]; bool disturb = true; - if ( o != null && o is double ) + if ( o is double ) { if ( ((double)o) > Utility.RandomDouble()*100.0 ) disturb = false; @@ -513,7 +513,7 @@ namespace Server.Spells m_Caster.SendLocalizedMessage( 1072060 ); // You cannot cast a spell while calmed. } #region Dueling - else if ( m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).DuelContext != null && !((PlayerMobile)m_Caster).DuelContext.AllowSpellCast( m_Caster, this ) ) + else if ( (m_Caster as PlayerMobile)?.DuelContext != null && !((PlayerMobile)m_Caster).DuelContext.AllowSpellCast( m_Caster, this ) ) { } #endregion @@ -899,7 +899,7 @@ namespace Server.Spells protected override void OnTick() { - if ( m_Spell == null || m_Spell.m_Caster == null ) + if ( m_Spell?.m_Caster == null ) { return; } diff --git a/Scripts/Spells/Base/SpellHelper.cs b/Scripts/Spells/Base/SpellHelper.cs index 2cb13bfc5..2214292f6 100644 --- a/Scripts/Spells/Base/SpellHelper.cs +++ b/Scripts/Spells/Base/SpellHelper.cs @@ -747,7 +747,7 @@ namespace Server.Spells { PlayerMobile pm = m_TravelCaster as PlayerMobile; - if ( pm != null && pm.DuelPlayer != null && !pm.DuelPlayer.Eliminated ) + if ( pm?.DuelPlayer != null && !pm.DuelPlayer.Eliminated ) return true; } @@ -880,7 +880,7 @@ namespace Server.Spells { PlayerMobile pm = (PlayerMobile) caster; - if ( pm == null || pm.DuelContext == null || !pm.DuelContext.Started || pm.DuelPlayer == null || pm.DuelPlayer.Eliminated ) + if ( pm?.DuelContext == null || !pm.DuelContext.Started || pm.DuelPlayer == null || pm.DuelPlayer.Eliminated ) return true; } #endregion diff --git a/Scripts/Spells/Chivalry/DispelEvil.cs b/Scripts/Spells/Chivalry/DispelEvil.cs index d6a892721..ac1912225 100644 --- a/Scripts/Spells/Chivalry/DispelEvil.cs +++ b/Scripts/Spells/Chivalry/DispelEvil.cs @@ -94,7 +94,7 @@ namespace Server.Spells.Chivalry } TransformContext context = TransformationSpellHelper.GetContext( m ); - if ( context != null && context.Spell is NecromancerSpell ) //Trees are not evil! TODO: OSI confirm? + if ( context?.Spell is NecromancerSpell ) //Trees are not evil! TODO: OSI confirm? { // transformed .. diff --git a/Scripts/Spells/Fifth/Incognito.cs b/Scripts/Spells/Fifth/Incognito.cs index 5bac70b3f..cf5260e75 100644 --- a/Scripts/Spells/Fifth/Incognito.cs +++ b/Scripts/Spells/Fifth/Incognito.cs @@ -77,7 +77,7 @@ namespace Server.Spells.Fifth PlayerMobile pm = Caster as PlayerMobile; - if ( pm != null && pm.Race != null ) + if ( pm?.Race != null ) { pm.SetHairMods( pm.Race.RandomHair( pm.Female ), pm.Race.RandomFacialHair( pm.Female ) ); pm.HairHue = pm.Race.RandomHairHue(); diff --git a/Scripts/Spells/Necromancy/AnimateDeadSpell.cs b/Scripts/Spells/Necromancy/AnimateDeadSpell.cs index 283b56521..1952c9c97 100644 --- a/Scripts/Spells/Necromancy/AnimateDeadSpell.cs +++ b/Scripts/Spells/Necromancy/AnimateDeadSpell.cs @@ -197,7 +197,7 @@ namespace Server.Spells.Necromancy type = c.Owner.GetType(); } - if ( c.ItemID != 0x2006 || c.Animated || type == typeof( PlayerMobile ) || type == null || ( c.Owner != null && c.Owner.Fame < 100 ) || ( ( c.Owner != null ) && ( c.Owner is BaseCreature ) && ( ( ( BaseCreature )c.Owner ).Summoned || ( ( BaseCreature )c.Owner ).IsBonded ) ) ) + if ( c.ItemID != 0x2006 || c.Animated || type == typeof( PlayerMobile ) || type == null || ( c.Owner != null && c.Owner.Fame < 100 ) || ( c.Owner is BaseCreature && ( ( ( BaseCreature )c.Owner ).Summoned || ( ( BaseCreature )c.Owner ).IsBonded ) ) ) { Caster.SendLocalizedMessage( 1061085 ); // There's not enough life force there to animate. } diff --git a/Scripts/Spells/Necromancy/SummonFamiliar.cs b/Scripts/Spells/Necromancy/SummonFamiliar.cs index f19e08268..576716c8d 100644 --- a/Scripts/Spells/Necromancy/SummonFamiliar.cs +++ b/Scripts/Spells/Necromancy/SummonFamiliar.cs @@ -156,7 +156,7 @@ namespace Server.Spells.Necromancy BaseCreature check = (BaseCreature)SummonFamiliarSpell.Table[m_From]; #region Dueling - if ( m_From is PlayerMobile && ( (PlayerMobile)m_From ).DuelContext != null && !( (PlayerMobile)m_From ).DuelContext.AllowSpellCast( m_From, m_Spell ) ) + if ( (m_From as PlayerMobile)?.DuelContext != null && !( (PlayerMobile)m_From ).DuelContext.AllowSpellCast( m_From, m_Spell ) ) { } #endregion diff --git a/Scripts/Spells/Ninjitsu/AnimalForm.cs b/Scripts/Spells/Ninjitsu/AnimalForm.cs index 242272c14..8876284bd 100644 --- a/Scripts/Spells/Ninjitsu/AnimalForm.cs +++ b/Scripts/Spells/Ninjitsu/AnimalForm.cs @@ -479,7 +479,7 @@ namespace Server.Spells.Ninjitsu else if (BaseFormTalisman.EntryEnabled(sender.Mobile, entry.Type)) { #region Dueling - if ( m_Caster is PlayerMobile && ((PlayerMobile)m_Caster).DuelContext != null && !((PlayerMobile)m_Caster).DuelContext.AllowSpellCast( m_Caster, m_Spell ) ) + if ( (m_Caster as PlayerMobile)?.DuelContext != null && !((PlayerMobile)m_Caster).DuelContext.AllowSpellCast( m_Caster, m_Spell ) ) { } #endregion diff --git a/Scripts/Spells/Spellweaving/ArcanistSpell.cs b/Scripts/Spells/Spellweaving/ArcanistSpell.cs index 19ff1fe0a..f8f2a9876 100644 --- a/Scripts/Spells/Spellweaving/ArcanistSpell.cs +++ b/Scripts/Spells/Spellweaving/ArcanistSpell.cs @@ -36,7 +36,7 @@ namespace Server.Spells.Spellweaving public static ArcaneFocus FindArcaneFocus( Mobile from ) { - if ( from == null || from.Backpack == null ) + if ( @from?.Backpack == null ) return null; if ( from.Holding is ArcaneFocus ) diff --git a/Scripts/Spells/Spellweaving/GiftOfLife.cs b/Scripts/Spells/Spellweaving/GiftOfLife.cs index fa3827afc..12b9a630d 100644 --- a/Scripts/Spells/Spellweaving/GiftOfLife.cs +++ b/Scripts/Spells/Spellweaving/GiftOfLife.cs @@ -107,7 +107,7 @@ namespace Server.Spells.Spellweaving BaseCreature pet = (BaseCreature)m; Mobile master = pet.GetMaster(); - if ( master != null && master.NetState != null && Utility.InUpdateRange( pet, master ) ) + if ( master?.NetState != null && Utility.InUpdateRange( pet, master ) ) { master.CloseGump( typeof( PetResurrectGump ) ); master.SendGump( new PetResurrectGump( master, pet, hitsScalar ) ); diff --git a/Scripts/Spells/Spellweaving/NatureFury.cs b/Scripts/Spells/Spellweaving/NatureFury.cs index b8841f431..dc5a38890 100644 --- a/Scripts/Spells/Spellweaving/NatureFury.cs +++ b/Scripts/Spells/Spellweaving/NatureFury.cs @@ -52,7 +52,7 @@ namespace Server.Spells.Spellweaving HouseRegion r = Region.Find( p, map ).GetRegion( typeof( HouseRegion ) ) as HouseRegion; - if ( r != null && r.House != null && !r.House.IsFriend( Caster ) ) + if ( r?.House != null && !r.House.IsFriend( Caster ) ) return; if ( !map.CanSpawnMobile( p.X, p.Y, p.Z ) ) diff --git a/Scripts/Spells/Third/Telekinesis.cs b/Scripts/Spells/Third/Telekinesis.cs index e596f9e8f..60cb7c546 100644 --- a/Scripts/Spells/Third/Telekinesis.cs +++ b/Scripts/Spells/Third/Telekinesis.cs @@ -51,7 +51,7 @@ namespace Server.Spells.Third else if ( !item.CheckItemUse( Caster, item ) ) { } - else if ( root != null && root is Mobile && root != Caster ) + else if ( root is Mobile && root != Caster ) { item.OnSnoop( Caster ); } diff --git a/Server/Body.cs b/Server/Body.cs index 1adbe8290..82cf2f45d 100644 --- a/Server/Body.cs +++ b/Server/Body.cs @@ -183,7 +183,7 @@ namespace Server public override bool Equals( object o ) { - if ( o == null || !(o is Body) ) return false; + if ( !(o is Body) ) return false; return ((Body)o).m_BodyID == m_BodyID; } diff --git a/Server/Items/Containers.cs b/Server/Items/Containers.cs index 2ba17219a..db57bc34f 100644 --- a/Server/Items/Containers.cs +++ b/Server/Items/Containers.cs @@ -148,7 +148,7 @@ namespace Server.Items public override int GetTotal(TotalType type) { - if (AccountGold.Enabled && Owner != null && Owner.Account != null && type == TotalType.Gold) + if (AccountGold.Enabled && Owner?.Account != null && type == TotalType.Gold) { return Owner.Account.TotalGold; } diff --git a/Server/Items/VirtualCheck.cs b/Server/Items/VirtualCheck.cs index b49e01c91..bc763457e 100644 --- a/Server/Items/VirtualCheck.cs +++ b/Server/Items/VirtualCheck.cs @@ -87,7 +87,7 @@ namespace Server { if (UseEditGump && IsAccessibleTo(from)) { - if (Editor == null || Editor.Check == null || Editor.Check.Deleted) + if (Editor?.Check == null || Editor.Check.Deleted) { Editor = new EditGump(from, this); Editor.Send(); @@ -125,7 +125,7 @@ namespace Server { var c = GetSecureTradeCont(); - if (c == null || c.Trade == null) + if (c?.Trade == null) { return; } diff --git a/Server/Map.cs b/Server/Map.cs index bd8a39726..2d8689038 100644 --- a/Server/Map.cs +++ b/Server/Map.cs @@ -70,7 +70,7 @@ namespace Server public static IEnumerable SelectClients(Sector s, Rectangle2D bounds) { - return s.Clients.Where(o => o != null && o.Mobile != null && !o.Mobile.Deleted && bounds.Contains(o.Mobile)); + return s.Clients.Where(o => o?.Mobile != null && !o.Mobile.Deleted && bounds.Contains(o.Mobile)); } public static IEnumerable SelectEntities(Sector s, Rectangle2D bounds) diff --git a/Server/Network/PacketHandlers.cs b/Server/Network/PacketHandlers.cs index 20d6a0710..63031e749 100644 --- a/Server/Network/PacketHandlers.cs +++ b/Server/Network/PacketHandlers.cs @@ -1610,7 +1610,7 @@ namespace Server.Network bool rightClick = pvSrc.ReadBoolean(); Mobile from = state.Mobile; - if ( from != null && from.QuestArrow != null ) + if ( @from?.QuestArrow != null ) from.QuestArrow.OnClick( rightClick ); }