-
Notifications
You must be signed in to change notification settings - Fork 112
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
Make Cannon respect srcPos on HaveFreeLineOfFire. #1852
Make Cannon respect srcPos on HaveFreeLineOfFire. #1852
Conversation
Looks good, but this reverts a part of ce4c51d from #891 which had a lot of discussion in it that I'm not sure anybody remembers. Maybe @KyleAnthonyShepherd is around to take a look? |
For what I could see it looks like changing srcPos will affect only lua code trying to set srcPos (calls through TryTarget will still use the muzzle as pointed at PR description) , and those can still use muzzlepos if they want (I suppose). Still, for sure it would be great to see any remarks from @KyleAnthonyShepherd, maybe he can point to other issues here. |
Ya, I can take a review this weekend :) |
Alright, this looks safe to me. I think I swapped CCannon::HaveFreeLineOfFire to use weaponMuzzlePos instead of srcPos when testing and implementing the trajectory fixes (to ensure I knew what coordinates were being used), but did not check to see if it was actually necessary. And, to make sure I have the context correct:
So this PR will fix that, and allow the Lua code to test "what-if" coordinates for cannons. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above comment, looks good to me
Work done
Details
I think all other weapons do this.
Looks safe since the only in-engine user is
HaveFreeLineOfFire(GetAimFromPos(preFire), tgtPos, trg)
at TryTarget. AndGetAimFromPos
for cannon is hardcoded to use weaponMuzzlePos anyways. (see Cannon.h).Could break lua api users (GetUnitWeaponHaveFreeLineOfFire) but I think those seem fine too (actually the fix is for them) since also using GetAimFromPos unless user wants a different srcPos.
Marking as "lua api" since afaics this only affects
Spring.GetUnitWeaponHaveFreeLineOfFire
.