Page 1 of 1

Calling updatePageTitle() from within onUpdateActionButtons()

Posted: 07 March 2021, 17:25
by SardaukarWI
I'm currently trying to call updatePageTitle() from within onUpdateActionButtons(). But it appears that calling this function causes onUpdateActionButtons() to be called again. So I get into an infinite loop and that results in a stack overflow. Now before I go and set a flag to simply ignore this second call, I wanted to ask if there was a better way to handle this?

The game I'm working on has many unique cards that players will need to react to and what they need to do is different for each card. Instead of having dozens of different states on the server, I am having a single state for "cardPlayed" which passes down which card was played as an arg. Then the client can put up a unique "descriptionmyturn" message instructing the player what they need to do to respond to it. onUpdateActionButtons() is called for each active player in this mutipleactivestate, so this seems to be the appropriate place to set the title message.

Thanks for your feedback.

Re: Calling updatePageTitle() from within onUpdateActionButtons()

Posted: 09 March 2021, 19:56
by RavingWanderer
I ended up using a flag to prevent this.

Re: Calling updatePageTitle() from within onUpdateActionButtons()

Posted: 10 March 2021, 15:01
by SardaukarWI
That's what I ended up doing as well. I was hoping there was something I was missing or was undocumented.

Re: Calling updatePageTitle() from within onUpdateActionButtons()

Posted: 10 March 2021, 17:29
by Benoit314
You could also do a client state transition with a different title.
It would call onUpdateActionButtons() again, but on the client state.
It would be my way to go if you interface changes slightly depending on the different titles (different actions buttons or things you can select).