Skip to content

Fix bug that allowed banner capture at unlimited distance below the banner#970

Merged
LlmDl merged 1 commit intoTownyAdvanced:masterfrom
p3sto:master
May 26, 2025
Merged

Fix bug that allowed banner capture at unlimited distance below the banner#970
LlmDl merged 1 commit intoTownyAdvanced:masterfrom
p3sto:master

Conversation

@p3sto
Copy link
Copy Markdown
Contributor

@p3sto p3sto commented May 26, 2025

Description:

There has been an existing bug in SiegeWar that has gone unnoticed for quite a long time (about a year). The bug allows players to capture the banner at any height below the banner, completely ignoring the war.distances.banner_control_session_radius_blocks config setting. This PR aims to solve this bug by simplifying the vertical distance check and fixing the issue.

The Bug

The issue is with how the vertical distance check between the player and flag is calculated. Currently, the calculation for the vertical distance is calculated as follows:

    //Check vertical distance
		
    double yDistance = Math.sqrt(MathUtil.sqr(location1.getY()) - MathUtil.sqr(location2.getY()));
    if (yDistance > maxAllowedDistance)
       return false;

    return true;

If the player is below the flag, then this difference in their Y is negative producing a square root that is always NaN. When compared to any maxAllowedDistance (always false), the return is true allowing the check to incorrectly pass.


New Nodes/Commands/ConfigOptions:


Relevant Issue ticket:


  • I have tested this pull request for defects on a server.

By making this pull request, I represent that I have the right to waive copyright and related rights to my contribution, and agree that all copyright and related rights in my contributions are waived, and I acknowledge that the TownyAdvanced organization has the copyright to use and modify my contribution under the SiegeWar License for perpetuity.

@LlmDl LlmDl added this to the 2.19.3 milestone May 26, 2025
@LlmDl LlmDl merged commit 1d3a10a into TownyAdvanced:master May 26, 2025
@tlm9201
Copy link
Copy Markdown
Contributor

tlm9201 commented May 26, 2025

Wow 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants