Fixes implicit ternary expressions

This commit is contained in:
Kamron Batman 2018-09-14 14:56:48 -07:00
parent c85b0a740c
commit ff26dfa375
345 changed files with 1905 additions and 2336 deletions

View file

@ -1014,7 +1014,7 @@ namespace Server.Factions
if ( pack != null )
{
Container killerPack = ( killer == null ? null : killer.Backpack );
Container killerPack = killer?.Backpack;
Item[] sigils = pack.FindItemsByType( typeof( Sigil ) );
for ( int i = 0; i < sigils.Length; ++i )

View file

@ -59,7 +59,8 @@ namespace Server.Factions
ps.IsActive = false;
continue;
}
else if ( ps.KillPoints > 0 )
if ( ps.KillPoints > 0 )
{
int atrophy = ( ps.KillPoints + 9 ) / 10;
ps.KillPoints -= atrophy;

View file

@ -143,7 +143,7 @@ namespace Server.Factions
{
Faction faction = Faction.Find( from );
faction?.BeginHonorLeadership( @from );
faction?.BeginHonorLeadership( from );
break;
}

View file

@ -21,11 +21,9 @@ namespace Server.Factions
index = offset / ButtonTypes;
return true;
}
else
{
type = index = 0;
return false;
}
type = index = 0;
return false;
}
public static bool Exists( Mobile mob )

View file

@ -128,10 +128,10 @@ namespace Server.Factions
AddHtml( 120, 100, 150, 20, from.Name, false, false );
AddHtmlLocalized( 20, 130, 100, 20, 1018064, false, false ); // score :
AddHtml( 120, 130, 100, 20, (pl != null ? pl.KillPoints : 0).ToString(), false, false );
AddHtml( 120, 130, 100, 20, (pl?.KillPoints ?? 0).ToString(), false, false );
AddHtmlLocalized( 20, 160, 100, 20, 1011446, false, false ); // Rank :
AddHtml( 120, 160, 100, 20, (pl != null ? pl.Rank.Rank : 0).ToString(), false, false );
AddHtml( 120, 160, 100, 20, (pl?.Rank.Rank ?? 0).ToString(), false, false );
AddHtmlLocalized( 55, 250, 100, 20, 1011447, false, false ); // BACK
AddButton( 20, 250, 4005, 4007, 0, GumpButtonType.Page, 1 );

View file

@ -118,7 +118,8 @@ namespace Server.Factions
from.SendLocalizedMessage( 1010339 ); // You no longer control this city
return;
}
else if ( m_Town.Sheriff != null )
if ( m_Town.Sheriff != null )
{
from.SendLocalizedMessage( 1010342 ); // You must fire your Sheriff before you can elect a new one
}

View file

@ -47,7 +47,7 @@ namespace Server.Factions
set
{
m_Faction = value;
Hue = ( m_Faction == null ? 0 : m_Faction.Definition.HuePrimary );
Hue = m_Faction?.Definition.HuePrimary ?? 0;
}
}

View file

@ -15,7 +15,7 @@ namespace Server.Factions
{
m_Faction = value;
AssignName( m_Faction == null ? null : m_Faction.Definition.FactionStoneName );
AssignName( m_Faction?.Definition.FactionStoneName );
}
}

View file

@ -15,8 +15,8 @@ namespace Server.Factions
{
m_Faction = value;
Hue = ( m_Faction == null ? 0 : m_Faction.Definition.HueJoin );
AssignName( m_Faction == null ? null : m_Faction.Definition.SignupName );
Hue = m_Faction?.Definition.HueJoin ?? 0;
AssignName( m_Faction?.Definition.SignupName );
}
}

View file

@ -30,11 +30,11 @@ namespace Server {
from.AddStatMod( new StatMod( StatType.All, "blood-rose", amount, TimeSpan.FromMinutes( time ) ) );
return true;
} else {
from.SendLocalizedMessage( 1062927 ); // You have eaten one of these recently and eating another would provide no benefit.
return false;
}
from.SendLocalizedMessage( 1062927 ); // You have eaten one of these recently and eating another would provide no benefit.
return false;
}
public override void Serialize( GenericWriter writer ) {
@ -49,4 +49,4 @@ namespace Server {
int version = reader.ReadEncodedInt();
}
}
}
}

View file

@ -73,7 +73,8 @@ namespace Server {
weight = Utility.Random( weight );
foreach ( WeightedItem item in _items ) {
foreach ( WeightedItem item in _items )
{
if ( weight < item.Weight ) {
Item obj = item.Construct();
@ -95,9 +96,9 @@ namespace Server {
}
break;
} else {
weight -= item.Weight;
}
weight -= item.Weight;
}
}
}

View file

@ -103,7 +103,7 @@ namespace Server.Factions
public void Update()
{
ItemID = ( m_Town == null ? 0x1869 : m_Town.Definition.SigilID );
ItemID = m_Town?.Definition.SigilID ?? 0x1869;
if ( m_Town == null )
AssignName( null );

View file

@ -29,10 +29,9 @@ namespace Server.Factions
{
if ( Amount <= 1 )
return 0x2E4;
else if ( Amount <= 5 )
if ( Amount <= 5 )
return 0x2E5;
else
return 0x2E6;
return 0x2E6;
}
public override void Serialize( GenericWriter writer )

View file

@ -6,7 +6,7 @@ namespace Server.Factions
public override void OnTownChanged()
{
AssignName( Town == null ? null : Town.Definition.StrongholdMonolithName );
AssignName( Town?.Definition.StrongholdMonolithName );
}
public StrongholdMonolith() : this( null, null )

View file

@ -6,7 +6,7 @@ namespace Server.Factions
public override void OnTownChanged()
{
AssignName( Town == null ? null : Town.Definition.TownMonolithName );
AssignName( Town?.Definition.TownMonolithName );
}
public TownMonolith() : this( null )

View file

@ -14,7 +14,7 @@ namespace Server.Factions
{
m_Town = value;
AssignName( m_Town == null ? null : m_Town.Definition.TownStoneName );
AssignName( m_Town?.Definition.TownStoneName );
}
}

View file

@ -93,7 +93,7 @@ namespace Server.Factions
if ( from.Alive )
m_Placer.SendMessage( "You have earned {0} silver pieces because {1} fell for your trap.", silverGiven, from.Name );
else
m_Placer.SendLocalizedMessage( 1042736, $"{silverGiven} silver\t{@from.Name}"); // You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~!
m_Placer.SendLocalizedMessage( 1042736, $"{silverGiven} silver\t{from.Name}"); // You have earned ~1_SILVER_AMOUNT~ pieces for vanquishing ~2_PLAYER_NAME~!
}
victimState.OnGivenSilverTo( m_Placer );

View file

@ -15,8 +15,8 @@ namespace Server.Factions
{
m_Faction = value;
Body = ( m_Faction == null ? 0xE2 : m_Faction.Definition.WarHorseBody );
ItemID = ( m_Faction == null ? 0x3EA0 : m_Faction.Definition.WarHorseItem );
Body = m_Faction?.Definition.WarHorseBody ?? 0xE2;
ItemID = m_Faction?.Definition.WarHorseItem ?? 0x3EA0;
}
}

View file

@ -310,45 +310,43 @@ namespace Server.Factions
return active;
}
else
Map map = m_Mobile.Map;
if ( map != null )
{
Map map = m_Mobile.Map;
Mobile active = null, inactive = null;
double actPrio = 0.0, inactPrio = 0.0;
if ( map != null )
Mobile comb = m_Mobile.Combatant;
if ( comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && CanDispel( comb ) )
{
Mobile active = null, inactive = null;
double actPrio = 0.0, inactPrio = 0.0;
active = inactive = comb;
actPrio = inactPrio = m_Mobile.GetDistanceToSqrt( comb );
}
Mobile comb = m_Mobile.Combatant;
if ( comb != null && !comb.Deleted && comb.Alive && !comb.IsDeadBondedPet && CanDispel( comb ) )
foreach ( Mobile m in m_Mobile.GetMobilesInRange( 12 ) )
{
if ( m != m_Mobile && CanDispel( m ) )
{
active = inactive = comb;
actPrio = inactPrio = m_Mobile.GetDistanceToSqrt( comb );
}
double prio = m_Mobile.GetDistanceToSqrt( m );
foreach ( Mobile m in m_Mobile.GetMobilesInRange( 12 ) )
{
if ( m != m_Mobile && CanDispel( m ) )
if ( !activeOnly && (inactive == null || prio < inactPrio) )
{
double prio = m_Mobile.GetDistanceToSqrt( m );
inactive = m;
inactPrio = prio;
}
if ( !activeOnly && (inactive == null || prio < inactPrio) )
{
inactive = m;
inactPrio = prio;
}
if ( (m_Mobile.Combatant == m || m.Combatant == m_Mobile) && (active == null || prio < actPrio) )
{
active = m;
actPrio = prio;
}
if ( (m_Mobile.Combatant == m || m.Combatant == m_Mobile) && (active == null || prio < actPrio) )
{
active = m;
actPrio = prio;
}
}
return active != null ? active : inactive;
}
return active ?? inactive;
}
return null;
@ -473,7 +471,7 @@ namespace Server.Factions
{
Target targ = m_Guard.Target;
Mobile toHarm = ( dispelTarget == null ? combatant : dispelTarget );
Mobile toHarm = dispelTarget ?? combatant;
if ( (targ.Flags & TargetFlags.Harmful) != 0 && toHarm != null )
{