aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/script
diff options
context:
space:
mode:
authorMatthew Hoops2011-05-03 17:17:27 -0400
committerMatthew Hoops2011-05-03 17:25:41 -0400
commit9cb600099f4c29298707787cafad2741a1cd6686 (patch)
treefb1930fa56b611317831d66442cba19b18d2e57a /engines/sword25/script
parent3b2283daf850605ca897002afbafe44489c35473 (diff)
parent95a6098f672191dc0792bd4f9bfa18706bbe8e3a (diff)
downloadscummvm-rg350-9cb600099f4c29298707787cafad2741a1cd6686.tar.gz
scummvm-rg350-9cb600099f4c29298707787cafad2741a1cd6686.tar.bz2
scummvm-rg350-9cb600099f4c29298707787cafad2741a1cd6686.zip
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'engines/sword25/script')
-rw-r--r--engines/sword25/script/luabindhelper.cpp21
-rw-r--r--engines/sword25/script/luabindhelper.h2
-rw-r--r--engines/sword25/script/luacallback.cpp2
3 files changed, 25 insertions, 0 deletions
diff --git a/engines/sword25/script/luabindhelper.cpp b/engines/sword25/script/luabindhelper.cpp
index 5ff9708b95..03a1802a04 100644
--- a/engines/sword25/script/luabindhelper.cpp
+++ b/engines/sword25/script/luabindhelper.cpp
@@ -303,6 +303,27 @@ bool LuaBindhelper::getMetatable(lua_State *L, const Common::String &tableName)
return true;
}
+// Like luaL_checkudata, only without that no error is generated.
+void *LuaBindhelper::my_checkudata(lua_State *L, int ud, const char *tname) {
+ int top = lua_gettop(L);
+
+ void *p = lua_touserdata(L, ud);
+ if (p != NULL) { /* value is a userdata? */
+ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
+ // lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
+ LuaBindhelper::getMetatable(L, tname);
+ if (lua_rawequal(L, -1, -2)) { /* does it have the correct mt? */
+ lua_settop(L, top);
+ return p;
+ }
+ }
+ }
+
+ lua_settop(L, top);
+ return NULL;
+}
+
+
bool LuaBindhelper::createTable(lua_State *L, const Common::String &tableName) {
const char *partBegin = tableName.c_str();
diff --git a/engines/sword25/script/luabindhelper.h b/engines/sword25/script/luabindhelper.h
index dc45104d53..94f52743f3 100644
--- a/engines/sword25/script/luabindhelper.h
+++ b/engines/sword25/script/luabindhelper.h
@@ -110,6 +110,8 @@ public:
static bool getMetatable(lua_State *L, const Common::String &tableName);
+ static void *my_checkudata(lua_State *L, int ud, const char *tname);
+
private:
static bool createTable(lua_State *L, const Common::String &tableName);
};
diff --git a/engines/sword25/script/luacallback.cpp b/engines/sword25/script/luacallback.cpp
index 137e37bf8d..809676796e 100644
--- a/engines/sword25/script/luacallback.cpp
+++ b/engines/sword25/script/luacallback.cpp
@@ -32,6 +32,8 @@
*
*/
+#include "common/textconsole.h"
+
#include "sword25/script/luacallback.h"
#include "sword25/script/luabindhelper.h"