← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1451147 into lp:widelands

 

TiborB has proposed merging lp:~widelands-dev/widelands/bug-1451147 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1451147 in widelands: "Game crashes when headquarters is taken over"
  https://bugs.launchpad.net/widelands/+bug/1451147

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1451147/+merge/258812

The table of players has a one line selected, but sometimes it wanted to select a non-existent line.

Now, it selects current player or first item in table (some games does not have a current player).
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1451147 into lp:widelands.
=== modified file 'src/wui/game_summary.cc'
--- src/wui/game_summary.cc	2015-03-21 14:11:39 +0000
+++ src/wui/game_summary.cc	2015-05-11 20:30:41 +0000
@@ -135,12 +135,16 @@
 	Widelands::Player* single_won = nullptr;
 	uint8_t team_won = 0;
 	InteractivePlayer* ipl = m_game.get_ipl();
+	//this defines a row to be selected, current player,
+	//if not then the first line
+	uint32_t current_player_position = 0;
 
 	for (uintptr_t i = 0; i < players_status.size(); i++) {
 		Widelands::PlayerEndStatus pes = players_status.at(i);
 		if (ipl && pes.player == ipl->player_number()) {
 			local_in_game = true;
 			local_won = pes.result == Widelands::PlayerEndResult::PLAYER_WON;
+			current_player_position = i;
 		}
 		Widelands::Player* p = m_game.get_player(pes.player);
 		UI::Table<uintptr_t const>::EntryRecord & te = m_players_table->add(i);
@@ -199,7 +203,7 @@
 	}
 	m_players_table->update();
 	if (!players_status.empty()) {
-		m_players_table->select(players_status.at(0).player);
+		m_players_table->select(current_player_position);
 	}
 	m_gametime_value->set_text(gametimestring(m_game.get_gametime()));
 }


Follow ups