summaryrefslogtreecommitdiffstats
path: root/src/Bindings/ManualBindings_BlockArea.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2023-05-11 22:05:17 +0200
committerMattes D <github@xoft.cz>2023-05-16 23:50:37 +0200
commitc9522fb740200ccef6230cec452c48efb31e5394 (patch)
tree7e74d70699e13dd0a92444a1a0add7a3059ac7ca /src/Bindings/ManualBindings_BlockArea.cpp
parentTry a timeout for jobs. (diff)
downloadcuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.gz
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.bz2
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.lz
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.xz
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.tar.zst
cuberite-c9522fb740200ccef6230cec452c48efb31e5394.zip
Diffstat (limited to 'src/Bindings/ManualBindings_BlockArea.cpp')
-rw-r--r--src/Bindings/ManualBindings_BlockArea.cpp81
1 files changed, 42 insertions, 39 deletions
diff --git a/src/Bindings/ManualBindings_BlockArea.cpp b/src/Bindings/ManualBindings_BlockArea.cpp
index c363e082f..ed6309cee 100644
--- a/src/Bindings/ManualBindings_BlockArea.cpp
+++ b/src/Bindings/ManualBindings_BlockArea.cpp
@@ -52,9 +52,9 @@ static int DoWithXYZ(lua_State * tolua_S)
}
if (!(Self->*CoordCheckFn)(BlockX, BlockY, BlockZ))
{
- return L.FApiParamError("The provided coordinates ({0}) are not valid",
+ return L.ApiParamError(fmt::format(FMT_STRING("The provided coordinates ({0}) are not valid"),
Vector3i{BlockX, BlockY, BlockZ}
- );
+ ));
}
// Call the DoWith function:
@@ -134,7 +134,7 @@ static int readVector3iOverloadParams(cLuaState & a_LuaState, int a_StartParam,
// Assume the 3-number version:
if (!a_LuaState.GetStackValues(a_StartParam, a_Coords.x, a_Coords.y, a_Coords.z))
{
- return a_LuaState.ApiParamError("Cannot read the %s, expected 3 numbers", a_ParamName);
+ return a_LuaState.ApiParamError(fmt::format(FMT_STRING("Cannot read the {}, expected 3 numbers"), a_ParamName));
}
return a_StartParam + 3;
}
@@ -143,7 +143,7 @@ static int readVector3iOverloadParams(cLuaState & a_LuaState, int a_StartParam,
// Assume the Vector3i version:
if (!a_LuaState.GetStackValues(a_StartParam, a_Coords))
{
- return a_LuaState.ApiParamError("Cannot read the %s, expected a Vector3i instance", a_ParamName);
+ return a_LuaState.ApiParamError(fmt::format(FMT_STRING("Cannot read the {}, expected a Vector3i instance"), a_ParamName));
}
return a_StartParam + 1;
}
@@ -177,13 +177,13 @@ static int tolua_cBlockArea_Create(lua_State * a_LuaState)
L.GetStackValue(dataTypesIdx, dataTypes);
if (!cBlockArea::IsValidDataTypeCombination(dataTypes))
{
- return L.ApiParamError("Invalid combination of baDataTypes specified (%d)", dataTypes);
+ return L.ApiParamError(fmt::format(FMT_STRING("Invalid combination of baDataTypes specified (0x{:02x})"), dataTypes));
}
// Create the area:
if ((size.x <= 0) || (size.y <= 0) || (size.z <= 0))
{
- return L.FApiParamError("Invalid sizes, must be greater than zero, got {0}", size);
+ return L.ApiParamError(fmt::format(FMT_STRING("Invalid sizes, must be greater than zero, got {}"), size));
}
ASSERT(self != nullptr);
self->Create(size, dataTypes);
@@ -221,13 +221,13 @@ static int tolua_cBlockArea_FillRelCuboid(lua_State * a_LuaState)
bounds.Sort();
if (!(self->IsValidRelCoords(bounds.p1) && self->IsValidRelCoords(bounds.p2)))
{
- return L.FApiParamError(
- "The bounds ({0} - {1}) are out of range ({2} - {3})",
+ return L.ApiParamError(fmt::format(
+ FMT_STRING("The bounds ({0} - {1}) are out of range ({2} - {3})"),
bounds.p1,
bounds.p2,
Vector3i(0, 0, 0),
(self->GetSize() - Vector3i{1, 1, 1})
- );
+ ));
}
int dataTypes = cBlockArea::baTypes | cBlockArea::baMetas | cBlockArea::baBlockEntities;
BLOCKTYPE blockType;
@@ -239,7 +239,7 @@ static int tolua_cBlockArea_FillRelCuboid(lua_State * a_LuaState)
L.GetStackValues(nextIdx + 2, blockMeta, blockLight, blockSkyLight); // These values are optional
if (!cBlockArea::IsValidDataTypeCombination(dataTypes))
{
- return L.ApiParamError("Invalid baDataTypes combination (%d)", dataTypes);
+ return L.ApiParamError(fmt::format(FMT_STRING("Invalid baDataTypes combination (0x{:02x})"), dataTypes));
}
// Do the actual Fill:
@@ -275,9 +275,9 @@ static int tolua_cBlockArea_GetBlockTypeMeta(lua_State * a_LuaState)
readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidCoords(coords))
{
- return L.FApiParamError("Coords ({0}) out of range ({1} - {2})",
+ return L.ApiParamError(fmt::format(FMT_STRING("Coords ({0}) out of range ({1} - {2})"),
coords, self->GetOrigin(), self->GetOrigin() + self->GetSize() - Vector3i{1, 1, 1}
- );
+ ));
}
BLOCKTYPE blockType;
NIBBLETYPE blockMeta;
@@ -425,9 +425,9 @@ static int tolua_cBlockArea_GetRelBlockTypeMeta(lua_State * a_LuaState)
readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidRelCoords(coords))
{
- return L.FApiParamError("The coords ({0}) are out of range (max {1})",
+ return L.ApiParamError(fmt::format(FMT_STRING("The coords ({0}) are out of range (max {1})"),
coords, (self->GetSize() - Vector3i{1, 1, 1})
- );
+ ));
}
BLOCKTYPE blockType;
NIBBLETYPE blockMeta;
@@ -587,13 +587,13 @@ static int tolua_cBlockArea_Read(lua_State * a_LuaState)
L.GetStackValues(dataTypesIdx, dataTypes);
if (!cBlockArea::IsValidDataTypeCombination(dataTypes))
{
- return L.ApiParamError("Invalid baDataTypes combination (%d)", dataTypes);
+ return L.ApiParamError(fmt::format(FMT_STRING("Invalid baDataTypes combination (0x{:02x})"), dataTypes));
}
// Check the coords:
if (!cChunkDef::IsValidHeight(bounds.p1) || !cChunkDef::IsValidHeight(bounds.p2))
{
- return L.FApiParamError("Coordinates {0} - {1} exceed world bounds", bounds.p1, bounds.p2);
+ return L.ApiParamError(fmt::format(FMT_STRING("Coordinates {0} - {1} exceed world bounds"), bounds.p1, bounds.p2));
}
bounds.Sort();
@@ -636,13 +636,14 @@ static int tolua_cBlockArea_RelLine(lua_State * a_LuaState)
L.GetStackValues(idx, dataTypes, blockType, blockMeta, blockLight, blockSkyLight);
if (!cBlockArea::IsValidDataTypeCombination(dataTypes))
{
- return L.ApiParamError("Invalid baDataTypes combination (%d)", dataTypes);
+ return L.ApiParamError(fmt::format(FMT_STRING("Invalid baDataTypes combination (0x{:02x})"), dataTypes));
}
if ((self->GetDataTypes() & dataTypes) != dataTypes)
{
- return L.ApiParamError("Requested datatypes not present in the cBlockArea. Got only 0x%02x, requested 0x%02x",
+ return L.ApiParamError(fmt::format(
+ FMT_STRING("Requested datatypes not present in the cBlockArea. Got only 0x{:02x}, requested 0x{:02x}"),
self->GetDataTypes(), dataTypes
- );
+ ));
}
// Draw the line:
@@ -771,13 +772,14 @@ static int tolua_cBlockArea_Write(lua_State * a_LuaState)
{
if (!cBlockArea::IsValidDataTypeCombination(dataTypes))
{
- return L.ApiParamError("Invalid datatype combination (%d)", dataTypes);
+ return L.ApiParamError(fmt::format(FMT_STRING("Invalid datatype combination (0x{:02x})"), dataTypes));
}
if ((self->GetDataTypes() & dataTypes) != dataTypes)
{
- return L.ApiParamError("Requesting datatypes not present in the cBlockArea. Got only 0x%02x, requested 0x%02x",
+ return L.ApiParamError(fmt::format(
+ FMT_STRING("Requesting datatypes not present in the cBlockArea. Got only 0x{:02x}, requested 0x{:02x}"),
self->GetDataTypes(), dataTypes
- );
+ ));
}
}
@@ -844,7 +846,7 @@ static int GetBlock(lua_State * a_LuaState)
// Check the datatype's presence:
if ((self->GetDataTypes() & DataTypeFlag) == 0)
{
- return L.ApiParamError("The area doesn't contain the datatype (%d)", DataTypeFlag);
+ return L.ApiParamError(fmt::format(FMT_STRING("The area doesn't contain the datatype (0x{:02x})"), DataTypeFlag));
}
// Read the overloaded params:
@@ -852,9 +854,9 @@ static int GetBlock(lua_State * a_LuaState)
readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidCoords(coords))
{
- return L.FApiParamError("The coords ({0}) are out of range ({1} - {2})",
+ return L.ApiParamError(fmt::format(FMT_STRING("The coords ({0}) are out of range ({1} - {2})"),
coords, self->GetOrigin(), self->GetOrigin() + self->GetSize() - Vector3i{1, 1, 1}
- );
+ ));
}
// Get the block info:
@@ -895,7 +897,7 @@ static int GetRelBlock(lua_State * a_LuaState)
// Check the datatype's presence:
if ((self->GetDataTypes() & DataTypeFlag) == 0)
{
- return L.ApiParamError("The area doesn't contain the datatype (%d)", DataTypeFlag);
+ return L.ApiParamError(fmt::format(FMT_STRING("The area doesn't contain the datatype (0x{:02x})"), DataTypeFlag));
}
// Read the overloaded params:
@@ -903,9 +905,9 @@ static int GetRelBlock(lua_State * a_LuaState)
readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidRelCoords(coords))
{
- return L.FApiParamError("The coords ({0}) are out of range ({1})",
+ return L.ApiParamError(fmt::format(FMT_STRING("The coords ({0}) are out of range ({1})"),
coords, (self->GetSize() - Vector3i(1, 1, 1))
- );
+ ));
}
// Get the block info:
@@ -946,7 +948,7 @@ static int SetBlock(lua_State * a_LuaState)
// Check the datatype's presence:
if ((self->GetDataTypes() & DataTypeFlag) == 0)
{
- return L.ApiParamError("The area doesn't contain the datatype (%d)", DataTypeFlag);
+ return L.ApiParamError(fmt::format(FMT_STRING("The area doesn't contain the datatype (0x{:02x})"), DataTypeFlag));
}
// Read the overloaded params:
@@ -954,9 +956,9 @@ static int SetBlock(lua_State * a_LuaState)
auto idx = readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidCoords(coords))
{
- return L.FApiParamError("The coords ({0}) are out of range ({1} - {2})",
+ return L.ApiParamError(fmt::format(FMT_STRING("The coords ({0}) are out of range ({1} - {2})"),
coords, self->GetOrigin(), self->GetOrigin() + self->GetSize() - Vector3i{1, 1, 1}
- );
+ ));
}
DataType data;
L.GetStackValues(idx, data);
@@ -999,7 +1001,7 @@ static int SetRelBlock(lua_State * a_LuaState)
// Check the datatype's presence:
if ((self->GetDataTypes() & DataTypeFlag) == 0)
{
- return L.ApiParamError("The area doesn't contain the datatype (%d)", DataTypeFlag);
+ return L.ApiParamError(fmt::format(FMT_STRING("The area doesn't contain the datatype (0x{:02x})"), DataTypeFlag));
}
// Read the overloaded params:
@@ -1007,9 +1009,10 @@ static int SetRelBlock(lua_State * a_LuaState)
auto idx = readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidRelCoords(coords))
{
- return L.FApiParamError("The coords ({0}) are out of range ({1})",
+ return L.ApiParamError(fmt::format(
+ FMT_STRING("The coords ({0}) are out of range ({1})"),
coords, (self->GetSize() - Vector3i(1, 1, 1))
- );
+ ));
}
DataType data;
L.GetStackValues(idx, data);
@@ -1050,9 +1053,9 @@ static int tolua_cBlockArea_SetBlockTypeMeta(lua_State * a_LuaState)
auto idx = readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidCoords(coords))
{
- return L.FApiParamError("The coords ({0}) are out of range ({1} - {2})",
+ return L.ApiParamError(fmt::format(FMT_STRING("The coords ({0}) are out of range ({1} - {2})"),
coords, self->GetOrigin(), self->GetOrigin() + self->GetSize() - Vector3i{1, 1, 1}
- );
+ ));
}
BLOCKTYPE block;
@@ -1090,7 +1093,7 @@ static int tolua_cBlockArea_SetRelBlockTypeMeta(lua_State * a_LuaState)
// Check if block types and metas are present:
if (!self->HasBlockTypes() || !self->HasBlockMetas())
{
- return L.ApiParamError("The area doesn't contain the baTypes or baMetas datatypes (0x%02x)", self->GetDataTypes());
+ return L.ApiParamError(fmt::format(FMT_STRING("The area doesn't contain the baTypes or baMetas datatypes (0x{:02x})"), self->GetDataTypes()));
}
// Read the overloaded params:
@@ -1098,9 +1101,9 @@ static int tolua_cBlockArea_SetRelBlockTypeMeta(lua_State * a_LuaState)
auto idx = readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidRelCoords(coords))
{
- return L.FApiParamError("The coords ({0}) are out of range ({1})",
+ return L.ApiParamError(fmt::format(FMT_STRING("The coords ({0}) are out of range ({1})"),
coords, (self->GetSize() - Vector3i(1, 1, 1))
- );
+ ));
}
BLOCKTYPE block;