-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix issue with position calculation in move function #4323
Conversation
Co-Authored-By: Taoprox <84152770+projectMWX@users.noreply.github.com>
This reverts commit c3eb78f.
Just to clarify, made this fix from my phone laying in bed. Was going to check to see if there was a magic method set anywhere and if so, why the addition isn't applying properly. But if not, Omarcopires is happy and tested with no problems. |
Co-Authored-By: Taoprox <84152770+projectMWX@users.noreply.github.com>
I correctly applied the fix, but now it's working as it should. |
Position.directionOffset is not a valid Position even with the z co-ord. The meta requires both sides of the addition to be Positions. And we can't create Position offsets i.e Position(-1, 0 0) as they require unsigned co-ordinates |
Have you even bothered to test the code? I wrote it from my phone laying in bed to help a dude on OTAcademy and to be quite honest, didn't want to be tagged into this PR or anything affiliated with TFS for this exact reason. As it stands, you can't create a Position with a negative value, it's that simple. The code I wrote for him fixes it. It's up to you to include it or create a separate metamethod. |
You can create them explicitly like 65535, y, z, if z is 0 then |
I see the logic, but definitely isn't working based on what I've seen. I don't have a copy of latest to test, but the reason it's gone un-noticed for this long is due to the fact that most stairs wont have a default south blocked tile. I think the lua fails and halts the script before the server can process the underflow/overflow, but it's only a guess. |
There is no checking in lua that would "halt" the execution, calls from lua go directly to C lua api, because By defining it like that you can see, how ugly this hack actually is. To be entirely honest about how this should be handled. TFS should have |
Co-authored-by: Taoprox <84152770+projectMWX@users.noreply.github.com>
Pull Request Prelude
Changes Proposed
This pull request fixes an issue with the move function that was causing incorrect position calculation. The issue was due to the use of the + operator to add a Position object to a directionOffset object, which was resulting in unexpected behavior. The correct behavior is to create a new Position object with the correct coordinates.
To fix the issue, the code has been modified to create a new Position object using the x and y values of the current position, and the x and y values of the directionOffset object. The z value is left unchanged since we're assuming the character is moving on the same floor.
This fix has been tested and verified to work correctly in a variety of scenarios.
Issues addressed:
Close #4316