summaryrefslogtreecommitdiff
path: root/src/scripting/luautil.h
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-02-20 15:34:28 +0100
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-02-20 15:34:28 +0100
commitc70c6d19c1cabf46b595591802bceab63d371788 (patch)
tree1c153d2bfe560171bad5889d528dc5cf110e8533 /src/scripting/luautil.h
parentd707495540581f8c1b9ab3d5007c9c4d1ab83b53 (diff)
parent587b7682e6bf7dd9e616c1d4789a5ed9aa986e6d (diff)
downloadmanaserv-c70c6d19c1cabf46b595591802bceab63d371788.tar.gz
manaserv-c70c6d19c1cabf46b595591802bceab63d371788.tar.bz2
manaserv-c70c6d19c1cabf46b595591802bceab63d371788.tar.xz
manaserv-c70c6d19c1cabf46b595591802bceab63d371788.zip
Merge branch 'master' into lpc2012
Conflicts: gameserver.cbp src/account-server/accounthandler.cpp src/game-server/attack.cpp src/game-server/attack.h src/game-server/being.cpp src/game-server/being.h src/game-server/character.cpp src/game-server/character.h src/game-server/inventory.cpp src/game-server/item.h src/game-server/monster.cpp src/game-server/monster.h
Diffstat (limited to 'src/scripting/luautil.h')
-rw-r--r--src/scripting/luautil.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/scripting/luautil.h b/src/scripting/luautil.h
index 1ff2ab8d..8e380d4e 100644
--- a/src/scripting/luautil.h
+++ b/src/scripting/luautil.h
@@ -102,8 +102,13 @@ public:
mTypeName = typeName;
luaL_newmetatable(s, mTypeName); // metatable
- lua_pushstring(s, "__index"); // metatable, "__index"
- luaL_register(s, typeName, members); // metatable, "__index", {}
+ lua_pushliteral(s, "__index"); // metatable, "__index"
+ lua_createtable(s, 0, 0); // metatable, "__index", {}
+#if LUA_VERSION_NUM < 502
+ luaL_register(s, NULL, members);
+#else
+ luaL_setfuncs(s, members, 0);
+#endif
lua_rawset(s, -3); // metatable
lua_pop(s, 1); // -empty-
}
@@ -125,8 +130,12 @@ public:
void *userData = lua_newuserdata(s, sizeof(T*));
* static_cast<T**>(userData) = object;
+#if LUA_VERSION_NUM < 502
luaL_newmetatable(s, mTypeName);
lua_setmetatable(s, -2);
+#else
+ luaL_setmetatable(s, mTypeName);
+#endif
UserDataCache::insert(s, object);
}
@@ -188,7 +197,7 @@ inline void push(lua_State *s, int val)
inline void push(lua_State *s, const std::string &val)
{
- lua_pushstring(s, val.c_str());
+ lua_pushlstring(s, val.c_str(), val.length());
}
inline void push(lua_State *s, Entity *val)