← Back to team overview

widelands-dev team mailing list archive

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

 

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

Commit message:
When IA finds that it has more than one barrack, it will disassemble abundant barracks. Should happen only after human player.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1800818 in widelands: "AI does not cope with two barracks after human player"
  https://bugs.launchpad.net/widelands/+bug/1800818

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1800818/+merge/358368
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1800818 into lp:widelands.
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc	2018-10-12 10:02:20 +0000
+++ src/ai/defaultai.cc	2018-11-06 10:30:11 +0000
@@ -4278,6 +4278,19 @@
 
 	// Barracks
 	if (site.bo->is(BuildingAttribute::kBarracks)) {
+		// If we somehow have more than one barracks we will dismantle current one
+		if (site.bo->total_count() > 1) {
+			log("%2d: We have %d barracks, that is not supported by AI and if caused by AI it is an error; dismantling the barracks at %3dx%3d\n",
+			player_number(), site.bo->total_count(), site.site->get_position().x, site.site->get_position().y);
+			if (connected_to_wh) {
+				game().send_player_dismantle(*site.site);
+			} else {
+				game().send_player_bulldoze(*site.site);
+			}
+			return true;
+		}
+
+
 		assert(site.bo->total_count() == 1);
 		for (auto& queue : site.site->inputqueues()) {
 			if (queue->get_max_fill() > 4) {


Follow ups