From ba23b0af0a0fe092043248a9cd518629451c2f48 Mon Sep 17 00:00:00 2001 From: mark Date: Sun, 21 Jan 2007 02:58:17 +0000 Subject: [PATCH] additional generics, fixed retarded bug --- Scripts/Misc/InhumanSpeech.cs | 16 ++++++++-------- Scripts/Mobiles/Vendors/GenericBuy.cs | 3 +++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Scripts/Misc/InhumanSpeech.cs b/Scripts/Misc/InhumanSpeech.cs index 3764f5680..48ad49cc6 100644 --- a/Scripts/Misc/InhumanSpeech.cs +++ b/Scripts/Misc/InhumanSpeech.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Text; using Server; @@ -280,7 +279,7 @@ namespace Server.Misc private string[] m_Keywords; private string[] m_Responses; - private Hashtable m_KeywordHash; + private Dictionary m_KeywordHash; private int m_Hue; private int m_Sound; @@ -299,7 +298,7 @@ namespace Server.Misc set { m_Keywords = value; - m_KeywordHash = new Hashtable( m_Keywords.Length, StringComparer.OrdinalIgnoreCase ); + m_KeywordHash = new Dictionary( m_Keywords.Length, StringComparer.OrdinalIgnoreCase ); for ( int i = 0; i < m_Keywords.Length; ++i ) m_KeywordHash[m_Keywords[i]] = m_Keywords[i]; } @@ -402,12 +401,12 @@ namespace Server.Misc mob.Say( sentancesInEnglish[Utility.Random( sentancesInEnglish.Length )] ); } - private string GetRandomResponseWord( ArrayList keywordsFound ) + private string GetRandomResponseWord( List keywordsFound ) { int random = Utility.Random( keywordsFound.Count + m_Responses.Length ); if ( random < keywordsFound.Count ) - return (string)keywordsFound[random]; + return keywordsFound[random]; return m_Responses[random - keywordsFound.Count]; } @@ -430,11 +429,12 @@ namespace Server.Misc return false; string[] split = text.Split( ' ' ); - ArrayList keywordsFound = new ArrayList(); + List keywordsFound = new List(); for ( int i = 0; i < split.Length; ++i ) { - string keyword = (string) m_KeywordHash[split[i]]; + string keyword; + m_KeywordHash.TryGetValue( split[i], out keyword ); if ( keyword != null ) keywordsFound.Add( keyword ); @@ -447,7 +447,7 @@ namespace Server.Misc if ( Utility.RandomBool() ) responseWord = GetRandomResponseWord( keywordsFound ); else - responseWord = (string)keywordsFound[Utility.Random( keywordsFound.Count )]; + responseWord = keywordsFound[Utility.Random( keywordsFound.Count )]; string secondResponseWord = GetRandomResponseWord( keywordsFound ); diff --git a/Scripts/Mobiles/Vendors/GenericBuy.cs b/Scripts/Mobiles/Vendors/GenericBuy.cs index d3ff8ef4f..eea30f2fe 100644 --- a/Scripts/Mobiles/Vendors/GenericBuy.cs +++ b/Scripts/Mobiles/Vendors/GenericBuy.cs @@ -129,6 +129,9 @@ namespace Server.Mobiles public void DeleteDisplayEntity() { + if ( m_DisplayEntity == null ) + return; + m_DisplayEntity.Delete(); m_DisplayEntity = null; }