-
Notifications
You must be signed in to change notification settings - Fork 104
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
Apply radar error to lua spatial queries. #1811
Apply radar error to lua spatial queries. #1811
Conversation
3b959ae
to
ec3183e
Compare
Looks like a large chunk of the PR are refactors (e.g. changing macros from |
Well, it's not really a refactor, it's just I need to get Anyways sure, I can split in two commits but it's going to be just a couple of those changing (literally 4 lines in total, 2 at the defines and 2 at GetUnitsInPlanes). ie, it's not a large part at all. I don't think I changed any other lines unless I really needed too due to the way I need to apply a solution. edit: already done: 0b35f6c |
Anyways, I'll explain the general idea: Before, we had tests like: spring/rts/Lua/LuaSyncedRead.cpp Lines 3069 to 3073 in 27c6bab
And then it would loop like: spring/rts/Lua/LuaSyncedRead.cpp Line 3086 in 27c6bab
Problem here, is in some cases (the ones actually looping enemy units) we need to get the error position. So, I'm taking pos out of those defines, so they assume spring/rts/Lua/LuaSyncedRead.cpp Lines 2936 to 2942 in 4960869
So, for example the start of the cylinder test becomes: spring/rts/Lua/LuaSyncedRead.cpp Lines 3124 to 3125 in 4960869
And the tests become (when doing just allies): spring/rts/Lua/LuaSyncedRead.cpp Line 3141 in 4960869
or (when enemies can appear in the loop): spring/rts/Lua/LuaSyncedRead.cpp Line 3143 in 4960869
And then we have the helper So, as in other similar fixes, we're enlarging the quadfield search to make sure we catch all radar drifted dots. And then in the test for distance we use the radar corrected position. That's basically it, it's just 4-5 functions with very similar code (imo most of that could be refactored into just one define since it's cloned code but just changing the spatial test). |
can use the already defined readAllyTeam.
4960869
to
4738d93
Compare
There you go: 0b35f6c |
Yes, I mean the lines that needed changing to apply the solution as well. There is a lot of this kind of preparation, and splitting it off into separate tiny commits makes it possible to quickly tell "yeah this is a no-op" from a reviewer PoV and be done with it while reducing the commit that contains the actual changes. As an exercise, here is a branch where I split this PR into chunks ideal from my PoV - all commits except the last one are trivially reviewable and can easily be shown not to affect logic, and that leaves the last one the smallest it can be: https://github.com/beyond-all-reason/spring/commits/refactoring-split-example/ I'm not necessarily asking to make PRs with this level of splitting, but I would generally be happy to get as much as possible out of the way and tiny no-logic-change chunks greatly speed this up. |
All right. For next time I know what to do then. Thanks for taking the time to make that branch! |
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.
Looks good, just minor nits
Co-authored-by: sprunk <spr.ng@o2.pl>
Can you get rid of these ugly macro defs? |
not really without a huge refactor, imo that should be left for a future PR |
Got it, not a problem. |
Work done
Considerations
I understand this might break backwards compatibility, but it could also not be the case (probably not, please read on :)).
I think it's worth it to review and maybe also review games using this to see if they actually will break (only if they tried to workaround the broken implementation... checked a bit and didn't see any cases, but it's possible there are some).
Even when working around previous behaviour, I think their code would still work, just be doing extra work for nothing.
Also, even if working around this in a breaking way, they will be better off by removing the work around, I guess that can be signalled by exposing the feature capability somehow, so games know engine already has the correct implementation and could prepare in advance.
In case we need to keep backwards compatibility I suppose this has to be controlled through a modinfo switch, or maybe just a new parameter for all those functions. Imo better modinfo since having a parameter just to make the function do the right thing seems a bit awkward.
Anyways let me know what you think is best.
Why?
This automatically fixes users of this functions, like for example bar's settarget circle selection.
The effect is similar to this (the video is from a previous PR, but pre and post situation is basically the same):
Before patch
After patch