1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Unify wield item handling (#8677)

This moves the wield item functions to Player and the tool utils for range calculation
Also 'local_inventory' was removed due to redundancy in Client
This commit is contained in:
SmallJoker 2019-08-07 19:16:31 +02:00 committed by GitHub
parent 003af74213
commit e462a9a5ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 154 additions and 249 deletions

View file

@ -308,8 +308,9 @@ int ObjectRef::l_get_wield_list(lua_State *L)
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
ServerActiveObject *co = getobject(ref);
if (co == NULL) return 0;
// Do it
if (!co)
return 0;
lua_pushstring(L, co->getWieldList().c_str());
return 1;
}
@ -320,8 +321,9 @@ int ObjectRef::l_get_wield_index(lua_State *L)
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
ServerActiveObject *co = getobject(ref);
if (co == NULL) return 0;
// Do it
if (!co)
return 0;
lua_pushinteger(L, co->getWieldIndex() + 1);
return 1;
}
@ -332,12 +334,12 @@ int ObjectRef::l_get_wielded_item(lua_State *L)
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
ServerActiveObject *co = getobject(ref);
if (co == NULL) {
if (!co) {
// Empty ItemStack
LuaItemStack::create(L, ItemStack());
return 1;
}
// Do it
LuaItemStack::create(L, co->getWieldedItem());
return 1;
}