Fixed cRoot:GetFurnaceRecipe() Lua binding.
This commit is contained in:
parent
7fd3fda5d3
commit
14569885e5
@ -739,6 +739,39 @@ bool cLuaState::CallFunction(int a_NumResults)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cLuaState::CheckParamUserTable(int a_StartParam, const char * a_UserTable, int a_EndParam)
|
||||||
|
{
|
||||||
|
ASSERT(IsValid());
|
||||||
|
|
||||||
|
if (a_EndParam < 0)
|
||||||
|
{
|
||||||
|
a_EndParam = a_StartParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
tolua_Error tolua_err;
|
||||||
|
for (int i = a_StartParam; i <= a_EndParam; i++)
|
||||||
|
{
|
||||||
|
if (tolua_isusertable(m_LuaState, i, a_UserTable, 0, &tolua_err))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Not the correct parameter
|
||||||
|
lua_Debug entry;
|
||||||
|
VERIFY(lua_getstack(m_LuaState, 0, &entry));
|
||||||
|
VERIFY(lua_getinfo (m_LuaState, "n", &entry));
|
||||||
|
AString ErrMsg = Printf("#ferror in function '%s'.", (entry.name != NULL) ? entry.name : "?");
|
||||||
|
tolua_error(m_LuaState, ErrMsg.c_str(), &tolua_err);
|
||||||
|
return false;
|
||||||
|
} // for i - Param
|
||||||
|
|
||||||
|
// All params checked ok
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cLuaState::CheckParamUserType(int a_StartParam, const char * a_UserType, int a_EndParam)
|
bool cLuaState::CheckParamUserType(int a_StartParam, const char * a_UserType, int a_EndParam)
|
||||||
{
|
{
|
||||||
ASSERT(IsValid());
|
ASSERT(IsValid());
|
||||||
|
@ -764,7 +764,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool CallFunction(int a_NumReturnValues);
|
bool CallFunction(int a_NumReturnValues);
|
||||||
|
|
||||||
/// Returns true if the specified parameters on the stack are of the specified usertype; also logs warning if not
|
/// Returns true if the specified parameters on the stack are of the specified usertable type; also logs warning if not. Used for static functions
|
||||||
|
bool CheckParamUserTable(int a_StartParam, const char * a_UserTable, int a_EndParam = -1);
|
||||||
|
|
||||||
|
/// Returns true if the specified parameters on the stack are of the specified usertype; also logs warning if not. Used for regular functions
|
||||||
bool CheckParamUserType(int a_StartParam, const char * a_UserType, int a_EndParam = -1);
|
bool CheckParamUserType(int a_StartParam, const char * a_UserType, int a_EndParam = -1);
|
||||||
|
|
||||||
/// Returns true if the specified parameters on the stack are a table; also logs warning if not
|
/// Returns true if the specified parameters on the stack are a table; also logs warning if not
|
||||||
|
@ -2067,15 +2067,16 @@ static int tolua_cRoot_GetFurnaceRecipe(lua_State * tolua_S)
|
|||||||
{
|
{
|
||||||
cLuaState L(tolua_S);
|
cLuaState L(tolua_S);
|
||||||
if (
|
if (
|
||||||
!L.CheckParamUserType(1, "const cItem") ||
|
!L.CheckParamUserTable(1, "cRoot") ||
|
||||||
!L.CheckParamEnd (2)
|
!L.CheckParamUserType (2, "const cItem") ||
|
||||||
|
!L.CheckParamEnd (3)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the input param:
|
// Check the input param:
|
||||||
cItem * Input = (cItem *)tolua_tousertype(L, 1, NULL);
|
cItem * Input = (cItem *)tolua_tousertype(L, 2, NULL);
|
||||||
if (Input == NULL)
|
if (Input == NULL)
|
||||||
{
|
{
|
||||||
LOGWARNING("cRoot:GetFurnaceRecipe: the Input parameter is nil or missing.");
|
LOGWARNING("cRoot:GetFurnaceRecipe: the Input parameter is nil or missing.");
|
||||||
|
Loading…
Reference in New Issue
Block a user