Fix crate math.

I forgot that -1 & 1 = 1 rather than 0 so all the bit math didn't work. But I can fix it with polynomial algebra! this is much better.
This commit is contained in:
Kistaro Windrider 2022-12-23 00:02:02 -08:00
parent 0fe3b1699f
commit 9d93f30426
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -502,11 +502,7 @@ function level:get_latch(dx,dy,px,py)
local dx1,dy1=-sgn0(dx),-sgn0(dy) local dx1,dy1=-sgn0(dx),-sgn0(dy)
if crate then if crate then
if crate.def & ( if crate.def & dy1*dy1*(2.5+1.5*dy1)+dx1*dx1*(5-3*dx1) ~= 0 then
dy1 >>> 15 |
(dy1 & 0x1) << 2 |
(dx1 & 0x8000) >>> 12 |
(dx1 & 0x1) << 1) ~= 0 then
return { return {
el="crate", el="crate",
dx=dx1,dy=dy1, dx=dx1,dy=dy1,