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
This commit is contained in:
parent
2431b077cd
commit
211cec621e
@ -1898,7 +1898,7 @@ return
|
|||||||
Type = "boolean",
|
Type = "boolean",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Notes = "Writes the area into World at the specified coords, returns true if successful. baTypes and baMetas are written.",
|
Notes = "Writes the area into World at the specified coords, returns true if successful. All present data types are written.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Params =
|
Params =
|
||||||
@ -1952,7 +1952,7 @@ return
|
|||||||
Type = "boolean",
|
Type = "boolean",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Notes = "Writes the area into World at the specified coords, returns true if successful. baTypes and baMetas are written.",
|
Notes = "Writes the area into World at the specified coords, returns true if successful. All present data types are written.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Params =
|
Params =
|
||||||
|
@ -700,20 +700,23 @@ static int tolua_cBlockArea_Write(lua_State * a_LuaState)
|
|||||||
|
|
||||||
// Check and get the overloaded params:
|
// Check and get the overloaded params:
|
||||||
Vector3i coords;
|
Vector3i coords;
|
||||||
int dataTypes = cBlockArea::baTypes | cBlockArea::baMetas | cBlockArea::baBlockEntities;
|
int dataTypes = 0;
|
||||||
auto dataTypesIdx = readVector3iOverloadParams(L, 3, coords, "coords");
|
auto dataTypesIdx = readVector3iOverloadParams(L, 3, coords, "coords");
|
||||||
L.GetStackValues(dataTypesIdx, dataTypes);
|
auto HasDataTypes = L.GetStackValues(dataTypesIdx, dataTypes);
|
||||||
|
|
||||||
// Check the dataType parameter validity:
|
// Check the dataType parameter validity:
|
||||||
if (!cBlockArea::IsValidDataTypeCombination(dataTypes))
|
if (HasDataTypes)
|
||||||
{
|
{
|
||||||
return L.ApiParamError("Invalid datatype combination (%d).", dataTypes);
|
if (!cBlockArea::IsValidDataTypeCombination(dataTypes))
|
||||||
}
|
{
|
||||||
if ((self->GetDataTypes() & dataTypes) != dataTypes)
|
return L.ApiParamError("Invalid datatype combination (%d).", dataTypes);
|
||||||
{
|
}
|
||||||
return L.ApiParamError("Requesting datatypes not present in the cBlockArea. Got only 0x%02x, requested 0x%02x",
|
if ((self->GetDataTypes() & dataTypes) != dataTypes)
|
||||||
self->GetDataTypes(), 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:
|
// Check and adjust the coord params:
|
||||||
@ -735,7 +738,14 @@ static int tolua_cBlockArea_Write(lua_State * a_LuaState)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do the actual write:
|
// 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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,11 +120,27 @@ public:
|
|||||||
|
|
||||||
/** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all.
|
/** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all.
|
||||||
Doesn't wake up the simulators. */
|
Doesn't wake up the simulators. */
|
||||||
bool Write(cForEachChunkProvider & a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes = baTypes | baMetas | baBlockEntities);
|
bool Write(cForEachChunkProvider & a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes);
|
||||||
|
|
||||||
/** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all.
|
/** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all.
|
||||||
Doesn't wake up the simulators. */
|
Doesn't wake up the simulators. */
|
||||||
bool Write(cForEachChunkProvider & a_ForEachChunkProvider, const Vector3i & a_MinCoords, int a_DataTypes = baTypes | baMetas | baBlockEntities);
|
bool Write(cForEachChunkProvider & a_ForEachChunkProvider, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ)
|
||||||
|
{
|
||||||
|
// Write all available data
|
||||||
|
return Write(a_ForEachChunkProvider, a_MinBlockX, a_MinBlockY, a_MinBlockZ, GetDataTypes());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all.
|
||||||
|
Doesn't wake up the simulators. */
|
||||||
|
bool Write(cForEachChunkProvider & a_ForEachChunkProvider, const Vector3i & a_MinCoords, int a_DataTypes);
|
||||||
|
|
||||||
|
/** Writes the area back into cWorld at the coords specified. Returns true if successful in all chunks, false if only partially / not at all.
|
||||||
|
Doesn't wake up the simulators. */
|
||||||
|
bool Write(cForEachChunkProvider & a_ForEachChunkProvider, const Vector3i & a_MinCoords)
|
||||||
|
{
|
||||||
|
// Write all available data
|
||||||
|
return Write(a_ForEachChunkProvider, a_MinCoords.x, a_MinCoords.y, a_MinCoords.z, GetDataTypes());
|
||||||
|
}
|
||||||
|
|
||||||
// tolua_begin
|
// tolua_begin
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user