Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Units Attacking from Transporter Use Wrong Tile Size #24

Closed
timfel opened this issue Nov 19, 2015 · 6 comments
Closed

Units Attacking from Transporter Use Wrong Tile Size #24

timfel opened this issue Nov 19, 2015 · 6 comments

Comments

@timfel
Copy link
Member

timfel commented Nov 19, 2015

Units attacking from a transporter seemingly use their own tile size to calculate whether the enemy is within range, rather than the container's tile size.

I changed the CUnit::MapDistanceTo function to use the container's tile size instead of the unit's own tile size if it is inside a container, but that didn't fix the issue with range not being calculated correctly.


Imported from Launchpad using lp2gh.

@timfel
Copy link
Member Author

timfel commented Nov 19, 2015

(by iddqd-mail)
Check, if this was fixed in rev.8959

@timfel
Copy link
Member Author

timfel commented Nov 19, 2015

(by andre-ng)
I tried out the fix, but unfortunately it seems that it didn't work :( I tried putting archers (range 4) in a garrisonable building of 4x4 tile size, and they could still only attack units to the south of the building that were adjacent to the building (meaning that the range is being counted without taking into account the building's larger tile size).

@timfel
Copy link
Member Author

timfel commented Nov 19, 2015

(by iddqd-mail)
Another fix in rev.8961, check, if that bug has been fixed.

@timfel
Copy link
Member Author

timfel commented Nov 19, 2015

(by andre-ng)
cybermind, thanks for your attention in trying to fix this bug. I tested the fix in revision 8961, and unfortunately it did not solve the issue. Everything happens exactly the same as before.

@timfel
Copy link
Member Author

timfel commented Nov 19, 2015

(by iddqd-mail)
Could you upload a test map or something to show this bug?

@timfel
Copy link
Member Author

timfel commented Nov 19, 2015

(by andre-ng)
I managed to pinpoint the reason for the bug. It was in the function MapDistanceTo(const CUnit &dst) in unit.h. Here is a fixed version of the function:

int MapDistanceTo(const CUnit &dst) const
{
    const CUnitType *distance_unit_type = Container ? Container->Type : Type;
    return MapDistanceBetweenTypes(*distance_unit_type, tilePos, *dst.Type, dst.tilePos);
}

I have tested it and can confirm this fix works.

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

No branches or pull requests

1 participant