Skip to content

Commit

Permalink
Prevent accidental wallmounted_to_dir poisoning (#15810)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TheEt1234 authored Feb 18, 2025
1 parent f4bdf72 commit ef0219c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions builtin/common/item_s.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ local facedir_to_dir_map = {
1, 4, 3, 2,
}
function core.facedir_to_dir(facedir)
return facedir_to_dir[facedir_to_dir_map[facedir % 32]]
return vector.copy(facedir_to_dir[facedir_to_dir_map[facedir % 32]])
end

function core.dir_to_fourdir(dir)
Expand All @@ -110,7 +110,7 @@ function core.dir_to_fourdir(dir)
end

function core.fourdir_to_dir(fourdir)
return facedir_to_dir[facedir_to_dir_map[fourdir % 4]]
return vector.copy(facedir_to_dir[facedir_to_dir_map[fourdir % 4]])
end

function core.dir_to_wallmounted(dir)
Expand Down Expand Up @@ -147,7 +147,7 @@ local wallmounted_to_dir = {
vector.new( 0, -1, 0),
}
function core.wallmounted_to_dir(wallmounted)
return wallmounted_to_dir[wallmounted % 8]
return vector.copy(wallmounted_to_dir[wallmounted % 8])
end

function core.dir_to_yaw(dir)
Expand Down

0 comments on commit ef0219c

Please sign in to comment.