← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug1504366 into lp:widelands

 

Jens Beyer has proposed merging lp:~widelands-dev/widelands/bug1504366 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1504366 in widelands: "editor crashes unexpectedly"
  https://bugs.launchpad.net/widelands/+bug/1504366

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug1504366/+merge/273995

Fix the crash, and by the way, replace the 99 as loop boundary by the MAX_PLAYERS define used everywhere else.

For me it works... but as usual, I'm not a C++ programmer yet ^^ so please check well.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug1504366 into lp:widelands.
=== modified file 'src/editor/ui_menus/editor_player_menu.cc'
--- src/editor/ui_menus/editor_player_menu.cc	2015-09-08 07:16:17 +0000
+++ src/editor/ui_menus/editor_player_menu.cc	2015-10-09 15:28:49 +0000
@@ -126,7 +126,7 @@
 	Widelands::Map & map = eia().egbase().map();
 	Widelands::PlayerNumber const nr_players = map.get_nrplayers();
 	{
-		assert(nr_players <= 99); //  2 decimal digits
+		assert(nr_players <= MAX_PLAYERS); //  2 decimal digits
 		char text[3];
 		if (char const nr_players_10 = nr_players / 10) {
 			text[0] = '0' + nr_players_10;
@@ -176,12 +176,12 @@
 
 		// Get/Set (localized) tribe names
 		if (map.get_scenario_player_tribe(p) != UNDEFINED_TRIBE_NAME) {
-			m_selected_tribes[p] = map.get_scenario_player_tribe(p);
+			m_selected_tribes[p - 1] = map.get_scenario_player_tribe(p);
 		} else {
-			m_selected_tribes[p] = m_tribenames[0];
-			map.set_scenario_player_tribe(p, m_selected_tribes[p]);
+			m_selected_tribes[p - 1] = m_tribenames[0];
+			map.set_scenario_player_tribe(p, m_selected_tribes[p - 1]);
 		}
-		m_plr_set_tribes_buts[p - 1]->set_title(m_tribe_descnames.find(m_selected_tribes[p])->second);
+		m_plr_set_tribes_buts[p - 1]->set_title(m_tribe_descnames.find(m_selected_tribes[p - 1])->second);
 
 		// Set default AI and closeable to false (always default - should be changed by hand)
 		map.set_scenario_player_ai(p, "");


Follow ups