From f089103c2b121f8128abfd6cdf0bd3cfbeca4465 Mon Sep 17 00:00:00 2001 From: Debucquoy Anthony tonitch Date: Sat, 18 Jun 2022 02:09:58 +0200 Subject: Additional Y height checks (#5405) For redstone wire, block area bindings, and fire simulator. Co-authored-by: Tiger Wang --- src/Bindings/ManualBindings_BlockArea.cpp | 37 +++++-------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) (limited to 'src/Bindings/ManualBindings_BlockArea.cpp') diff --git a/src/Bindings/ManualBindings_BlockArea.cpp b/src/Bindings/ManualBindings_BlockArea.cpp index a53a7bebf..c363e082f 100644 --- a/src/Bindings/ManualBindings_BlockArea.cpp +++ b/src/Bindings/ManualBindings_BlockArea.cpp @@ -590,41 +590,14 @@ static int tolua_cBlockArea_Read(lua_State * a_LuaState) return L.ApiParamError("Invalid baDataTypes combination (%d)", dataTypes); } - // Check the coords, shift if needed: - bounds.Sort(); - if (bounds.p1.y < 0) + // Check the coords: + if (!cChunkDef::IsValidHeight(bounds.p1) || !cChunkDef::IsValidHeight(bounds.p2)) { - FLOGWARNING("cBlockArea:Read(): MinBlockY less than zero, adjusting to zero. Coords: {0} - {1}", - bounds.p1, bounds.p2 - ); - L.LogStackTrace(); - bounds.p1.y = 0; - } - else if (bounds.p1.y >= cChunkDef::Height) - { - FLOGWARNING("cBlockArea:Read(): MinBlockY more than chunk height, adjusting to chunk height. Coords: {0} - {1}", - bounds.p1, bounds.p2 - ); - L.LogStackTrace(); - bounds.p1.y = cChunkDef::Height - 1; - } - if (bounds.p2.y < 0) - { - FLOGWARNING("cBlockArea:Read(): MaxBlockY less than zero, adjusting to zero. Coords: {0} - {1}", - bounds.p1, bounds.p2 - ); - L.LogStackTrace(); - bounds.p2.y = 0; - } - else if (bounds.p2.y > cChunkDef::Height) - { - FLOGWARNING("cBlockArea:Read(): MaxBlockY more than chunk height, adjusting to chunk height. Coords: {0} - {1}", - bounds.p1, bounds.p2 - ); - L.LogStackTrace(); - bounds.p2.y = cChunkDef::Height; + return L.FApiParamError("Coordinates {0} - {1} exceed world bounds", bounds.p1, bounds.p2); } + bounds.Sort(); + // Do the actual read: L.Push(self->Read(*world, bounds, dataTypes)); return 1; -- cgit v1.2.3