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

Proposed by TiborB
Status: Merged
Merged at revision: 7461
Proposed branch: lp:~widelands-dev/widelands/bug-1451147
Merge into: lp:widelands
Diff against target: 29 lines (+5/-1)
1 file modified
src/wui/game_summary.cc (+5/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1451147
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+258812@code.launchpad.net

Description of the change

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).

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

LGTM :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/wui/game_summary.cc'
2--- src/wui/game_summary.cc 2015-03-21 14:11:39 +0000
3+++ src/wui/game_summary.cc 2015-05-12 20:07:08 +0000
4@@ -135,12 +135,16 @@
5 Widelands::Player* single_won = nullptr;
6 uint8_t team_won = 0;
7 InteractivePlayer* ipl = m_game.get_ipl();
8+ //this defines a row to be selected, current player,
9+ //if not then the first line
10+ uint32_t current_player_position = 0;
11
12 for (uintptr_t i = 0; i < players_status.size(); i++) {
13 Widelands::PlayerEndStatus pes = players_status.at(i);
14 if (ipl && pes.player == ipl->player_number()) {
15 local_in_game = true;
16 local_won = pes.result == Widelands::PlayerEndResult::PLAYER_WON;
17+ current_player_position = i;
18 }
19 Widelands::Player* p = m_game.get_player(pes.player);
20 UI::Table<uintptr_t const>::EntryRecord & te = m_players_table->add(i);
21@@ -199,7 +203,7 @@
22 }
23 m_players_table->update();
24 if (!players_status.empty()) {
25- m_players_table->select(players_status.at(0).player);
26+ m_players_table->select(current_player_position);
27 }
28 m_gametime_value->set_text(gametimestring(m_game.get_gametime()));
29 }