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

Prevent accidental wallmounted_to_dir poisoning by mods #15810

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

TheEt1234
Copy link
Contributor

@TheEt1234 TheEt1234 commented Feb 18, 2025

  • Goal of the PR

I'll copy paste the commit's description (but slightly edited to correct things):

Prior to this commit, if you used a function like core.wallmounted_to_dir, and modified its output, it would modify all of the output in the future

So, something like this:

local v = core.wallmounted_to_dir(0)
v.y = v.y + 1
core.debug(v:to_string()) -- result: (0, 2, 0)
local v2 = core.wallmounted_to_dir(0)
core.debug(v2:to_string()) -- result: (0, 2, 0)

This would result in some bugs that are really hard to catch if you don't know this undocumented behavior


Now that i'm writing this i realize i made an error in the commit description, line 9 of the commit description was supposed to have result: (0, 2, 0) not result: (0, 1, 0), and in line 10 i have put core.get_wallmounted_to_dir(0) when i should've put core.wallmounted_to_dir(0), i'm never making commit descriptions again

I don't know how to change the commit message description, besides just making a new fork and PR, is this a problem?


i think i just experienced possibly the weirdest engine bug ever?
`core.wallmounted_to_dir(1)` for some reason wasn't `vector.new(0,-1,0)` but was `vector.new(0,1,0)` instead, 

it starts to happen completely randomly

(i was completely clueless about it back then)

To do

This PR is Ready for Review.

How to test

local v = core.wallmounted_to_dir(0)
v.y = v.y + 1
local v2 = core.wallmounted_to_dir(0)
assert(v2.y == 1, "test failed") 

Prior to this commit, if you used a function like `core.wallmounted_to_dir`, and modified its output, it would modify all of the output in the future

So, something like this:
```lua
local v = core.wallmounted_to_dir(0)
v.y = v.y + 1
core.debug(v:to_string()) -- result: (0, 1, 0)
local v2 = core.get_wallmounted_to_dir(0)
core.debug(v2:to_string()) -- result: (0, 2, 0)
```

This would result in some bugs that are really hard to catch if you don't know this undocumented behavior
@sfan5 sfan5 added Bugfix 🐛 PRs that fix a bug @ Builtin labels Feb 18, 2025
@sfan5 sfan5 changed the title Prevent accidental cache poisoning by mods Prevent accidental wallmounted_to_dir poisoning by mods Feb 18, 2025
@sfan5
Copy link
Collaborator

sfan5 commented Feb 18, 2025

I don't know how to change the commit message description, besides just making a new fork and PR, is this a problem?

It's possible to edit commits in-place, but we can also just strip the description upon merging.
IMO there is no need for the commit description to be that verbose anyway since interested people can just look up the PR a commit came from.

@sfan5 sfan5 merged commit ef0219c into luanti-org:master Feb 18, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants