Merge lp:~widelands-dev/widelands/bug-impregnable-castles into lp:widelands

Proposed by Notabilis
Status: Merged
Merged at revision: 8706
Proposed branch: lp:~widelands-dev/widelands/bug-impregnable-castles
Merge into: lp:widelands
Diff against target: 20 lines (+9/-1)
1 file modified
src/wui/attack_box.cc (+9/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-impregnable-castles
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+345468@code.launchpad.net

Commit message

Checking for visibility of military building before permitting attack.

Description of the change

With big military buildings, i.e., castles, it can happen that only the left side of the building is in the visibility range of another player.
If an own military building is near, that player can open the attack window and select and order some soldiers to attack the castle. Only after ordering the attack the game checks whether the door of the building is visible. Since it isn't, no attack happens.
For the player this has the effect that an attack is ordered but is never executed. This branch does an additional visibility check when calculating the number of available soldiers for displaying the UI, returning 0 when the door is invisible and the attack command would fail later on.

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

Good catch!

Code LGTM, not tested

review: Approve
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 3509. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/378301859.
Appveyor build 3314. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_impregnable_castles-3314.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Did a bit of testing.

I think we should pull out functions here in the future - I have created a bug: https://bugs.launchpad.net/widelands/+bug/1771058

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/wui/attack_box.cc'
2--- src/wui/attack_box.cc 2018-05-13 07:15:39 +0000
3+++ src/wui/attack_box.cc 2018-05-13 07:57:07 +0000
4@@ -48,8 +48,16 @@
5 uint32_t AttackBox::get_max_attackers() {
6 assert(player_);
7
8- if (upcast(Building, building, map_.get_immovable(*node_coordinates_)))
9+ if (upcast(Building, building, map_.get_immovable(*node_coordinates_))) {
10+ if (player_->vision(
11+ map_.get_index(building->get_position(), map_.get_width())) <= 1) {
12+ // Player can't see the buildings door, so it can't be attacked
13+ // This is the same check as done later on in send_player_enemyflagaction()
14+ return 0;
15+ }
16+
17 return player_->find_attack_soldiers(building->base_flag());
18+ }
19 return 0;
20 }
21

Subscribers

People subscribed via source and target branches

to status/vote changes: