Hans Joachim Desserud has proposed merging 
lp:~hjd/widelands/assert-to-exception into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~hjd/widelands/assert-to-exception/+merge/238824

As mentioned, turn this assert into an exception so that it will also work with 
release builds and resolve unused assignment issue.

Btw, this seems rather small and independent so I believe it can be refactored 
into a separate method getWareInfoIndex(workarea_info.size()). However, 
::size_type seems to take whichever class/type the map use so I don't know what 
the return class should be for this new method.
-- 
https://code.launchpad.net/~hjd/widelands/assert-to-exception/+merge/238824
Your team Widelands Developers is requested to review the proposed merge of 
lp:~hjd/widelands/assert-to-exception into lp:widelands.
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc	2014-10-11 16:03:18 +0000
+++ src/wui/interactive_base.cc	2014-10-19 16:26:43 +0000
@@ -253,7 +253,7 @@
 OverlayManager::JobId InteractiveBase::show_work_area
 	(const WorkareaInfo & workarea_info, Widelands::Coords coords)
 {
-	uint8_t workareas_nrs = workarea_info.size();
+	const uint8_t workareas_nrs = workarea_info.size();
 	WorkareaInfo::size_type wa_index;
 	switch (workareas_nrs) {
 		case 0: return 0; // no workarea
@@ -261,8 +261,7 @@
 		case 2: wa_index = 3; break;
 		case 3: wa_index = 0; break;
 		default:
-			wa_index = 0;
-			assert(false);
+			throw wexception("Encountered unexpected WorkareaInfo size %i", workareas_nrs);
 			break;
 	}
 	Widelands::Map & map = m_egbase.map();

_______________________________________________
Mailing list: https://launchpad.net/~widelands-dev
Post to     : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to