aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_storage.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com>2020-11-04 16:44:42 +0100
committerGitHub <noreply@github.com>2020-11-04 16:44:42 +0100
commit5d9ae5a91c544fc7fbd475decf47cef7e09ef8fc (patch)
treec980d614fec4a5495798be3e79e033229062c3cd /src/script/lua_api/l_storage.cpp
parent28f6a79706b088c37268a59d90878220dc4ef9c7 (diff)
parent3af10766fd2b58b068e970266724d7eb10e9316b (diff)
downloaddragonfireclient-5d9ae5a91c544fc7fbd475decf47cef7e09ef8fc.tar.xz
Merge branch 'master' into master
Diffstat (limited to 'src/script/lua_api/l_storage.cpp')
-rw-r--r--src/script/lua_api/l_storage.cpp43
1 files changed, 18 insertions, 25 deletions
diff --git a/src/script/lua_api/l_storage.cpp b/src/script/lua_api/l_storage.cpp
index cba34fb63..fe3b4d74c 100644
--- a/src/script/lua_api/l_storage.cpp
+++ b/src/script/lua_api/l_storage.cpp
@@ -53,8 +53,7 @@ void ModApiStorage::Initialize(lua_State *L, int top)
API_FCT(get_mod_storage);
}
-StorageRef::StorageRef(ModMetadata *object):
- m_object(object)
+StorageRef::StorageRef(ModMetadata *object) : m_object(object)
{
}
@@ -90,7 +89,7 @@ void StorageRef::Register(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));
@@ -108,27 +107,28 @@ void StorageRef::Register(lua_State *L)
lua_pushcfunction(L, l_equals);
lua_settable(L, metatable);
- lua_pop(L, 1); // drop metatable
+ lua_pop(L, 1); // drop metatable
- luaL_openlib(L, 0, methods, 0); // fill methodtable
- lua_pop(L, 1); // drop methodtable
+ luaL_openlib(L, 0, methods, 0); // fill methodtable
+ lua_pop(L, 1); // drop methodtable
}
-StorageRef* StorageRef::checkobject(lua_State *L, int narg)
+StorageRef *StorageRef::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 *(StorageRef**)ud; // unbox pointer
+ if (!ud)
+ luaL_typerror(L, narg, className);
+ return *(StorageRef **)ud; // unbox pointer
}
-ModMetadata* StorageRef::getobject(StorageRef *ref)
+ModMetadata *StorageRef::getobject(StorageRef *ref)
{
ModMetadata *co = ref->m_object;
return co;
}
-Metadata* StorageRef::getmeta(bool auto_create)
+Metadata *StorageRef::getmeta(bool auto_create)
{
return m_object;
}
@@ -139,17 +139,10 @@ void StorageRef::clearMeta()
}
const char StorageRef::className[] = "StorageRef";
-const luaL_Reg StorageRef::methods[] = {
- 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(MetaDataRef, equals),
- {0,0}
-};
+const luaL_Reg StorageRef::methods[] = {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(MetaDataRef, equals),
+ {0, 0}};