aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_nodetimer.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_nodetimer.cpp
parent244713971a976e43e8740b6a9d9d122e37020ef2 (diff)
downloaddragonfireclient-6ccb5835ff55d85156be91473c598eca9d6cb9a6.tar.xz
Revert "Make Lint Happy"
This reverts commit ad148587dcf5244c2d2011dba339786c765c54c4.
Diffstat (limited to 'src/script/lua_api/l_nodetimer.cpp')
-rw-r--r--src/script/lua_api/l_nodetimer.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/script/lua_api/l_nodetimer.cpp b/src/script/lua_api/l_nodetimer.cpp
index 621af5fd3..c2df52c05 100644
--- a/src/script/lua_api/l_nodetimer.cpp
+++ b/src/script/lua_api/l_nodetimer.cpp
@@ -22,28 +22,27 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "serverenvironment.h"
#include "map.h"
-int NodeTimerRef::gc_object(lua_State *L)
-{
+
+int NodeTimerRef::gc_object(lua_State *L) {
NodeTimerRef *o = *(NodeTimerRef **)(lua_touserdata(L, 1));
delete o;
return 0;
}
-NodeTimerRef *NodeTimerRef::checkobject(lua_State *L, int narg)
+NodeTimerRef* NodeTimerRef::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 *(NodeTimerRef **)ud; // unbox pointer
+ if(!ud) luaL_typerror(L, narg, className);
+ return *(NodeTimerRef**)ud; // unbox pointer
}
int NodeTimerRef::l_set(lua_State *L)
{
MAP_LOCK_REQUIRED;
NodeTimerRef *o = checkobject(L, 1);
- f32 t = readParam<float>(L, 2);
- f32 e = readParam<float>(L, 3);
+ f32 t = readParam<float>(L,2);
+ f32 e = readParam<float>(L,3);
o->m_map->setNodeTimer(NodeTimer(t, e, o->m_p));
return 0;
}
@@ -52,7 +51,7 @@ int NodeTimerRef::l_start(lua_State *L)
{
MAP_LOCK_REQUIRED;
NodeTimerRef *o = checkobject(L, 1);
- f32 t = readParam<float>(L, 2);
+ f32 t = readParam<float>(L,2);
o->m_map->setNodeTimer(NodeTimer(t, 0, o->m_p));
return 0;
}
@@ -70,7 +69,7 @@ int NodeTimerRef::l_is_started(lua_State *L)
MAP_LOCK_REQUIRED;
NodeTimerRef *o = checkobject(L, 1);
NodeTimer t = o->m_map->getNodeTimer(o->m_p);
- lua_pushboolean(L, (t.timeout != 0));
+ lua_pushboolean(L,(t.timeout != 0));
return 1;
}
@@ -79,7 +78,7 @@ int NodeTimerRef::l_get_timeout(lua_State *L)
MAP_LOCK_REQUIRED;
NodeTimerRef *o = checkobject(L, 1);
NodeTimer t = o->m_map->getNodeTimer(o->m_p);
- lua_pushnumber(L, t.timeout);
+ lua_pushnumber(L,t.timeout);
return 1;
}
@@ -88,7 +87,7 @@ int NodeTimerRef::l_get_elapsed(lua_State *L)
MAP_LOCK_REQUIRED;
NodeTimerRef *o = checkobject(L, 1);
NodeTimer t = o->m_map->getNodeTimer(o->m_p);
- lua_pushnumber(L, t.elapsed);
+ lua_pushnumber(L,t.elapsed);
return 1;
}
@@ -111,7 +110,7 @@ void NodeTimerRef::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, "__index");
lua_pushvalue(L, methodtable);
@@ -121,17 +120,22 @@ void NodeTimerRef::Register(lua_State *L)
lua_pushcfunction(L, gc_object);
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
// Cannot be created from Lua
- // lua_register(L, className, create_object);
+ //lua_register(L, className, create_object);
}
const char NodeTimerRef::className[] = "NodeTimerRef";
-const luaL_Reg NodeTimerRef::methods[] = {luamethod(NodeTimerRef, start),
- luamethod(NodeTimerRef, set), luamethod(NodeTimerRef, stop),
- luamethod(NodeTimerRef, is_started), luamethod(NodeTimerRef, get_timeout),
- luamethod(NodeTimerRef, get_elapsed), {0, 0}};
+const luaL_Reg NodeTimerRef::methods[] = {
+ luamethod(NodeTimerRef, start),
+ luamethod(NodeTimerRef, set),
+ luamethod(NodeTimerRef, stop),
+ luamethod(NodeTimerRef, is_started),
+ luamethod(NodeTimerRef, get_timeout),
+ luamethod(NodeTimerRef, get_elapsed),
+ {0,0}
+};