← Back to team overview

widelands-dev team mailing list archive

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

 

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

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1533183 in widelands: "kNoResource crashes game when querying DBG info on empty field"
  https://bugs.launchpad.net/widelands/+bug/1533183

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

DBG window now prints "Resources: None" - if current resource is kNoResource
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1533183 into lp:widelands.
=== modified file 'src/wui/game_debug_ui.cc'
--- src/wui/game_debug_ui.cc	2015-11-29 09:43:15 +0000
+++ src/wui/game_debug_ui.cc	2016-01-14 20:07:54 +0000
@@ -358,14 +358,19 @@
 		}
 	}
 	{
-		Widelands::DescriptionIndex ridx = m_coords.field->get_resources();
-		int ramount = m_coords.field->get_resources_amount();
-		int initial_amount = m_coords.field->get_initial_res_amount();
-
-		str += (boost::format("Resource: %s\n")
-				  % ibase().egbase().world().get_resource(ridx)->name().c_str()).str();
-
-		str += (boost::format("  Amount: %i/%i\n") % ramount % initial_amount).str();
+		const Widelands::DescriptionIndex ridx = m_coords.field->get_resources();
+
+		if (ridx == Widelands::kNoResource) {
+			str += "Resource: None\n";
+		} else {
+			const int ramount = m_coords.field->get_resources_amount();
+			const int initial_amount = m_coords.field->get_initial_res_amount();
+
+			str += (boost::format("Resource: %s\n")
+					  % ibase().egbase().world().get_resource(ridx)->name().c_str()).str();
+
+			str += (boost::format("  Amount: %i/%i\n") % ramount % initial_amount).str();
+		}
 	}
 
 	m_ui_field.set_text(str.c_str());


Follow ups