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

Proposed by TiborB
Status: Merged
Merged at revision: 8912
Proposed branch: lp:~widelands-dev/widelands/bug-1800818
Merge into: lp:widelands
Diff against target: 23 lines (+13/-0)
1 file modified
src/ai/defaultai.cc (+13/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1800818
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+358368@code.launchpad.net

Commit message

When An AI finds that it has more than one barracks, it will disassemble the additional barracks. Should happen only after taking over from a human player.

To post a comment you must log in.
Revision history for this message
GunChleoc (gunchleoc) wrote :

Code LGTM, not tested yet

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ai/defaultai.cc'
2--- src/ai/defaultai.cc 2018-10-12 10:02:20 +0000
3+++ src/ai/defaultai.cc 2018-11-06 10:30:11 +0000
4@@ -4278,6 +4278,19 @@
5
6 // Barracks
7 if (site.bo->is(BuildingAttribute::kBarracks)) {
8+ // If we somehow have more than one barracks we will dismantle current one
9+ if (site.bo->total_count() > 1) {
10+ 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",
11+ player_number(), site.bo->total_count(), site.site->get_position().x, site.site->get_position().y);
12+ if (connected_to_wh) {
13+ game().send_player_dismantle(*site.site);
14+ } else {
15+ game().send_player_bulldoze(*site.site);
16+ }
17+ return true;
18+ }
19+
20+
21 assert(site.bo->total_count() == 1);
22 for (auto& queue : site.site->inputqueues()) {
23 if (queue->get_max_fill() > 4) {

Subscribers

People subscribed via source and target branches

to status/vote changes: