← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~hjd/widelands/fixes into lp:widelands

 

Hans Joachim Desserud has proposed merging lp:~hjd/widelands/fixes into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~hjd/widelands/fixes/+merge/224333

Another variable whose value was unused (might have been added to silence the switch missing default case warning?)

Also converted a few foo.size() > 0 to !foo.empty(). Oh, and some style changes to improve readability in the same place. Could probably be improved further by splitting some of the things in the if-conditional into smaller methods if descriptive names can be found.
-- 
https://code.launchpad.net/~hjd/widelands/fixes/+merge/224333
Your team Widelands Developers is requested to review the proposed merge of lp:~hjd/widelands/fixes into lp:widelands.
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc	2014-06-21 10:24:12 +0000
+++ src/ai/defaultai.cc	2014-06-24 16:56:03 +0000
@@ -1266,9 +1266,10 @@
 					} else if (bo.inputs_.size() > 0) {
 						// to have two buildings from everything (intended for upgradeable buildings)
 						// but I do not know how to identify such buildings
-						if (bo.cnt_built_ == 1 and game().get_gametime() >
-						                        60 * 60 * 1000 and bo.desc->enhancements().size() >
-						                        0 and mines_.size() > 0) {
+						if (bo.cnt_built_ == 1
+						    and game().get_gametime() > 60 * 60 * 1000
+						    and !bo.desc->enhancements().empty()
+						    and !mines_.empty()) {
 							prio = max_preciousness + bulgarian_constant;
 						}
 						// if output is needed and there are no idle buildings
@@ -1438,7 +1439,7 @@
 		update_all_mineable_fields(gametime);
 		next_mine_construction_due_ = gametime + kIdleMineUpdateInterval;
 
-		if (mineable_fields.size() > 0) {
+		if (!mineable_fields.empty()) {
 
 			for (uint32_t i = 0; i < buildings.size() && productionsites.size() > 8; ++i) {
 				BuildingObserver& bo = buildings.at(i);
@@ -2225,11 +2226,11 @@
 				continue;
 
 			// forcing first upgrade
-			if ((en_bo.cnt_under_construction_ + en_bo.cnt_built_ + en_bo.unoccupied_) ==
-			    0 and(productionsite_observer.bo->cnt_built_ -
-			          productionsite_observer.bo->unoccupied_) >=
-			       1 and(game().get_gametime() - productionsite_observer.built_time_) >
-			       30 * 60 * 1000 and mines_.size() > 0) {
+			if ((en_bo.cnt_under_construction_ + en_bo.cnt_built_ + en_bo.unoccupied_) == 0
+			    and (productionsite_observer.bo->cnt_built_ -
+			          productionsite_observer.bo->unoccupied_) >= 1
+			    and (game().get_gametime() - productionsite_observer.built_time_) > 30 * 60 * 1000
+			    and !mines_.empty()) {
 				if (kUpgradeDebug)
 					log(" UPGRADE: upgrading (forcing as first) %12s at %3d x %3d: age %d min.\n",
 					    productionsite_observer.bo->name,

=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc	2014-06-14 19:36:03 +0000
+++ src/wui/interactive_base.cc	2014-06-24 16:56:03 +0000
@@ -265,7 +265,6 @@
 		case 2: wa_index = 3; break;
 		case 3: wa_index = 0; break;
 		default:
-		  wa_index = 0;
 		  assert(false);
 		  break;
 	}


Follow ups