aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_nodemeta.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2020-11-04 16:57:41 +0100
committerElias Fleckenstein <eliasfleckenstein@web.de>2020-11-04 16:57:41 +0100
commit6ccb5835ff55d85156be91473c598eca9d6cb9a6 (patch)
tree7f1eaf8b94694c8e24e206909ba8f55a1ebfbb3e /src/script/lua_api/l_nodemeta.cpp
parent244713971a976e43e8740b6a9d9d122e37020ef2 (diff)
downloaddragonfireclient-6ccb5835ff55d85156be91473c598eca9d6cb9a6.tar.xz
Revert "Make Lint Happy"
This reverts commit ad148587dcf5244c2d2011dba339786c765c54c4.
Diffstat (limited to 'src/script/lua_api/l_nodemeta.cpp')
-rw-r--r--src/script/lua_api/l_nodemeta.cpp89
1 files changed, 54 insertions, 35 deletions
diff --git a/src/script/lua_api/l_nodemeta.cpp b/src/script/lua_api/l_nodemeta.cpp
index 934c08796..57052cb42 100644
--- a/src/script/lua_api/l_nodemeta.cpp
+++ b/src/script/lua_api/l_nodemeta.cpp
@@ -29,16 +29,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
/*
NodeMetaRef
*/
-NodeMetaRef *NodeMetaRef::checkobject(lua_State *L, int narg)
+NodeMetaRef* NodeMetaRef::checkobject(lua_State *L, int narg)
{
luaL_checktype(L, narg, LUA_TUSERDATA);
void *ud = luaL_checkudata(L, narg, className);
- if (!ud)
- luaL_typerror(L, narg, className);
- return *(NodeMetaRef **)ud; // unbox pointer
+ if(!ud) luaL_typerror(L, narg, className);
+ return *(NodeMetaRef**)ud; // unbox pointer
}
-Metadata *NodeMetaRef::getmeta(bool auto_create)
+Metadata* NodeMetaRef::getmeta(bool auto_create)
{
if (m_is_local)
return m_meta;
@@ -65,7 +64,7 @@ void NodeMetaRef::reportMetadataChange(const std::string *name)
SANITY_CHECK(!m_is_local);
// NOTE: This same code is in rollback_interface.cpp
// Inform other things that the metadata has changed
- NodeMetadata *meta = dynamic_cast<NodeMetadata *>(m_meta);
+ NodeMetadata *meta = dynamic_cast<NodeMetadata*>(m_meta);
MapEditEvent event;
event.type = MEET_BLOCK_NODE_METADATA_CHANGED;
@@ -77,8 +76,7 @@ void NodeMetaRef::reportMetadataChange(const std::string *name)
// Exported functions
// garbage collector
-int NodeMetaRef::gc_object(lua_State *L)
-{
+int NodeMetaRef::gc_object(lua_State *L) {
NodeMetaRef *o = *(NodeMetaRef **)(lua_touserdata(L, 1));
delete o;
return 0;
@@ -90,7 +88,7 @@ int NodeMetaRef::l_get_inventory(lua_State *L)
MAP_LOCK_REQUIRED;
NodeMetaRef *ref = checkobject(L, 1);
- ref->getmeta(true); // try to ensure the metadata exists
+ ref->getmeta(true); // try to ensure the metadata exists
InvRef::createNodeMeta(L, ref->m_p);
return 1;
}
@@ -101,7 +99,7 @@ int NodeMetaRef::l_mark_as_private(lua_State *L)
MAP_LOCK_REQUIRED;
NodeMetaRef *ref = checkobject(L, 1);
- NodeMetadata *meta = dynamic_cast<NodeMetadata *>(ref->getmeta(true));
+ NodeMetadata *meta = dynamic_cast<NodeMetadata*>(ref->getmeta(true));
assert(meta);
if (lua_istable(L, 2)) {
@@ -126,15 +124,15 @@ void NodeMetaRef::handleToTable(lua_State *L, Metadata *_meta)
// fields
MetaDataRef::handleToTable(L, _meta);
- NodeMetadata *meta = (NodeMetadata *)_meta;
+ NodeMetadata *meta = (NodeMetadata*) _meta;
// inventory
lua_newtable(L);
Inventory *inv = meta->getInventory();
if (inv) {
std::vector<const InventoryList *> lists = inv->getLists();
- for (std::vector<const InventoryList *>::const_iterator i = lists.begin();
- i != lists.end(); ++i) {
+ for(std::vector<const InventoryList *>::const_iterator
+ i = lists.begin(); i != lists.end(); ++i) {
push_inventory_list(L, inv, (*i)->getName().c_str());
lua_setfield(L, -2, (*i)->getName().c_str());
}
@@ -149,7 +147,7 @@ bool NodeMetaRef::handleFromTable(lua_State *L, int table, Metadata *_meta)
if (!MetaDataRef::handleFromTable(L, table, _meta))
return false;
- NodeMetadata *meta = (NodeMetadata *)_meta;
+ NodeMetadata *meta = (NodeMetadata*) _meta;
// inventory
Inventory *inv = meta->getInventory();
@@ -169,11 +167,16 @@ bool NodeMetaRef::handleFromTable(lua_State *L, int table, Metadata *_meta)
return true;
}
-NodeMetaRef::NodeMetaRef(v3s16 p, ServerEnvironment *env) : m_p(p), m_env(env)
+
+NodeMetaRef::NodeMetaRef(v3s16 p, ServerEnvironment *env):
+ m_p(p),
+ m_env(env)
{
}
-NodeMetaRef::NodeMetaRef(Metadata *meta) : m_meta(meta), m_is_local(true)
+NodeMetaRef::NodeMetaRef(Metadata *meta):
+ m_meta(meta),
+ m_is_local(true)
{
}
@@ -182,7 +185,7 @@ NodeMetaRef::NodeMetaRef(Metadata *meta) : m_meta(meta), m_is_local(true)
void NodeMetaRef::create(lua_State *L, v3s16 p, ServerEnvironment *env)
{
NodeMetaRef *o = new NodeMetaRef(p, env);
- // infostream<<"NodeMetaRef::create: o="<<o<<std::endl;
+ //infostream<<"NodeMetaRef::create: o="<<o<<std::endl;
*(void **)(lua_newuserdata(L, sizeof(void *))) = o;
luaL_getmetatable(L, className);
lua_setmetatable(L, -2);
@@ -207,7 +210,7 @@ void NodeMetaRef::RegisterCommon(lua_State *L)
lua_pushliteral(L, "__metatable");
lua_pushvalue(L, methodtable);
- lua_settable(L, metatable); // hide metatable from Lua getmetatable()
+ lua_settable(L, metatable); // hide metatable from Lua getmetatable()
lua_pushliteral(L, "metadata_class");
lua_pushlstring(L, className, strlen(className));
@@ -225,33 +228,49 @@ void NodeMetaRef::RegisterCommon(lua_State *L)
lua_pushcfunction(L, l_equals);
lua_settable(L, metatable);
- lua_pop(L, 1); // drop metatable
+ lua_pop(L, 1); // drop metatable
}
void NodeMetaRef::Register(lua_State *L)
{
RegisterCommon(L);
- luaL_openlib(L, 0, methodsServer, 0); // fill methodtable
- lua_pop(L, 1); // drop methodtable
+ luaL_openlib(L, 0, methodsServer, 0); // fill methodtable
+ lua_pop(L, 1); // drop methodtable
}
-const luaL_Reg NodeMetaRef::methodsServer[] = {luamethod(MetaDataRef, contains),
- luamethod(MetaDataRef, get), luamethod(MetaDataRef, get_string),
- luamethod(MetaDataRef, set_string), luamethod(MetaDataRef, get_int),
- luamethod(MetaDataRef, set_int), luamethod(MetaDataRef, get_float),
- luamethod(MetaDataRef, set_float), luamethod(MetaDataRef, to_table),
- luamethod(MetaDataRef, from_table), luamethod(NodeMetaRef, get_inventory),
- luamethod(NodeMetaRef, mark_as_private), luamethod(MetaDataRef, equals),
- {0, 0}};
+
+const luaL_Reg NodeMetaRef::methodsServer[] = {
+ luamethod(MetaDataRef, contains),
+ luamethod(MetaDataRef, get),
+ luamethod(MetaDataRef, get_string),
+ luamethod(MetaDataRef, set_string),
+ luamethod(MetaDataRef, get_int),
+ luamethod(MetaDataRef, set_int),
+ luamethod(MetaDataRef, get_float),
+ luamethod(MetaDataRef, set_float),
+ luamethod(MetaDataRef, to_table),
+ luamethod(MetaDataRef, from_table),
+ luamethod(NodeMetaRef, get_inventory),
+ luamethod(NodeMetaRef, mark_as_private),
+ luamethod(MetaDataRef, equals),
+ {0,0}
+};
+
void NodeMetaRef::RegisterClient(lua_State *L)
{
RegisterCommon(L);
- luaL_openlib(L, 0, methodsClient, 0); // fill methodtable
- lua_pop(L, 1); // drop methodtable
+ luaL_openlib(L, 0, methodsClient, 0); // fill methodtable
+ lua_pop(L, 1); // drop methodtable
}
-const luaL_Reg NodeMetaRef::methodsClient[] = {luamethod(MetaDataRef, contains),
- luamethod(MetaDataRef, get), luamethod(MetaDataRef, get_string),
- luamethod(MetaDataRef, get_int), luamethod(MetaDataRef, get_float),
- luamethod(MetaDataRef, to_table), {0, 0}};
+
+const luaL_Reg NodeMetaRef::methodsClient[] = {
+ luamethod(MetaDataRef, contains),
+ luamethod(MetaDataRef, get),
+ luamethod(MetaDataRef, get_string),
+ luamethod(MetaDataRef, get_int),
+ luamethod(MetaDataRef, get_float),
+ luamethod(MetaDataRef, to_table),
+ {0,0}
+};