← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1535065-random-map-id into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1535065-random-map-id into lp:widelands.

Commit message:
Fixed Island Mode on/off for random map generation. Added log output.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1535065 in widelands: "Editor crashes with random map regarding player positions + starting positions that are not viable"
  https://bugs.launchpad.net/widelands/+bug/1535065

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1535065-random-map-id/+merge/294379

This should help us track down the crashes in the attached bug.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1535065-random-map-id into lp:widelands.
=== modified file 'src/editor/ui_menus/main_menu_random_map.cc'
--- src/editor/ui_menus/main_menu_random_map.cc	2016-04-25 07:35:45 +0000
+++ src/editor/ui_menus/main_menu_random_map.cc	2016-05-11 14:31:37 +0000
@@ -27,6 +27,7 @@
 #include <boost/format.hpp>
 
 #include "base/i18n.h"
+#include "base/log.h"
 #include "base/wexception.h"
 #include "editor/editorinteractive.h"
 #include "editor/map_generator.h"
@@ -266,6 +267,9 @@
 	box_.add_space(margin_);
 	box_height += margin_;
 
+	island_mode_.changed.connect
+		(boost::bind(&MainMenuNewRandomMap::button_clicked, this, ButtonId::kIslandMode));
+
 	// ---------- Random map number edit ----------
 
 	map_number_box_.add(&map_number_label_, UI::Align::kLeft);
@@ -357,6 +361,8 @@
 		current_world_ %= world_descriptions_.size();
 		world_.set_title(world_descriptions_[current_world_].descname);
 		break;
+	case ButtonId::kIslandMode:
+		break;
 	case ButtonId::kNone:
 		// Make sure that all conditions are met
 		max_players_ =
@@ -456,6 +462,33 @@
 		g_options.pull_section("global").get_string("realname", pgettext("map_name", "Unknown")),
 		sstrm.str().c_str());
 	loader_ui.step(_("Generating random map…"));
+
+	log("============== Generating Map ==============\n");
+	log("ID:            %s\n", map_id_edit_.text().c_str());
+	log("Random number: %u\n", map_info.mapNumber);
+	log("Dimensions:    %d x %d\n", map_info.w, map_info.h);
+	log("Players:       %d\n", map_info.numPlayers);
+	log("World:         %s\n", map_info.world_name.c_str());
+	switch (map_info.resource_amount) {
+	case UniqueRandomMapInfo::ResourceAmount::raLow:
+		log("Resources:     low\n");
+		break;
+	case UniqueRandomMapInfo::ResourceAmount::raMedium:
+		log("Resources:     medium\n");
+		break;
+	case UniqueRandomMapInfo::ResourceAmount::raHigh:
+		log("Resources:     high\n");
+		break;
+	default:
+		NEVER_HERE();
+	}
+	log("Land: %0.2f%%  Water: %0.2f%%  Wasteland: %0.2f%%\n",
+	    map_info.landRatio, map_info.waterRatio, map_info.wastelandRatio);
+	if (map_info.islandMode) {
+		log("Using Island Mode\n");
+	}
+	log("\n");
+
 	gen.create_random_map();
 
 	egbase.postload     ();

=== modified file 'src/editor/ui_menus/main_menu_random_map.h'
--- src/editor/ui_menus/main_menu_random_map.h	2016-04-06 09:23:04 +0000
+++ src/editor/ui_menus/main_menu_random_map.h	2016-05-11 14:31:37 +0000
@@ -54,7 +54,8 @@
 		kLand,
 		kWasteland,
 		kResources,
-		kWorld
+		kWorld,
+		kIslandMode
 	};
 
 private:


Follow ups