Page 1 of 1

Stack Overflow when using Message Events component

Posted: Wed Feb 02, 2022 11:39 am
by mroshaw
Hi again! I've added a "Message Events" component to a quest object. I've configured as follows:
  • Required Sender: <None>
  • Required Target: <None>
  • Message: Quest State Changed
  • Parameter: my_quest_id
  • On Message (Message Args): Quest Object.OnMessage(MessageArgs messageArgs)
I have some code in a public method, "OnMessage", on the Quest Object, that does a switch on messageArgs.values[1], looking for QuestState.Active and QuestState.Successful. The code basically shows or hides the quest object on a minimap.

When I accept the quest, however, I get an exception - well, 7 exceptions all "stack overflow":

Code: Select all

Message System exception sending 'Quest State Changed'/'find_rexxars_family' to Rexxars Family (PixelCrushers.Wrappers.MessageEvents): The requested operation caused a stack overflow.
UnityEngine.Debug:LogError (object)
PixelCrushers.MessageSystem:SendMessageWithTarget (object,object,string,string,object[]) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Message System/MessageSystem.cs:358)
PixelCrushers.MessageSystem:SendMessage (object,string,PixelCrushers.StringField,object[]) (at Assets/Plugins/Pixel Crushers/Common/Scripts/Message System/MessageSystem.cs:454)
PixelCrushers.QuestMachine.QuestMachineMessages:QuestStateChanged (object,PixelCrushers.StringField,PixelCrushers.QuestMachine.QuestState) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Utility/QuestMachineMessages.cs:160)
PixelCrushers.QuestMachine.Quest:SetState (PixelCrushers.QuestMachine.QuestState,bool) (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest.cs:879)
PixelCrushers.QuestMachine.Quest:OnDestroy () (at Assets/Plugins/Pixel Crushers/Quest Machine/Scripts/Quest/Quest.cs:626)
If I disable the Message Events component, I don't get the exceptions thrown.

Any ideas?

Re: Stack Overflow when using Message Events component

Posted: Wed Feb 02, 2022 11:54 am
by mroshaw
Dammit! Totally my fault (again!). Instead of selecting "Quest Object.OnMessage" in the event handler, I'd selected "MessageEvents.OnMessage"! No wonder it caused a stack overflow, it was calling itself! :roll:

Re: Stack Overflow when using Message Events component

Posted: Wed Feb 02, 2022 12:00 pm
by mroshaw
Can I also just add, the Messaging System in Quest Machine is just absolutely brilliant. It is making the process of integrating quest behaviours an absolute breeze, and all without a line of code! I am loving Quest Machine, especially when I use it right!

Re: Stack Overflow when using Message Events component

Posted: Wed Feb 02, 2022 12:11 pm
by Tony Li
Thanks! Glad you like it.