From 211cec621e5e23e0e3a9c5e0880ddea24b6418c3 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Thu, 19 Jul 2018 22:36:46 +0100 Subject: cBlockArea: Write all present data types by default (#4252) cBlockArea::Write now defaults to use GetDataTypes() instead of assuming all data types are present. Fixes cuberite/WorldEdit#130 --- src/Bindings/ManualBindings_BlockArea.cpp | 32 ++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'src/Bindings/ManualBindings_BlockArea.cpp') diff --git a/src/Bindings/ManualBindings_BlockArea.cpp b/src/Bindings/ManualBindings_BlockArea.cpp index 038c571ac..126b35386 100644 --- a/src/Bindings/ManualBindings_BlockArea.cpp +++ b/src/Bindings/ManualBindings_BlockArea.cpp @@ -700,20 +700,23 @@ static int tolua_cBlockArea_Write(lua_State * a_LuaState) // Check and get the overloaded params: Vector3i coords; - int dataTypes = cBlockArea::baTypes | cBlockArea::baMetas | cBlockArea::baBlockEntities; + int dataTypes = 0; auto dataTypesIdx = readVector3iOverloadParams(L, 3, coords, "coords"); - L.GetStackValues(dataTypesIdx, dataTypes); + auto HasDataTypes = L.GetStackValues(dataTypesIdx, dataTypes); // Check the dataType parameter validity: - if (!cBlockArea::IsValidDataTypeCombination(dataTypes)) + if (HasDataTypes) { - return L.ApiParamError("Invalid datatype combination (%d).", dataTypes); - } - if ((self->GetDataTypes() & dataTypes) != dataTypes) - { - return L.ApiParamError("Requesting datatypes not present in the cBlockArea. Got only 0x%02x, requested 0x%02x", - self->GetDataTypes(), dataTypes - ); + if (!cBlockArea::IsValidDataTypeCombination(dataTypes)) + { + return L.ApiParamError("Invalid datatype combination (%d).", dataTypes); + } + if ((self->GetDataTypes() & dataTypes) != dataTypes) + { + return L.ApiParamError("Requesting datatypes not present in the cBlockArea. Got only 0x%02x, requested 0x%02x", + self->GetDataTypes(), dataTypes + ); + } } // Check and adjust the coord params: @@ -735,7 +738,14 @@ static int tolua_cBlockArea_Write(lua_State * a_LuaState) } // Do the actual write: - L.Push(self->Write(*world, coords, dataTypes)); + if (HasDataTypes) + { + L.Push(self->Write(*world, coords, dataTypes)); + } + else + { + L.Push(self->Write(*world, coords)); + } return 1; } -- cgit v1.2.3