← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1714681-multiplayer-tribe-team into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1714681-multiplayer-tribe-team into lp:widelands.

Commit message:
Always update MultiPlayerPlayerGroup when a NoteGameSettings::Action::kUser notification is received

This fixes a bug where players could still edit the tribe and team for a shared slot after moving away from it

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1714681 in widelands: "Player has access to other player's tribe & team during game setup"
  https://bugs.launchpad.net/widelands/+bug/1714681

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1714681-multiplayer-tribe-team/+merge/344875
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1714681-multiplayer-tribe-team into lp:widelands.
=== modified file 'src/wui/multiplayersetupgroup.cc'
--- src/wui/multiplayersetupgroup.cc	2018-04-07 16:59:00 +0000
+++ src/wui/multiplayersetupgroup.cc	2018-05-01 08:06:08 +0000
@@ -227,19 +227,23 @@
 
 		subscriber_ = Notifications::subscribe<NoteGameSettings>([this](
 		   const NoteGameSettings& note) {
-			const std::vector<PlayerSettings>& players = settings_->settings().players;
+			if (settings_->settings().players.empty()) {
+				// No map/savegame yet
+				return;
+			}
+
 			switch (note.action) {
 			case NoteGameSettings::Action::kMap:
 				// We don't care about map updates, since we receive enough notifications for the
 				// slots.
 				break;
+			case NoteGameSettings::Action::kUser:
+				// We might have moved away from a slot, so we need to update the previous slot too. Since we can't track the slots here, we just update everything.
+				update();
+				break;
 			default:
-				if (players.empty()) {
-					// No map/savegame yet
-					return;
-				}
 				if (id_ == note.position ||
-				    (id_ < players.size() && players.at(id_).state == PlayerSettings::State::kShared)) {
+					(id_ < settings_->settings().players.size() && settings_->settings().players.at(id_).state == PlayerSettings::State::kShared)) {
 					update();
 				}
 			}


Follow ups