From c0c4bf3314d161339de4de6abe113691d25b4187 Mon Sep 17 00:00:00 2001 From: gfgtdf Date: Thu, 22 Dec 2016 22:07:11 +0100 Subject: [PATCH] deprecate needs_select=yes The behaviour of needs_select=yes event is rather strange and hard to understand: When a menu items with needs_select=yes it clicked, it first fires the previous select event again but this time in a synced context, so that the select event was fires 2 times total on the playing client and one time at the other clients. It also the breaks the specification in the wiki that select events are not fired in synced contexts. Also it might happen that the unit stands no longer at the position from where it was selected because it has moved causing unexpected behaviour in this case. The new way to let other clients know the currents selected unit is the [sync_variable] tag which was added in 1.13. --- src/game_events/menu_item.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/game_events/menu_item.cpp b/src/game_events/menu_item.cpp index be6e250aac5c..747976fa5560 100644 --- a/src/game_events/menu_item.cpp +++ b/src/game_events/menu_item.cpp @@ -93,6 +93,9 @@ wml_menu_item::wml_menu_item(const std::string& id, const config & cfg) : use_wml_menu_(cfg["use_hotkey"].str() != "only"), is_synced_(cfg["synced"].to_bool(true)) { + if(needs_select_) { + ERR_NG << "needs_select=yes is deprecated\n"; + } } /** @@ -309,8 +312,10 @@ void wml_menu_item::update(const vconfig & vcfg) hotkey_updated = true; } - if ( vcfg.has_attribute("needs_select") ) + if ( vcfg.has_attribute("needs_select") ) { + ERR_NG << "needs_select=yes is deprecated\n"; needs_select_ = vcfg["needs_select"].to_bool(); + } if ( vcfg.has_attribute("synced") ) is_synced_ = vcfg["synced"].to_bool(true);