Merge lp:~hjd/widelands/assert-to-exception into lp:widelands

Proposed by Hans Joachim Desserud
Status: Merged
Merged at revision: 7224
Proposed branch: lp:~hjd/widelands/assert-to-exception
Merge into: lp:widelands
Diff against target: 22 lines (+2/-3)
1 file modified
src/wui/interactive_base.cc (+2/-3)
To merge this branch: bzr merge lp:~hjd/widelands/assert-to-exception
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+238824@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
SirVer (sirver) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
253OverlayManager::JobId InteractiveBase::show_work_area253OverlayManager::JobId InteractiveBase::show_work_area
254 (const WorkareaInfo & workarea_info, Widelands::Coords coords)254 (const WorkareaInfo & workarea_info, Widelands::Coords coords)
255{255{
256 uint8_t workareas_nrs = workarea_info.size();256 const uint8_t workareas_nrs = workarea_info.size();
257 WorkareaInfo::size_type wa_index;257 WorkareaInfo::size_type wa_index;
258 switch (workareas_nrs) {258 switch (workareas_nrs) {
259 case 0: return 0; // no workarea259 case 0: return 0; // no workarea
@@ -261,8 +261,7 @@
261 case 2: wa_index = 3; break;261 case 2: wa_index = 3; break;
262 case 3: wa_index = 0; break;262 case 3: wa_index = 0; break;
263 default:263 default:
264 wa_index = 0;264 throw wexception("Encountered unexpected WorkareaInfo size %i", workareas_nrs);
265 assert(false);
266 break;265 break;
267 }266 }
268 Widelands::Map & map = m_egbase.map();267 Widelands::Map & map = m_egbase.map();

Subscribers

People subscribed via source and target branches

to status/vote changes: