forked from Mirrorlandia_minetest/minetest
Fix set_bone_position regression (error on passing none)
This commit is contained in:
parent
cb38b841af
commit
cad8e895f2
@ -124,8 +124,10 @@ void script_error(lua_State *L, int pcall_result, const char *mod, const char *f
|
|||||||
|
|
||||||
static void script_log_add_source(lua_State *L, std::string &message, int stack_depth)
|
static void script_log_add_source(lua_State *L, std::string &message, int stack_depth)
|
||||||
{
|
{
|
||||||
lua_Debug ar;
|
if (stack_depth <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lua_Debug ar;
|
||||||
if (lua_getstack(L, stack_depth, &ar)) {
|
if (lua_getstack(L, stack_depth, &ar)) {
|
||||||
FATAL_ERROR_IF(!lua_getinfo(L, "Sl", &ar), "lua_getinfo() failed");
|
FATAL_ERROR_IF(!lua_getinfo(L, "Sl", &ar), "lua_getinfo() failed");
|
||||||
message.append(" (at " + std::string(ar.short_src) + ":"
|
message.append(" (at " + std::string(ar.short_src) + ":"
|
||||||
@ -172,15 +174,18 @@ DeprecatedHandlingMode get_deprecated_handling_mode()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void log_deprecated(lua_State *L, std::string message, int stack_depth)
|
void log_deprecated(lua_State *L, std::string message, int stack_depth, bool once)
|
||||||
{
|
{
|
||||||
DeprecatedHandlingMode mode = get_deprecated_handling_mode();
|
DeprecatedHandlingMode mode = get_deprecated_handling_mode();
|
||||||
if (mode == DeprecatedHandlingMode::Ignore)
|
if (mode == DeprecatedHandlingMode::Ignore)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (stack_depth >= 0)
|
if (once) {
|
||||||
|
script_log_unique(L, message, warningstream, stack_depth);
|
||||||
|
} else {
|
||||||
script_log_add_source(L, message, stack_depth);
|
script_log_add_source(L, message, stack_depth);
|
||||||
warningstream << message << std::endl;
|
warningstream << message << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
if (mode == DeprecatedHandlingMode::Error)
|
if (mode == DeprecatedHandlingMode::Error)
|
||||||
script_error(L, LUA_ERRRUN, NULL, NULL);
|
script_error(L, LUA_ERRRUN, NULL, NULL);
|
||||||
|
@ -149,8 +149,9 @@ DeprecatedHandlingMode get_deprecated_handling_mode();
|
|||||||
* @param message The deprecation method
|
* @param message The deprecation method
|
||||||
* @param stack_depth How far on the stack to the first user function
|
* @param stack_depth How far on the stack to the first user function
|
||||||
* (ie: not builtin or core). -1 to disabled.
|
* (ie: not builtin or core). -1 to disabled.
|
||||||
|
* @param once Log the deprecation warning only once per callsite.
|
||||||
*/
|
*/
|
||||||
void log_deprecated(lua_State *L, std::string message, int stack_depth = 1);
|
void log_deprecated(lua_State *L, std::string message, int stack_depth = 1, bool once = false);
|
||||||
|
|
||||||
// Safely call string.dump on a function value
|
// Safely call string.dump on a function value
|
||||||
// (does not pop, leaves one value on stack)
|
// (does not pop, leaves one value on stack)
|
||||||
|
@ -520,7 +520,7 @@ int ObjectRef::l_set_bone_position(lua_State *L)
|
|||||||
{
|
{
|
||||||
NO_MAP_LOCK_REQUIRED;
|
NO_MAP_LOCK_REQUIRED;
|
||||||
|
|
||||||
log_deprecated(L,"Deprecated call to set_bone_position, use set_bone_override instead");
|
log_deprecated(L, "Deprecated call to set_bone_position, use set_bone_override instead", 1, true);
|
||||||
|
|
||||||
ObjectRef *ref = checkObject<ObjectRef>(L, 1);
|
ObjectRef *ref = checkObject<ObjectRef>(L, 1);
|
||||||
ServerActiveObject *sao = getobject(ref);
|
ServerActiveObject *sao = getobject(ref);
|
||||||
@ -528,12 +528,12 @@ int ObjectRef::l_set_bone_position(lua_State *L)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
std::string bone;
|
std::string bone;
|
||||||
if (!lua_isnil(L, 2))
|
if (!lua_isnoneornil(L, 2))
|
||||||
bone = readParam<std::string>(L, 2);
|
bone = readParam<std::string>(L, 2);
|
||||||
BoneOverride props;
|
BoneOverride props;
|
||||||
if (!lua_isnil(L, 3))
|
if (!lua_isnoneornil(L, 3))
|
||||||
props.position.vector = check_v3f(L, 3);
|
props.position.vector = check_v3f(L, 3);
|
||||||
if (!lua_isnil(L, 4))
|
if (!lua_isnoneornil(L, 4))
|
||||||
props.rotation.next = core::quaternion(check_v3f(L, 4) * core::DEGTORAD);
|
props.rotation.next = core::quaternion(check_v3f(L, 4) * core::DEGTORAD);
|
||||||
props.position.absolute = true;
|
props.position.absolute = true;
|
||||||
props.rotation.absolute = true;
|
props.rotation.absolute = true;
|
||||||
@ -546,7 +546,7 @@ int ObjectRef::l_get_bone_position(lua_State *L)
|
|||||||
{
|
{
|
||||||
NO_MAP_LOCK_REQUIRED;
|
NO_MAP_LOCK_REQUIRED;
|
||||||
|
|
||||||
log_deprecated(L,"Deprecated call to get_bone_position, use get_bone_override instead");
|
log_deprecated(L, "Deprecated call to get_bone_position, use get_bone_override instead", 1, true);
|
||||||
|
|
||||||
ObjectRef *ref = checkObject<ObjectRef>(L, 1);
|
ObjectRef *ref = checkObject<ObjectRef>(L, 1);
|
||||||
ServerActiveObject *sao = getobject(ref);
|
ServerActiveObject *sao = getobject(ref);
|
||||||
|
Loading…
Reference in New Issue
Block a user