[set_menu_item] and needs_select

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
mich
Translator
Posts: 134
Joined: November 11th, 2008, 8:54 am
Location: Italy

[set_menu_item] and needs_select

Post by mich »

I'm having trouble using a select event and needs_select in a [set_menu_item] in a multiplayer scenario (on wesnoth 1.7.6).
If I trigger a select event, then move the selected unit, and then right click and use the new menu voice, the select event doesn't trigger on the others clients causing oos. If I trigger the select event, then move another unit (that doesn't trigger the select event) and then right click, the select event works good on all the clients. Obviously, if I trigger the select event and then right click all works too.
Just want to know if this is normal (but probably yes). If yes, well, I just have to find a way to filter the possibility of right click only in safe cases.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: [set_menu_item] and needs_select

Post by Sapient »

congratulations, you found a bug.
this may be difficult to fix, however, because of the way this feature works.

When you move the unit and cannot undo the movement, then the "moveto" event has already been sent and synchronized on all clients.

Next, you use the menu item and then the game realizes it needs to sync that last "select" event as well, before it fires the menu item.

But it is already too late to send the last select event, because it would be sent out of order.

So this is a limitation of needs_select. :(

I can only think of one idea to fix it... The game may be able to send a select event at the new location of the unit, but this assumes two things: 1) that the unit wasn't killed since the time it was selected. And 2) that processing the select out of order with the moveto would not pose a concern. Probably, the engine should fire a new select event on the originating client at this new location *before* processing the menu item [command] block, so that the behavior of needs_select would be similar on all clients. Also, to alleviate problem #1, the game could hide all needs_select menu items if the last selected unit has been killed or removed from the gamemap.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
mich
Translator
Posts: 134
Joined: November 11th, 2008, 8:54 am
Location: Italy

Re: [set_menu_item] and needs_select

Post by mich »

I have thought of something like that and I understand that it will not be so easy to fix.
Well, for the moment I have filtered the menu item to appear only in safe cases.
Thanks for your answer.
Post Reply