mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-24 04:50:30 -04:00
Merge branch 'MC1.7' of github.com:MightyPirates/OpenComputers into MC1.7.10
This commit is contained in:
commit
57c98e4b0f
@ -67,7 +67,7 @@ public interface Environment {
|
||||
* it to query it for other nodes. Use this to perform initialization logic,
|
||||
* such as building lists of nodes of a certain type in the network.
|
||||
* <p/>
|
||||
* For example, if node C is added to a network with nodes A and B, these
|
||||
* For example, if node A is added to a network with nodes B and C, these
|
||||
* calls are made:
|
||||
* <ul>
|
||||
* <li>A.onConnect(A)</li>
|
||||
@ -90,7 +90,7 @@ public interface Environment {
|
||||
* Use this to perform clean-up logic such as removing references to the
|
||||
* removed node.
|
||||
* <p/>
|
||||
* For example, if node C is removed from a network with nodes A, B and C,
|
||||
* For example, if node A is removed from a network with nodes A, B and C,
|
||||
* these calls are made:
|
||||
* <ul>
|
||||
* <li>A.onDisconnect(A)</li>
|
||||
|
@ -80,12 +80,19 @@ sandbox = {
|
||||
setmetatable = function(t, mt)
|
||||
local gc = rawget(mt, "__gc")
|
||||
if type(gc) == "function" then
|
||||
-- For all user __gc functions we enforce a much tighter deadline.
|
||||
-- This is because these functions may be called from the main
|
||||
-- thread under certain circumstanced (such as when saving the world),
|
||||
-- which can lead to noticeable lag if the __gc function behaves badly.
|
||||
rawset(mt, "__gc", function(self)
|
||||
local oldDeadline, oldHitDeadline = deadline, hitDeadline
|
||||
local co = coroutine.create(gc)
|
||||
debug.sethook(co, checkDeadline, "", hookInterval)
|
||||
deadline, hitDeadline = math.min(oldDeadline, computer.realTime() + 0.5), true
|
||||
local result, reason = coroutine.resume(co, self)
|
||||
debug.sethook(co)
|
||||
checkDeadline()
|
||||
deadline, hitDeadline = oldDeadline, oldHitDeadline
|
||||
if not result then
|
||||
error(reason, 0)
|
||||
end
|
||||
@ -440,17 +447,18 @@ end
|
||||
|
||||
local libcomponent
|
||||
|
||||
local proxyCache = setmetatable({}, {__mode="v"})
|
||||
local proxyDirectCache = setmetatable({}, {__mode="v"})
|
||||
|
||||
local componentCallback = {
|
||||
__call = function(self, ...)
|
||||
return libcomponent.invoke(self.address, self.name, ...)
|
||||
return invoke(component, not not proxyDirectCache[self], self.address, self.name, ...)
|
||||
end,
|
||||
__tostring = function(self)
|
||||
return libcomponent.doc(self.address, self.name) or "function"
|
||||
end
|
||||
}
|
||||
|
||||
local proxyCache = setmetatable({}, {__mode="v"})
|
||||
|
||||
libcomponent = {
|
||||
doc = function(address, method)
|
||||
checkArg(1, address, "string")
|
||||
@ -500,8 +508,9 @@ libcomponent = {
|
||||
if not methods then
|
||||
return nil, reason
|
||||
end
|
||||
for method in pairs(methods) do
|
||||
for method, direct in pairs(methods) do
|
||||
proxy[method] = setmetatable({address=address,name=method}, componentCallback)
|
||||
proxyDirectCache[proxy[method]] = direct
|
||||
end
|
||||
proxyCache[address] = proxy
|
||||
return proxy
|
||||
|
@ -138,7 +138,7 @@ trait ComponentInventory extends Inventory with network.Environment {
|
||||
def isComponentSlot(slot: Int) = true
|
||||
|
||||
protected def connectItemNode(node: Node) {
|
||||
if (node != null) {
|
||||
if (this.node != null && node != null) {
|
||||
this.node.connect(node)
|
||||
}
|
||||
}
|
||||
|
@ -413,6 +413,9 @@ class NativeLuaArchitecture(val machine: api.machine.Machine) extends Architectu
|
||||
case e: LuaRuntimeException =>
|
||||
OpenComputers.log.warn("Could not persist computer.\n" + e.toString + (if (e.getLuaStackTrace.isEmpty) "" else "\tat " + e.getLuaStackTrace.mkString("\n\tat ")))
|
||||
nbt.removeTag("state")
|
||||
case e: LuaGcMetamethodException =>
|
||||
OpenComputers.log.warning("Could not persist computer.\n" + e.toString)
|
||||
nbt.removeTag("state")
|
||||
}
|
||||
|
||||
// Limit memory again.
|
||||
|
Loading…
x
Reference in New Issue
Block a user