From 329a1c0a0896c05ffb6954883248cb87f82daa56 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 10 May 2012 20:19:49 +0200 Subject: Removed raiseScriptError It wasn't really adding anything since errors raised using luaL_error are already logged anyway. Reviewed-by: Erik Schilling --- src/scripting/luautil.cpp | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src/scripting/luautil.cpp') diff --git a/src/scripting/luautil.cpp b/src/scripting/luautil.cpp index fd83b58b..e753e1bc 100644 --- a/src/scripting/luautil.cpp +++ b/src/scripting/luautil.cpp @@ -33,18 +33,6 @@ #include "scripting/luascript.h" -void raiseScriptError(lua_State *s, const char *format, ...) -{ - va_list args; - va_start(args, format); - char message[1024]; - vsprintf(message, format, args); - va_end(args); - - LOG_WARN("Lua script error: "<< message); - luaL_error(s, message); -} - void raiseWarning(lua_State *, const char *format, ...) { va_list args; -- cgit v1.2.3-70-g09d2 From 4f6f59bfb33bb5814b5489a405074c900b5299ab Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sun, 13 May 2012 15:17:38 +0200 Subject: Fixed an error message and inlined some one-liners --- src/scripting/luautil.cpp | 23 +---------------------- src/scripting/luautil.h | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 30 deletions(-) (limited to 'src/scripting/luautil.cpp') diff --git a/src/scripting/luautil.cpp b/src/scripting/luautil.cpp index e753e1bc..3de23c77 100644 --- a/src/scripting/luautil.cpp +++ b/src/scripting/luautil.cpp @@ -247,7 +247,7 @@ int checkSkill(lua_State *s, int p) return luaL_checkint(s, p); int id = skillManager->getId(luaL_checkstring(s, p)); - luaL_argcheck(s, id != 0, p, "invalid special name"); + luaL_argcheck(s, id != 0, p, "invalid skill name"); return id; } @@ -285,24 +285,3 @@ Script::Thread *checkCurrentThread(lua_State *s, Script *script /* = 0 */) return thread; } - - -void push(lua_State *s, int val) -{ - lua_pushinteger(s, val); -} - -void push(lua_State *s, const std::string &val) -{ - lua_pushstring(s, val.c_str()); -} - -void push(lua_State *s, Entity *val) -{ - lua_pushlightuserdata(s, val); -} - -void push(lua_State *s, double val) -{ - lua_pushnumber(s, val); -} diff --git a/src/scripting/luautil.h b/src/scripting/luautil.h index 3c8ada48..36ed80f4 100644 --- a/src/scripting/luautil.h +++ b/src/scripting/luautil.h @@ -177,10 +177,26 @@ Script::Thread* checkCurrentThread(lua_State *s, Script *script = 0); /* Polymorphic wrapper for pushing variables. Useful for templates.*/ -void push(lua_State *s, int val); -void push(lua_State *s, const std::string &val); -void push(lua_State *s, Entity *val); -void push(lua_State *s, double val); + +inline void push(lua_State *s, int val) +{ + lua_pushinteger(s, val); +} + +inline void push(lua_State *s, const std::string &val) +{ + lua_pushstring(s, val.c_str()); +} + +inline void push(lua_State *s, Entity *val) +{ + lua_pushlightuserdata(s, val); +} + +inline void push(lua_State *s, double val) +{ + lua_pushnumber(s, val); +} inline void push(lua_State *s, MapObject *val) { @@ -189,7 +205,8 @@ inline void push(lua_State *s, MapObject *val) /* Pushes an STL LIST */ -template void pushSTLContainer(lua_State *s, const std::list &container) +template +void pushSTLContainer(lua_State *s, const std::list &container) { int len = container.size(); lua_createtable(s, len, 0); @@ -206,7 +223,8 @@ template void pushSTLContainer(lua_State *s, const std::list &co } /* Pushes an STL VECTOR */ -template void pushSTLContainer(lua_State *s, const std::vector &container) +template +void pushSTLContainer(lua_State *s, const std::vector &container) { int len = container.size(); lua_createtable(s, len, 0); @@ -220,7 +238,8 @@ template void pushSTLContainer(lua_State *s, const std::vector & } /* Pushes an STL MAP */ -template void pushSTLContainer(lua_State *s, const std::map &container) +template +void pushSTLContainer(lua_State *s, const std::map &container) { int len = container.size(); lua_createtable(s, 0, len); @@ -238,7 +257,8 @@ template void pushSTLContainer(lua_State *s, cons } /* Pushes an STL SET */ -template void pushSTLContainer(lua_State *s, const std::set &container) +template +void pushSTLContainer(lua_State *s, const std::set &container) { int len = container.size(); lua_createtable(s, len, 0); -- cgit v1.2.3-70-g09d2