From 51345e02a05455096acfc12115c2980f430d20e4 Mon Sep 17 00:00:00 2001 From: krrios Date: Sun, 27 Aug 2006 20:39:11 +0000 Subject: [PATCH] Faction.ClearSkillLoss now returns true or false indicating if the player was actually under skill loss Refactored some gump methods to account for the respective core changes --- Scripts/Engines/Factions/Core/Faction.cs | 9 +++++--- Scripts/Engines/Factions/Gumps/FactionGump.cs | 13 +----------- Scripts/Items/Skill Items/Magical/Runebook.cs | 16 +++++--------- Scripts/Mobiles/PlayerMobile.cs | 21 ++++++------------- 4 files changed, 18 insertions(+), 41 deletions(-) diff --git a/Scripts/Engines/Factions/Core/Faction.cs b/Scripts/Engines/Factions/Core/Faction.cs index e8fee9c48..83ac2f7f4 100644 --- a/Scripts/Engines/Factions/Core/Faction.cs +++ b/Scripts/Engines/Factions/Core/Faction.cs @@ -900,12 +900,13 @@ namespace Server.Factions ClearSkillLoss( (Mobile) state ); } - public static void ClearSkillLoss( Mobile mob ) + public static bool ClearSkillLoss( Mobile mob ) { SkillLossContext context = (SkillLossContext)m_SkillLoss[mob]; - if ( context == null ) - return; + if ( context == null ) { + return false; + } m_SkillLoss.Remove( mob ); @@ -915,6 +916,8 @@ namespace Server.Factions mob.RemoveSkillMod( (SkillMod) mods[i] ); context.m_Timer.Stop(); + + return true; } #endregion diff --git a/Scripts/Engines/Factions/Gumps/FactionGump.cs b/Scripts/Engines/Factions/Gumps/FactionGump.cs index d08b96a55..6256d1c3a 100644 --- a/Scripts/Engines/Factions/Gumps/FactionGump.cs +++ b/Scripts/Engines/Factions/Gumps/FactionGump.cs @@ -33,18 +33,7 @@ namespace Server.Factions public static bool Exists( Mobile mob ) { - NetState ns = mob.NetState; - - if ( ns == null ) - return false; - - for ( int i = 0; i < ns.Gumps.Count; ++i ) - { - if ( ns.Gumps[i] is FactionGump ) - return true; - } - - return false; + return ( mob.FindGump( typeof( FactionGump ) ) != null ); } public void AddHtmlText( int x, int y, int width, int height, TextDefinition text, bool back, bool scroll ) diff --git a/Scripts/Items/Skill Items/Magical/Runebook.cs b/Scripts/Items/Skill Items/Magical/Runebook.cs index 9dbd4adc4..b9a7a3495 100644 --- a/Scripts/Items/Skill Items/Magical/Runebook.cs +++ b/Scripts/Items/Skill Items/Magical/Runebook.cs @@ -237,19 +237,13 @@ namespace Server.Items { NetState ns = toCheck.NetState; - if ( ns == null ) - return false; + if ( ns != null ) { + foreach ( Gump gump in ns.Gumps ) { + RunebookGump bookGump = gump as RunebookGump; - List gumps = ns.Gumps; - - for ( int i = 0; i < gumps.Count; ++i ) - { - if ( gumps[i] is RunebookGump ) - { - RunebookGump gump = (RunebookGump)gumps[i]; - - if ( gump.Book == this ) + if ( bookGump != null && bookGump.Book == this ) { return true; + } } } diff --git a/Scripts/Mobiles/PlayerMobile.cs b/Scripts/Mobiles/PlayerMobile.cs index 44e9574eb..b3910ec82 100644 --- a/Scripts/Mobiles/PlayerMobile.cs +++ b/Scripts/Mobiles/PlayerMobile.cs @@ -1079,21 +1079,12 @@ namespace Server.Mobiles if ( ns != null ) { - List gumps = ns.Gumps; - - for ( int i = 0; i < gumps.Count; ++i ) - { - if ( gumps[i] is ResurrectGump ) - { - if ( Alive ) - { - CloseGump( typeof( ResurrectGump ) ); - } - else - { - SendLocalizedMessage( 500111 ); // You are frozen and cannot move. - return false; - } + if ( HasGump( typeof( ResurrectGump ) ) ) { + if ( Alive ) { + CloseGump( typeof( ResurrectGump ) ); + } else { + SendLocalizedMessage( 500111 ); // You are frozen and cannot move. + return false; } } }