]> git.lizzy.rs Git - minetest.git/commitdiff
Abort raycasts that go out-of-bounds (#12006)
authorsfan5 <sfan5@live.de>
Sun, 30 Jan 2022 20:31:18 +0000 (21:31 +0100)
committerGitHub <noreply@github.com>
Sun, 30 Jan 2022 20:31:18 +0000 (21:31 +0100)
src/environment.cpp

index 06f2b8bf9d9ad80892e13294fe11736ce1479fcf..b04f77557190d03bfae6830fd2a6d7883dfb2a9f 100644 (file)
@@ -169,6 +169,12 @@ void Environment::continueRaycast(RaycastState *state, PointedThing *result)
                        new_nodes.MaxEdge.Z = new_nodes.MinEdge.Z;
                }
 
+               if (new_nodes.MaxEdge.X == S16_MAX ||
+                       new_nodes.MaxEdge.Y == S16_MAX ||
+                       new_nodes.MaxEdge.Z == S16_MAX) {
+                       break; // About to go out of bounds
+               }
+
                // For each untested node
                for (s16 x = new_nodes.MinEdge.X; x <= new_nodes.MaxEdge.X; x++)
                for (s16 y = new_nodes.MinEdge.Y; y <= new_nodes.MaxEdge.Y; y++)