Fixes more casting

This commit is contained in:
Kamron Batman 2018-08-19 11:04:07 +08:00
parent 61937d9c97
commit e77d695684
91 changed files with 512 additions and 908 deletions

View file

@ -11,7 +11,7 @@ namespace Server.Engines.Quests.Ninja
public GuardianBarrier() : base( 0x3967 ) public GuardianBarrier() : base( 0x3967 )
{ {
Movable = false; Movable = false;
Visible = false; Visible = false;
} }
public override bool OnMoveOver( Mobile m ) public override bool OnMoveOver( Mobile m )
@ -23,28 +23,19 @@ namespace Server.Engines.Quests.Ninja
if ( this.Y >= m.Y ) if ( this.Y >= m.Y )
return true; return true;
if ( m is BaseCreature ) if ( m is BaseCreature creature )
{ {
Mobile master = ((BaseCreature)m).GetMaster(); Mobile master = creature.GetMaster();
// Allow creatures to cross from the south to the north only if their master is near to the north // Allow creatures to cross from the south to the north only if their master is near to the north
if ( master != null && this.Y >= master.Y && master.InRange( this, 4 ) ) return master != null && this.Y >= master.Y && master.InRange(this, 4);
return true;
else
return false;
} }
PlayerMobile pm = m as PlayerMobile; if ( m is PlayerMobile pm )
if ( pm != null )
{ {
EminosUndertakingQuest qs = pm.Quest as EminosUndertakingQuest; if ( pm.Quest is EminosUndertakingQuest qs )
if ( qs != null )
{ {
SneakPastGuardiansObjective obj = qs.FindObjective( typeof( SneakPastGuardiansObjective ) ) as SneakPastGuardiansObjective; if ( qs.FindObjective( typeof( SneakPastGuardiansObjective ) ) is SneakPastGuardiansObjective obj )
if ( obj != null )
{ {
if ( m.Hidden ) if ( m.Hidden )
return true; // Hidden ninjas can pass return true; // Hidden ninjas can pass
@ -79,4 +70,4 @@ namespace Server.Engines.Quests.Ninja
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
} }
} }

View file

@ -22,13 +22,9 @@ namespace Server.Engines.Quests.Ninja
public override bool CanDrop( PlayerMobile player ) public override bool CanDrop( PlayerMobile player )
{ {
EminosUndertakingQuest qs = player.Quest as EminosUndertakingQuest; return !(player.Quest is EminosUndertakingQuest);
if ( qs == null )
return true;
//return !qs.IsObjectiveInProgress( typeof( GiveZoelNoteObjective ) ); //return !qs.IsObjectiveInProgress( typeof( GiveZoelNoteObjective ) );
return false;
} }
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter writer )

View file

@ -148,8 +148,7 @@ namespace Server.Engines.Quests.Ninja
{ {
bool stolenTreasure = false; bool stolenTreasure = false;
HallwayWalkObjective walk = qs.FindObjective( typeof( HallwayWalkObjective ) ) as HallwayWalkObjective; if ( qs.FindObjective( typeof( HallwayWalkObjective ) ) is HallwayWalkObjective walk )
if ( walk != null )
stolenTreasure = walk.StolenTreasure; stolenTreasure = walk.StolenTreasure;
Kama kama = new Kama(); Kama kama = new Kama();

View file

@ -70,9 +70,7 @@ namespace Server.Engines.Quests.Ninja
public override bool OnDragDrop( Mobile from, Item dropped ) public override bool OnDragDrop( Mobile from, Item dropped )
{ {
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player )
if ( player != null )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;

View file

@ -128,9 +128,7 @@ namespace Server.Engines.Quests.Samurai
public static bool HasLostHaochisKatana( Mobile from ) public static bool HasLostHaochisKatana( Mobile from )
{ {
PlayerMobile pm = from as PlayerMobile; if ( !(from is PlayerMobile pm) )
if ( pm == null )
return false; return false;
QuestSystem qs = pm.Quest; QuestSystem qs = pm.Quest;
@ -139,9 +137,7 @@ namespace Server.Engines.Quests.Samurai
{ {
if ( qs.IsObjectiveInProgress( typeof( FifthTrialReturnObjective ) ) ) if ( qs.IsObjectiveInProgress( typeof( FifthTrialReturnObjective ) ) )
{ {
Container pack = from.Backpack; return ( from.Backpack?.FindItemByType( typeof( HaochisKatana ) ) == null );
return ( pack == null || pack.FindItemByType( typeof( HaochisKatana ) ) == null );
} }
} }

View file

@ -20,13 +20,9 @@ namespace Server.Engines.Quests.Samurai
public override bool CanDrop( PlayerMobile player ) public override bool CanDrop( PlayerMobile player )
{ {
HaochisTrialsQuest qs = player.Quest as HaochisTrialsQuest; return !(player.Quest is HaochisTrialsQuest );
if ( qs == null )
return true;
//return !qs.IsObjectiveInProgress( typeof( FifthTrialReturnObjective ) ); //return !qs.IsObjectiveInProgress( typeof( FifthTrialReturnObjective ) );
return false;
} }
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter writer )

View file

@ -17,9 +17,7 @@ namespace Server.Engines.Quests.Samurai
public override bool OnMoveOver( Mobile m ) public override bool OnMoveOver( Mobile m )
{ {
PlayerMobile player = m as PlayerMobile; if ( m is PlayerMobile player )
if ( player != null )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;

View file

@ -53,13 +53,9 @@ namespace Server.Engines.Quests.Samurai
if ( from.AccessLevel >= AccessLevel.GameMaster ) if ( from.AccessLevel >= AccessLevel.GameMaster )
return true; return true;
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player && player.Quest is HaochisTrialsQuest )
if ( player != null && player.Quest is HaochisTrialsQuest )
{ {
FifthTrialIntroObjective obj = player.Quest.FindObjective( typeof( FifthTrialIntroObjective ) ) as FifthTrialIntroObjective; if ( player.Quest.FindObjective( typeof( FifthTrialIntroObjective ) ) is FifthTrialIntroObjective obj )
if ( obj != null )
{ {
if ( obj.StolenTreasure ) if ( obj.StolenTreasure )
from.SendLocalizedMessage( 1063247 ); // The guard is watching you carefully! It would be unwise to remove another item from here. from.SendLocalizedMessage( 1063247 ); // The guard is watching you carefully! It would be unwise to remove another item from here.
@ -73,13 +69,9 @@ namespace Server.Engines.Quests.Samurai
public override void OnItemLifted( Mobile from, Item item ) public override void OnItemLifted( Mobile from, Item item )
{ {
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player && player.Quest is HaochisTrialsQuest )
if ( player != null && player.Quest is HaochisTrialsQuest )
{ {
FifthTrialIntroObjective obj = player.Quest.FindObjective( typeof( FifthTrialIntroObjective ) ) as FifthTrialIntroObjective; if ( player.Quest.FindObjective( typeof( FifthTrialIntroObjective ) ) is FifthTrialIntroObjective obj )
if ( obj != null )
obj.StolenTreasure = true; obj.StolenTreasure = true;
} }

View file

@ -31,14 +31,12 @@ namespace Server.Engines.Quests.Samurai
if ( !wasBurning && Burning ) if ( !wasBurning && Burning )
{ {
PlayerMobile player = from as PlayerMobile; if ( !(from is PlayerMobile player) )
if ( player == null )
return; return;
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;
if ( qs != null && qs is HaochisTrialsQuest ) if ( qs is HaochisTrialsQuest )
{ {
QuestObjective obj = qs.FindObjective( typeof( SixthTrialIntroObjective ) ); QuestObjective obj = qs.FindObjective( typeof( SixthTrialIntroObjective ) );

View file

@ -44,8 +44,7 @@ namespace Server.Engines.Quests.Samurai
{ {
base.AggressiveAction( aggressor, criminal ); base.AggressiveAction( aggressor, criminal );
PlayerMobile player = aggressor as PlayerMobile; if ( aggressor is PlayerMobile player )
if ( player != null )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;
if ( qs is HaochisTrialsQuest ) if ( qs is HaochisTrialsQuest )

View file

@ -66,8 +66,7 @@ namespace Server.Engines.Quests.Samurai
{ {
base.AggressiveAction( aggressor, criminal ); base.AggressiveAction( aggressor, criminal );
PlayerMobile player = aggressor as PlayerMobile; if ( aggressor is PlayerMobile player )
if ( player != null )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;
if ( qs is HaochisTrialsQuest ) if ( qs is HaochisTrialsQuest )

View file

@ -44,9 +44,7 @@ namespace Server.Engines.Quests.Samurai
public override bool OnDragDrop( Mobile from, Item dropped ) public override bool OnDragDrop( Mobile from, Item dropped )
{ {
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player )
if ( player != null )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;
@ -56,9 +54,7 @@ namespace Server.Engines.Quests.Samurai
if ( obj != null && !obj.Completed ) if ( obj != null && !obj.Completed )
{ {
Gold gold = dropped as Gold; if ( dropped is Gold gold )
if ( gold != null )
{ {
obj.Complete(); obj.Complete();
qs.AddObjective( new FourthTrialReturnObjective( false ) ); qs.AddObjective( new FourthTrialReturnObjective( false ) );

View file

@ -37,18 +37,14 @@ namespace Server.Engines.Quests.Matriarch
if ( SolenMatriarchQuest.IsFriend( to, this.RedSolen ) ) if ( SolenMatriarchQuest.IsFriend( to, this.RedSolen ) )
return true; return true;
SolenMatriarchQuest qs = to.Quest as SolenMatriarchQuest; return to.Quest is SolenMatriarchQuest qs && qs.RedSolen == this.RedSolen;
return qs != null && qs.RedSolen == this.RedSolen;
} }
public override void OnTalk( PlayerMobile player, bool contextMenu ) public override void OnTalk( PlayerMobile player, bool contextMenu )
{ {
this.Direction = GetDirectionTo( player ); this.Direction = GetDirectionTo( player );
SolenMatriarchQuest qs = player.Quest as SolenMatriarchQuest; if ( player.Quest is SolenMatriarchQuest qs && qs.RedSolen == this.RedSolen )
if ( qs != null && qs.RedSolen == this.RedSolen )
{ {
if ( qs.IsObjectiveInProgress( typeof( KillInfiltratorsObjective ) ) ) if ( qs.IsObjectiveInProgress( typeof( KillInfiltratorsObjective ) ) )
{ {
@ -114,15 +110,11 @@ namespace Server.Engines.Quests.Matriarch
public override bool OnDragDrop( Mobile from, Item dropped ) public override bool OnDragDrop( Mobile from, Item dropped )
{ {
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player )
if ( player != null )
{ {
if ( dropped is Seed ) if ( dropped is Seed )
{ {
SolenMatriarchQuest qs = player.Quest as SolenMatriarchQuest; if ( player.Quest is SolenMatriarchQuest qs && qs.RedSolen == this.RedSolen )
if ( qs != null && qs.RedSolen == this.RedSolen )
{ {
SayTo( player, 1054080 ); // Thank you for that plant seed. Those have such wonderful flavor. SayTo( player, 1054080 ); // Thank you for that plant seed. Those have such wonderful flavor.
} }
@ -143,11 +135,11 @@ namespace Server.Engines.Quests.Matriarch
dropped.Delete(); dropped.Delete();
return true; return true;
} }
else if ( dropped is ZoogiFungus ) if ( dropped is ZoogiFungus fungus )
{ {
OnGivenFungi( player, (ZoogiFungus)dropped ); OnGivenFungi( player, fungus );
return dropped.Deleted; return fungus.Deleted;
} }
} }
@ -160,13 +152,9 @@ namespace Server.Engines.Quests.Matriarch
if ( from.Alive ) if ( from.Alive )
{ {
PlayerMobile pm = from as PlayerMobile; if ( from is PlayerMobile pm )
if ( pm != null )
{ {
SolenMatriarchQuest qs = pm.Quest as SolenMatriarchQuest; if ( pm.Quest is SolenMatriarchQuest qs && qs.RedSolen == this.RedSolen )
if ( qs != null && qs.RedSolen == this.RedSolen )
{ {
if ( qs.IsObjectiveInProgress( typeof( ProcessFungiObjective ) ) ) if ( qs.IsObjectiveInProgress( typeof( ProcessFungiObjective ) ) )
{ {
@ -213,12 +201,10 @@ namespace Server.Engines.Quests.Matriarch
protected override void OnTarget( Mobile from, object targeted ) protected override void OnTarget( Mobile from, object targeted )
{ {
if ( targeted is ZoogiFungus ) if ( targeted is ZoogiFungus fungus )
{ {
ZoogiFungus fungus = (ZoogiFungus)targeted;
if ( fungus.IsChildOf( m_From.Backpack ) ) if ( fungus.IsChildOf( m_From.Backpack ) )
m_Matriarch.OnGivenFungi( m_From, (ZoogiFungus)targeted ); m_Matriarch.OnGivenFungi( m_From, fungus );
else else
m_From.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it. m_From.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
} }
@ -229,9 +215,7 @@ namespace Server.Engines.Quests.Matriarch
{ {
this.Direction = GetDirectionTo( player ); this.Direction = GetDirectionTo( player );
SolenMatriarchQuest qs = player.Quest as SolenMatriarchQuest; if ( player.Quest is SolenMatriarchQuest qs && qs.RedSolen == this.RedSolen )
if ( qs != null && qs.RedSolen == this.RedSolen )
{ {
QuestObjective obj = qs.FindObjective( typeof( ProcessFungiObjective ) ); QuestObjective obj = qs.FindObjective( typeof( ProcessFungiObjective ) );

View file

@ -38,13 +38,9 @@ namespace Server.Engines.Quests.Naturalist
public override void OnTalk( PlayerMobile player, bool contextMenu ) public override void OnTalk( PlayerMobile player, bool contextMenu )
{ {
StudyOfSolenQuest qs = player.Quest as StudyOfSolenQuest; if ( player.Quest is StudyOfSolenQuest qs && qs.Naturalist == this )
if ( qs != null && qs.Naturalist == this )
{ {
StudyNestsObjective study = qs.FindObjective( typeof( StudyNestsObjective ) ) as StudyNestsObjective; if ( qs.FindObjective( typeof( StudyNestsObjective ) ) is StudyNestsObjective study )
if ( study != null )
{ {
if ( !study.Completed ) if ( !study.Completed )
{ {
@ -155,4 +151,4 @@ namespace Server.Engines.Quests.Naturalist
int version = reader.ReadEncodedInt(); int version = reader.ReadEncodedInt();
} }
} }
} }

View file

@ -72,9 +72,7 @@ namespace Server.Engines.Quests.Zento
if ( Utility.RandomBool() ) if ( Utility.RandomBool() )
{ {
BaseWeapon weapon = Loot.Construct( Loot.SEWeaponTypes ) as BaseWeapon; if ( Loot.Construct( Loot.SEWeaponTypes ) is BaseWeapon weapon )
if ( weapon != null )
{ {
BaseRunicTool.ApplyAttributesTo( weapon, 3, 10, 30 ); BaseRunicTool.ApplyAttributesTo( weapon, 3, 10, 30 );
cont.DropItem( weapon ); cont.DropItem( weapon );
@ -82,9 +80,7 @@ namespace Server.Engines.Quests.Zento
} }
else else
{ {
BaseArmor armor = Loot.Construct( Loot.SEArmorTypes ) as BaseArmor; if ( Loot.Construct( Loot.SEArmorTypes ) is BaseArmor armor )
if ( armor != null )
{ {
BaseRunicTool.ApplyAttributesTo( armor, 1, 10, 20 ); BaseRunicTool.ApplyAttributesTo( armor, 1, 10, 20 );
cont.DropItem( armor ); cont.DropItem( armor );

View file

@ -53,9 +53,9 @@ namespace Server.Engines.Quests.Doom
{ {
foreach ( Item item in GetItemsInRange( AltarRange ) ) foreach ( Item item in GetItemsInRange( AltarRange ) )
{ {
if ( item is SummoningAltar ) if ( item is SummoningAltar altar )
{ {
m_Altar = (SummoningAltar)item; m_Altar = altar;
break; break;
} }
} }
@ -79,18 +79,14 @@ namespace Server.Engines.Quests.Doom
public override bool OnDragDrop( Mobile from, Item dropped ) public override bool OnDragDrop( Mobile from, Item dropped )
{ {
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player )
if ( player != null )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;
if ( qs is TheSummoningQuest ) if ( qs is TheSummoningQuest )
{ {
if ( dropped is DaemonBone ) if ( dropped is DaemonBone bones )
{ {
DaemonBone bones = (DaemonBone)dropped;
QuestObjective obj = qs.FindObjective( typeof( CollectBonesObjective ) ); QuestObjective obj = qs.FindObjective( typeof( CollectBonesObjective ) );
if ( obj != null && !obj.Completed ) if ( obj != null && !obj.Completed )

View file

@ -152,8 +152,8 @@ namespace Server.Engines.Quests.Haven
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty( AccessLevel.GameMaster )]
public MilitiaCanoneer Canoneer public MilitiaCanoneer Canoneer
{ {
get { return Addon is Cannon ? ((Cannon)Addon).Canoneer : null; } get { return Addon is Cannon cannon ? cannon.Canoneer : null; }
set { if ( Addon is Cannon ) ((Cannon)Addon).Canoneer = value; } set { if ( Addon is Cannon cannon ) cannon.Canoneer = value; }
} }
public CannonComponent( int itemID ) : base( itemID ) public CannonComponent( int itemID ) : base( itemID )

View file

@ -20,9 +20,7 @@ namespace Server.Engines.Quests.Haven
public override void OnDoubleClick( Mobile from ) public override void OnDoubleClick( Mobile from )
{ {
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player && player.InRange( GetWorldLocation(), 2 ) )
if ( player != null && player.InRange( GetWorldLocation(), 2 ) )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;
@ -69,4 +67,4 @@ namespace Server.Engines.Quests.Haven
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
} }
} }

View file

@ -19,13 +19,9 @@ namespace Server.Engines.Quests.Haven
public override bool CanDrop( PlayerMobile player ) public override bool CanDrop( PlayerMobile player )
{ {
UzeraanTurmoilQuest qs = player.Quest as UzeraanTurmoilQuest; return !(player.Quest is UzeraanTurmoilQuest);
if ( qs == null )
return true;
/*return !qs.IsObjectiveInProgress( typeof( ReturnDaemonBloodObjective ) );*/ /*return !qs.IsObjectiveInProgress( typeof( ReturnDaemonBloodObjective ) );*/
return false;
} }
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter writer )
@ -42,4 +38,4 @@ namespace Server.Engines.Quests.Haven
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
} }
} }

View file

@ -19,13 +19,9 @@ namespace Server.Engines.Quests.Haven
public override bool CanDrop( PlayerMobile player ) public override bool CanDrop( PlayerMobile player )
{ {
UzeraanTurmoilQuest qs = player.Quest as UzeraanTurmoilQuest; return !(player.Quest is UzeraanTurmoilQuest);
if ( qs == null )
return true;
//return !qs.IsObjectiveInProgress( typeof( ReturnDaemonBoneObjective ) ); //return !qs.IsObjectiveInProgress( typeof( ReturnDaemonBoneObjective ) );
return false;
} }
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter writer )
@ -42,4 +38,4 @@ namespace Server.Engines.Quests.Haven
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
} }
} }

View file

@ -19,13 +19,9 @@ namespace Server.Engines.Quests.Haven
public override bool CanDrop( PlayerMobile player ) public override bool CanDrop( PlayerMobile player )
{ {
UzeraanTurmoilQuest qs = player.Quest as UzeraanTurmoilQuest; return !(player.Quest is UzeraanTurmoilQuest);
if ( qs == null )
return true;
//return !qs.IsObjectiveInProgress( typeof( ReturnFertileDirtObjective ) ); //return !qs.IsObjectiveInProgress( typeof( ReturnFertileDirtObjective ) );
return false;
} }
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter writer )
@ -42,4 +38,4 @@ namespace Server.Engines.Quests.Haven
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
} }
} }

View file

@ -128,9 +128,7 @@ namespace Server.Engines.Quests.Haven
if ( !from.InRange( this.GetWorldLocation(), 2 ) ) if ( !from.InRange( this.GetWorldLocation(), 2 ) )
return; return;
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player )
if ( player != null )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;
@ -202,4 +200,4 @@ namespace Server.Engines.Quests.Haven
m_Lantern = (Lantern)reader.ReadItem(); m_Lantern = (Lantern)reader.ReadItem();
} }
} }
} }

View file

@ -21,12 +21,8 @@ namespace Server.Engines.Quests.Haven
public override bool CanDrop( PlayerMobile player ) public override bool CanDrop( PlayerMobile player )
{ {
UzeraanTurmoilQuest qs = player.Quest as UzeraanTurmoilQuest; return !(player.Quest is UzeraanTurmoilQuest qs &&
qs.IsObjectiveInProgress(typeof(ReturnScrollOfPowerObjective)));
if ( qs == null )
return true;
return !qs.IsObjectiveInProgress( typeof( ReturnScrollOfPowerObjective ) );
} }
public override void Serialize( GenericWriter writer ) public override void Serialize( GenericWriter writer )

View file

@ -10,9 +10,7 @@ namespace Server.Engines.Quests.Haven
{ {
public override bool ValidateUse( Mobile from ) public override bool ValidateUse( Mobile from )
{ {
PlayerMobile pm = from as PlayerMobile; return ( from is PlayerMobile pm && pm.Quest is UzeraanTurmoilQuest );
return ( pm != null && pm.Quest is UzeraanTurmoilQuest );
} }
[Constructible] [Constructible]
@ -40,4 +38,4 @@ namespace Server.Engines.Quests.Haven
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
} }
} }

View file

@ -67,9 +67,7 @@ namespace Server.Engines.Quests.Haven
public override bool CanTalkTo( PlayerMobile to ) public override bool CanTalkTo( PlayerMobile to )
{ {
UzeraanTurmoilQuest qs = to.Quest as UzeraanTurmoilQuest; return ( to.Quest is UzeraanTurmoilQuest qs && qs.FindObjective( typeof( FindDryadObjective ) ) != null );
return ( qs != null && qs.FindObjective( typeof( FindDryadObjective ) ) != null );
} }
public override void OnTalk( PlayerMobile player, bool contextMenu ) public override void OnTalk( PlayerMobile player, bool contextMenu )
@ -114,13 +112,9 @@ namespace Server.Engines.Quests.Haven
public override bool OnDragDrop( Mobile from, Item dropped ) public override bool OnDragDrop( Mobile from, Item dropped )
{ {
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player )
if ( player != null )
{ {
UzeraanTurmoilQuest qs = player.Quest as UzeraanTurmoilQuest; if ( player.Quest is UzeraanTurmoilQuest qs && dropped is Apple && UzeraanTurmoilQuest.HasLostFertileDirt( from ) )
if ( qs != null && dropped is Apple && UzeraanTurmoilQuest.HasLostFertileDirt( from ) )
{ {
FocusTo( from ); FocusTo( from );
@ -132,12 +126,10 @@ namespace Server.Engines.Quests.Haven
player.SendLocalizedMessage( 1046260 ); // You need to clear some space in your inventory to continue with the quest. Come back here when you have more space in your inventory. player.SendLocalizedMessage( 1046260 ); // You need to clear some space in your inventory to continue with the quest. Come back here when you have more space in your inventory.
return false; return false;
} }
else
{ dropped.Consume();
dropped.Consume(); qs.AddConversation( new DryadAppleConversation() );
qs.AddConversation( new DryadAppleConversation() ); return dropped.Deleted;
return dropped.Deleted;
}
} }
} }

View file

@ -64,10 +64,8 @@ namespace Server.Engines.Quests.Haven
if ( m.Player || m is BaseVendor ) if ( m.Player || m is BaseVendor )
return false; return false;
if ( m is BaseCreature ) if ( m is BaseCreature bc )
{ {
BaseCreature bc = (BaseCreature)m;
Mobile master = bc.GetMaster(); Mobile master = bc.GetMaster();
if ( master != null ) if ( master != null )
return IsEnemy( master ); return IsEnemy( master );

View file

@ -62,10 +62,8 @@ namespace Server.Engines.Quests.Haven
if ( m.Player || m is BaseVendor ) if ( m.Player || m is BaseVendor )
return false; return false;
if ( m is BaseCreature ) if ( m is BaseCreature bc )
{ {
BaseCreature bc = (BaseCreature)m;
Mobile master = bc.GetMaster(); Mobile master = bc.GetMaster();
if ( master != null ) if ( master != null )
return IsEnemy( master ); return IsEnemy( master );

View file

@ -54,9 +54,7 @@ namespace Server.Engines.Quests.Haven
public override bool CanTalkTo( PlayerMobile to ) public override bool CanTalkTo( PlayerMobile to )
{ {
UzeraanTurmoilQuest qs = to.Quest as UzeraanTurmoilQuest; return ( to.Quest is UzeraanTurmoilQuest qs && qs.FindObjective( typeof( FindSchmendrickObjective ) ) != null );
return ( qs != null && qs.FindObjective( typeof( FindSchmendrickObjective ) ) != null );
} }
public override void OnTalk( PlayerMobile player, bool contextMenu ) public override void OnTalk( PlayerMobile player, bool contextMenu )

View file

@ -198,20 +198,16 @@ namespace Server.Engines.Quests.Haven
public override bool OnDragDrop( Mobile from, Item dropped ) public override bool OnDragDrop( Mobile from, Item dropped )
{ {
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player )
if ( player != null )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;
if ( qs is UzeraanTurmoilQuest ) if ( qs is UzeraanTurmoilQuest )
{ {
if ( dropped is UzeraanTurmoilHorn ) if ( dropped is UzeraanTurmoilHorn horn )
{ {
if ( player.Young ) if ( player.Young )
{ {
UzeraanTurmoilHorn horn = (UzeraanTurmoilHorn)dropped;
if ( horn.Charges < 10 ) if ( horn.Charges < 10 )
{ {
SayTo( from, 1049384 ); // I have recharged the item for you. SayTo( from, 1049384 ); // I have recharged the item for you.
@ -248,12 +244,10 @@ namespace Server.Engines.Quests.Haven
player.SendLocalizedMessage( 1046260 ); // You need to clear some space in your inventory to continue with the quest. Come back here when you have more space in your inventory. player.SendLocalizedMessage( 1046260 ); // You need to clear some space in your inventory to continue with the quest. Come back here when you have more space in your inventory.
return false; return false;
} }
else
{ dropped.Delete();
dropped.Delete(); obj.Complete();
obj.Complete(); return true;
return true;
}
} }
} }
else if ( dropped is QuestFertileDirt ) else if ( dropped is QuestFertileDirt )
@ -293,12 +287,10 @@ namespace Server.Engines.Quests.Haven
player.SendLocalizedMessage( 1046260 ); // You need to clear some space in your inventory to continue with the quest. Come back here when you have more space in your inventory. player.SendLocalizedMessage( 1046260 ); // You need to clear some space in your inventory to continue with the quest. Come back here when you have more space in your inventory.
return false; return false;
} }
else
{ dropped.Delete();
dropped.Delete(); obj.Complete();
obj.Complete(); return true;
return true;
}
} }
} }
else if ( dropped is QuestDaemonBlood ) else if ( dropped is QuestDaemonBlood )
@ -353,12 +345,10 @@ namespace Server.Engines.Quests.Haven
player.SendLocalizedMessage( 1046260 ); // You need to clear some space in your inventory to continue with the quest. Come back here when you have more space in your inventory. player.SendLocalizedMessage( 1046260 ); // You need to clear some space in your inventory to continue with the quest. Come back here when you have more space in your inventory.
return false; return false;
} }
else
{ dropped.Delete();
dropped.Delete(); obj.Complete();
obj.Complete(); return true;
return true;
}
} }
} }
else if ( dropped is QuestDaemonBone ) else if ( dropped is QuestDaemonBone )
@ -377,12 +367,10 @@ namespace Server.Engines.Quests.Haven
player.SendLocalizedMessage( 1046260 ); // You need to clear some space in your inventory to continue with the quest. Come back here when you have more space in your inventory. player.SendLocalizedMessage( 1046260 ); // You need to clear some space in your inventory to continue with the quest. Come back here when you have more space in your inventory.
return false; return false;
} }
else
{ dropped.Delete();
dropped.Delete(); obj.Complete();
obj.Complete(); return true;
return true;
}
} }
} }
} }

View file

@ -143,9 +143,7 @@ namespace Server.Engines.Quests.Haven
public static bool HasLostScrollOfPower( Mobile from ) public static bool HasLostScrollOfPower( Mobile from )
{ {
PlayerMobile pm = from as PlayerMobile; if ( !(from is PlayerMobile pm) )
if ( pm == null )
return false; return false;
QuestSystem qs = pm.Quest; QuestSystem qs = pm.Quest;
@ -154,9 +152,7 @@ namespace Server.Engines.Quests.Haven
{ {
if ( qs.IsObjectiveInProgress( typeof( ReturnScrollOfPowerObjective ) ) ) if ( qs.IsObjectiveInProgress( typeof( ReturnScrollOfPowerObjective ) ) )
{ {
Container pack = from.Backpack; return ( from.Backpack?.FindItemByType( typeof( SchmendrickScrollOfPower ) ) == null );
return ( pack == null || pack.FindItemByType( typeof( SchmendrickScrollOfPower ) ) == null );
} }
} }
@ -165,9 +161,7 @@ namespace Server.Engines.Quests.Haven
public static bool HasLostFertileDirt( Mobile from ) public static bool HasLostFertileDirt( Mobile from )
{ {
PlayerMobile pm = from as PlayerMobile; if ( !(from is PlayerMobile pm) )
if ( pm == null )
return false; return false;
QuestSystem qs = pm.Quest; QuestSystem qs = pm.Quest;
@ -176,9 +170,7 @@ namespace Server.Engines.Quests.Haven
{ {
if ( qs.IsObjectiveInProgress( typeof( ReturnFertileDirtObjective ) ) ) if ( qs.IsObjectiveInProgress( typeof( ReturnFertileDirtObjective ) ) )
{ {
Container pack = from.Backpack; return ( from.Backpack?.FindItemByType( typeof( QuestFertileDirt ) ) == null );
return ( pack == null || pack.FindItemByType( typeof( QuestFertileDirt ) ) == null );
} }
} }
@ -187,9 +179,7 @@ namespace Server.Engines.Quests.Haven
public static bool HasLostDaemonBlood( Mobile from ) public static bool HasLostDaemonBlood( Mobile from )
{ {
PlayerMobile pm = from as PlayerMobile; if ( !(from is PlayerMobile pm) )
if ( pm == null )
return false; return false;
QuestSystem qs = pm.Quest; QuestSystem qs = pm.Quest;
@ -198,9 +188,7 @@ namespace Server.Engines.Quests.Haven
{ {
if ( qs.IsObjectiveInProgress( typeof( ReturnDaemonBloodObjective ) ) ) if ( qs.IsObjectiveInProgress( typeof( ReturnDaemonBloodObjective ) ) )
{ {
Container pack = from.Backpack; return ( from.Backpack?.FindItemByType( typeof( QuestDaemonBlood ) ) == null );
return ( pack == null || pack.FindItemByType( typeof( QuestDaemonBlood ) ) == null );
} }
} }
@ -209,9 +197,7 @@ namespace Server.Engines.Quests.Haven
public static bool HasLostDaemonBone( Mobile from ) public static bool HasLostDaemonBone( Mobile from )
{ {
PlayerMobile pm = from as PlayerMobile; if ( !(from is PlayerMobile pm) )
if ( pm == null )
return false; return false;
QuestSystem qs = pm.Quest; QuestSystem qs = pm.Quest;
@ -220,9 +206,7 @@ namespace Server.Engines.Quests.Haven
{ {
if ( qs.IsObjectiveInProgress( typeof( ReturnDaemonBoneObjective ) ) ) if ( qs.IsObjectiveInProgress( typeof( ReturnDaemonBoneObjective ) ) )
{ {
Container pack = from.Backpack; return ( from.Backpack?.FindItemByType( typeof( QuestDaemonBone ) ) == null );
return ( pack == null || pack.FindItemByType( typeof( QuestDaemonBone ) ) == null );
} }
} }

View file

@ -427,9 +427,7 @@ namespace Server.Engines.Quests.Hag
public override void OnRead() public override void OnRead()
{ {
FindIngredientObjective obj = System.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective; if ( System.FindObjective( typeof( FindIngredientObjective ) ) is FindIngredientObjective obj )
if ( obj != null )
System.AddObjective( new FindIngredientObjective( obj.Ingredients, true ) ); System.AddObjective( new FindIngredientObjective( obj.Ingredients, true ) );
} }
} }
@ -627,9 +625,7 @@ namespace Server.Engines.Quests.Hag
public override void OnRead() public override void OnRead()
{ {
FindIngredientObjective obj = System.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective; if ( System.FindObjective( typeof( FindIngredientObjective ) ) is FindIngredientObjective obj )
if ( obj != null )
obj.NextStep(); obj.NextStep();
} }

View file

@ -62,17 +62,13 @@ namespace Server.Engines.Quests.Hag
if ( !from.InRange( this.GetWorldLocation(), 2 ) ) if ( !from.InRange( this.GetWorldLocation(), 2 ) )
return; return;
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player )
if ( player != null )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;
if ( qs is WitchApprenticeQuest ) if ( qs is WitchApprenticeQuest )
{ {
FindApprenticeObjective obj = qs.FindObjective( typeof( FindApprenticeObjective ) ) as FindApprenticeObjective; if ( qs.FindObjective( typeof( FindApprenticeObjective ) ) is FindApprenticeObjective obj && !obj.Completed )
if ( obj != null && !obj.Completed )
{ {
if ( obj.Corpse == this ) if ( obj.Corpse == this )
{ {
@ -106,4 +102,4 @@ namespace Server.Engines.Quests.Hag
int version = reader.ReadInt(); int version = reader.ReadInt();
} }
} }
} }

View file

@ -25,17 +25,13 @@ namespace Server.Engines.Quests.Hag
from.PlaySound( 0x3D ); from.PlaySound( 0x3D );
PlayerMobile player = from as PlayerMobile; if ( from is PlayerMobile player )
if ( player != null )
{ {
QuestSystem qs = player.Quest; QuestSystem qs = player.Quest;
if ( qs is WitchApprenticeQuest ) if ( qs is WitchApprenticeQuest )
{ {
FindZeefzorpulObjective obj = qs.FindObjective( typeof( FindZeefzorpulObjective ) ) as FindZeefzorpulObjective; if ( qs.FindObjective( typeof( FindZeefzorpulObjective ) ) is FindZeefzorpulObjective obj && !obj.Completed )
if ( obj != null && !obj.Completed )
{ {
if ( ( player.Map != Map.Trammel && player.Map != Map.Felucca ) || !player.InRange( obj.ImpLocation, 8 ) ) if ( ( player.Map != Map.Trammel && player.Map != Map.Felucca ) || !player.InRange( obj.ImpLocation, 8 ) )
{ {

View file

@ -58,9 +58,7 @@ namespace Server.Engines.Quests.Hag
if ( qs is WitchApprenticeQuest ) if ( qs is WitchApprenticeQuest )
{ {
FindIngredientObjective obj = qs.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective; if ( qs.FindObjective( typeof( FindIngredientObjective ) ) is FindIngredientObjective obj && !obj.Completed && obj.Ingredient == Ingredient.Whiskey )
if ( obj != null && !obj.Completed && obj.Ingredient == Ingredient.Whiskey )
{ {
PlaySound( Utility.RandomBool() ? 0x42E : 0x43F ); PlaySound( Utility.RandomBool() ? 0x42E : 0x43F );
@ -71,10 +69,7 @@ namespace Server.Engines.Quests.Hag
{ {
obj.Complete(); obj.Complete();
if ( obj.BlackheartMet ) qs.AddConversation( new BlackheartPirateConversation( !obj.BlackheartMet ) );
qs.AddConversation( new BlackheartPirateConversation( false ) );
else
qs.AddConversation( new BlackheartPirateConversation( true ) );
} }
else if ( !obj.BlackheartMet ) else if ( !obj.BlackheartMet )
{ {

View file

@ -138,10 +138,10 @@ namespace Server.Engines.Quests.Hag
{ {
item = Loot.RandomArmorOrShieldOrJewelry(); item = Loot.RandomArmorOrShieldOrJewelry();
if ( item is BaseArmor ) if ( item is BaseArmor armor )
BaseRunicTool.ApplyAttributesTo( (BaseArmor)item, 2, 20, 30 ); BaseRunicTool.ApplyAttributesTo( armor, 2, 20, 30 );
else if ( item is BaseJewel ) else if ( item is BaseJewel jewel )
BaseRunicTool.ApplyAttributesTo( (BaseJewel)item, 2, 20, 30 ); BaseRunicTool.ApplyAttributesTo( jewel, 2, 20, 30 );
} }
else else
{ {

View file

@ -75,9 +75,7 @@ namespace Server.Engines.Quests.Hag
private void DeleteImp( object imp ) private void DeleteImp( object imp )
{ {
Mobile m = imp as Mobile; if ( imp is Mobile m && !m.Deleted )
if ( m != null && !m.Deleted )
{ {
Effects.SendLocationEffect( m.Location, m.Map, 0x3728, 10, 10 ); Effects.SendLocationEffect( m.Location, m.Map, 0x3728, 10, 10 );
Effects.PlaySound( m.Location, m.Map, 0x1FE ); Effects.PlaySound( m.Location, m.Map, 0x1FE );
@ -269,9 +267,7 @@ namespace Server.Engines.Quests.Hag
private void DeleteImp( object imp ) private void DeleteImp( object imp )
{ {
Mobile m = imp as Mobile; if ( imp is Mobile m && !m.Deleted )
if ( m != null && !m.Deleted )
{ {
Effects.SendLocationEffect( m.Location, m.Map, 0x3728, 10, 10 ); Effects.SendLocationEffect( m.Location, m.Map, 0x3728, 10, 10 );
Effects.PlaySound( m.Location, m.Map, 0x1FE ); Effects.PlaySound( m.Location, m.Map, 0x1FE );

View file

@ -159,8 +159,7 @@ namespace Server.RemoteAdmin
string user = pvSrc.ReadString( 30 ); string user = pvSrc.ReadString( 30 );
string pw = pvSrc.ReadString( 30 ); string pw = pvSrc.ReadString( 30 );
Account a = Accounts.GetAccount( user ) as Account; if ( !(Accounts.GetAccount( user ) is Account a) )
if ( a == null )
{ {
state.Send( new Login( LoginResponse.NoUser ) ); state.Send( new Login( LoginResponse.NoUser ) );
Console.WriteLine( "ADMIN: Invalid username '{0}' from {1}", user, state ); Console.WriteLine( "ADMIN: Invalid username '{0}' from {1}", user, state );

View file

@ -90,9 +90,7 @@ namespace Server.Engines.Reports
{ {
for ( int j = 0; j < ss.Children.Count; ++j ) for ( int j = 0; j < ss.Children.Count; ++j )
{ {
Report report = ss.Children[j] as Report; if ( !(ss.Children[j] is Report report) || report.Name != reportName )
if ( report == null || report.Name != reportName )
continue; continue;
for ( int k = 0; k < report.Items.Count; ++k ) for ( int k = 0; k < report.Items.Count; ++k )

View file

@ -64,10 +64,10 @@ namespace Server.Engines.Reports
{ {
PersistableObject child = ip.GetChild(); PersistableObject child = ip.GetChild();
if ( child is ReportColumn ) if ( child is ReportColumn column )
m_Columns.Add( (ReportColumn) child ); m_Columns.Add( column );
else if ( child is ReportItem ) else if ( child is ReportItem item )
m_Items.Add( (ReportItem) child ); m_Items.Add( item );
} }
} }
} }

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections; using System.Collections;
using Server; using Server;
using Server.Accounting;
using Server.Engines; using Server.Engines;
using Server.Engines.Help; using Server.Engines.Help;
@ -192,15 +193,7 @@ namespace Server.Engines.Reports
public static string GetAccount( Mobile mob ) public static string GetAccount( Mobile mob )
{ {
if ( mob == null ) return mob?.Account is Account acct ? acct.Username : null;
return null;
Accounting.Account acct = mob.Account as Accounting.Account;
if ( acct == null )
return null;
return acct.Username;
} }
public PageInfo() public PageInfo()

View file

@ -51,12 +51,10 @@ namespace Server.Engines.Reports
{ {
lock ( RenderLock ) lock ( RenderLock )
{ {
if ( account == null || account.Length == 0 ) if ( string.IsNullOrEmpty(account) )
return null; return null;
StaffInfo info = m_StaffInfo[account] as StaffInfo; if ( !(m_StaffInfo[account] is StaffInfo info) )
if ( info == null )
m_StaffInfo[account] = info = new StaffInfo( account ); m_StaffInfo[account] = info = new StaffInfo( account );
return info; return info;
@ -65,12 +63,10 @@ namespace Server.Engines.Reports
public UserInfo GetUserInfo( string account ) public UserInfo GetUserInfo( string account )
{ {
if ( account == null || account.Length == 0 ) if ( string.IsNullOrEmpty(account) )
return null; return null;
UserInfo info = m_UserInfo[account] as UserInfo; if ( !(m_UserInfo[account] is UserInfo info) )
if ( info == null )
m_UserInfo[account] = info = new UserInfo( account ); m_UserInfo[account] = info = new UserInfo( account );
return info; return info;
@ -123,10 +119,8 @@ namespace Server.Engines.Reports
{ {
PersistableObject obj = ip.GetChild(); PersistableObject obj = ip.GetChild();
if ( obj is PageInfo ) if ( obj is PageInfo pageInfo )
{ {
PageInfo pageInfo = obj as PageInfo;
pageInfo.UpdateResolver(); pageInfo.UpdateResolver();
if ( pageInfo.TimeSent >= min || pageInfo.TimeResolved >= min ) if ( pageInfo.TimeSent >= min || pageInfo.TimeResolved >= min )
@ -140,10 +134,8 @@ namespace Server.Engines.Reports
pageInfo.Resolver = null; pageInfo.Resolver = null;
} }
} }
else if ( obj is QueueStatus ) else if ( obj is QueueStatus queueStatus )
{ {
QueueStatus queueStatus = obj as QueueStatus;
if ( queueStatus.TimeStamp >= min ) if ( queueStatus.TimeStamp >= min )
m_QueueStats.Add( queueStatus ); m_QueueStats.Add( queueStatus );
} }

View file

@ -218,10 +218,10 @@ namespace Server.Engines.Reports
private string FindNameFrom( PersistableObject obj ) private string FindNameFrom( PersistableObject obj )
{ {
if ( obj is Report ) if ( obj is Report report )
return (obj as Report).Name; return report.Name;
else if ( obj is Chart ) if ( obj is Chart chart )
return (obj as Chart).Name; return chart.Name;
return "Invalid"; return "Invalid";
} }
@ -266,12 +266,12 @@ namespace Server.Engines.Reports
public void RenderDirect( PersistableObject obj, HtmlTextWriter html ) public void RenderDirect( PersistableObject obj, HtmlTextWriter html )
{ {
if ( obj is Report ) if ( obj is Report report )
RenderReport( obj as Report, html ); RenderReport( report, html );
else if ( obj is BarGraph ) else if ( obj is BarGraph graph )
RenderBarGraph( obj as BarGraph, html ); RenderBarGraph( graph, html );
else if ( obj is PieChart ) else if ( obj is PieChart chart )
RenderPieChart( obj as PieChart, html ); RenderPieChart( chart, html );
} }
private void RenderPieChart( PieChart chart, HtmlTextWriter html ) private void RenderPieChart( PieChart chart, HtmlTextWriter html )
@ -538,4 +538,4 @@ namespace Server.Engines.Reports
html.RenderEndTag(); html.RenderEndTag();
} }
} }
} }

View file

@ -485,16 +485,14 @@ namespace Server.Engines.Reports
string controller = "Unknown"; string controller = "Unknown";
Mobile mob = sigil.RootParent as Mobile; if ( sigil.RootParent is Mobile mob )
if ( mob != null )
{ {
Faction faction = Faction.Find( mob ); Faction faction = Faction.Find( mob );
if ( faction != null ) if ( faction != null )
controller = faction.Definition.FriendlyName; controller = faction.Definition.FriendlyName;
} }
else if ( sigil.LastMonolith != null && sigil.LastMonolith.Faction != null ) else if ( sigil.LastMonolith?.Faction != null )
{ {
controller = sigil.LastMonolith.Faction.Definition.FriendlyName; controller = sigil.LastMonolith.Faction.Definition.FriendlyName;
} }

View file

@ -94,13 +94,8 @@ namespace Server.Mobiles
public virtual bool ValidTrigger( Mobile m ) public virtual bool ValidTrigger( Mobile m )
{ {
if ( m is BaseCreature ) if (m is BaseCreature bc && (bc.IsDeadBondedPet || !(bc.Controlled || bc.Summoned)))
{ return false;
BaseCreature bc = m as BaseCreature;
if ( bc.IsDeadBondedPet || !(bc.Controlled || bc.Summoned) )
return false;
}
return m.AccessLevel == AccessLevel.Player && ( m.Player || ( m.Alive && !m.Hidden && m.CanBeDamaged() ) ); return m.AccessLevel == AccessLevel.Player && ( m.Player || ( m.Alive && !m.Hidden && m.CanBeDamaged() ) );
} }
@ -120,8 +115,8 @@ namespace Server.Mobiles
if ( m_InstantFlag ) if ( m_InstantFlag )
{ {
foreach ( ISpawnable spawned in Spawned.Keys ) foreach ( ISpawnable spawned in Spawned.Keys )
if ( spawned is Mobile ) if ( spawned is Mobile mobile )
((Mobile)spawned).Combatant = m; mobile.Combatant = m;
} }
} }
} }

View file

@ -41,9 +41,8 @@ namespace Server.Mobiles
public override void OnAfterDuped( Item newItem ) public override void OnAfterDuped( Item newItem )
{ {
if ( newItem is Spawner ) if ( newItem is Spawner newSpawner )
{ {
Spawner newSpawner = newItem as Spawner;
for ( int i = 0; i < m_Entries.Count; i++ ) for ( int i = 0; i < m_Entries.Count; i++ )
newSpawner.AddEntry( m_Entries[i].SpawnedName, m_Entries[i].SpawnedProbability, m_Entries[i].SpawnedMaxCount, false ); newSpawner.AddEntry( m_Entries[i].SpawnedName, m_Entries[i].SpawnedProbability, m_Entries[i].SpawnedMaxCount, false );
} }
@ -479,8 +478,8 @@ namespace Server.Mobiles
{ {
flags = EntryFlags.InvalidProps; flags = EntryFlags.InvalidProps;
if ( o is ISpawnable ) if ( o is ISpawnable spawnable )
((ISpawnable)o).Delete(); spawnable.Delete();
return false; return false;
} }
@ -492,10 +491,8 @@ namespace Server.Mobiles
} }
} }
if ( o is Mobile ) if ( o is Mobile m )
{ {
Mobile m = (Mobile)o;
m_Spawned.Add( m, entry ); m_Spawned.Add( m, entry );
entry.Spawned.Add( m ); entry.Spawned.Add( m );
@ -506,10 +503,8 @@ namespace Server.Mobiles
m.MoveToWorld( loc, map ); m.MoveToWorld( loc, map );
if ( m is BaseCreature ) if ( m is BaseCreature c )
{ {
BaseCreature c = (BaseCreature)m;
int walkrange = GetWalkingRange(); int walkrange = GetWalkingRange();
if ( walkrange >= 0 ) if ( walkrange >= 0 )
@ -529,10 +524,8 @@ namespace Server.Mobiles
m.Spawner = this; m.Spawner = this;
m.OnAfterSpawn(); m.OnAfterSpawn();
} }
else if ( o is Item ) else if ( o is Item item )
{ {
Item item = (Item)o;
m_Spawned.Add( item, entry ); m_Spawned.Add( item, entry );
entry.Spawned.Add( item ); entry.Spawned.Add( item );
@ -583,10 +576,8 @@ namespace Server.Mobiles
bool waterMob, waterOnlyMob; bool waterMob, waterOnlyMob;
if ( spawned is Mobile ) if ( spawned is Mobile mob )
{ {
Mobile mob = (Mobile)spawned;
waterMob = mob.CanSwim; waterMob = mob.CanSwim;
waterOnlyMob = ( mob.CanSwim && mob.CantWalk ); waterOnlyMob = ( mob.CanSwim && mob.CantWalk );
} }
@ -958,12 +949,10 @@ namespace Server.Mobiles
for ( int i = 0; i < count; ++i ) for ( int i = 0; i < count; ++i )
{ {
ISpawnable e = reader.ReadEntity() as ISpawnable; if ( reader.ReadEntity() is ISpawnable e )
if ( e != null )
{ {
if ( e is BaseCreature ) if ( e is BaseCreature creature )
((BaseCreature)e).RemoveIfUntamed = true; creature.RemoveIfUntamed = true;
e.Spawner = this; e.Spawner = this;
@ -1145,10 +1134,10 @@ namespace Server.Mobiles
{ {
object o = m_Spawned[i]; object o = m_Spawned[i];
if ( o is Item ) if ( o is Item item )
writer.Write( (Item)o ); writer.Write( item );
else if ( o is Mobile ) else if ( o is Mobile mobile )
writer.Write( (Mobile)o ); writer.Write( mobile );
else else
writer.Write( Serial.MinusOne ); writer.Write( Serial.MinusOne );
} }
@ -1172,14 +1161,13 @@ namespace Server.Mobiles
for ( int i = 0; i < count; ++i ) for ( int i = 0; i < count; ++i )
{ {
//IEntity e = World.FindEntity( reader.ReadInt() ); //IEntity e = World.FindEntity( reader.ReadInt() );
ISpawnable e = reader.ReadEntity() as ISpawnable;
if ( e != null ) if ( reader.ReadEntity() is ISpawnable e )
{ {
e.Spawner = parent; e.Spawner = parent;
if ( e is BaseCreature ) if ( e is BaseCreature creature )
((BaseCreature)e).RemoveIfUntamed = true; creature.RemoveIfUntamed = true;
m_Spawned.Add( e ); m_Spawned.Add( e );
@ -1196,23 +1184,17 @@ namespace Server.Mobiles
ISpawnable e = m_Spawned[i]; ISpawnable e = m_Spawned[i];
bool remove = false; bool remove = false;
if ( e is Item ) if ( e is Item item )
{ {
Item item = (Item)e;
if ( item.Deleted || item.RootParent is Mobile || item.IsLockedDown || item.IsSecure || item.Spawner == null ) if ( item.Deleted || item.RootParent is Mobile || item.IsLockedDown || item.IsSecure || item.Spawner == null )
remove = true; remove = true;
} }
else if ( e is Mobile ) else if ( e is Mobile m )
{ {
Mobile m = (Mobile)e;
if ( m.Deleted ) if ( m.Deleted )
remove = true; remove = true;
else if ( m is BaseCreature ) else if ( m is BaseCreature c )
{ {
BaseCreature c = (BaseCreature)m;
if ( c.Controlled || c.IsStabled ) if ( c.Controlled || c.IsStabled )
remove = true; remove = true;
/* /*

View file

@ -124,9 +124,7 @@ namespace Server.Items
if ( pigment.Deleted || pigment.UsesRemaining <= 0 || !from.InRange( pigment.GetWorldLocation(), 3 ) || !pigment.IsAccessibleTo( from )) if ( pigment.Deleted || pigment.UsesRemaining <= 0 || !from.InRange( pigment.GetWorldLocation(), 3 ) || !pigment.IsAccessibleTo( from ))
return; return;
Item i = targeted as Item; if ( !(targeted is Item i) )
if ( i == null )
from.SendLocalizedMessage( 1070931 ); // You can only dye artifacts and enhanced magic items with this tub. from.SendLocalizedMessage( 1070931 ); // You can only dye artifacts and enhanced magic items with this tub.
else if ( !from.InRange( i.GetWorldLocation(), 3 ) || !IsAccessibleTo( from ) ) else if ( !from.InRange( i.GetWorldLocation(), 3 ) || !IsAccessibleTo( from ) )
from.SendLocalizedMessage( 502436 ); // That is not accessible. from.SendLocalizedMessage( 502436 ); // That is not accessible.
@ -165,12 +163,12 @@ namespace Server.Items
CraftResource resource = CraftResource.None; CraftResource resource = CraftResource.None;
if ( i is BaseWeapon ) if ( i is BaseWeapon weapon )
resource = ((BaseWeapon)i).Resource; resource = weapon.Resource;
else if ( i is BaseArmor ) else if ( i is BaseArmor armor )
resource = ((BaseArmor)i).Resource; resource = armor.Resource;
else if (i is BaseClothing) else if (i is BaseClothing clothing)
resource = ((BaseClothing)i).Resource; resource = clothing.Resource;
if ( !CraftResources.IsStandard( resource ) ) if ( !CraftResources.IsStandard( resource ) )
return true; return true;

View file

@ -815,10 +815,8 @@ namespace Server.Items
int min = 20; int min = 20;
int max = 80; int max = 80;
if ( item is BaseWeapon ) if ( item is BaseWeapon weapon )
{ {
BaseWeapon weapon = (BaseWeapon)item;
if ( Core.AOS ) if ( Core.AOS )
BaseRunicTool.ApplyAttributesTo( weapon, attributeCount, min, max ); BaseRunicTool.ApplyAttributesTo( weapon, attributeCount, min, max );
else else
@ -828,10 +826,8 @@ namespace Server.Items
weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 ); weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random( 6 );
} }
} }
else if ( item is BaseArmor ) else if ( item is BaseArmor armor )
{ {
BaseArmor armor = (BaseArmor)item;
if ( Core.AOS ) if ( Core.AOS )
BaseRunicTool.ApplyAttributesTo( armor, attributeCount, min, max ); BaseRunicTool.ApplyAttributesTo( armor, attributeCount, min, max );
else else
@ -840,10 +836,13 @@ namespace Server.Items
armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 ); armor.Durability = (ArmorDurabilityLevel)Utility.Random( 6 );
} }
} }
else if ( item is BaseHat && Core.AOS ) else if (Core.AOS)
BaseRunicTool.ApplyAttributesTo( (BaseHat)item, attributeCount, min, max ); {
else if ( item is BaseJewel && Core.AOS ) if ( item is BaseHat hat )
BaseRunicTool.ApplyAttributesTo( (BaseJewel)item, attributeCount, min, max ); BaseRunicTool.ApplyAttributesTo( hat, attributeCount, min, max );
else if ( item is BaseJewel jewel )
BaseRunicTool.ApplyAttributesTo( jewel, attributeCount, min, max );
}
DropItem( item ); DropItem( item );
} }

View file

@ -124,10 +124,7 @@ namespace Server.Misc
public static void HandleKill( Mobile victim, Mobile killer ) public static void HandleKill( Mobile victim, Mobile killer )
{ {
PlayerMobile pm = killer as PlayerMobile; if ( DropEra == TreasuresOfTokunoEra.None || !(killer is PlayerMobile pm) || !(victim is BaseCreature bc) || !CheckLocation( bc ) || !CheckLocation( pm )|| !killer.InRange( victim, 18 ))
BaseCreature bc = victim as BaseCreature;
if ( DropEra == TreasuresOfTokunoEra.None || pm == null || bc == null || !CheckLocation( bc ) || !CheckLocation( pm )|| !killer.InRange( victim, 18 ))
return; return;
if ( bc.Controlled || bc.Owners.Count > 0 || bc.Fame <= 0 ) if ( bc.Controlled || bc.Owners.Count > 0 || bc.Fame <= 0 )
@ -246,13 +243,11 @@ namespace Server.Mobiles
public override void OnMovement( Mobile m, Point3D oldLocation ) public override void OnMovement( Mobile m, Point3D oldLocation )
{ {
if ( m.Alive && m is PlayerMobile ) if ( m.Alive && m is PlayerMobile pm )
{ {
PlayerMobile pm = (PlayerMobile)m;
int range = 3; int range = 3;
if ( m.Alive && Math.Abs( Z - m.Z ) < 16 && InRange( m, range ) && !InRange( oldLocation, range ) ) if ( pm.Alive && Math.Abs( Z - pm.Z ) < 16 && InRange( m, range ) && !InRange( oldLocation, range ) )
{ {
if ( pm.ToTItemsTurnedIn >= TreasuresOfTokuno.ItemsPerReward ) if ( pm.ToTItemsTurnedIn >= TreasuresOfTokuno.ItemsPerReward )
{ {
@ -323,13 +318,13 @@ namespace Server.Gumps
for( int i = 0; i < items.Count; i++ ) for( int i = 0; i < items.Count; i++ )
{ {
Item item = (Item)items[i]; Item item = (Item)items[i];
if ( item is ChestOfHeirlooms && !((ChestOfHeirlooms)item).Locked ) if ( item is ChestOfHeirlooms heirlooms && !heirlooms.Locked )
continue; continue;
if ( item is ChestOfHeirlooms && ((ChestOfHeirlooms)item).TrapLevel != 10 ) if ( item is ChestOfHeirlooms ofHeirlooms && ofHeirlooms.TrapLevel != 10 )
continue; continue;
if ( item is PigmentsOfTokuno && ((PigmentsOfTokuno)item).Type != PigmentType.None ) if ( item is PigmentsOfTokuno tokuno && tokuno.Type != PigmentType.None )
continue; continue;
buttons.Add( new ItemTileButtonInfo( item ) ); buttons.Add( new ItemTileButtonInfo( item ) );
@ -385,9 +380,7 @@ namespace Server.Gumps
public override void HandleCancel( NetState sender ) public override void HandleCancel( NetState sender )
{ {
PlayerMobile pm = sender.Mobile as PlayerMobile; if ( !(sender.Mobile is PlayerMobile pm) || !pm.InRange( m_Collector.Location, 7 ) )
if ( pm == null || !pm.InRange( m_Collector.Location, 7 ) )
return; return;
if ( pm.ToTItemsTurnedIn == 0 ) if ( pm.ToTItemsTurnedIn == 0 )
@ -555,9 +548,7 @@ namespace Server.Gumps
public override void HandleButtonResponse( NetState sender, int adjustedButton, ImageTileButtonInfo buttonInfo ) public override void HandleButtonResponse( NetState sender, int adjustedButton, ImageTileButtonInfo buttonInfo )
{ {
PlayerMobile pm = sender.Mobile as PlayerMobile; if ( !(sender.Mobile is PlayerMobile pm) || !pm.InRange( m_Collector.Location, 7 ) || !(pm.ToTItemsTurnedIn >= TreasuresOfTokuno.ItemsPerReward) )
if ( pm == null || !pm.InRange( m_Collector.Location, 7 ) || !(pm.ToTItemsTurnedIn >= TreasuresOfTokuno.ItemsPerReward) )
return; return;
bool pigments = (buttonInfo is PigmentsTileButtonInfo); bool pigments = (buttonInfo is PigmentsTileButtonInfo);
@ -566,7 +557,7 @@ namespace Server.Gumps
if ( pigments ) if ( pigments )
{ {
PigmentsTileButtonInfo p = buttonInfo as PigmentsTileButtonInfo; PigmentsTileButtonInfo p = (PigmentsTileButtonInfo) buttonInfo;
item = new PigmentsOfTokuno( p.Pigment ); item = new PigmentsOfTokuno( p.Pigment );
} }
@ -610,9 +601,7 @@ namespace Server.Gumps
public override void HandleCancel( NetState sender ) public override void HandleCancel( NetState sender )
{ {
PlayerMobile pm = sender.Mobile as PlayerMobile; if ( !(sender.Mobile is PlayerMobile pm) || !pm.InRange( m_Collector.Location, 7 ) )
if ( pm == null || !pm.InRange( m_Collector.Location, 7 ) )
return; return;
if ( pm.ToTItemsTurnedIn == 0 ) if ( pm.ToTItemsTurnedIn == 0 )

View file

@ -498,9 +498,7 @@ namespace Server.Mobiles
public override void OnDoubleClick( Mobile from ) public override void OnDoubleClick( Mobile from )
{ {
Account acct = from.Account as Account; if ( from.Account is Account acct && from.AccessLevel == AccessLevel.Player )
if ( acct != null && from.AccessLevel == AccessLevel.Player )
{ {
TimeSpan time = TimeSpan.FromDays( RewardSystem.RewardInterval.TotalDays * 6 ) - ( DateTime.UtcNow - acct.Created ); TimeSpan time = TimeSpan.FromDays( RewardSystem.RewardInterval.TotalDays * 6 ) - ( DateTime.UtcNow - acct.Created );
@ -585,12 +583,12 @@ namespace Server.Mobiles
BaseHouse house = null; BaseHouse house = null;
Point3D loc = new Point3D( p ); Point3D loc = new Point3D( p );
if ( targeted is Item && !((Item) targeted).IsLockedDown && !((Item) targeted).IsSecure && !(targeted is AddonComponent) ) if ( targeted is Item item && !item.IsLockedDown && !item.IsSecure && !(item is AddonComponent) )
{ {
from.SendLocalizedMessage( 1076191 ); // Statues can only be placed in houses. from.SendLocalizedMessage( 1076191 ); // Statues can only be placed in houses.
return; return;
} }
else if ( from.IsBodyMod ) if ( from.IsBodyMod )
{ {
from.SendLocalizedMessage( 1073648 ); // You may only proceed while in your original state... from.SendLocalizedMessage( 1073648 ); // You may only proceed while in your original state...
return; return;
@ -605,8 +603,8 @@ namespace Server.Mobiles
house.Addons.Add( plinth ); house.Addons.Add( plinth );
if ( m_Maker is IRewardItem ) if ( m_Maker is IRewardItem rewardItem )
statue.IsRewardItem = ( (IRewardItem) m_Maker).IsRewardItem; statue.IsRewardItem = rewardItem.IsRewardItem;
statue.Plinth = plinth; statue.Plinth = plinth;
plinth.MoveToWorld( loc, map ); plinth.MoveToWorld( loc, map );
@ -638,10 +636,10 @@ namespace Server.Mobiles
{ {
if ( !map.CanFit( p.X, p.Y, p.Z, 20, true, true, true ) ) if ( !map.CanFit( p.X, p.Y, p.Z, 20, true, true, true ) )
return AddonFitResult.Blocked; return AddonFitResult.Blocked;
else if ( !BaseAddon.CheckHouse( from, p, map, 20, ref house ) ) if ( !BaseAddon.CheckHouse( from, p, map, 20, ref house ) )
return AddonFitResult.NotInHouse; return AddonFitResult.NotInHouse;
else
return CheckDoors( p, 20, house ); return CheckDoors( p, 20, house );
} }
public static AddonFitResult CheckDoors( Point3D p, int height, BaseHouse house ) public static AddonFitResult CheckDoors( Point3D p, int height, BaseHouse house )

View file

@ -133,9 +133,9 @@ namespace Server.Gumps
if ( info.ButtonID == (int) Buttons.Sculpt ) if ( info.ButtonID == (int) Buttons.Sculpt )
{ {
if ( m_Maker is CharacterStatueDeed ) if ( m_Maker is CharacterStatueDeed deed )
{ {
CharacterStatue backup = ( (CharacterStatueDeed) m_Maker ).Statue; CharacterStatue backup = deed.Statue;
if ( backup != null ) if ( backup != null )
backup.Delete(); backup.Delete();
@ -180,9 +180,9 @@ namespace Server.Gumps
} }
else if ( info.ButtonID == (int) Buttons.Restore ) else if ( info.ButtonID == (int) Buttons.Restore )
{ {
if ( m_Maker is CharacterStatueDeed ) if ( m_Maker is CharacterStatueDeed deed )
{ {
CharacterStatue backup = ( (CharacterStatueDeed) m_Maker ).Statue; CharacterStatue backup = deed.Statue;
if ( backup != null ) if ( backup != null )
m_Statue.Restore( backup ); m_Statue.Restore( backup );

View file

@ -1,6 +1,7 @@
using System; using System;
using Server; using Server;
using Server.Gumps; using Server.Gumps;
using Server.Items;
using Server.Network; using Server.Network;
namespace Server.Engines.VeteranRewards namespace Server.Engines.VeteranRewards
@ -51,9 +52,9 @@ namespace Server.Engines.VeteranRewards
if ( item != null ) if ( item != null )
{ {
if ( item is Server.Items.RedSoulstone ) if ( item is RedSoulstone soulstone )
((Server.Items.RedSoulstone) item).Account = m_From.Account.Username; soulstone.Account = m_From.Account.Username;
if ( RewardSystem.ConsumeRewardPoint( m_From ) ) if ( RewardSystem.ConsumeRewardPoint( m_From ) )
m_From.AddToBackpack( item ); m_From.AddToBackpack( item );
else else
@ -69,4 +70,4 @@ namespace Server.Engines.VeteranRewards
m_From.SendGump( new RewardNoticeGump( m_From ) ); m_From.SendGump( new RewardNoticeGump( m_From ) );
} }
} }
} }

View file

@ -5,11 +5,11 @@ using Server.Multis;
using Server.Network; using Server.Network;
namespace Server.Gumps namespace Server.Gumps
{ {
public class RewardDemolitionGump : Gump public class RewardDemolitionGump : Gump
{ {
private IAddon m_Addon; private IAddon m_Addon;
private enum Buttons private enum Buttons
{ {
Cancel, Cancel,
@ -27,9 +27,9 @@ namespace Server.Gumps
AddBackground( 0, 0, 220, 170, 0x13BE ); AddBackground( 0, 0, 220, 170, 0x13BE );
AddBackground( 10, 10, 200, 150, 0xBB8 ); AddBackground( 10, 10, 200, 150, 0xBB8 );
AddHtmlLocalized( 20, 30, 180, 60, question, false, false ); // Do you wish to re-deed this decoration? AddHtmlLocalized( 20, 30, 180, 60, question, false, false ); // Do you wish to re-deed this decoration?
AddHtmlLocalized( 55, 100, 150, 25, 1011011, false, false ); // CONTINUE AddHtmlLocalized( 55, 100, 150, 25, 1011011, false, false ); // CONTINUE
AddButton( 20, 100, 0xFA5, 0xFA7, (int) Buttons.Confirm, GumpButtonType.Reply, 0 ); AddButton( 20, 100, 0xFA5, 0xFA7, (int) Buttons.Confirm, GumpButtonType.Reply, 0 );
@ -39,27 +39,25 @@ namespace Server.Gumps
public override void OnResponse( NetState sender, RelayInfo info ) public override void OnResponse( NetState sender, RelayInfo info )
{ {
Item item = m_Addon as Item; if ( !(m_Addon is Item item) || item.Deleted )
return;
if ( item == null || item.Deleted )
return;
if ( info.ButtonID == (int) Buttons.Confirm ) if ( info.ButtonID == (int) Buttons.Confirm )
{ {
Mobile m = sender.Mobile; Mobile m = sender.Mobile;
BaseHouse house = BaseHouse.FindHouseAt( m ); BaseHouse house = BaseHouse.FindHouseAt( m );
if ( house != null && house.IsOwner( m ) ) if ( house?.IsOwner( m ) == true )
{ {
if ( m.InRange( item.Location, 2 ) ) if ( m.InRange( item.Location, 2 ) )
{ {
Item deed = m_Addon.Deed; Item deed = m_Addon.Deed;
if ( deed != null ) if ( deed != null )
{ {
m.AddToBackpack( deed ); m.AddToBackpack( deed );
house.Addons.Remove( item ); house.Addons.Remove( item );
item.Delete(); item.Delete();
} }
} }
else else

View file

@ -26,8 +26,8 @@ namespace Server.Engines.VeteranRewards
{ {
Item item = Activator.CreateInstance( m_ItemType, m_Args ) as Item; Item item = Activator.CreateInstance( m_ItemType, m_Args ) as Item;
if ( item is IRewardItem ) if ( item is IRewardItem rewardItem )
((IRewardItem)item).IsRewardItem = true; rewardItem.IsRewardItem = true;
return item; return item;
} }
@ -78,4 +78,4 @@ namespace Server.Engines.VeteranRewards
category.Entries.Add( this ); category.Entries.Add( this );
} }
} }
} }

View file

@ -73,9 +73,7 @@ namespace Server.Engines.VeteranRewards
return false; return false;
} }
Account acct = mob.Account as Account; if ( !(mob.Account is Account acct) )
if ( acct == null )
{ {
ts = TimeSpan.Zero; ts = TimeSpan.Zero;
return false; return false;
@ -93,9 +91,7 @@ namespace Server.Engines.VeteranRewards
public static int GetRewardLevel( Mobile mob ) public static int GetRewardLevel( Mobile mob )
{ {
Account acct = mob.Account as Account; if ( !(mob.Account is Account acct) )
if ( acct == null )
return 0; return 0;
return GetRewardLevel( acct ); return GetRewardLevel( acct );
@ -115,9 +111,7 @@ namespace Server.Engines.VeteranRewards
public static bool HasHalfLevel( Mobile mob ) public static bool HasHalfLevel( Mobile mob )
{ {
Account acct = mob.Account as Account; if ( !(mob.Account is Account acct) )
if ( acct == null )
return false; return false;
return HasHalfLevel( acct ); return HasHalfLevel( acct );
@ -134,16 +128,12 @@ namespace Server.Engines.VeteranRewards
public static bool ConsumeRewardPoint( Mobile mob ) public static bool ConsumeRewardPoint( Mobile mob )
{ {
int cur, max; ComputeRewardInfo( mob, out var cur, out var max );
ComputeRewardInfo( mob, out cur, out max );
if ( cur >= max ) if ( cur >= max )
return false; return false;
Account acct = mob.Account as Account; if ( !(mob.Account is Account acct) )
if ( acct == null )
return false; return false;
//if ( mob.AccessLevel < AccessLevel.GameMaster ) //if ( mob.AccessLevel < AccessLevel.GameMaster )
@ -154,16 +144,12 @@ namespace Server.Engines.VeteranRewards
public static void ComputeRewardInfo( Mobile mob, out int cur, out int max ) public static void ComputeRewardInfo( Mobile mob, out int cur, out int max )
{ {
int level; ComputeRewardInfo( mob, out cur, out max, out _ );
ComputeRewardInfo( mob, out cur, out max, out level );
} }
public static void ComputeRewardInfo( Mobile mob, out int cur, out int max, out int level ) public static void ComputeRewardInfo( Mobile mob, out int cur, out int max, out int level )
{ {
Account acct = mob.Account as Account; if ( !(mob.Account is Account acct) )
if ( acct == null )
{ {
cur = max = level = 0; cur = max = level = 0;
return; return;
@ -213,7 +199,7 @@ namespace Server.Engines.VeteranRewards
{ {
if ( (!isRelaxedRules || i > 0) && !HasAccess( from, list, out ts ) ) if ( (!isRelaxedRules || i > 0) && !HasAccess( from, list, out ts ) )
{ {
from.SendLocalizedMessage( 1008126, true, Math.Ceiling( ts.TotalDays / 30.0 ).ToString() ); // Your account is not old enough to use this item. Months until you can use this item : from.SendLocalizedMessage( 1008126, true, Math.Ceiling( ts.TotalDays / 30.0 ).ToString() ); // Your account is not old enough to use this item. Months until you can use this item :
return false; return false;
} }
@ -231,7 +217,7 @@ namespace Server.Engines.VeteranRewards
{ {
if ( (!isRelaxedRules || i > 0) && !HasAccess( from, list, out ts ) ) if ( (!isRelaxedRules || i > 0) && !HasAccess( from, list, out ts ) )
{ {
from.SendLocalizedMessage( 1008126, true, Math.Ceiling( ts.TotalDays / 30.0 ).ToString() ); // Your account is not old enough to use this item. Months until you can use this item : from.SendLocalizedMessage( 1008126, true, Math.Ceiling( ts.TotalDays / 30.0 ).ToString() ); // Your account is not old enough to use this item. Months until you can use this item :
return false; return false;
} }
@ -427,17 +413,17 @@ namespace Server.Engines.VeteranRewards
new RewardEntry( etherealSteeds, 1049748, typeof( EtherealBeetle ) ), new RewardEntry( etherealSteeds, 1049748, typeof( EtherealBeetle ) ),
new RewardEntry( houseAddOns, 1049739, typeof( StoneAnkhDeed ) ), new RewardEntry( houseAddOns, 1049739, typeof( StoneAnkhDeed ) ),
new RewardEntry( houseAddOns, 1080384, typeof( BloodyPentagramDeed ), Expansion.ML ) new RewardEntry( houseAddOns, 1080384, typeof( BloodyPentagramDeed ), Expansion.ML )
} ), } ),
new RewardList( RewardInterval, 6, new RewardEntry[] new RewardList( RewardInterval, 6, new RewardEntry[]
{ {
new RewardEntry( houseAddOns, 1076188, typeof( CharacterStatueMaker ), Expansion.ML, StatueType.Jade ), new RewardEntry( houseAddOns, 1076188, typeof( CharacterStatueMaker ), Expansion.ML, StatueType.Jade ),
new RewardEntry( houseAddOns, 1076189, typeof( CharacterStatueMaker ), Expansion.ML, StatueType.Marble ), new RewardEntry( houseAddOns, 1076189, typeof( CharacterStatueMaker ), Expansion.ML, StatueType.Marble ),
new RewardEntry( houseAddOns, 1076190, typeof( CharacterStatueMaker ), Expansion.ML, StatueType.Bronze ), new RewardEntry( houseAddOns, 1076190, typeof( CharacterStatueMaker ), Expansion.ML, StatueType.Bronze ),
new RewardEntry( houseAddOns, 1080527, typeof( RewardBrazierDeed ), Expansion.ML ) new RewardEntry( houseAddOns, 1080527, typeof( RewardBrazierDeed ), Expansion.ML )
} ), } ),
new RewardList( RewardInterval, 7, new RewardEntry[] new RewardList( RewardInterval, 7, new RewardEntry[]
{ {
new RewardEntry( houseAddOns, 1076157, typeof( CannonDeed ), Expansion.ML ), new RewardEntry( houseAddOns, 1076157, typeof( CannonDeed ), Expansion.ML ),
new RewardEntry( houseAddOns, 1080550, typeof( TreeStumpDeed ), Expansion.ML ) new RewardEntry( houseAddOns, 1080550, typeof( TreeStumpDeed ), Expansion.ML )
} ), } ),
new RewardList( RewardInterval, 8, new RewardEntry[] new RewardList( RewardInterval, 8, new RewardEntry[]
@ -450,17 +436,17 @@ namespace Server.Engines.VeteranRewards
new RewardEntry( houseAddOns, 1080549, typeof( WallBannerDeed ), Expansion.ML ) new RewardEntry( houseAddOns, 1080549, typeof( WallBannerDeed ), Expansion.ML )
} ), } ),
new RewardList( RewardInterval, 10, new RewardEntry[] new RewardList( RewardInterval, 10, new RewardEntry[]
{ {
new RewardEntry( monsterStatues, 1080520, typeof( MonsterStatuette ), Expansion.ML, MonsterStatuetteType.Harrower ), new RewardEntry( monsterStatues, 1080520, typeof( MonsterStatuette ), Expansion.ML, MonsterStatuetteType.Harrower ),
new RewardEntry( monsterStatues, 1080521, typeof( MonsterStatuette ), Expansion.ML, MonsterStatuetteType.Efreet ), new RewardEntry( monsterStatues, 1080521, typeof( MonsterStatuette ), Expansion.ML, MonsterStatuetteType.Efreet ),
new RewardEntry( cloaksAndRobes, 1080382, typeof( RewardCloak ), Expansion.ML, Pink, 1080382 ), new RewardEntry( cloaksAndRobes, 1080382, typeof( RewardCloak ), Expansion.ML, Pink, 1080382 ),
new RewardEntry( cloaksAndRobes, 1080380, typeof( RewardRobe ), Expansion.ML, Pink, 1080380 ), new RewardEntry( cloaksAndRobes, 1080380, typeof( RewardRobe ), Expansion.ML, Pink, 1080380 ),
new RewardEntry( cloaksAndRobes, 1080378, typeof( RewardDress ), Expansion.ML, Pink, 1080378 ), new RewardEntry( cloaksAndRobes, 1080378, typeof( RewardDress ), Expansion.ML, Pink, 1080378 ),
new RewardEntry( cloaksAndRobes, 1080383, typeof( RewardCloak ), Expansion.ML, Crimson, 1080383 ), new RewardEntry( cloaksAndRobes, 1080383, typeof( RewardCloak ), Expansion.ML, Crimson, 1080383 ),
new RewardEntry( cloaksAndRobes, 1080381, typeof( RewardRobe ), Expansion.ML, Crimson, 1080381 ), new RewardEntry( cloaksAndRobes, 1080381, typeof( RewardRobe ), Expansion.ML, Crimson, 1080381 ),
new RewardEntry( cloaksAndRobes, 1080379, typeof( RewardDress ), Expansion.ML, Crimson, 1080379 ), new RewardEntry( cloaksAndRobes, 1080379, typeof( RewardDress ), Expansion.ML, Crimson, 1080379 ),
new RewardEntry( etherealSteeds, 1080386, typeof( EtherealCuSidhe ), Expansion.ML ), new RewardEntry( etherealSteeds, 1080386, typeof( EtherealCuSidhe ), Expansion.ML ),
new RewardEntry( houseAddOns, 1080548, typeof( MiningCartDeed ), Expansion.ML ), new RewardEntry( houseAddOns, 1080548, typeof( MiningCartDeed ), Expansion.ML ),
@ -506,10 +492,10 @@ namespace Server.Engines.VeteranRewards
e.Mobile.SkillsCap = 7000; e.Mobile.SkillsCap = 7000;
} }
if ( Core.ML && e.Mobile is PlayerMobile && !((PlayerMobile)e.Mobile).HasStatReward && HasHalfLevel( e.Mobile ) ) if ( Core.ML && e.Mobile is PlayerMobile mobile && !mobile.HasStatReward && HasHalfLevel( mobile ) )
{ {
((PlayerMobile)e.Mobile).HasStatReward = true; mobile.HasStatReward = true;
e.Mobile.StatCap += 5; mobile.StatCap += 5;
} }
if ( cur < max ) if ( cur < max )

View file

@ -25,9 +25,7 @@ namespace Server
public static void CheckAtrophy( Mobile from ) public static void CheckAtrophy( Mobile from )
{ {
PlayerMobile pm = from as PlayerMobile; if ( !(from is PlayerMobile pm) )
if ( pm == null )
return; return;
try try
@ -44,4 +42,4 @@ namespace Server
} }
} }
} }
} }

View file

@ -35,16 +35,15 @@ namespace Server
protected override void OnTarget( Mobile from, object targeted ) protected override void OnTarget( Mobile from, object targeted )
{ {
PlayerMobile pm = from as PlayerMobile; if ( !(from is PlayerMobile pm) )
if ( pm == null )
return; return;
if ( targeted == pm ) if ( targeted == pm )
{ {
EmbraceHonor( pm ); EmbraceHonor( pm );
} }
else if ( targeted is Mobile ) else if ( targeted is Mobile mobile )
Honor( pm, (Mobile) targeted ); Honor( pm, mobile );
} }
protected override void OnTargetOutOfRange( Mobile from, object targeted ) protected override void OnTargetOutOfRange( Mobile from, object targeted )
@ -145,8 +144,7 @@ namespace Server
return; return;
} }
BaseCreature cret = target as BaseCreature; if ( target.Body.IsHuman && (!(target is BaseCreature cret) || (!cret.AlwaysAttackable && !cret.AlwaysMurderer)) )
if ( target.Body.IsHuman && (cret == null || (!cret.AlwaysAttackable && !cret.AlwaysMurderer)) )
{ {
if ( reg == null || reg.IsDisabled() ) if ( reg == null || reg.IsDisabled() )
@ -170,8 +168,7 @@ namespace Server
return; return;
} }
if ( source.SentHonorContext != null ) source.SentHonorContext?.Cancel();
source.SentHonorContext.Cancel();
new HonorContext( source, target ); new HonorContext( source, target );
@ -283,7 +280,7 @@ namespace Server
m_HonorDamage += amount * 0.8; m_HonorDamage += amount * 0.8;
} }
} }
else if ( from is BaseCreature && ((BaseCreature)from).GetMaster() == m_Source ) else if ( from is BaseCreature creature && creature.GetMaster() == m_Source )
{ {
m_HonorDamage += amount * 0.8; m_HonorDamage += amount * 0.8;
} }

View file

@ -47,9 +47,7 @@ namespace Server
if ( !from.CheckAlive() ) if ( !from.CheckAlive() )
return; return;
PlayerMobile protector = from as PlayerMobile; if ( !(from is PlayerMobile protector) )
if ( protector == null )
return; return;
if ( !VirtueHelper.IsSeeker( protector, VirtueName.Justice ) ) if ( !VirtueHelper.IsSeeker( protector, VirtueName.Justice ) )
@ -159,17 +157,13 @@ namespace Server
public static void RejectDelay_Callback( object state ) public static void RejectDelay_Callback( object state )
{ {
Mobile m = state as Mobile; if ( state is Mobile m )
if ( m != null )
m.EndAction( typeof( JusticeVirtue ) ); m.EndAction( typeof( JusticeVirtue ) );
} }
public static void CheckAtrophy( Mobile from ) public static void CheckAtrophy( Mobile from )
{ {
PlayerMobile pm = from as PlayerMobile; if ( !(from is PlayerMobile pm) )
if ( pm == null )
return; return;
try try
@ -207,7 +201,7 @@ namespace Server
AddImageTiled( 15, 15, 365, 190, 2624 ); AddImageTiled( 15, 15, 365, 190, 2624 );
AddAlphaRegion( 15, 15, 365, 190 ); AddAlphaRegion( 15, 15, 365, 190 );
AddHtmlLocalized( 30, 20, 360, 25, 1049365, 0x7FFF, false, false ); // Another player is offering you their <a href="?ForceTopic88">protection</a>: AddHtmlLocalized( 30, 20, 360, 25, 1049365, 0x7FFF, false, false ); // Another player is offering you their <a href="?ForceTopic88">protection</a>:
AddLabel( 90, 55, 1153, protector.Name ); AddLabel( 90, 55, 1153, protector.Name );
AddImage( 50, 45, 9005 ); AddImage( 50, 45, 9005 );
@ -247,4 +241,4 @@ namespace Server
} }
} }
} }
} }

View file

@ -33,9 +33,7 @@ namespace Server
public static void CheckAtrophy( Mobile from ) public static void CheckAtrophy( Mobile from )
{ {
PlayerMobile pm = from as PlayerMobile; if ( !(from is PlayerMobile pm) )
if ( pm == null )
return; return;
try try
@ -61,9 +59,7 @@ namespace Server
if ( from.Alive ) if ( from.Alive )
return; return;
PlayerMobile pm = from as PlayerMobile; if ( !(from is PlayerMobile pm) )
if ( pm == null )
return; return;
if ( from.Criminal ) if ( from.Criminal )
@ -94,14 +90,10 @@ namespace Server
if ( !from.CheckAlive() ) if ( !from.CheckAlive() )
return; return;
PlayerMobile pm = from as PlayerMobile; if ( !(from is PlayerMobile pm) )
if ( pm == null )
return; return;
Mobile targ = targeted as Mobile; if ( !(targeted is Mobile targ) )
if ( targ == null )
return; return;
if ( !ValidateCreature( targ ) ) if ( !ValidateCreature( targ ) )
@ -173,7 +165,7 @@ namespace Server
public static bool ValidateCreature( Mobile m ) public static bool ValidateCreature( Mobile m )
{ {
if ( m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned) ) if ( m is BaseCreature creature && (creature.Controlled || creature.Summoned) )
return false; return false;
return ( m is Lich || m is Succubus || m is Daemon || m is EvilMage || m is EnslavedGargoyle || m is GargoyleEnforcer ); return ( m is Lich || m is Succubus || m is Daemon || m is EvilMage || m is EnslavedGargoyle || m is GargoyleEnforcer );

View file

@ -30,9 +30,7 @@ namespace Server
public static void CheckAtrophy( Mobile from ) public static void CheckAtrophy( Mobile from )
{ {
PlayerMobile pm = from as PlayerMobile; if ( !(from is PlayerMobile pm) )
if ( pm == null )
return; return;
try try
@ -52,9 +50,7 @@ namespace Server
public static void Valor( Mobile from, object targ ) public static void Valor( Mobile from, object targ )
{ {
IdolOfTheChampion idol = targ as IdolOfTheChampion; if ( !(targ is IdolOfTheChampion idol) || idol.Deleted || idol.Spawn == null || idol.Spawn.Deleted )
if ( idol == null || idol.Deleted || idol.Spawn == null || idol.Spawn.Deleted )
from.SendLocalizedMessage( 1054035 ); // You must target a Champion Idol to challenge the Champion's spawn! from.SendLocalizedMessage( 1054035 ); // You must target a Champion Idol to challenge the Champion's spawn!
else if ( from.Hidden ) else if ( from.Hidden )
from.SendLocalizedMessage( 1052015 ); // You cannot do that while hidden. from.SendLocalizedMessage( 1052015 ); // You cannot do that while hidden.

View file

@ -180,14 +180,12 @@ namespace Server.Gumps
protected override void OnTarget( Mobile from, object o ) protected override void OnTarget( Mobile from, object o )
{ {
IPoint3D p = o as IPoint3D; if ( o is IPoint3D p )
if ( p != null )
{ {
if ( p is Item ) if ( p is Item item )
p = ((Item)p).GetWorldTop(); p = item.GetWorldTop();
else if ( p is Mobile ) else if ( p is Mobile m )
p = ((Mobile)p).Location; p = m.Location;
Server.Commands.Add.Invoke( from, new Point3D( p ), new Point3D( p ), new string[]{ m_Type.Name } ); Server.Commands.Add.Invoke( from, new Point3D( p ), new Point3D( p ), new string[]{ m_Type.Name } );
@ -254,4 +252,4 @@ namespace Server.Gumps
} }
} }
} }
} }

View file

@ -543,9 +543,7 @@ namespace Server.Gumps
for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index ) for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
{ {
NetState ns = m_List[index] as NetState; if ( !(m_List[index] is NetState ns) )
if ( ns == null )
continue; continue;
Mobile m = ns.Mobile; Mobile m = ns.Mobile;
@ -575,9 +573,7 @@ namespace Server.Gumps
} }
case AdminGumpPage.ClientInfo: case AdminGumpPage.ClientInfo:
{ {
Mobile m = state as Mobile; if ( !(state is Mobile m) )
if ( m == null )
break; break;
AddClientHeader(); AddClientHeader();
@ -764,17 +760,12 @@ namespace Server.Gumps
for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index ) for ( int i = 0, index = (listPage * 12); i < 12 && index >= 0 && index < m_List.Count; ++i, ++index )
{ {
Account a = m_List[index] as Account; if ( !(m_List[index] is Account a) )
if ( a == null )
continue; continue;
int offset = 140 + (i * 20); int offset = 140 + (i * 20);
AccessLevel accessLevel; GetAccountInfo( a, out var accessLevel, out var online );
bool online;
GetAccountInfo( a, out accessLevel, out online );
if ( rads == null ) if ( rads == null )
{ {
@ -811,9 +802,7 @@ namespace Server.Gumps
} }
case AdminGumpPage.AccountDetails_ChangePassword: case AdminGumpPage.AccountDetails_ChangePassword:
{ {
Account a = state as Account; if ( !(state is Account a) )
if ( a == null )
break; break;
AddHtml( 10, 125, 400, 20, Color( Center( "Change Password" ), LabelColor32 ), false, false ); AddHtml( 10, 125, 400, 20, Color( Center( "Change Password" ), LabelColor32 ), false, false );
@ -833,9 +822,7 @@ namespace Server.Gumps
} }
case AdminGumpPage.AccountDetails_ChangeAccess: case AdminGumpPage.AccountDetails_ChangeAccess:
{ {
Account a = state as Account; if ( !(state is Account a) )
if ( a == null )
break; break;
AddHtml( 10, 125, 400, 20, Color( Center( "Change Access Level" ), LabelColor32 ), false, false ); AddHtml( 10, 125, 400, 20, Color( Center( "Change Access Level" ), LabelColor32 ), false, false );
@ -868,9 +855,7 @@ namespace Server.Gumps
} }
case AdminGumpPage.AccountDetails_Information: case AdminGumpPage.AccountDetails_Information:
{ {
Account a = state as Account; if ( !(state is Account a) )
if ( a == null )
break; break;
int charCount = 0; int charCount = 0;
@ -892,10 +877,7 @@ namespace Server.Gumps
AddLabel( 20, 190, LabelHue, "Status:" ); AddLabel( 20, 190, LabelHue, "Status:" );
AddLabel( 200, 190, a.Banned ? RedHue : GreenHue, a.Banned ? "Banned" : "Active" ); AddLabel( 200, 190, a.Banned ? RedHue : GreenHue, a.Banned ? "Banned" : "Active" );
DateTime banTime; if ( a.Banned && a.GetBanTags( out var banTime, out var banDuration ) )
TimeSpan banDuration;
if ( a.Banned && a.GetBanTags( out banTime, out banDuration ) )
{ {
if ( banDuration == TimeSpan.MaxValue ) if ( banDuration == TimeSpan.MaxValue )
{ {
@ -956,9 +938,7 @@ namespace Server.Gumps
} }
case AdminGumpPage.AccountDetails_Access: case AdminGumpPage.AccountDetails_Access:
{ {
Account a = state as Account; if ( !(state is Account a) )
if ( a == null )
break; break;
AddHtml( 10, 125, 400, 20, Color( Center( "Access" ), LabelColor32 ), false, false ); AddHtml( 10, 125, 400, 20, Color( Center( "Access" ), LabelColor32 ), false, false );
@ -970,9 +950,7 @@ namespace Server.Gumps
} }
case AdminGumpPage.AccountDetails_Access_ClientIPs: case AdminGumpPage.AccountDetails_Access_ClientIPs:
{ {
Account a = state as Account; if ( !(state is Account a) )
if ( a == null )
break; break;
if ( m_List == null ) if ( m_List == null )
@ -1017,9 +995,7 @@ namespace Server.Gumps
} }
case AdminGumpPage.AccountDetails_Access_Restrictions: case AdminGumpPage.AccountDetails_Access_Restrictions:
{ {
Account a = state as Account; if ( !(state is Account a) )
if ( a == null )
break; break;
if ( m_List == null ) if ( m_List == null )
@ -1061,9 +1037,7 @@ namespace Server.Gumps
} }
case AdminGumpPage.AccountDetails_Characters: case AdminGumpPage.AccountDetails_Characters:
{ {
Account a = state as Account; if ( !(state is Account a) )
if ( a == null )
break; break;
AddHtml( 10, 125, 400, 20, Color( Center( "Characters" ), LabelColor32 ), false, false ); AddHtml( 10, 125, 400, 20, Color( Center( "Characters" ), LabelColor32 ), false, false );
@ -1103,9 +1077,7 @@ namespace Server.Gumps
} }
case AdminGumpPage.AccountDetails_Comments: case AdminGumpPage.AccountDetails_Comments:
{ {
Account a = state as Account; if ( !(state is Account a) )
if ( a == null )
break; break;
AddHtml( 10, 125, 400, 20, Color( Center( "Comments" ), LabelColor32 ), false, false ); AddHtml( 10, 125, 400, 20, Color( Center( "Comments" ), LabelColor32 ), false, false );
@ -1133,9 +1105,7 @@ namespace Server.Gumps
} }
case AdminGumpPage.AccountDetails_Tags: case AdminGumpPage.AccountDetails_Tags:
{ {
Account a = state as Account; if ( !(state is Account a) )
if ( a == null )
break; break;
AddHtml( 10, 125, 400, 20, Color( Center( "Tags" ), LabelColor32 ), false, false ); AddHtml( 10, 125, 400, 20, Color( Center( "Tags" ), LabelColor32 ), false, false );
@ -1215,8 +1185,11 @@ namespace Server.Gumps
{ {
m_List = new ArrayList(); m_List = new ArrayList();
foreach ( Account acct in Accounts.GetAccounts() ) foreach ( IAccount ia in Accounts.GetAccounts() )
{ {
if (!(ia is Account acct))
continue;
IPAddress[] loginList = acct.LoginIPs; IPAddress[] loginList = acct.LoginIPs;
bool contains = false; bool contains = false;
@ -1256,10 +1229,7 @@ namespace Server.Gumps
int offset = 200 + (i * 20); int offset = 200 + (i * 20);
AccessLevel accessLevel; GetAccountInfo( a, out var accessLevel, out var online );
bool online;
GetAccountInfo( a, out accessLevel, out online );
AddLabelCropped( 12, offset, 120, 20, LabelHue, a.Username ); AddLabelCropped( 12, offset, 120, 20, LabelHue, a.Username );
AddLabelCropped( 132, offset, 120, 20, LabelHue, FormatAccessLevel( accessLevel ) ); AddLabelCropped( 132, offset, 120, 20, LabelHue, FormatAccessLevel( accessLevel ) );
@ -1671,9 +1641,8 @@ namespace Server.Gumps
if ( m_PageType == AdminGumpPage.Accounts ) if ( m_PageType == AdminGumpPage.Accounts )
{ {
ArrayList list = m_List; ArrayList list = m_List;
ArrayList rads = m_State as ArrayList;
if ( list != null && rads != null ) if ( list != null && m_State is ArrayList rads )
{ {
for ( int i = 0, v = m_ListPage*12; i < 12 && v < list.Count; ++i, ++v ) for ( int i = 0, v = m_ListPage*12; i < 12 && v < list.Count; ++i, ++v )
{ {
@ -1780,10 +1749,9 @@ namespace Server.Gumps
case 210: case 210:
case 211: case 211:
{ {
TextRelay relay = info.GetTextEntry( 0 ); string text = info.GetTextEntry( 0 )?.Text.Trim();
string text = ( relay == null ? null : relay.Text.Trim() );
if ( text == null || text.Length == 0 ) if ( string.IsNullOrEmpty(text) )
{ {
notice = "You must enter text to broadcast it."; notice = "You must enter text to broadcast it.";
} }
@ -1956,11 +1924,10 @@ namespace Server.Gumps
ArrayList results = new ArrayList(); ArrayList results = new ArrayList();
TextRelay matchEntry = info.GetTextEntry( 0 ); string match = info.GetTextEntry( 0 )?.Text.Trim().ToLower();
string match = ( matchEntry == null ? null : matchEntry.Text.Trim().ToLower() );
string notice = null; string notice = null;
if ( match == null || match.Length == 0 ) if ( string.IsNullOrEmpty(match) )
{ {
notice = String.Format( "You must enter {0} to search.", forName ? "a name" : "an ip address" ); notice = String.Format( "You must enter {0} to search.", forName ? "a name" : "an ip address" );
} }
@ -2022,9 +1989,7 @@ namespace Server.Gumps
if ( m_List != null && index >= 0 && index < m_List.Count ) if ( m_List != null && index >= 0 && index < m_List.Count )
{ {
NetState ns = m_List[index] as NetState; if ( !(m_List[index] is NetState ns) )
if ( ns == null )
break; break;
Mobile m = ns.Mobile; Mobile m = ns.Mobile;
@ -2057,20 +2022,17 @@ namespace Server.Gumps
case 5: from.Prompt = new AddTagNamePrompt( m_State as Account ); from.SendMessage( "Enter the new tag name." ); break; case 5: from.Prompt = new AddTagNamePrompt( m_State as Account ); from.SendMessage( "Enter the new tag name." ); break;
case 6: case 6:
{ {
TextRelay unEntry = info.GetTextEntry( 0 ); string un = info.GetTextEntry( 0 )?.Text.Trim();
TextRelay pwEntry = info.GetTextEntry( 1 ); string pw = info.GetTextEntry( 1 )?.Text.Trim();
string un = ( unEntry == null ? null : unEntry.Text.Trim() );
string pw = ( pwEntry == null ? null : pwEntry.Text.Trim() );
Account dispAccount = null; Account dispAccount = null;
string notice; string notice;
if ( un == null || un.Length == 0 ) if ( string.IsNullOrEmpty(un) )
{ {
notice = "You must enter a username to add an account."; notice = "You must enter a username to add an account.";
} }
else if ( pw == null || pw.Length == 0 ) else if ( string.IsNullOrEmpty(pw) )
{ {
notice = "You must enter a password to add an account."; notice = "You must enter a password to add an account.";
} }
@ -2098,10 +2060,10 @@ namespace Server.Gumps
ArrayList results; ArrayList results;
TextRelay matchEntry = info.GetTextEntry( 0 ); TextRelay matchEntry = info.GetTextEntry( 0 );
string match = ( matchEntry == null ? null : matchEntry.Text.Trim().ToLower() ); string match = matchEntry?.Text.Trim().ToLower();
string notice = null; string notice = null;
if ( match == null || match.Length == 0 ) if ( string.IsNullOrEmpty(match) )
{ {
results = new ArrayList( (ICollection)Accounts.GetAccounts() ); results = new ArrayList( (ICollection)Accounts.GetAccounts() );
results.Sort( AccountComparer.Instance ); results.Sort( AccountComparer.Instance );
@ -2110,10 +2072,10 @@ namespace Server.Gumps
else else
{ {
results = new ArrayList(); results = new ArrayList();
foreach ( Account check in Accounts.GetAccounts() ) foreach ( IAccount acct in Accounts.GetAccounts() )
{ {
if ( check.Username.ToLower().IndexOf( match ) >= 0 ) if ( acct.Username.ToLower().IndexOf( match ) >= 0 )
results.Add( check ); results.Add( acct );
} }
results.Sort( AccountComparer.Instance ); results.Sort( AccountComparer.Instance );
@ -2130,9 +2092,7 @@ namespace Server.Gumps
case 9: from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_ChangeAccess, 0, null, null, m_State ) ); break; case 9: from.SendGump( new AdminGump( from, AdminGumpPage.AccountDetails_ChangeAccess, 0, null, null, m_State ) ); break;
case 10: case 11: case 10: case 11:
{ {
Account a = m_State as Account; if ( !(m_State is Account a) )
if ( a == null )
break; break;
a.SetUnspecifiedBan( from ); a.SetUnspecifiedBan( from );
@ -2147,21 +2107,19 @@ namespace Server.Gumps
} }
case 12: case 12:
{ {
Account a = m_State as Account; if ( !(m_State is Account a) )
if ( a == null )
break; break;
TextRelay passwordEntry = info.GetTextEntry( 0 ); TextRelay passwordEntry = info.GetTextEntry( 0 );
TextRelay confirmEntry = info.GetTextEntry( 1 ); TextRelay confirmEntry = info.GetTextEntry( 1 );
string password = ( passwordEntry == null ? null : passwordEntry.Text.Trim() ); string password = passwordEntry?.Text.Trim();
string confirm = ( confirmEntry == null ? null : confirmEntry.Text.Trim() ); string confirm = confirmEntry?.Text.Trim();
string notice; string notice;
AdminGumpPage page = AdminGumpPage.AccountDetails_ChangePassword; AdminGumpPage page = AdminGumpPage.AccountDetails_ChangePassword;
if ( password == null || password.Length == 0 ) if ( string.IsNullOrEmpty(password) )
{ {
notice = "You must enter the password."; notice = "You must enter the password.";
} }
@ -2183,9 +2141,7 @@ namespace Server.Gumps
} }
case 16: // view shared case 16: // view shared
{ {
Account a = m_State as Account; if ( !(m_State is Account a) )
if ( a == null )
break; break;
ArrayList list = GetSharedAccounts( a.LoginIPs ); ArrayList list = GetSharedAccounts( a.LoginIPs );
@ -2207,9 +2163,7 @@ namespace Server.Gumps
} }
case 17: // ban shared case 17: // ban shared
{ {
Account a = m_State as Account; if ( !(m_State is Account a) )
if ( a == null )
break; break;
ArrayList list = GetSharedAccounts( a.LoginIPs ); ArrayList list = GetSharedAccounts( a.LoginIPs );
@ -2238,9 +2192,7 @@ namespace Server.Gumps
} }
case 18: // firewall all case 18: // firewall all
{ {
Account a = m_State as Account; if ( !(m_State is Account a) )
if ( a == null )
break; break;
if ( a.LoginIPs.Length > 0 ) if ( a.LoginIPs.Length > 0 )
@ -2256,17 +2208,15 @@ namespace Server.Gumps
} }
case 19: // add case 19: // add
{ {
Account a = m_State as Account; if ( !(m_State is Account a) )
if ( a == null )
break; break;
TextRelay entry = info.GetTextEntry( 0 ); TextRelay entry = info.GetTextEntry( 0 );
string ip = ( entry == null ? null : entry.Text.Trim() ); string ip = entry?.Text.Trim();
string notice; string notice;
if ( ip == null || ip.Length == 0 ) if ( string.IsNullOrEmpty(ip) )
{ {
notice = "You must enter an address to add."; notice = "You must enter an address to add.";
} }
@ -2307,9 +2257,7 @@ namespace Server.Gumps
case 23: case 23:
case 24: case 24:
{ {
Account a = m_State as Account; if ( !(m_State is Account a) )
if ( a == null )
break; break;
AccessLevel newLevel; AccessLevel newLevel;
@ -2338,9 +2286,7 @@ namespace Server.Gumps
} }
case 25: case 25:
{ {
Account a = m_State as Account; if ( !(m_State is Account a) )
if ( a == null )
break; break;
from.SendGump( new WarningGump( 1060635, 30720, String.Format( "<center>Account of {0}</center><br>You are about to <em><basefont color=red>permanently delete</basefont></em> the account. Likewise, all characters on the account will be deleted, including equipped, inventory, and banked items. Any houses tied to the account will be demolished.<br><br>Do you wish to continue?", a.Username ), 0xFFC000, 420, 280, new WarningGumpCallback( AccountDelete_Callback ), m_State ) ); from.SendGump( new WarningGump( 1060635, 30720, String.Format( "<center>Account of {0}</center><br>You are about to <em><basefont color=red>permanently delete</basefont></em> the account. Likewise, all characters on the account will be deleted, including equipped, inventory, and banked items. Any houses tied to the account will be demolished.<br><br>Do you wish to continue?", a.Username ), 0xFFC000, 420, 280, new WarningGumpCallback( AccountDelete_Callback ), m_State ) );
@ -2354,9 +2300,8 @@ namespace Server.Gumps
case 27: // Ban marked case 27: // Ban marked
{ {
ArrayList list = m_List; ArrayList list = m_List;
ArrayList rads = m_State as ArrayList;
if ( list == null || rads == null ) if ( list == null || !(m_State is ArrayList rads) )
break; break;
if ( rads.Count > 0 ) if ( rads.Count > 0 )
@ -2369,9 +2314,8 @@ namespace Server.Gumps
case 28: // Delete marked case 28: // Delete marked
{ {
ArrayList list = m_List; ArrayList list = m_List;
ArrayList rads = m_State as ArrayList;
if ( list == null || rads == null ) if ( list == null || !(m_State is ArrayList rads) )
break; break;
if ( rads.Count > 0 ) if ( rads.Count > 0 )
@ -2384,9 +2328,8 @@ namespace Server.Gumps
case 29: // Mark all case 29: // Mark all
{ {
ArrayList list = m_List; ArrayList list = m_List;
ArrayList rads = m_State as ArrayList;
if ( list == null || rads == null ) if ( list == null || !(m_State is ArrayList rads) )
break; break;
from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, m_ListPage, m_List, null, new ArrayList( list ) ) ); from.SendGump( new AdminGump( from, AdminGumpPage.Accounts, m_ListPage, m_List, null, new ArrayList( list ) ) );
@ -2397,7 +2340,7 @@ namespace Server.Gumps
{ {
ArrayList results = new ArrayList(); ArrayList results = new ArrayList();
foreach ( Account acct in Accounts.GetAccounts() ) foreach ( IAccount acct in Accounts.GetAccounts() )
{ {
bool empty = true; bool empty = true;
@ -2419,9 +2362,9 @@ namespace Server.Gumps
{ {
ArrayList results = new ArrayList(); ArrayList results = new ArrayList();
foreach ( Account acct in Accounts.GetAccounts() ) foreach ( IAccount acct in Accounts.GetAccounts() )
{ {
if ( acct.Inactive ) if ((acct as Account)?.Inactive == true )
results.Add( acct ); results.Add( acct );
} }
@ -2436,9 +2379,9 @@ namespace Server.Gumps
{ {
ArrayList results = new ArrayList(); ArrayList results = new ArrayList();
foreach ( Account acct in Accounts.GetAccounts() ) foreach ( IAccount acct in Accounts.GetAccounts() )
{ {
if ( acct.Banned ) if ((acct as Account)?.Banned == true )
results.Add( acct ); results.Add( acct );
} }
@ -2500,9 +2443,7 @@ namespace Server.Gumps
{ {
index -= 50; index -= 50;
Account a = m_State as Account; if ( m_State is Account a && index >= 0 && index < a.Length )
if ( a != null && index >= 0 && index < a.Length )
{ {
Mobile m = a[index]; Mobile m = a[index];
@ -2535,12 +2476,12 @@ namespace Server.Gumps
case 0: case 0:
{ {
TextRelay matchEntry = info.GetTextEntry( 0 ); TextRelay matchEntry = info.GetTextEntry( 0 );
string match = ( matchEntry == null ? null : matchEntry.Text.Trim() ); string match = matchEntry?.Text.Trim();
string notice = null; string notice = null;
ArrayList results = new ArrayList(); ArrayList results = new ArrayList();
if ( match == null || match.Length == 0 ) if ( string.IsNullOrEmpty(match) )
{ {
notice = "You must enter a username to search."; notice = "You must enter a username to search.";
} }
@ -2676,17 +2617,14 @@ namespace Server.Gumps
} }
case 3: case 3:
{ {
Account a = m.Account as Account; if ( m.Account is Account a )
if ( a != null )
{ {
CommandLogging.WriteLine( from, "{0} {1} {2} {3}", from.AccessLevel, CommandLogging.Format( from ), "banning", CommandLogging.Format( m ) ); CommandLogging.WriteLine( from, "{0} {1} {2} {3}", from.AccessLevel, CommandLogging.Format( from ), "banning", CommandLogging.Format( m ) );
a.Banned = true; a.Banned = true;
NetState ns = m.NetState; NetState ns = m.NetState;
if ( ns != null ) ns?.Dispose();
ns.Dispose();
notice = "They have been banned."; notice = "They have been banned.";
} }
@ -2758,9 +2696,7 @@ namespace Server.Gumps
{ {
case 3: case 3:
{ {
Account a = m.Account as Account; if ( m.Account is Account a )
if ( a != null )
from.SendGump( new BanDurationGump( a ) ); from.SendGump( new BanDurationGump( a ) );
break; break;
@ -2976,15 +2912,12 @@ namespace Server.Gumps
{ {
if ( x == null && y == null ) if ( x == null && y == null )
return 0; return 0;
else if ( x == null ) if ( x == null )
return -1; return -1;
else if ( y == null ) if ( y == null )
return 1; return 1;
NetState a = x as NetState; if ( !(x is NetState a) || !(y is NetState b) )
NetState b = y as NetState;
if ( a == null || b == null )
throw new ArgumentException(); throw new ArgumentException();
Mobile aMob = a.Mobile; Mobile aMob = a.Mobile;
@ -2992,17 +2925,16 @@ namespace Server.Gumps
if ( aMob == null && bMob == null ) if ( aMob == null && bMob == null )
return 0; return 0;
else if ( aMob == null ) if ( aMob == null )
return 1; return 1;
else if ( bMob == null ) if ( bMob == null )
return -1; return -1;
if ( aMob.AccessLevel > bMob.AccessLevel ) if ( aMob.AccessLevel > bMob.AccessLevel )
return -1; return -1;
else if ( aMob.AccessLevel < bMob.AccessLevel ) if ( aMob.AccessLevel < bMob.AccessLevel )
return 1; return 1;
else return Insensitive.Compare( aMob.Name, bMob.Name );
return Insensitive.Compare( aMob.Name, bMob.Name );
} }
} }
@ -3018,33 +2950,26 @@ namespace Server.Gumps
{ {
if ( x == null && y == null ) if ( x == null && y == null )
return 0; return 0;
else if ( x == null ) if ( x == null )
return -1; return -1;
else if ( y == null ) if ( y == null )
return 1; return 1;
Account a = x as Account; if ( !(x is Account a) || !(y is Account b) )
Account b = y as Account;
if ( a == null || b == null )
throw new ArgumentException(); throw new ArgumentException();
AccessLevel aLevel, bLevel; GetAccountInfo( a, out var aLevel, out var aOnline );
bool aOnline, bOnline; GetAccountInfo( b, out var bLevel, out var bOnline );
GetAccountInfo( a, out aLevel, out aOnline );
GetAccountInfo( b, out bLevel, out bOnline );
if ( aOnline && !bOnline ) if ( aOnline && !bOnline )
return -1; return -1;
else if ( bOnline && !aOnline ) if ( bOnline && !aOnline )
return 1; return 1;
else if ( aLevel > bLevel ) if ( aLevel > bLevel )
return -1; return -1;
else if ( aLevel < bLevel ) if ( aLevel < bLevel )
return 1; return 1;
else return Insensitive.Compare( a.Username, b.Username );
return Insensitive.Compare( a.Username, b.Username );
} }
} }
} }

View file

@ -315,9 +315,8 @@ namespace Server.Gumps
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 4, GumpButtonType.Reply, 0 ); AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 4, GumpButtonType.Reply, 0 );
if ( node is CAGObject ) if ( node is CAGObject obj )
{ {
CAGObject obj = (CAGObject)node;
int itemID = obj.ItemID; int itemID = obj.ItemID;
Rectangle2D bounds = ItemBounds.Table[itemID]; Rectangle2D bounds = ItemBounds.Table[itemID];

View file

@ -27,8 +27,7 @@ namespace Server.Gumps
private static void OnTarget( Mobile from, object target ) private static void OnTarget( Mobile from, object target )
{ {
Mobile m = target as Mobile; if ( !(target is Mobile m) || !m.Player )
if ( m == null || !m.Player )
{ {
from.SendMessage( "You must target a player." ); from.SendMessage( "You must target a player." );
return; return;
@ -53,7 +52,7 @@ namespace Server.Gumps
int x = 205 - ((title.Length / 2) * 7); int x = 205 - ((title.Length / 2) * 7);
if ( x < 120 ) if ( x < 120 )
x = 120; x = 120;
AddLabel( x, 12, 2100, title ); AddLabel( x, 12, 2100, title );
AddPage( 1 ); AddPage( 1 );
AddButton( 12, 12, 0xFA8, 0xFAA, 0x7F, GumpButtonType.Reply, 0 ); AddButton( 12, 12, 0xFA8, 0xFAA, 0x7F, GumpButtonType.Reply, 0 );
@ -97,7 +96,7 @@ namespace Server.Gumps
public class CommentPrompt : Prompt public class CommentPrompt : Prompt
{ {
private Account m_Acct; private Account m_Acct;
public CommentPrompt( Account acct ) public CommentPrompt( Account acct )
{ {
m_Acct = acct; m_Acct = acct;
} }

View file

@ -119,8 +119,8 @@ namespace Server.Gumps
if ( box.TryDropItem( m_Mobile, toGive, false ) ) if ( box.TryDropItem( m_Mobile, toGive, false ) )
{ {
if ( toGive is BankCheck ) if ( toGive is BankCheck check )
m_Mobile.SendLocalizedMessage( 1060397, ( (BankCheck)toGive ).Worth.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. m_Mobile.SendLocalizedMessage( 1060397, check.Worth.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box.
m_House.RemoveKeys( m_Mobile ); m_House.RemoveKeys( m_Mobile );
new TempNoHousingRegion( m_House, m_Mobile ); new TempNoHousingRegion( m_House, m_Mobile );

View file

@ -177,10 +177,10 @@ namespace Server.Gumps
object child = node.Children[index]; object child = node.Children[index];
string name = ""; string name = "";
if ( child is ParentNode ) if ( child is ParentNode parentNode )
name = ((ParentNode)child).Name; name = parentNode.Name;
else if ( child is ChildNode ) else if ( child is ChildNode childNode )
name = ((ChildNode)child).Name; name = childNode.Name;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID ); AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, name ); AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, name );
@ -229,16 +229,10 @@ namespace Server.Gumps
{ {
object o = m_Node.Children[index]; object o = m_Node.Children[index];
if ( o is ParentNode ) if ( o is ParentNode node )
{ from.SendGump( new GoGump( 0, from, m_Tree, node ) );
from.SendGump( new GoGump( 0, from, m_Tree, (ParentNode)o ) );
}
else else
{ from.MoveToWorld(((ChildNode)o).Location, m_Tree.Map );
ChildNode n = (ChildNode)o;
from.MoveToWorld( n.Location, m_Tree.Map );
}
} }
break; break;

View file

@ -80,8 +80,8 @@ namespace Server.Gumps
if ( Guild.NewGuildSystem ) if ( Guild.NewGuildSystem )
{ {
if ( m_Mobile is PlayerMobile ) if ( m_Mobile is PlayerMobile mobile )
m_Mobile.SendGump( new GuildInfoGump( (PlayerMobile)m_Mobile, m_Guild ) ); mobile.SendGump( new GuildInfoGump( mobile, m_Guild ) );
return; return;
} }

View file

@ -51,9 +51,7 @@ namespace Server.Guilds
{ {
base.OnResponse( sender, info ); base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile; if ( !(sender.Mobile is PlayerMobile pm) || !IsMember( pm, guild ) )
if ( pm == null || !IsMember( pm, guild ) )
return; return;
GuildDisplayType display = m_Display; GuildDisplayType display = m_Display;

View file

@ -139,9 +139,7 @@ namespace Server.Guilds
{ {
base.OnResponse( sender, info ); base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile; if ( !(sender.Mobile is PlayerMobile pm) || !IsMember( pm, guild ) )
if ( pm == null || !IsMember( pm, guild ) )
return; return;
int id = info.ButtonID; int id = info.ButtonID;

View file

@ -43,9 +43,7 @@ namespace Server.Guilds
public override void OnResponse( NetState sender, RelayInfo info ) public override void OnResponse( NetState sender, RelayInfo info )
{ {
PlayerMobile pm = sender.Mobile as PlayerMobile; if ( !(sender.Mobile is PlayerMobile pm) || pm.Guild != null )
if ( pm == null || pm.Guild != null )
return; //Sanity return; //Sanity
switch( info.ButtonID ) switch( info.ButtonID )

View file

@ -272,9 +272,7 @@ namespace Server.Guilds
{ {
base.OnResponse( sender, info ); base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile; if ( !(sender.Mobile is PlayerMobile pm) || !IsMember( pm, guild ) )
if ( pm == null || !IsMember( pm, guild ) )
return; return;
if ( AllowAdvancedSearch && info.ButtonID == 8 ) if ( AllowAdvancedSearch && info.ButtonID == 8 )

View file

@ -62,9 +62,7 @@ namespace Server.Guilds
public override void OnResponse( NetState sender, RelayInfo info ) public override void OnResponse( NetState sender, RelayInfo info )
{ {
PlayerMobile pm = sender.Mobile as PlayerMobile; if ( !(sender.Mobile is PlayerMobile pm) || !IsMember( pm, guild ) || !IsMember( m_Member, guild ) )
if ( pm == null || !IsMember( pm, guild ) || !IsMember( m_Member, guild ) )
return; return;
RankDefinition playerRank = pm.GuildRank; RankDefinition playerRank = pm.GuildRank;
@ -192,15 +190,10 @@ namespace Server.Guilds
public void SetTitle_Callback( Mobile from, string text ) public void SetTitle_Callback( Mobile from, string text )
{ {
PlayerMobile pm = from as PlayerMobile; if (!(from is PlayerMobile pm) || m_Member == null )
PlayerMobile targ = m_Member;
if ( pm == null || targ == null )
return; return;
Guild g = targ.Guild as Guild; if ( !(m_Member.Guild is Guild g) || !IsMember( pm, g ) || !(pm.GuildRank.GetFlag( RankFlags.CanSetGuildTitle ) && (pm.GuildRank.Rank > m_Member.GuildRank.Rank || pm == m_Member)) )
if ( g == null || !IsMember( pm, g ) || !(pm.GuildRank.GetFlag( RankFlags.CanSetGuildTitle ) && (pm.GuildRank.Rank > targ.GuildRank.Rank || pm == targ)) )
{ {
if ( m_Member.GuildTitle == null || m_Member.GuildTitle.Length <= 0 ) if ( m_Member.GuildTitle == null || m_Member.GuildTitle.Length <= 0 )
pm.SendLocalizedMessage( 1070746 ); // You don't have the permission to set that member's guild title. pm.SendLocalizedMessage( 1070746 ); // You don't have the permission to set that member's guild title.
@ -220,11 +213,11 @@ namespace Server.Guilds
else else
{ {
if ( Insensitive.Equals( title, "none" ) ) if ( Insensitive.Equals( title, "none" ) )
targ.GuildTitle = null; m_Member.GuildTitle = null;
else else
targ.GuildTitle = title; m_Member.GuildTitle = title;
pm.SendLocalizedMessage( 1063156, targ.Name ); // The guild information for ~1_val~ has been updated. pm.SendLocalizedMessage( 1063156, m_Member.Name ); // The guild information for ~1_val~ has been updated.
} }
} }
} }

View file

@ -182,9 +182,7 @@ namespace Server.Guilds
{ {
base.OnResponse( sender, info ); base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile; if ( !(sender.Mobile is PlayerMobile pm) || !IsMember( pm, guild ) )
if ( pm == null || !IsMember( pm, guild ) )
return; return;
if ( info.ButtonID == 8 ) if ( info.ButtonID == 8 )

View file

@ -22,15 +22,13 @@ namespace Server.Gumps
if ( GuildGump.BadMember( m_Mobile, m_Guild ) ) if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return; return;
if ( targeted is Mobile ) if ( targeted is Mobile m )
{ {
Mobile m = (Mobile)targeted;
PlayerState guildState = PlayerState.Find( m_Guild.Leader ); PlayerState guildState = PlayerState.Find( m_Guild.Leader );
PlayerState targetState = PlayerState.Find( m ); PlayerState targetState = PlayerState.Find( m );
Faction guildFaction = ( guildState == null ? null : guildState.Faction ); Faction guildFaction = guildState?.Faction;
Faction targetFaction = ( targetState == null ? null : targetState.Faction ); Faction targetFaction = targetState?.Faction;
if ( !m.Player ) if ( !m.Player )
{ {
@ -92,4 +90,4 @@ namespace Server.Gumps
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) ); m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
} }
} }
} }

View file

@ -115,13 +115,15 @@ namespace Server.Gumps
toGive = new BankCheck( m_House.Price ); toGive = new BankCheck( m_House.Price );
} }
if (AccountGold.Enabled && toGive is BankCheck) BankCheck check = toGive as BankCheck;
if (AccountGold.Enabled && check != null)
{ {
var worth = ((BankCheck)toGive).Worth; var worth = check.Worth;
if (m_Mobile.Account != null && m_Mobile.Account.DepositGold(worth)) if (m_Mobile.Account != null && m_Mobile.Account.DepositGold(worth))
{ {
toGive.Delete(); check.Delete();
m_Mobile.SendLocalizedMessage(1060397, worth.ToString("#,0")); m_Mobile.SendLocalizedMessage(1060397, worth.ToString("#,0"));
// ~1_AMOUNT~ gold has been deposited into your bank box. // ~1_AMOUNT~ gold has been deposited into your bank box.
@ -138,8 +140,8 @@ namespace Server.Gumps
if ( box.TryDropItem( m_Mobile, toGive, false ) ) if ( box.TryDropItem( m_Mobile, toGive, false ) )
{ {
if ( toGive is BankCheck ) if ( check != null )
m_Mobile.SendLocalizedMessage( 1060397, ( (BankCheck)toGive ).Worth.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. m_Mobile.SendLocalizedMessage( 1060397, check.Worth.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box.
m_House.RemoveKeys( m_Mobile ); m_House.RemoveKeys( m_Mobile );
m_House.Delete(); m_House.Delete();

View file

@ -127,10 +127,8 @@ namespace Server.Gumps
string name; string name;
int labelHue = LabelHue; int labelHue = LabelHue;
if ( m is PlayerVendor ) if ( m is PlayerVendor vendor )
{ {
PlayerVendor vendor = (PlayerVendor) m;
name = vendor.ShopName; name = vendor.ShopName;
if ( vendor.IsOwner( from ) ) if ( vendor.IsOwner( from ) )
@ -763,10 +761,10 @@ namespace Server.Gumps
foreach ( Mobile mobile in newHouse.InternalizedVendors ) foreach ( Mobile mobile in newHouse.InternalizedVendors )
{ {
if ( mobile is PlayerVendor ) if ( mobile is PlayerVendor vendor )
((PlayerVendor)mobile).House = newHouse; vendor.House = newHouse;
else if ( mobile is PlayerBarkeeper ) else if ( mobile is PlayerBarkeeper barkeeper )
((PlayerBarkeeper)mobile).House = newHouse; barkeeper.House = newHouse;
} }
if ( house.MovingCrate != null ) if ( house.MovingCrate != null )

View file

@ -28,8 +28,8 @@ namespace Server.Gumps
AddImageTiled( 10, 40, width - 20, height - 80, 2624 ); AddImageTiled( 10, 40, width - 20, height - 80, 2624 );
AddAlphaRegion( 10, 40, width - 20, height - 80 ); AddAlphaRegion( 10, 40, width - 20, height - 80 );
if ( content is int ) if ( content is int i )
AddHtmlLocalized( 10, 40, width - 20, height - 80, (int)content, contentColor, false, true ); AddHtmlLocalized( 10, 40, width - 20, height - 80, i, contentColor, false, true );
else if ( content is string ) else if ( content is string )
AddHtml( 10, 40, width - 20, height - 80, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", contentColor, content ), false, true ); AddHtml( 10, 40, width - 20, height - 80, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", contentColor, content ), false, true );
@ -41,8 +41,8 @@ namespace Server.Gumps
public override void OnResponse( Server.Network.NetState sender, RelayInfo info ) public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
{ {
if ( info.ButtonID == 1 && m_Callback != null ) if ( info.ButtonID == 1 )
m_Callback( sender.Mobile, m_State ); m_Callback?.Invoke( sender.Mobile, m_State );
} }
} }
} }

View file

@ -67,7 +67,7 @@ namespace Server.Gumps
if ( from.Backpack != null ) if ( from.Backpack != null )
totalGold += from.Backpack.GetAmount( typeof( Gold ) ); totalGold += from.Backpack.GetAmount( typeof( Gold ) );
totalGold += Banker.GetBalance( from ); totalGold += Banker.GetBalance( from );
if ( totalGold < m_VI.Price ) if ( totalGold < m_VI.Price )
@ -132,9 +132,9 @@ namespace Server.Gumps
double days = (m_Vendor.HoldGold + m_Vendor.BankAccount) / ((double)perDay); double days = (m_Vendor.HoldGold + m_Vendor.BankAccount) / ((double)perDay);
AddHtmlLocalized( 40, 25, 260, 20, 1038318, false, false ); // Amount of days I can work: AddHtmlLocalized( 40, 25, 260, 20, 1038318, false, false ); // Amount of days I can work:
AddLabel( 300, 25, 0, ((int)days).ToString() ); AddLabel( 300, 25, 0, ((int)days).ToString() );
AddHtmlLocalized( 40, 48, 260, 20, 1038319, false, false ); // Earth days: AddHtmlLocalized( 40, 48, 260, 20, 1038319, false, false ); // Earth days:
AddLabel( 300, 48, 0, ((int)(days / 12.0)).ToString() ); AddLabel( 300, 48, 0, ((int)(days / 12.0)).ToString() );
} }
@ -188,30 +188,29 @@ namespace Server.Gumps
{ {
int goldNeeded = perRealWorldDay - goldHeld; int goldNeeded = perRealWorldDay - goldHeld;
AddHtmlLocalized( 40, 35, 260, 20, 1038320, 0x7FFF, false, false ); // Gold needed for 1 day of vendor salary: AddHtmlLocalized( 40, 35, 260, 20, 1038320, 0x7FFF, false, false ); // Gold needed for 1 day of vendor salary:
AddLabel( 300, 35, 0x1F, goldNeeded.ToString() ); AddLabel( 300, 35, 0x1F, goldNeeded.ToString() );
} }
else else
{ {
int days = goldHeld / perRealWorldDay; int days = goldHeld / perRealWorldDay;
AddHtmlLocalized( 40, 35, 260, 20, 1038318, 0x7FFF, false, false ); // # of days Vendor salary is paid for: AddHtmlLocalized( 40, 35, 260, 20, 1038318, 0x7FFF, false, false ); // # of days Vendor salary is paid for:
AddLabel( 300, 35, 0x480, days.ToString() ); AddLabel( 300, 35, 0x480, days.ToString() );
} }
AddHtmlLocalized( 40, 58, 260, 20, 1038324, 0x7FFF, false, false ); // My charge per real world day is: AddHtmlLocalized( 40, 58, 260, 20, 1038324, 0x7FFF, false, false ); // My charge per real world day is:
AddLabel( 300, 58, 0x480, perRealWorldDay.ToString() ); AddLabel( 300, 58, 0x480, perRealWorldDay.ToString() );
AddHtmlLocalized( 40, 82, 260, 20, 1038322, 0x7FFF, false, false ); // Gold held in my account: AddHtmlLocalized( 40, 82, 260, 20, 1038322, 0x7FFF, false, false ); // Gold held in my account:
AddLabel( 300, 82, 0x480, goldHeld.ToString() ); AddLabel( 300, 82, 0x480, goldHeld.ToString() );
AddHtmlLocalized( 40, 108, 260, 20, 1062509, 0x7FFF, false, false ); // Shop Name: AddHtmlLocalized( 40, 108, 260, 20, 1062509, 0x7FFF, false, false ); // Shop Name:
AddLabel( 140, 106, 0x66D, vendor.ShopName ); AddLabel( 140, 106, 0x66D, vendor.ShopName );
if ( vendor is RentedVendor ) if ( vendor is RentedVendor rentedVendor )
{ {
int days, hours; rentedVendor.ComputeRentalExpireDelay( out var days, out var hours );
((RentedVendor)vendor).ComputeRentalExpireDelay( out days, out hours );
AddLabel( 38, 132, 0x480, String.Format( "Location rental will expire in {0} day{1} and {2} hour{3}.", days, days != 1 ? "s" : "", hours, hours != 1 ? "s" : "" ) ); AddLabel( 38, 132, 0x480, String.Format( "Location rental will expire in {0} day{1} and {2} hour{3}.", days, days != 1 ? "s" : "", hours, hours != 1 ? "s" : "" ) );
} }
@ -342,7 +341,7 @@ namespace Server.Gumps
return null; return null;
Item i = null; Item i = null;
try try
{ {
ConstructorInfo ctor = m_Type.GetConstructor( new Type[0] ); ConstructorInfo ctor = m_Type.GetConstructor( new Type[0] );
@ -352,7 +351,7 @@ namespace Server.Gumps
catch catch
{ {
} }
return i; return i;
} }
@ -544,10 +543,10 @@ namespace Server.Gumps
Mobile from = state.Mobile; Mobile from = state.Mobile;
if ( m_Vendor is PlayerVendor && !((PlayerVendor)m_Vendor).CanInteractWith( from, true ) ) if ( m_Vendor is PlayerVendor vendor && !vendor.CanInteractWith( from, true ) )
return; return;
if ( m_Vendor is PlayerBarkeeper && !((PlayerBarkeeper)m_Vendor).IsOwner( from ) ) if ( m_Vendor is PlayerBarkeeper barkeeper && !barkeeper.IsOwner( from ) )
return; return;
if ( info.ButtonID == 0 ) if ( info.ButtonID == 0 )
@ -738,10 +737,10 @@ namespace Server.Gumps
if ( m_Item.Deleted ) if ( m_Item.Deleted )
return; return;
if ( m_Vendor is PlayerVendor && !((PlayerVendor)m_Vendor).CanInteractWith( m_Mob, true ) ) if ( m_Vendor is PlayerVendor vendor && !vendor.CanInteractWith( m_Mob, true ) )
return; return;
if ( m_Vendor is PlayerBarkeeper && !((PlayerBarkeeper)m_Vendor).IsOwner( m_Mob ) ) if ( m_Vendor is PlayerBarkeeper barkeeper && !barkeeper.IsOwner( m_Mob ) )
return; return;
m_Item.Hue = hue; m_Item.Hue = hue;
@ -767,10 +766,10 @@ namespace Server.Gumps
if ( m_Vendor.Deleted ) if ( m_Vendor.Deleted )
return; return;
if ( m_Vendor is PlayerVendor && !((PlayerVendor)m_Vendor).CanInteractWith( m_Mob, true ) ) if ( m_Vendor is PlayerVendor vendor && !vendor.CanInteractWith( m_Mob, true ) )
return; return;
if ( m_Vendor is PlayerBarkeeper && !((PlayerBarkeeper)m_Vendor).IsOwner( m_Mob ) ) if ( m_Vendor is PlayerBarkeeper barkeeper && !barkeeper.IsOwner( m_Mob ) )
return; return;
if ( m_FacialHair ) if ( m_FacialHair )

View file

@ -205,10 +205,8 @@ namespace Server.Gumps
{ {
AddImageTiled( x - OffsetSize, y, TotalWidth, EntryHeight, BackGumpID + 4 ); AddImageTiled( x - OffsetSize, y, TotalWidth, EntryHeight, BackGumpID + 4 );
} }
else if ( o is Type ) else if ( o is Type type )
{ {
Type type = (Type)o;
AddImageTiled( x, y, TypeWidth, EntryHeight, EntryGumpID ); AddImageTiled( x, y, TypeWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, TypeWidth - TextOffsetX, EntryHeight, TextHue, type.Name ); AddLabelCropped( x + TextOffsetX, y, TypeWidth - TextOffsetX, EntryHeight, TextHue, type.Name );
x += TypeWidth + OffsetSize; x += TypeWidth + OffsetSize;
@ -216,10 +214,8 @@ namespace Server.Gumps
if ( SetGumpID != 0 ) if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID ); AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
} }
else if ( o is PropertyInfo ) else if ( o is PropertyInfo prop )
{ {
PropertyInfo prop = (PropertyInfo)o;
AddImageTiled( x, y, NameWidth, EntryHeight, EntryGumpID ); AddImageTiled( x, y, NameWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, NameWidth - TextOffsetX, EntryHeight, TextHue, prop.Name ); AddLabelCropped( x + TextOffsetX, y, NameWidth - TextOffsetX, EntryHeight, TextHue, prop.Name );
x += NameWidth + OffsetSize; x += NameWidth + OffsetSize;
@ -321,10 +317,10 @@ namespace Server.Gumps
from.SendGump( new SetListOptionGump( prop, from, m_Object, m_Stack, m_Page, m_List, m_PoisonNames, m_PoisonValues ) ); from.SendGump( new SetListOptionGump( prop, from, m_Object, m_Stack, m_Page, m_List, m_PoisonNames, m_PoisonValues ) );
else if ( IsType( type, typeofMap ) ) else if ( IsType( type, typeofMap ) )
from.SendGump( new SetListOptionGump( prop, from, m_Object, m_Stack, m_Page, m_List, Map.GetMapNames(), Map.GetMapValues() ) ); from.SendGump( new SetListOptionGump( prop, from, m_Object, m_Stack, m_Page, m_List, Map.GetMapNames(), Map.GetMapValues() ) );
else if ( IsType( type, typeofSkills ) && m_Object is Mobile ) else if ( IsType( type, typeofSkills ) && m_Object is Mobile mobile )
{ {
from.SendGump( new PropertiesGump( from, m_Object, m_Stack, m_List, m_Page ) ); from.SendGump( new PropertiesGump( from, mobile, m_Stack, m_List, m_Page ) );
from.SendGump( new SkillsGump( from, (Mobile)m_Object ) ); from.SendGump( new SkillsGump( from, mobile ) );
} }
else if ( HasAttribute( type, typeofPropertyObject, true ) ) else if ( HasAttribute( type, typeofPropertyObject, true ) )
{ {
@ -378,9 +374,7 @@ namespace Server.Gumps
if ( attrs.Length == 0 ) if ( attrs.Length == 0 )
return new string[0]; return new string[0];
CustomEnumAttribute ce = attrs[0] as CustomEnumAttribute; if ( !(attrs[0] is CustomEnumAttribute ce) )
if ( ce == null )
return new string[0]; return new string[0];
return ce.Names; return ce.Names;
@ -465,60 +459,56 @@ namespace Server.Gumps
{ {
return "-null-"; return "-null-";
} }
else if ( o is string ) if ( o is string s )
{ {
return String.Format( "\"{0}\"", (string)o ); return String.Format( "\"{0}\"", s );
} }
else if ( o is bool ) if ( o is bool )
{ {
return o.ToString(); return o.ToString();
} }
else if ( o is char ) if ( o is char c )
{ {
return String.Format( "0x{0:X} '{1}'", (int)(char)o, (char)o ); return String.Format( "0x{0:X} '{1}'", (int)c, c );
} }
else if ( o is Serial ) if ( o is Serial serial )
{ {
Serial s = (Serial)o; if ( serial.IsValid )
if ( s.IsValid )
{ {
if ( s.IsItem ) if ( serial.IsItem )
{ {
return String.Format( "(I) 0x{0:X}", s.Value ); return String.Format( "(I) 0x{0:X}", serial.Value );
} }
else if ( s.IsMobile ) if ( serial.IsMobile )
{ {
return String.Format( "(M) 0x{0:X}", s.Value ); return String.Format( "(M) 0x{0:X}", serial.Value );
} }
} }
return String.Format( "(?) 0x{0:X}", s.Value ); return String.Format( "(?) 0x{0:X}", serial.Value );
} }
else if ( o is byte || o is sbyte || o is short || o is ushort || o is int || o is uint || o is long || o is ulong ) if ( o is byte || o is sbyte || o is short || o is ushort || o is int || o is uint || o is long || o is ulong )
{ {
return String.Format( "{0} (0x{0:X})", o ); return String.Format( "{0} (0x{0:X})", o );
} }
else if ( o is Mobile ) if ( o is Mobile mobile )
{ {
return String.Format( "(M) 0x{0:X} \"{1}\"", ((Mobile)o).Serial.Value, ((Mobile)o).Name ); return String.Format( "(M) 0x{0:X} \"{1}\"", mobile.Serial.Value, mobile.Name );
} }
else if ( o is Item ) if ( o is Item item )
{ {
return String.Format( "(I) 0x{0:X}", ((Item)o).Serial.Value ); return String.Format( "(I) 0x{0:X}", item.Serial.Value );
} }
else if ( o is Type ) if ( o is Type type )
{ {
return ((Type)o).Name; return type.Name;
} }
else if ( o is TextDefinition ) if ( o is TextDefinition definition )
{ {
return ((TextDefinition)o).Format( true ); return definition.Format( true );
}
else
{
return o.ToString();
} }
return o.ToString();
} }
private ArrayList BuildList() private ArrayList BuildList()
@ -653,56 +643,52 @@ namespace Server.Gumps
{ {
return "-null-"; return "-null-";
} }
else if ( o is string ) if ( o is string s )
{ {
return String.Format( "\"{0}\"", (string)o ); return String.Format( "\"{0}\"", s );
} }
else if ( o is bool ) if ( o is bool )
{ {
return o.ToString(); return o.ToString();
} }
else if ( o is char ) if ( o is char c )
{ {
return String.Format( "0x{0:X} '{1}'", (int)(char)o, (char)o ); return String.Format( "0x{0:X} '{1}'", (int)c, c );
} }
else if ( o is Serial ) if ( o is Serial serial )
{ {
Serial s = (Serial)o; if ( serial.IsValid )
if ( s.IsValid )
{ {
if ( s.IsItem ) if ( serial.IsItem )
{ {
return String.Format( "(I) 0x{0:X}", s.Value ); return String.Format( "(I) 0x{0:X}", serial.Value );
} }
else if ( s.IsMobile ) if ( serial.IsMobile )
{ {
return String.Format( "(M) 0x{0:X}", s.Value ); return String.Format( "(M) 0x{0:X}", serial.Value );
} }
} }
return String.Format( "(?) 0x{0:X}", s.Value ); return String.Format( "(?) 0x{0:X}", serial.Value );
} }
else if ( o is byte || o is sbyte || o is short || o is ushort || o is int || o is uint || o is long || o is ulong ) if ( o is byte || o is sbyte || o is short || o is ushort || o is int || o is uint || o is long || o is ulong )
{ {
return String.Format( "{0} (0x{0:X})", o ); return String.Format( "{0} (0x{0:X})", o );
} }
else if ( o is Mobile ) if ( o is Mobile mobile )
{ {
return String.Format( "(M) 0x{0:X} \"{1}\"", ((Mobile)o).Serial.Value, ((Mobile)o).Name ); return String.Format( "(M) 0x{0:X} \"{1}\"", mobile.Serial.Value, mobile.Name );
} }
else if ( o is Item ) if ( o is Item item )
{ {
return String.Format( "(I) 0x{0:X}", ((Item)o).Serial.Value ); return String.Format( "(I) 0x{0:X}", item.Serial.Value );
} }
else if ( o is Type ) if ( o is Type type )
{ {
return ((Type)o).Name; return type.Name;
}
else
{
return o.ToString();
} }
return o.ToString();
} }
private class PropertySorter : IComparer private class PropertySorter : IComparer
@ -717,9 +703,9 @@ namespace Server.Gumps
{ {
if ( x == null && y == null ) if ( x == null && y == null )
return 0; return 0;
else if ( x == null ) if ( x == null )
return -1; return -1;
else if ( y == null ) if ( y == null )
return 1; return 1;
PropertyInfo a = x as PropertyInfo; PropertyInfo a = x as PropertyInfo;
@ -759,9 +745,9 @@ namespace Server.Gumps
{ {
if ( x == null && y == null ) if ( x == null && y == null )
return 0; return 0;
else if ( x == null ) if ( x == null )
return -1; return -1;
else if ( y == null ) if ( y == null )
return 1; return 1;
if ( !(x is DictionaryEntry) || !(y is DictionaryEntry) ) if ( !(x is DictionaryEntry) || !(y is DictionaryEntry) )
@ -770,10 +756,7 @@ namespace Server.Gumps
DictionaryEntry de1 = (DictionaryEntry)x; DictionaryEntry de1 = (DictionaryEntry)x;
DictionaryEntry de2 = (DictionaryEntry)y; DictionaryEntry de2 = (DictionaryEntry)y;
Type a = (Type)de1.Key; return GetDistance( (Type)de1.Key ).CompareTo( GetDistance( (Type)de2.Key ) );
Type b = (Type)de2.Key;
return GetDistance( a ).CompareTo( GetDistance( b ) );
} }
} }
} }

View file

@ -78,8 +78,8 @@ namespace Server.Gumps
if ( val == null ) if ( val == null )
initialText = ""; initialText = "";
else if ( val is TextDefinition ) else if ( val is TextDefinition definition )
initialText = ((TextDefinition)val).GetValue(); initialText = definition.GetValue();
else else
initialText = val.ToString(); initialText = val.ToString();
@ -279,4 +279,4 @@ namespace Server.Gumps
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) ); m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
} }
} }
} }

View file

@ -148,9 +148,7 @@ namespace Server.Gumps
protected override void OnTarget( Mobile from, object targeted ) protected override void OnTarget( Mobile from, object targeted )
{ {
IPoint3D p = targeted as IPoint3D; if ( targeted is IPoint3D p )
if ( p != null )
{ {
try try
{ {
@ -235,4 +233,4 @@ namespace Server.Gumps
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) ); m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
} }
} }
} }

View file

@ -153,9 +153,7 @@ namespace Server.Gumps
protected override void OnTarget( Mobile from, object targeted ) protected override void OnTarget( Mobile from, object targeted )
{ {
IPoint3D p = targeted as IPoint3D; if ( targeted is IPoint3D p )
if ( p != null )
{ {
try try
{ {
@ -241,4 +239,4 @@ namespace Server.Gumps
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) ); m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
} }
} }
} }

View file

@ -66,7 +66,7 @@ namespace Server.Gumps
Titles.AwardKarma( g, karmaAward, true ); Titles.AwardKarma( g, karmaAward, true );
} }
if ( m is PlayerMobile && ((PlayerMobile)m).NpcGuild == NpcGuild.ThievesGuild ) if ( m is PlayerMobile mobile && mobile.NpcGuild == NpcGuild.ThievesGuild )
return; return;
if ( killers.Count > 0 ) if ( killers.Count > 0 )
@ -164,9 +164,8 @@ namespace Server.Gumps
Timer.DelayCall(TimeSpan.FromMinutes(10), new TimerStateCallback(ReportedListExpiry_Callback), new object[] { from, killer }); Timer.DelayCall(TimeSpan.FromMinutes(10), new TimerStateCallback(ReportedListExpiry_Callback), new object[] { from, killer });
} }
if (killer is PlayerMobile) if (killer is PlayerMobile pk)
{ {
PlayerMobile pk = (PlayerMobile)killer;
pk.ResetKillTime(); pk.ResetKillTime();
pk.SendLocalizedMessage(1049067);//You have been reported for murder! pk.SendLocalizedMessage(1049067);//You have been reported for murder!
@ -193,4 +192,4 @@ namespace Server.Gumps
from.SendGump( new ReportMurdererGump( from, m_Killers, m_Idx ) ); from.SendGump( new ReportMurdererGump( from, m_Killers, m_Idx ) );
} }
} }
} }

View file

@ -192,12 +192,12 @@ namespace Server.Gumps
} }
} }
if ( m_FromSacrifice && from is PlayerMobile ) if ( m_FromSacrifice && from is PlayerMobile mobile )
{ {
((PlayerMobile)from).AvailableResurrects -= 1; mobile.AvailableResurrects -= 1;
Container pack = from.Backpack; Container pack = mobile.Backpack;
Container corpse = from.Corpse; Container corpse = mobile.Corpse;
if ( pack != null && corpse != null ) if ( pack != null && corpse != null )
{ {

View file

@ -325,9 +325,7 @@ namespace Server.Gumps
if ( !m_Contract.IsUsableBy( from, true, false, true, true ) ) if ( !m_Contract.IsUsableBy( from, true, false, true, true ) )
return; return;
Mobile mob = targeted as Mobile; if ( !(targeted is Mobile mob) || !mob.Player || !mob.Alive || mob == from )
if ( mob == null || !mob.Player || !mob.Alive || mob == from )
{ {
from.SendLocalizedMessage(1071984); //That is not a valid target for a rental contract! from.SendLocalizedMessage(1071984); //That is not a valid target for a rental contract!
} }
@ -555,7 +553,7 @@ namespace Server.Gumps
/* The landlord for this vendor is offering you a partial refund of your rental fee /* The landlord for this vendor is offering you a partial refund of your rental fee
* in exchange for immediate termination of your rental contract.<BR><BR> * in exchange for immediate termination of your rental contract.<BR><BR>
* *
* If you accept this offer, the vendor will be immediately dismissed. You will then * If you accept this offer, the vendor will be immediately dismissed. You will then
* be able to claim the inventory and any funds the vendor may be holding for you via * be able to claim the inventory and any funds the vendor may be holding for you via
* a context menu on the house sign for this house. * a context menu on the house sign for this house.
@ -613,4 +611,4 @@ namespace Server.Gumps
} }
} }
} }
} }

View file

@ -26,8 +26,8 @@ namespace Server.Gumps
public static void ViewHouses_OnTarget( Mobile from, object targeted ) public static void ViewHouses_OnTarget( Mobile from, object targeted )
{ {
if ( targeted is Mobile ) if ( targeted is Mobile mobile )
from.SendGump( new ViewHousesGump( from, GetHouses( (Mobile)targeted ), null ) ); from.SendGump( new ViewHousesGump( from, GetHouses( mobile ), null ) );
} }
private class HouseComparer : IComparer<BaseHouse> private class HouseComparer : IComparer<BaseHouse>
@ -44,9 +44,7 @@ namespace Server.Gumps
{ {
List<BaseHouse> list = new List<BaseHouse>(); List<BaseHouse> list = new List<BaseHouse>();
Account acct = owner.Account as Account; if ( !(owner.Account is Account acct) )
if ( acct == null )
{ {
list.AddRange( BaseHouse.GetHouses( owner ) ); list.AddRange( BaseHouse.GetHouses( owner ) );
} }
@ -114,21 +112,21 @@ namespace Server.Gumps
AddHtml( 15, 40 + ((i % 15) * 20), 20, 20, Color( String.Format( "{0}.", i+1 ), White ), false, false ); AddHtml( 15, 40 + ((i % 15) * 20), 20, 20, Color( String.Format( "{0}.", i+1 ), White ), false, false );
if ( name is int ) if ( name is int nameInt )
AddHtmlLocalized( 35, 40 + ((i % 15) * 20), 160, 20, (int)name, White16, false, false ); AddHtmlLocalized( 35, 40 + ((i % 15) * 20), 160, 20, nameInt, White16, false, false );
else if ( name is string ) else
AddHtml( 35, 40 + ((i % 15) * 20), 160, 20, Color( (string)name, White ), false, false ); AddHtml( 35, 40 + ((i % 15) * 20), 160, 20, Color( name.ToString(), White ), false, false );
AddButton( 198, 39 + ((i % 15) * 20), 4005, 4007, i+1, GumpButtonType.Reply, 0 ); AddButton( 198, 39 + ((i % 15) * 20), 4005, 4007, i+1, GumpButtonType.Reply, 0 );
} }
} }
else else
{ {
string houseName, owner, location; string location;
Map map = sel.Map; Map map = sel.Map;
houseName = (sel.Sign == null) ? "An Unnamed House" : sel.Sign.GetName(); var houseName = (sel.Sign == null) ? "An Unnamed House" : sel.Sign.GetName();
owner = (sel.Owner == null) ? "nobody" : sel.Owner.Name; var owner = (sel.Owner == null) ? "nobody" : sel.Owner.Name;
int xLong = 0, yLat = 0, xMins = 0, yMins = 0; int xLong = 0, yLat = 0, xMins = 0, yMins = 0;
bool xEast = false, ySouth = false; bool xEast = false, ySouth = false;
@ -136,7 +134,7 @@ namespace Server.Gumps
bool valid = Sextant.Format( sel.Location, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth ); bool valid = Sextant.Format( sel.Location, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth );
if ( valid ) if ( valid )
location = String.Format( "{0}° {1}'{2}, {3}° {4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W" ); location = String.Format( "{0}° {1}'{2}, {3}° {4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W" );
else else
location = "unknown"; location = "unknown";
@ -300,4 +298,4 @@ namespace Server.Gumps
AddAlphaRegion( x, y, width, height ); AddAlphaRegion( x, y, width, height );
} }
} }
} }

View file

@ -35,8 +35,8 @@ namespace Server.Gumps
AddImageTiled( 10, 40, width - 20, height - 80, 2624 ); AddImageTiled( 10, 40, width - 20, height - 80, 2624 );
AddAlphaRegion( 10, 40, width - 20, height - 80 ); AddAlphaRegion( 10, 40, width - 20, height - 80 );
if ( content is int ) if ( content is int i )
AddHtmlLocalized( 10, 40, width - 20, height - 80, (int)content, contentColor, false, true ); AddHtmlLocalized( 10, 40, width - 20, height - 80, i, contentColor, false, true );
else if ( content is string ) else if ( content is string )
AddHtml( 10, 40, width - 20, height - 80, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", contentColor, content ), false, true ); AddHtml( 10, 40, width - 20, height - 80, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", contentColor, content ), false, true );
@ -55,10 +55,13 @@ namespace Server.Gumps
public override void OnResponse( Server.Network.NetState sender, RelayInfo info ) public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
{ {
if ( info.ButtonID == 1 && m_Callback != null ) if (m_Callback == null)
return;
if ( info.ButtonID == 1)
m_Callback( sender.Mobile, true, m_State ); m_Callback( sender.Mobile, true, m_State );
else if ( m_Callback != null ) else
m_Callback( sender.Mobile, false, m_State ); m_Callback.Invoke( sender.Mobile, false, m_State );
} }
} }
} }

View file

@ -127,7 +127,7 @@ namespace Server.Gumps
{ {
Mobile m = states[i].Mobile; Mobile m = states[i].Mobile;
if ( m != null && (m == owner || !m.Hidden || owner.AccessLevel >= m.AccessLevel || (m is PlayerMobile && ((PlayerMobile)m).VisibilityList.Contains( owner ) ) ) ) if ( m != null && (m == owner || !m.Hidden || owner.AccessLevel >= m.AccessLevel || (m is PlayerMobile mobile && mobile.VisibilityList.Contains( owner ) ) ) )
{ {
if ( filter != null && ( m.Name == null || m.Name.ToLower().IndexOf( filter ) < 0 ) ) if ( filter != null && ( m.Name == null || m.Name.ToLower().IndexOf( filter ) < 0 ) )
continue; continue;
@ -281,7 +281,7 @@ namespace Server.Gumps
from.SendMessage( "That player is no longer online." ); from.SendMessage( "That player is no longer online." );
from.SendGump( new WhoGump( from, m_Mobiles, m_Page ) ); from.SendGump( new WhoGump( from, m_Mobiles, m_Page ) );
} }
else if ( m == from || !m.Hidden || from.AccessLevel >= m.AccessLevel || (m is PlayerMobile && ((PlayerMobile)m).VisibilityList.Contains( from ))) else if ( m == from || !m.Hidden || from.AccessLevel >= m.AccessLevel || (m is PlayerMobile mobile && mobile.VisibilityList.Contains( from )))
{ {
from.SendGump( new ClientGump( from, m.NetState ) ); from.SendGump( new ClientGump( from, m.NetState ) );
} }
@ -297,4 +297,4 @@ namespace Server.Gumps
} }
} }
} }
} }

View file

@ -59,11 +59,11 @@ namespace Server.Gumps
/* As a 'Young' player, you are currently under a system of protection that prevents /* As a 'Young' player, you are currently under a system of protection that prevents
* you from being attacked by other players and certain monsters.<br><br> * you from being attacked by other players and certain monsters.<br><br>
* *
* If you choose to renounce your status as a 'Young' player, you will lose this protection. * If you choose to renounce your status as a 'Young' player, you will lose this protection.
* You will become vulnerable to other players, and many monsters that had only glared * You will become vulnerable to other players, and many monsters that had only glared
* at you menacingly before will now attack you on sight!<br><br> * at you menacingly before will now attack you on sight!<br><br>
* *
* Select OKAY now if you wish to renounce your status as a 'Young' player, otherwise * Select OKAY now if you wish to renounce your status as a 'Young' player, otherwise
* press CANCEL. * press CANCEL.
*/ */
@ -82,9 +82,7 @@ namespace Server.Gumps
if ( info.ButtonID == 1 ) if ( info.ButtonID == 1 )
{ {
Account acc = from.Account as Account; if ( from.Account is Account acc )
if ( acc != null )
{ {
acc.RemoveYoungStatus( 502085 ); // You have chosen to renounce your `Young' player status. acc.RemoveYoungStatus( 502085 ); // You have chosen to renounce your `Young' player status.
} }
@ -95,4 +93,4 @@ namespace Server.Gumps
} }
} }
} }
} }

View file

@ -69,18 +69,8 @@ namespace Server.Engines.Events
public static void EventSink_PlayerDeath( PlayerDeathEventArgs e ) public static void EventSink_PlayerDeath( PlayerDeathEventArgs e )
{ {
if ( e.Mobile != null && !e.Mobile.Deleted ) /* not sure .. better safe than sorry? */ if ( e.Mobile is PlayerMobile player && !player.Deleted && m_Timer.Running && !m_DeathQueue.Contains( player ) && m_DeathQueue.Count < m_DeathQueueLimit )
{ m_DeathQueue.Add( player );
if ( e.Mobile is PlayerMobile )
{
PlayerMobile player = e.Mobile as PlayerMobile;
if ( m_Timer.Running && !m_DeathQueue.Contains( player ) && m_DeathQueue.Count < m_DeathQueueLimit )
{
m_DeathQueue.Add( player );
}
}
}
} }
private static void Clear_Callback() private static void Clear_Callback()

View file

@ -84,10 +84,8 @@ namespace Server.Items
if ( IsSigned || !IsChildOf( from.Backpack ) ) if ( IsSigned || !IsChildOf( from.Backpack ) )
return; return;
if ( targeted is Mobile ) if ( targeted is Mobile m )
{ {
Mobile m = (Mobile)targeted;
if ( !m.Alive ) if ( !m.Alive )
{ {
from.SendLocalizedMessage( 1152269 ); // That target is dead and even Cupid's arrow won't make them love you. from.SendLocalizedMessage( 1152269 ); // That target is dead and even Cupid's arrow won't make them love you.

View file

@ -134,9 +134,7 @@ namespace Server.Items
public void Fire( Mobile from ) public void Fire( Mobile from )
{ {
BaseRanged bow = from.Weapon as BaseRanged; if ( !(from.Weapon is BaseRanged bow) )
if ( bow == null )
{ {
SendLocalizedMessageTo( from, 500593 ); // You must practice with ranged weapons on this. SendLocalizedMessageTo( from, 500593 ); // You must practice with ranged weapons on this.
return; return;