Code:
    public override void OnSpeech( SpeechEventArgs e )
        {
            if ( SpeechLog.Enabled && NetState != null )
            {
                if ( m_SpeechLog == null )
                    m_SpeechLog = new SpeechLog();

                m_SpeechLog.Add( e.Mobile, e.Speech );

             //Added section spell fizzle
            if ( e.Mobile.Spell != null && e.Mobile.Spell.IsCasting)
            {
            ((Spell) Spell).DoFizzle();
            }
            //
        }


DoSpeech method:

Code:
        public override void DoSpeech(string text, int[] keywords, MessageType type, int hue)
        {
       
            if (Map != null)
            {
                if (Deleted || Commands.CommandSystem.Handle(this, text, type))
                    return;

                if (WopLock == null)
                    WopLock = new WopLock();

                if (!WopLock.CanWop(this, false))
                    return;

                int range = 15;

                switch (type)
                {
                    case MessageType.Regular:
                        SpeechHue = hue;
                        break;
                    case MessageType.Emote:
                        EmoteHue = hue;
                        break;
                    case MessageType.Whisper:
                        WhisperHue = hue;
                        range = 1;
                        break;
                    case MessageType.Yell:
                        YellHue = hue;
                        range = 18;
                        break;
                    default:
                        type = MessageType.Regular;
                        break;
                }

                SpeechEventArgs regArgs = new SpeechEventArgs(this, text, type, hue, keywords);

                EventSink.InvokeSpeech(regArgs);
                Region.OnSpeech(regArgs);
                OnSaid(regArgs);

                if (regArgs.Blocked)
                    return;

                text = regArgs.Speech;

                if (string.IsNullOrEmpty(text))
                    return;

                if (m_Hears == null)
                    m_Hears = new List<Mobile>();
                else if (m_Hears.Count > 0)
                    m_Hears.Clear();

                if (m_OnSpeech == null)
                    m_OnSpeech = new ArrayList();
                else if (m_OnSpeech.Count > 0)
                    m_OnSpeech.Clear();

                List<Mobile> hears = m_Hears;
                ArrayList onSpeech = m_OnSpeech;

                IPooledEnumerable eable = Map.GetObjectsInRange(Location, range);

                foreach (object o in eable)
                {
                    if (o is Mobile)
                    {
                        Mobile heard = (Mobile)o;

                        if ( (heard.CanSee(this) || ((!Alive || HiddenWithSpell))) && (!heard.HasFilter || InLOS(heard)))
                        {
                            if (heard.NetState != null)
                                hears.Add(heard);

                            if (heard.HandlesOnSpeech(this))
                                onSpeech.Add(heard);

                            for (int i = 0; i < heard.Items.Count; ++i)
                            {
                                Item item = heard.Items[i];

                                if (item.HandlesOnSpeech)
                                    onSpeech.Add(item);

                                if (item is Container)
                                    AddSpeechItemsFrom(onSpeech, (Container)item);
                            }
                        }
                    }
                    else if (o is Item)
                    {
                        if (((Item)o).HandlesOnSpeech)
                            onSpeech.Add(o);

                        if (o is Container)
                            AddSpeechItemsFrom(onSpeech, (Container)o);
                    }
                }

                eable.Free();

                object mutateContext = null;
                string mutatedText = text;
                SpeechEventArgs mutatedArgs = null;

                if (MutateSpeech(hears, ref mutatedText, ref mutateContext))
                    mutatedArgs = new SpeechEventArgs(this, mutatedText, type, hue, new int[0]);

           

                ProcessDelta();

                Packet regp = null;
                Packet mutp = null;
                Packet regp2 = null;
                Packet mutp2 = null;

          if (hue > 670 && hue <= 1001) //invalid hues
                    hue = 902;

            
                if (UseUnicodeSpeech)
                {
                    for (int i = 0; i < hears.Count; ++i)
                    {
                        Mobile heard = hears[i];
                        NetState ns = heard.NetState;

                        if (ns == null)
                            continue;

                        if (mutatedArgs == null || !CheckHearsMutatedSpeech(heard, mutateContext) || heard.Skills.SpiritSpeak.Value >= 100.0)
                        {
                            heard.OnSpeech(regArgs);

                            if (heard.CanSee(this))
                            {
                                if (regp == null)
                                    regp = Packet.Acquire(new UnicodeMessage(Serial, Body, type, hue, 3, Language, Name, text));

                                ns.Send(regp);
                            }
                            else
                            {
                                if (regp2 == null)
                                    regp2 = Packet.Acquire(new UnicodeMessage(Serial, Body, type, hue, 3, Language, Name, Name + ": " + text));

                                ns.Send(regp2);
                            }
                        }
                        else
                        {
                            heard.OnSpeech(mutatedArgs);

                            if (heard.CanSee(this))
                            {
                                if (mutp == null)
                                    mutp = Packet.Acquire(new UnicodeMessage(Serial, Body, type, hue, 3, Language, Name, mutatedText));

                                ns.Send(mutp);
                            }
                            else
                            {
                                if (mutp2 == null)
                                    mutp2 = Packet.Acquire((new UnicodeMessage(Serial, Body, type, hue, 3, Language, Name, Name + ": " + mutatedText)));

                                ns.Send(mutp2);
                            }

                            heard.SendSound(Utility.RandomMinMax(382, 385));
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < hears.Count; ++i)
                    {
                        Mobile heard = hears[i];
                        NetState ns = heard.NetState;

                        if (ns == null)
                            continue;

                        if (mutatedArgs == null || !CheckHearsMutatedSpeech(heard, mutateContext) || heard.Skills.SpiritSpeak.Value >= 100.0)
                        {
                            heard.OnSpeech(regArgs);

                            if (heard.CanSee(this))
                            {
                                if (regp == null)
                                    regp = Packet.Acquire(new AsciiMessage(Serial, Body, type, hue, 3, Name, text));

                                ns.Send(regp);
                            }
                            else
                            {
                                if (regp2 == null)
                                    regp2 = Packet.Acquire(new AsciiMessage(Serial, Body, type, hue, 3, Name, Name + ": " + text));

                                ns.Send(regp2);
                            }
                        }
                        else
                        {
                            heard.OnSpeech(mutatedArgs);

                            if (heard.CanSee(this))
                            {
                                if (mutp == null)
                                    mutp = Packet.Acquire(new AsciiMessage(Serial, Body, type, hue, 3, Name, mutatedText));

                                ns.Send(mutp);
                            }
                            else
                            {
                                if (mutp2 == null)
                                    mutp2 = Packet.Acquire((new AsciiMessage(Serial, Body, type, hue, 3, Name, Name + ": " + mutatedText)));

                                ns.Send(mutp2);
                            }

                            heard.SendSound(Utility.RandomMinMax(382, 385));
                        }
                    }
                }

                Packet.Release(regp);
                Packet.Release(mutp);

                if (onSpeech.Count > 1)
                    onSpeech.Sort(LocationComparer.GetInstance(this));

                for (int i = 0; i < onSpeech.Count; ++i)
                {
                    object obj = onSpeech[i];

                    if (obj is Mobile)
                    {
                        Mobile heard = (Mobile)obj;

                        if (mutatedArgs == null || !CheckHearsMutatedSpeech(heard, mutateContext) || heard.Skills.SpiritSpeak.Value >= 100.0)
                            heard.OnSpeech(regArgs);
                        else
                            heard.OnSpeech(mutatedArgs);
                    }
                    else
                    {
                        Item item = (Item)obj;

                        item.OnSpeech(regArgs);
                    }
                }           
            }
        }


I dont know how it happened tbh there was 2 players hitting each other thats all, forgot to run in debug mode, my bad

crash log:

System.NullReferenceException: Object reference not set to an instance of an object.
at Server.Mobiles.PlayerMobile.OnSpeech(SpeechEventArgs e)
at Server.Mobiles.PlayerMobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue)
at Server.Engines.PartySystem.Chat3Guild.UnicodeSpeechChat3(NetState state, PacketReader pvSrc)
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)
 
Last edited:
This is the first time i see a crash due OnSpeech/DoSpeech method, i dont know what caused it. Very weird i haven touch that code in months and havent got any crash

It only crashed once. I added this to OnSpeech method:
Code:
    public override void OnSpeech( SpeechEventArgs e )
        {
            if ( SpeechLog.Enabled && NetState != null )
            {
                if ( m_SpeechLog == null )
                    m_SpeechLog = new SpeechLog();

                m_SpeechLog.Add( e.Mobile, e.Speech );
                //
          
            }
             PlayerMobile pm = e.Mobile as PlayerMobile; //ADDED at 29/09/2017 PlayerMobile pm = e.Mobile as PlayerMobile  due crash 28/09/2017
             if (pm == null)                             //ADDED at 29/09/2017  if (pm == null)                            due crash 28/09/2017
                 return;                                 //ADDED at 29/09/2017 return;                                     due crash 28/09/2017
             //Added section spell fizzle
            if (e.Mobile != null && e.Mobile.Spell != null && e.Mobile.Spell.IsCasting) //e.Mobile != null added, due crash 28/09/2017
            {
            ((Spell) Spell).DoFizzle();   //line 5747
            }
            //
        }

Crash log,im running in debug mode, the crash points to the next lines;

Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.Mobiles.PlayerMobile.OnSpeech(SpeechEventArgs e) in c:\Users\immd\Desktop\Uos\29-08-2017 CRASH on speech cofresfaccion\Scripts\Mobiles\PlayerMobile.cs:line 5747
at Server.Mobiles.PlayerMobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue) in c:\Users\immd\Desktop\Uos\29-08-2017 CRASH on speech cofresfaccion\Scripts\Mobiles\PlayerMobile.cs:line 3816
at Server.Engines.PartySystem.Chat3Guild.UnicodeSpeechChat3(NetState state, PacketReader pvSrc) in c:\Users\immd\Desktop\Uos\29-08-2017 CRASH on speech cofresfaccion\Scripts\KUSTOM\Government System\Knives Chat 3.0 Beta 9\General\Chat3Guild.cs:line 122
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)


OnSpeech method:
Code:
((Spell) Spell).DoFizzle();    ///line 5747

DoSpeechmethod:
Code:
 if (UseUnicodeSpeech)
                {
                    for (int i = 0; i < hears.Count; ++i)
                    {
                        Mobile heard = hears[i];
                        NetState ns = heard.NetState;

                        if (ns == null)
                            continue;

                        if (mutatedArgs == null || !CheckHearsMutatedSpeech(heard, mutateContext) || heard.Skills.SpiritSpeak.Value >= 100.0)
                        {
                            heard.OnSpeech(regArgs);  //line 3816

                            if (heard.CanSee(this))
                            {
                                if (regp == null)
                                    regp = Packet.Acquire(new UnicodeMessage(Serial, Body, type, hue, 3, Language, Name, text));

                                ns.Send(regp);
                            }
                            else
                            {
                                if (regp2 == null)
                                    regp2 = Packet.Acquire(new UnicodeMessage(Serial, Body, type, hue, 3, Language, Name, Name + ": " + text));

                                ns.Send(regp2);
                            }
                        }
                     
                }



Exception:
System.NullReferenceException: Object reference not set to an instance of an object.
at Server.Mobiles.PlayerMobile.OnSpeech(SpeechEventArgs e) in c:\Users\immd\Desktop\Uos\29-08-2017 CRASH on speech cofresfaccion\Scripts\Mobiles\PlayerMobile.cs:line 5747
at Server.Mobiles.PlayerMobile.DoSpeech(String text, Int32[] keywords, MessageType type, Int32 hue) in c:\Users\immd\Desktop\Uos\29-08-2017 CRASH on speech cofresfaccion\Scripts\Mobiles\PlayerMobile.cs:line 3816
at Server.Engines.PartySystem.Chat3Guild.UnicodeSpeechChat3(NetState state, PacketReader pvSrc) in c:\Users\immd\Desktop\Uos\29-08-2017 CRASH on speech cofresfaccion\Scripts\KUSTOM\Government System\Knives Chat 3.0 Beta 9\General\Chat3Guild.cs:line 122
at Server.Network.MessagePump.HandleReceive(NetState ns)
at Server.Network.MessagePump.Slice()
at Server.Core.Main(String[] args)

Is that line making the server crash?

Thans
 
replace this
Code:
             //Added section spell fizzle
            if (e.Mobile != null && e.Mobile.Spell != null && e.Mobile.Spell.IsCasting) //e.Mobile != null added, due crash 28/09/2017
            {
            	((Spell) Spell).DoFizzle();   //line 5747
            }
            //
with this
Code:
			// Added section spell fizzle
			if (pm.Spell != null && pm.Spell.IsCasting)
			{
				((Spell)pm.Spell).DoFizzle();
			}
			//
 
Back