Stack Overflow when using Message Events component

Announcements, support questions, and discussion for Quest Machine.
Post Reply
mroshaw
Posts: 96
Joined: Wed Jan 19, 2022 4:10 am

Stack Overflow when using Message Events component

Post 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?
mroshaw
Posts: 96
Joined: Wed Jan 19, 2022 4:10 am

Re: Stack Overflow when using Message Events component

Post 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:
mroshaw
Posts: 96
Joined: Wed Jan 19, 2022 4:10 am

Re: Stack Overflow when using Message Events component

Post 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!
User avatar
Tony Li
Posts: 21928
Joined: Thu Jul 18, 2013 1:27 pm

Re: Stack Overflow when using Message Events component

Post by Tony Li »

Thanks! Glad you like it.
Post Reply