summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Bindings/LuaState.cpp68
-rw-r--r--src/Bindings/LuaState.h9
-rw-r--r--src/Bindings/ManualBindings.cpp40
-rw-r--r--src/Bindings/ManualBindings.h5
-rw-r--r--src/Bindings/ManualBindings_BlockArea.cpp136
5 files changed, 144 insertions, 114 deletions
diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp
index d18b6efcd..e30d0ed5f 100644
--- a/src/Bindings/LuaState.cpp
+++ b/src/Bindings/LuaState.cpp
@@ -1775,7 +1775,33 @@ bool cLuaState::CheckParamSelf(const char * a_SelfClassName)
VERIFY(lua_getstack(m_LuaState, 0, &entry));
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
AString ErrMsg = Printf(
- "Error in function '%s'. The 'self' parameter is not of the expected type, \"instance of %s\". Make sure you're using the correct calling convention (obj:fn() instead of obj.fn()).",
+ "Error in function '%s'. The 'self' parameter is not of the expected type, \"instance of %s\". " \
+ "Make sure you're using the correct calling convention (obj:fn() instead of obj.fn()).",
+ (entry.name != nullptr) ? entry.name : "<unknown>", a_SelfClassName
+ );
+ tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
+ return false;
+}
+
+
+
+
+
+bool cLuaState::CheckParamStaticSelf(const char * a_SelfClassName)
+{
+ tolua_Error tolua_err;
+ if (tolua_isusertable(m_LuaState, 1, a_SelfClassName, 0, &tolua_err) && !lua_isnil(m_LuaState, 1))
+ {
+ return true;
+ }
+
+ // Not the correct parameter
+ lua_Debug entry;
+ VERIFY(lua_getstack(m_LuaState, 0, &entry));
+ VERIFY(lua_getinfo (m_LuaState, "n", &entry));
+ AString ErrMsg = Printf(
+ "Error in function '%s'. The 'self' parameter is not of the expected type, \"class %s\". " \
+ "Make sure you're using the correct calling convention (cClassName:fn() instead of cClassName.fn() or obj:fn()).",
(entry.name != nullptr) ? entry.name : "<unknown>", a_SelfClassName
);
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
@@ -1863,6 +1889,46 @@ void cLuaState::LogStackTrace(lua_State * a_LuaState, int a_StartingDepth)
+int cLuaState::ApiParamError(const char * a_MsgFormat, ...)
+{
+ // Retrieve current function name
+ lua_Debug entry;
+ VERIFY(lua_getstack(m_LuaState, 0, &entry));
+ VERIFY(lua_getinfo(m_LuaState, "n", &entry));
+
+ // Compose the error message:
+ va_list argp;
+ va_start(argp, a_MsgFormat);
+ AString msg;
+
+ #ifdef __clang__
+ #pragma clang diagnostic push
+ #pragma clang diagnostic ignored "-Wformat-nonliteral"
+ #endif
+
+ AppendVPrintf(msg, a_MsgFormat, argp);
+
+ #ifdef __clang__
+ #pragma clang diagnostic pop
+ #endif
+
+ va_end(argp);
+ AString errorMsg = Printf("%s: %s", (entry.name != nullptr) ? entry.name : "<unknown function>", msg.c_str());
+
+ // Log everything into the console:
+ LOGWARNING("%s", errorMsg.c_str());
+ // cLuaState::LogStackTrace(a_LuaState); // Do NOT log stack trace, it is already output as part of the Lua error handling
+ LogStackValues(m_LuaState, "Parameters on the stack");
+
+ // Raise Lua error:
+ lua_pushstring(m_LuaState, errorMsg.c_str());
+ return lua_error(m_LuaState);
+}
+
+
+
+
+
AString cLuaState::GetTypeText(int a_StackPos)
{
return lua_typename(m_LuaState, lua_type(m_LuaState, a_StackPos));
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index 674c7a240..d8f39b09e 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -792,6 +792,10 @@ public:
Returns false and logs a special warning ("wrong calling convention") if not. */
bool CheckParamSelf(const char * a_SelfClassName);
+ /** Returns true if the first parameter is the expected class (static).
+ Returns false and logs a special warning ("wrong calling convention") if not. */
+ bool CheckParamStaticSelf(const char * a_SelfClassName);
+
bool IsParamUserType(int a_Param, AString a_UserType);
bool IsParamNumber(int a_Param);
@@ -808,6 +812,11 @@ public:
/** Logs all items in the current stack trace to the server console */
static void LogStackTrace(lua_State * a_LuaState, int a_StartingDepth = 0);
+ /** Formats and prints the message, prefixed with the current function name, then logs the stack contents and raises a Lua error.
+ To be used for bindings when they detect bad parameters.
+ Doesn't return, but a dummy return type is provided so that Lua API functions may do "return ApiParamError(...)". */
+ int ApiParamError(const char * a_MsgFormat, ...);
+
/** Returns the type of the item on the specified position in the stack */
AString GetTypeText(int a_StackPos);
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp
index 2c2de6296..565c636e3 100644
--- a/src/Bindings/ManualBindings.cpp
+++ b/src/Bindings/ManualBindings.cpp
@@ -132,46 +132,6 @@ int cManualBindings::lua_do_error(lua_State * L, const char * a_pFormat, ...)
-int cManualBindings::ApiParamError(lua_State * a_LuaState, const char * a_MsgFormat, ...)
-{
- // Retrieve current function name
- lua_Debug entry;
- VERIFY(lua_getstack(a_LuaState, 0, &entry));
- VERIFY(lua_getinfo(a_LuaState, "n", &entry));
-
- // Compose the error message:
- va_list argp;
- va_start(argp, a_MsgFormat);
- AString msg;
-
- #ifdef __clang__
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wformat-nonliteral"
- #endif
-
- AppendVPrintf(msg, a_MsgFormat, argp);
-
- #ifdef __clang__
- #pragma clang diagnostic pop
- #endif
-
- va_end(argp);
- AString errorMsg = Printf("%s: %s", (entry.name != nullptr) ? entry.name : "<unknown function>", msg.c_str());
-
- // Log everything into the console:
- LOGWARNING("%s", errorMsg.c_str());
- // cLuaState::LogStackTrace(a_LuaState); // Do NOT log stack trace, it is already output as part of the Lua error handling
- cLuaState::LogStackValues(a_LuaState, "Parameters on the stack");
-
- // Raise Lua error:
- lua_pushstring(a_LuaState, errorMsg.c_str());
- return lua_error(a_LuaState);
-}
-
-
-
-
-
// Lua bound functions with special return types
static int tolua_Clamp(lua_State * tolua_S)
{
diff --git a/src/Bindings/ManualBindings.h b/src/Bindings/ManualBindings.h
index 889e33664..dc9d9462f 100644
--- a/src/Bindings/ManualBindings.h
+++ b/src/Bindings/ManualBindings.h
@@ -52,11 +52,6 @@ public:
static int tolua_do_error(lua_State * L, const char * a_pMsg, tolua_Error * a_pToLuaError);
static int lua_do_error(lua_State * L, const char * a_pFormat, ...);
- /** Formats and prints the message, prefixed with the current function name, then logs the stack contents and raises a Lua error.
- To be used for bindings when they detect bad parameters.
- Doesn't return, but a dummy return type is provided so that Lua API functions may do "return ApiParamError(...)". */
- static int ApiParamError(lua_State * a_LuaState, const char * a_MsgFormat, ...);
-
/** Binds the DoWith(ItemName) functions of regular classes. */
template <
diff --git a/src/Bindings/ManualBindings_BlockArea.cpp b/src/Bindings/ManualBindings_BlockArea.cpp
index 506c84072..038c571ac 100644
--- a/src/Bindings/ManualBindings_BlockArea.cpp
+++ b/src/Bindings/ManualBindings_BlockArea.cpp
@@ -31,7 +31,7 @@ static int readCuboidOverloadParams(cLuaState & a_LuaState, int a_StartParam, cC
// Assume the 6-number version:
if (!a_LuaState.GetStackValues(a_StartParam, a_Cuboid.p1.x, a_Cuboid.p2.x, a_Cuboid.p1.y, a_Cuboid.p2.y, a_Cuboid.p1.z, a_Cuboid.p2.z))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the bounds parameters, expected 6 numbers.");
+ return a_LuaState.ApiParamError("Cannot read the bounds parameters, expected 6 numbers.");
}
return a_StartParam + 6;
}
@@ -41,7 +41,7 @@ static int readCuboidOverloadParams(cLuaState & a_LuaState, int a_StartParam, cC
cCuboid * c;
if (!a_LuaState.GetStackValues(a_StartParam, c))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the bounds parameter, expected a cCuboid instance.");
+ return a_LuaState.ApiParamError("Cannot read the bounds parameter, expected a cCuboid instance.");
}
a_Cuboid = *c;
return a_StartParam + 1;
@@ -53,7 +53,7 @@ static int readCuboidOverloadParams(cLuaState & a_LuaState, int a_StartParam, cC
Vector3i * p2;
if (!a_LuaState.GetStackValues(a_StartParam, p1, p2))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the bounds parameter, expected two Vector3i instances.");
+ return a_LuaState.ApiParamError("Cannot read the bounds parameter, expected two Vector3i instances.");
}
a_Cuboid.p1 = *p1;
a_Cuboid.p2 = *p2;
@@ -79,7 +79,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 cManualBindings::ApiParamError(a_LuaState, "Cannot read the %s, expected 3 numbers.", a_ParamName);
+ return a_LuaState.ApiParamError("Cannot read the %s, expected 3 numbers.", a_ParamName);
}
return a_StartParam + 3;
}
@@ -89,7 +89,7 @@ static int readVector3iOverloadParams(cLuaState & a_LuaState, int a_StartParam,
Vector3i * c;
if (!a_LuaState.GetStackValues(a_StartParam, c))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the %s, expected a Vector3i instance.", a_ParamName);
+ return a_LuaState.ApiParamError("Cannot read the %s, expected a Vector3i instance.", a_ParamName);
}
a_Coords = *c;
return a_StartParam + 1;
@@ -111,11 +111,11 @@ static int tolua_cBlockArea_Create(lua_State * a_LuaState)
cBlockArea * self = nullptr;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read self.");
+ return L.ApiParamError("Cannot read self.");
}
if (self == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid 'self', must not be nil.");
+ return L.ApiParamError("Invalid 'self', must not be nil.");
}
int dataTypes = cBlockArea::baTypes | cBlockArea::baMetas | cBlockArea::baBlockEntities;
@@ -124,13 +124,13 @@ static int tolua_cBlockArea_Create(lua_State * a_LuaState)
L.GetStackValue(dataTypesIdx, dataTypes);
if (!cBlockArea::IsValidDataTypeCombination(dataTypes))
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid combination of baDataTypes specified (%d).", dataTypes);
+ return L.ApiParamError("Invalid combination of baDataTypes specified (%d).", dataTypes);
}
// Create the area:
if ((size.x <= 0) || (size.y <= 0) || (size.z <= 0))
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid sizes, must be greater than zero, got {%d, %d, %d}", size.x, size.y, size.z);
+ return L.ApiParamError("Invalid sizes, must be greater than zero, got {%d, %d, %d}", size.x, size.y, size.z);
}
ASSERT(self != nullptr);
self->Create(size, dataTypes);
@@ -155,11 +155,11 @@ static int tolua_cBlockArea_FillRelCuboid(lua_State * a_LuaState)
cBlockArea * self = nullptr;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read self.");
+ return L.ApiParamError("Cannot read self.");
}
if (self == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid 'self', must not be nil.");
+ return L.ApiParamError("Invalid 'self', must not be nil.");
}
// Check and get the overloaded params:
@@ -170,12 +170,12 @@ static int tolua_cBlockArea_FillRelCuboid(lua_State * a_LuaState)
NIBBLETYPE blockMeta = 0, blockLight = 0, blockSkyLight = 0x0f;
if (!L.GetStackValues(nextIdx, dataTypes, blockType))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the datatypes or block type params");
+ return L.ApiParamError("Cannot read the datatypes or block type params");
}
L.GetStackValues(nextIdx + 2, blockMeta, blockLight, blockSkyLight); // These values are optional
if (!cBlockArea::IsValidDataTypeCombination(dataTypes))
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid baDataTypes combination (%d).", dataTypes);
+ return L.ApiParamError("Invalid baDataTypes combination (%d).", dataTypes);
}
// Check the coords, shift if needed:
@@ -206,18 +206,18 @@ static int tolua_cBlockArea_GetBlockTypeMeta(lua_State * a_LuaState)
cBlockArea * self;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read 'self'");
+ return L.ApiParamError("Cannot read 'self'");
}
if (self == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid 'self', must not be nil.");
+ return L.ApiParamError("Invalid 'self', must not be nil.");
}
Vector3i coords;
readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidCoords(coords))
{
- return cManualBindings::ApiParamError(a_LuaState, "Coords ({%d, %d, %d}) out of range ({%d, %d, %d} - {%d, %d, %d}).",
+ return L.ApiParamError("Coords ({%d, %d, %d}) out of range ({%d, %d, %d} - {%d, %d, %d}).",
coords.x, coords.y, coords.z,
self->GetOriginX(), self->GetOriginY(), self->GetOriginZ(),
self->GetOriginX() + self->GetSizeX() - 1, self->GetOriginY() + self->GetSizeY() - 1, self->GetOriginZ() + self->GetSizeZ() - 1
@@ -250,11 +250,11 @@ static int tolua_cBlockArea_GetCoordRange(lua_State * a_LuaState)
cBlockArea * self;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the 'self' parameter.");
+ return L.ApiParamError("Cannot read the 'self' parameter.");
}
if (self == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid 'self', must not be nil.");
+ return L.ApiParamError("Invalid 'self', must not be nil.");
}
L.Push(self->GetSizeX() - 1, self->GetSizeY() - 1, self->GetSizeZ() - 1);
@@ -280,15 +280,15 @@ static int tolua_cBlockArea_GetNonAirCropRelCoords(lua_State * a_LuaState)
BLOCKTYPE ignoreBlockType = E_BLOCK_AIR;
if (!L.GetStackValues(1, self, ignoreBlockType))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read params");
+ return L.ApiParamError("Cannot read params");
}
if (self == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid 'self', must not be nil");
+ return L.ApiParamError("Invalid 'self', must not be nil");
}
if (!self->HasBlockTypes())
{
- return cManualBindings::ApiParamError(a_LuaState, "The area doesn't contain baTypes datatype");
+ return L.ApiParamError("The area doesn't contain baTypes datatype");
}
// Calculate the crop coords:
@@ -320,11 +320,11 @@ static int tolua_cBlockArea_GetOrigin(lua_State * a_LuaState)
cBlockArea * self;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the 'self' parameter.");
+ return L.ApiParamError("Cannot read the 'self' parameter.");
}
if (self == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid 'self', must not be nil.");
+ return L.ApiParamError("Invalid 'self', must not be nil.");
}
// Push the three origin coords:
@@ -350,26 +350,26 @@ static int tolua_cBlockArea_GetRelBlockTypeMeta(lua_State * a_LuaState)
cBlockArea * self;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the 'self' parameter.");
+ return L.ApiParamError("Cannot read the 'self' parameter.");
}
if (self == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid 'self', must not be nil.");
+ return L.ApiParamError("Invalid 'self', must not be nil.");
}
if (!self->HasBlockTypes())
{
- return cManualBindings::ApiParamError(a_LuaState, "The area doesn't contain baTypes datatype");
+ return L.ApiParamError("The area doesn't contain baTypes datatype");
}
if (!self->HasBlockMetas())
{
- return cManualBindings::ApiParamError(a_LuaState, "The area doesn't contain baMetas datatype");
+ return L.ApiParamError("The area doesn't contain baMetas datatype");
}
Vector3i coords;
readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidRelCoords(coords))
{
- return cManualBindings::ApiParamError(a_LuaState, "The coords ({%d, %d, %d}) are out of range (max {%d, %d, %d}).",
+ return L.ApiParamError("The coords ({%d, %d, %d}) are out of range (max {%d, %d, %d}).",
coords.x, coords.y, coords.z,
self->GetSizeX() - 1, self->GetSizeY() - 1, self->GetSizeZ() - 1
);
@@ -401,11 +401,11 @@ static int tolua_cBlockArea_GetSize(lua_State * a_LuaState)
cBlockArea * self;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the 'self' parameter.");
+ return L.ApiParamError("Cannot read the 'self' parameter.");
}
if (self == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid 'self', must not be nil.");
+ return L.ApiParamError("Invalid 'self', must not be nil.");
}
L.Push(self->GetSizeX(), self->GetSizeY(), self->GetSizeZ());
@@ -433,11 +433,11 @@ static int tolua_cBlockArea_LoadFromSchematicFile(lua_State * a_LuaState)
AString fileName;
if (!L.GetStackValues(1, self, fileName))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the parameters.");
+ return L.ApiParamError("Cannot read the parameters.");
}
if (self == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid 'self', must not be nil.");
+ return L.ApiParamError("Invalid 'self', must not be nil.");
}
L.Push(cSchematicFileSerializer::LoadFromSchematicFile(*self, fileName));
@@ -465,11 +465,11 @@ static int tolua_cBlockArea_LoadFromSchematicString(lua_State * a_LuaState)
AString data;
if (!L.GetStackValues(1, self, data))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the parameters.");
+ return L.ApiParamError("Cannot read the parameters.");
}
if (self == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid 'self', must not be nil.");
+ return L.ApiParamError("Invalid 'self', must not be nil.");
}
L.Push(cSchematicFileSerializer::LoadFromSchematicString(*self, data));
@@ -498,11 +498,11 @@ static int tolua_cBlockArea_Read(lua_State * a_LuaState)
cWorld * world = nullptr;
if (!L.GetStackValues(1, self, world))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read self or world.");
+ return L.ApiParamError("Cannot read self or world.");
}
if (world == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid world instance. The world must be not nil.");
+ return L.ApiParamError("Invalid world instance. The world must be not nil.");
}
// Check and get the overloaded params:
@@ -512,7 +512,7 @@ static int tolua_cBlockArea_Read(lua_State * a_LuaState)
L.GetStackValues(dataTypesIdx, dataTypes);
if (!cBlockArea::IsValidDataTypeCombination(dataTypes))
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid baDataTypes combination (%d).", dataTypes);
+ return L.ApiParamError("Invalid baDataTypes combination (%d).", dataTypes);
}
// Check the coords, shift if needed:
@@ -574,7 +574,7 @@ static int tolua_cBlockArea_RelLine(lua_State * a_LuaState)
cBlockArea * self = nullptr;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read self.");
+ return L.ApiParamError("Cannot read self.");
}
// Check and get the overloaded params:
@@ -588,11 +588,11 @@ static int tolua_cBlockArea_RelLine(lua_State * a_LuaState)
L.GetStackValues(idx, dataTypes, blockType, blockMeta, blockLight, blockSkyLight);
if (!cBlockArea::IsValidDataTypeCombination(dataTypes))
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid baDataTypes combination (%d).", dataTypes);
+ return L.ApiParamError("Invalid baDataTypes combination (%d).", dataTypes);
}
if ((self->GetDataTypes() & dataTypes) != dataTypes)
{
- return cManualBindings::ApiParamError(a_LuaState, "Requested datatypes not present in the cBlockArea. Got only 0x%02x, requested 0x%02x",
+ return L.ApiParamError("Requested datatypes not present in the cBlockArea. Got only 0x%02x, requested 0x%02x",
self->GetDataTypes(), dataTypes
);
}
@@ -623,11 +623,11 @@ static int tolua_cBlockArea_SaveToSchematicFile(lua_State * a_LuaState)
AString fileName;
if (!L.GetStackValues(1, self, fileName))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the parameters.");
+ return L.ApiParamError("Cannot read the parameters.");
}
if (self == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid 'self', must not be nil.");
+ return L.ApiParamError("Invalid 'self', must not be nil.");
}
L.Push(cSchematicFileSerializer::SaveToSchematicFile(*self, fileName));
@@ -653,11 +653,11 @@ static int tolua_cBlockArea_SaveToSchematicString(lua_State * a_LuaState)
cBlockArea * self;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the 'self' parameter.");
+ return L.ApiParamError("Cannot read the 'self' parameter.");
}
if (self == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid 'self', must not be nil.");
+ return L.ApiParamError("Invalid 'self', must not be nil.");
}
AString data;
@@ -691,11 +691,11 @@ static int tolua_cBlockArea_Write(lua_State * a_LuaState)
cWorld * world = nullptr;
if (!L.GetStackValues(1, self, world))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read self or world.");
+ return L.ApiParamError("Cannot read self or world.");
}
if (world == nullptr)
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid world instance. The world must be not nil.");
+ return L.ApiParamError("Invalid world instance. The world must be not nil.");
}
// Check and get the overloaded params:
@@ -707,11 +707,11 @@ static int tolua_cBlockArea_Write(lua_State * a_LuaState)
// Check the dataType parameter validity:
if (!cBlockArea::IsValidDataTypeCombination(dataTypes))
{
- return cManualBindings::ApiParamError(a_LuaState, "Invalid datatype combination (%d).", dataTypes);
+ return L.ApiParamError("Invalid datatype combination (%d).", dataTypes);
}
if ((self->GetDataTypes() & dataTypes) != dataTypes)
{
- return cManualBindings::ApiParamError(a_LuaState, "Requesting datatypes not present in the cBlockArea. Got only 0x%02x, requested 0x%02x",
+ return L.ApiParamError("Requesting datatypes not present in the cBlockArea. Got only 0x%02x, requested 0x%02x",
self->GetDataTypes(), dataTypes
);
}
@@ -766,13 +766,13 @@ static int GetBlock(lua_State * a_LuaState)
cBlockArea * self;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the 'self' param.");
+ return L.ApiParamError("Cannot read the 'self' param.");
}
// Check the datatype's presence:
if ((self->GetDataTypes() & DataTypeFlag) == 0)
{
- return cManualBindings::ApiParamError(a_LuaState, "The area doesn't contain the datatype (%d).", DataTypeFlag);
+ return L.ApiParamError("The area doesn't contain the datatype (%d).", DataTypeFlag);
}
// Read the overloaded params:
@@ -780,7 +780,7 @@ static int GetBlock(lua_State * a_LuaState)
readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidCoords(coords))
{
- return cManualBindings::ApiParamError(a_LuaState, "The coords ({%d, %d, %d}) are out of range ({%d, %d, %d} - {%d, %d, %d}).",
+ return L.ApiParamError("The coords ({%d, %d, %d}) are out of range ({%d, %d, %d} - {%d, %d, %d}).",
coords.x, coords.y, coords.z,
self->GetOriginX(), self->GetOriginY(), self->GetOriginZ(),
self->GetOriginX() + self->GetSizeX() - 1, self->GetOriginY() + self->GetSizeY() - 1, self->GetOriginZ() + self->GetSizeZ() - 1
@@ -819,13 +819,13 @@ static int GetRelBlock(lua_State * a_LuaState)
cBlockArea * self;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the 'self' param.");
+ return L.ApiParamError("Cannot read the 'self' param.");
}
// Check the datatype's presence:
if ((self->GetDataTypes() & DataTypeFlag) == 0)
{
- return cManualBindings::ApiParamError(a_LuaState, "The area doesn't contain the datatype (%d).", DataTypeFlag);
+ return L.ApiParamError("The area doesn't contain the datatype (%d).", DataTypeFlag);
}
// Read the overloaded params:
@@ -833,7 +833,7 @@ static int GetRelBlock(lua_State * a_LuaState)
readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidRelCoords(coords))
{
- return cManualBindings::ApiParamError(a_LuaState, "The coords ({%d, %d, %d}) are out of range ({%d, %d, %d}).",
+ return L.ApiParamError("The coords ({%d, %d, %d}) are out of range ({%d, %d, %d}).",
coords.x, coords.y, coords.z,
self->GetSizeX(), self->GetSizeY(), self->GetSizeZ()
);
@@ -871,13 +871,13 @@ static int SetBlock(lua_State * a_LuaState)
cBlockArea * self;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the 'self' param.");
+ return L.ApiParamError("Cannot read the 'self' param.");
}
// Check the datatype's presence:
if ((self->GetDataTypes() & DataTypeFlag) == 0)
{
- return cManualBindings::ApiParamError(a_LuaState, "The area doesn't contain the datatype (%d).", DataTypeFlag);
+ return L.ApiParamError("The area doesn't contain the datatype (%d).", DataTypeFlag);
}
// Read the overloaded params:
@@ -885,7 +885,7 @@ static int SetBlock(lua_State * a_LuaState)
auto idx = readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidCoords(coords))
{
- return cManualBindings::ApiParamError(a_LuaState, "The coords ({%d, %d, %d}) are out of range ({%d, %d, %d} - {%d, %d, %d}).",
+ return L.ApiParamError("The coords ({%d, %d, %d}) are out of range ({%d, %d, %d} - {%d, %d, %d}).",
coords.x, coords.y, coords.z,
self->GetOriginX(), self->GetOriginY(), self->GetOriginZ(),
self->GetOriginX() + self->GetSizeX() - 1, self->GetOriginY() + self->GetSizeY() - 1, self->GetOriginZ() + self->GetSizeZ() - 1
@@ -926,13 +926,13 @@ static int SetRelBlock(lua_State * a_LuaState)
cBlockArea * self;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the 'self' param.");
+ return L.ApiParamError("Cannot read the 'self' param.");
}
// Check the datatype's presence:
if ((self->GetDataTypes() & DataTypeFlag) == 0)
{
- return cManualBindings::ApiParamError(a_LuaState, "The area doesn't contain the datatype (%d).", DataTypeFlag);
+ return L.ApiParamError("The area doesn't contain the datatype (%d).", DataTypeFlag);
}
// Read the overloaded params:
@@ -940,7 +940,7 @@ static int SetRelBlock(lua_State * a_LuaState)
auto idx = readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidRelCoords(coords))
{
- return cManualBindings::ApiParamError(a_LuaState, "The coords ({%d, %d, %d}) are out of range ({%d, %d, %d}).",
+ return L.ApiParamError("The coords ({%d, %d, %d}) are out of range ({%d, %d, %d}).",
coords.x, coords.y, coords.z,
self->GetSizeX(), self->GetSizeY(), self->GetSizeZ()
);
@@ -970,13 +970,13 @@ static int tolua_cBlockArea_SetBlockTypeMeta(lua_State * a_LuaState)
cBlockArea * self;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the 'self' param.");
+ return L.ApiParamError("Cannot read the 'self' param.");
}
// Check if block types and metas are present:
if (!self->HasBlockTypes() || !self->HasBlockMetas())
{
- return cManualBindings::ApiParamError(a_LuaState, "The area doesn't contain the datatypes baTypes and baMetas.");
+ return L.ApiParamError("The area doesn't contain the datatypes baTypes and baMetas.");
}
// Read the overloaded params:
@@ -984,7 +984,7 @@ static int tolua_cBlockArea_SetBlockTypeMeta(lua_State * a_LuaState)
auto idx = readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidCoords(coords))
{
- return cManualBindings::ApiParamError(a_LuaState, "The coords ({%d, %d, %d}) are out of range ({%d, %d, %d} - {%d, %d, %d}).",
+ return L.ApiParamError("The coords ({%d, %d, %d}) are out of range ({%d, %d, %d} - {%d, %d, %d}).",
coords.x, coords.y, coords.z,
self->GetOriginX(), self->GetOriginY(), self->GetOriginZ(),
self->GetOriginX() + self->GetSizeX() - 1, self->GetOriginY() + self->GetSizeY() - 1, self->GetOriginZ() + self->GetSizeZ() - 1
@@ -995,7 +995,7 @@ static int tolua_cBlockArea_SetBlockTypeMeta(lua_State * a_LuaState)
NIBBLETYPE meta;
if (!L.GetStackValues(idx, block, meta))
{
- return cManualBindings::ApiParamError(a_LuaState, "Bad number for block type or meta type.");
+ return L.ApiParamError("Bad number for block type or meta type.");
}
// Set block type and meta:
@@ -1020,13 +1020,13 @@ static int tolua_cBlockArea_SetRelBlockTypeMeta(lua_State * a_LuaState)
cBlockArea * self;
if (!L.GetStackValues(1, self))
{
- return cManualBindings::ApiParamError(a_LuaState, "Cannot read the 'self' param.");
+ return L.ApiParamError("Cannot read the 'self' param.");
}
// Check if block types and metas are present:
if (!self->HasBlockTypes() || !self->HasBlockMetas())
{
- return cManualBindings::ApiParamError(a_LuaState, "The area doesn't contain the datatypes baTypes and baMetas.");
+ return L.ApiParamError("The area doesn't contain the baTypes or baMetas datatypes (0x%02x).", self->GetDataTypes());
}
// Read the overloaded params:
@@ -1034,7 +1034,7 @@ static int tolua_cBlockArea_SetRelBlockTypeMeta(lua_State * a_LuaState)
auto idx = readVector3iOverloadParams(L, 2, coords, "coords");
if (!self->IsValidRelCoords(coords))
{
- return cManualBindings::ApiParamError(a_LuaState, "The coords ({%d, %d, %d}) are out of range ({%d, %d, %d}).",
+ return L.ApiParamError("The coords ({%d, %d, %d}) are out of range ({%d, %d, %d}).",
coords.x, coords.y, coords.z,
self->GetSizeX(), self->GetSizeY(), self->GetSizeZ()
);
@@ -1044,7 +1044,7 @@ static int tolua_cBlockArea_SetRelBlockTypeMeta(lua_State * a_LuaState)
NIBBLETYPE meta;
if (!L.GetStackValues(idx, block, meta))
{
- return cManualBindings::ApiParamError(a_LuaState, "Bad number for block type or meta type.");
+ return L.ApiParamError("Bad number for block type or meta type.");
}
// Set block type and meta: