Another go at fixing that native crash, better luck this time?

This commit is contained in:
Florian Nücke 2014-06-03 20:58:10 +02:00
parent 7cc239ebe3
commit 8642a4a559
5 changed files with 6 additions and 18 deletions

View File

@ -10,7 +10,7 @@ local env = {
MANPATH="/usr/man:.",
PAGER="/bin/more",
PATH="/bin:/usr/bin:/home/bin:.",
PS1="# ",
PS1="$PWD# ",
PWD="/",
SHELL="/bin/sh",
TMP="/tmp", -- Depricated

View File

@ -306,7 +306,9 @@ local userdataWrapper = {
return processResult(table.pack(userdata.call(wrappedUserdata[self], processArguments(...))))
end,
__gc = function(self)
userdata.dispose(wrappedUserdata[self])
local data = wrappedUserdata[self]
wrappedUserdata[self] = nil
userdata.dispose(data)
end,
-- This is the persistence protocol for userdata. Userdata is considered
-- to be 'owned' by Lua, and is saved to an NBT tag. We also get the name
@ -350,7 +352,7 @@ function wrapSingleUserdata(data)
for k, v in pairs(wrappedUserdata) do
-- We need a custom 'equals' check for userdata because metamethods on
-- userdata introduced by JNLua tend to crash the game for some reason.
if userdata.equal(v, data) then
if v == data then
return k
end
end

View File

@ -202,7 +202,7 @@ class Robot(val isRemote: Boolean) extends traits.Computer with traits.PowerInfo
def isAnimatingTurn = animationTicksLeft > 0 && turnAxis != 0
def animateSwing(duration: Double) = {
def animateSwing(duration: Double) = if (items(0).isDefined) {
setAnimateSwing((duration * 20).toInt)
ServerPacketSender.sendRobotAnimateSwing(this)
}

View File

@ -103,14 +103,6 @@ class UserdataAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) {
})
lua.setField(-2, "doc")
lua.pushScalaFunction(lua => {
val value1 = lua.toJavaObjectRaw(1)
val value2 = lua.toJavaObjectRaw(2)
lua.pushBoolean(value1.isInstanceOf[Value] && value2.isInstanceOf[Value] && value1 == value2)
1
})
lua.setField(-2, "equal")
lua.setGlobal("userdata")
}
}

View File

@ -59,12 +59,6 @@ class UserdataAPI(owner: LuaJLuaArchitecture) extends LuaJAPI(owner) {
owner.documentation(() => machine.documentation(value, method))
})
userdata.set("equal", (args: Varargs) => {
val value1 = args.checkuserdata(1, classOf[Value])
val value2 = args.checkuserdata(2, classOf[Value])
LuaValue.valueOf(value1.isInstanceOf[Value] && value2.isInstanceOf[Value] && value1 == value2)
})
lua.set("userdata", userdata)
}
}