mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 03:36:47 -04:00
Added setting for hologram render distance.
Added some settings for easier debugging. Minor refactoring.
This commit is contained in:
parent
fdf0f8f2bc
commit
1eae552aeb
@ -61,6 +61,11 @@ opencomputers {
|
|||||||
# filled chars to appear (i.e. the block symbol that is used for cursor
|
# filled chars to appear (i.e. the block symbol that is used for cursor
|
||||||
# blinking for example) on less accurate hardware.
|
# blinking for example) on less accurate hardware.
|
||||||
fontCharScale: 1.01
|
fontCharScale: 1.01
|
||||||
|
|
||||||
|
# The maximum render distance of a hologram projected by a highest tier
|
||||||
|
# hologram projector when at maximum scale. Render distance is scaled
|
||||||
|
# down with the actual scale of the hologram.
|
||||||
|
hologramRenderDistance: 64
|
||||||
}
|
}
|
||||||
|
|
||||||
# Computer related settings, concerns server performance and security.
|
# Computer related settings, concerns server performance and security.
|
||||||
@ -160,6 +165,18 @@ opencomputers {
|
|||||||
# See also: `canComputersBeOwned`.
|
# See also: `canComputersBeOwned`.
|
||||||
maxUsernameLength: 32
|
maxUsernameLength: 32
|
||||||
|
|
||||||
|
# Whether to delete all contents in the /tmp file system when performing
|
||||||
|
# a 'soft' reboot (i.e. via `computer.shutdown(true)`). The tmpfs will
|
||||||
|
# always be erased when the computer is completely powered off, even if
|
||||||
|
# it crashed. This setting is purely for software-triggered reboots.
|
||||||
|
eraseTmpOnReboot: false
|
||||||
|
|
||||||
|
debug {
|
||||||
|
# Forces the use of the LuaJ fallback instead of the native libraries.
|
||||||
|
# Use this if you have concerns using native libraries or experience
|
||||||
|
# issues with the native library.
|
||||||
|
forceLuaJ: false
|
||||||
|
|
||||||
# This setting is meant for debugging errors that occur in Lua callbacks.
|
# This setting is meant for debugging errors that occur in Lua callbacks.
|
||||||
# Per default, if an error occurs and it has a message set, only the
|
# Per default, if an error occurs and it has a message set, only the
|
||||||
# message is pushed back to Lua, and that's it. If you encounter weird
|
# message is pushed back to Lua, and that's it. If you encounter weird
|
||||||
@ -169,16 +186,22 @@ opencomputers {
|
|||||||
# exceptions such as IllegalArgumentExceptions and the like.
|
# exceptions such as IllegalArgumentExceptions and the like.
|
||||||
logCallbackErrors: false
|
logCallbackErrors: false
|
||||||
|
|
||||||
# Whether to delete all contents in the /tmp file system when performing
|
# Disable user data support. This means any otherwise supported
|
||||||
# a 'soft' reboot (i.e. via `computer.shutdown(true)`). The tmpfs will
|
# userdata (implementing the Value interface) will not be pushed
|
||||||
# always be erased when the computer is completely powered off, even if
|
# to the Lua state.
|
||||||
# it crashed. This setting is purely for software-triggered reboots.
|
disableUserdata: false
|
||||||
eraseTmpOnReboot: false
|
|
||||||
|
|
||||||
# Forces the use of the LuaJ fallback instead of the native libraries.
|
# Disable computer state persistence. This means that computers will
|
||||||
# Use this if you have (unfounded) concerns using native libraries or
|
# automatically be rebooted when loaded after being unloaded, instead
|
||||||
# experience issues with the native library. Also used for debugging.
|
# of resuming with their exection (it also means the state is not even
|
||||||
forceLuaJ: false
|
# saved). Only relevant when using the native library.
|
||||||
|
disablePersistence: false
|
||||||
|
|
||||||
|
# Disable memory limit enforcement. This means Lua states can
|
||||||
|
# theoretically use as much memory as they want. Only relevant when
|
||||||
|
# using the native library.
|
||||||
|
disableMemoryLimit: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Robot related settings, what they may do and general balancing.
|
# Robot related settings, what they may do and general balancing.
|
||||||
|
@ -31,6 +31,7 @@ class Settings(config: Config) {
|
|||||||
val robotLabels = config.getBoolean("client.robotLabels")
|
val robotLabels = config.getBoolean("client.robotLabels")
|
||||||
val soundVolume = config.getDouble("client.soundVolume").toFloat max 0 min 2
|
val soundVolume = config.getDouble("client.soundVolume").toFloat max 0 min 2
|
||||||
val fontCharScale = config.getDouble("client.fontCharScale") max 0.5 min 2
|
val fontCharScale = config.getDouble("client.fontCharScale") max 0.5 min 2
|
||||||
|
val hologramRenderDistance = config.getDouble("client.hologramRenderDistance") max 0
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
// computer
|
// computer
|
||||||
@ -56,10 +57,16 @@ class Settings(config: Config) {
|
|||||||
val maxUsers = config.getInt("computer.maxUsers") max 0
|
val maxUsers = config.getInt("computer.maxUsers") max 0
|
||||||
val maxUsernameLength = config.getInt("computer.maxUsernameLength") max 0
|
val maxUsernameLength = config.getInt("computer.maxUsernameLength") max 0
|
||||||
val allowBytecode = config.getBoolean("computer.allowBytecode")
|
val allowBytecode = config.getBoolean("computer.allowBytecode")
|
||||||
val logLuaCallbackErrors = config.getBoolean("computer.logCallbackErrors")
|
|
||||||
val eraseTmpOnReboot = config.getBoolean("computer.eraseTmpOnReboot")
|
val eraseTmpOnReboot = config.getBoolean("computer.eraseTmpOnReboot")
|
||||||
val forceLuaJ = config.getBoolean("computer.forceLuaJ")
|
|
||||||
val allowUserdata = false // unstable
|
// ----------------------------------------------------------------------- //
|
||||||
|
// computer.debug
|
||||||
|
|
||||||
|
val logLuaCallbackErrors = config.getBoolean("computer.debug.logCallbackErrors")
|
||||||
|
val forceLuaJ = config.getBoolean("computer.debug.forceLuaJ")
|
||||||
|
val allowUserdata = !config.getBoolean("computer.debug.disableUserdata")
|
||||||
|
val allowPersistence = !config.getBoolean("computer.debug.disablePersistence")
|
||||||
|
val limitMemory = !config.getBoolean("computer.debug.disableMemoryLimit")
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
// robot
|
// robot
|
||||||
|
@ -274,6 +274,8 @@ class Hologram(var tier: Int) extends traits.Environment with SidedEnvironment w
|
|||||||
|
|
||||||
override def shouldRenderInPass(pass: Int) = pass == 1
|
override def shouldRenderInPass(pass: Int) = pass == 1
|
||||||
|
|
||||||
|
override def getMaxRenderDistanceSquared = scale / Settings.hologramMaxScaleByTier.max * Settings.get.hologramRenderDistance * Settings.get.hologramRenderDistance
|
||||||
|
|
||||||
override def getRenderBoundingBox = AxisAlignedBB.getAABBPool.getAABB(xCoord + 0.5 - 1.5 * scale, yCoord, zCoord - scale, xCoord + 0.5 + 1.5 * scale, yCoord + 0.25 + 2 * scale, zCoord + 0.5 + 1.5 * scale)
|
override def getRenderBoundingBox = AxisAlignedBB.getAABBPool.getAABB(xCoord + 0.5 - 1.5 * scale, yCoord, zCoord - scale, xCoord + 0.5 + 1.5 * scale, yCoord + 0.25 + 2 * scale, zCoord + 0.5 + 1.5 * scale)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
@ -32,7 +32,7 @@ trait AbstractBusAware extends TileEntity with network.Environment {
|
|||||||
if (isAbstractBusAvailable) {
|
if (isAbstractBusAvailable) {
|
||||||
if (isServer) {
|
if (isServer) {
|
||||||
installedComponents.collect {
|
installedComponents.collect {
|
||||||
case abstractBus: component.AbstractBus => abstractBus.busInterface
|
case abstractBus: component.AbstractBusCard => abstractBus.busInterface
|
||||||
}.toArray
|
}.toArray
|
||||||
}
|
}
|
||||||
else fakeInterface.map(_.asInstanceOf[IBusInterface])
|
else fakeInterface.map(_.asInstanceOf[IBusInterface])
|
||||||
|
@ -9,7 +9,7 @@ import scala.collection.convert.WrapAsScala._
|
|||||||
import stargatetech2.api.StargateTechAPI
|
import stargatetech2.api.StargateTechAPI
|
||||||
import stargatetech2.api.bus._
|
import stargatetech2.api.bus._
|
||||||
|
|
||||||
class AbstractBus(val device: IBusDevice) extends component.ManagedComponent with IBusDriver {
|
class AbstractBusCard(val device: IBusDevice) extends component.ManagedComponent with IBusDriver {
|
||||||
val node = Network.newNode(this, Visibility.Neighbors).
|
val node = Network.newNode(this, Visibility.Neighbors).
|
||||||
withComponent("abstract_bus").
|
withComponent("abstract_bus").
|
||||||
withConnector().
|
withConnector().
|
||||||
@ -70,7 +70,7 @@ class AbstractBus(val device: IBusDevice) extends component.ManagedComponent wit
|
|||||||
result(address)
|
result(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback(doc = """function(address:number, data:table):boolean -- Sends data across the abstract bus.""")
|
@Callback(doc = """function(address:number, data:table):table -- Sends data across the abstract bus.""")
|
||||||
def send(context: Context, args: Arguments): Array[AnyRef] = this.synchronized {
|
def send(context: Context, args: Arguments): Array[AnyRef] = this.synchronized {
|
||||||
val target = args.checkInteger(0) & 0xFFFF
|
val target = args.checkInteger(0) & 0xFFFF
|
||||||
val data = args.checkTable(1)
|
val data = args.checkTable(1)
|
@ -125,7 +125,7 @@ class NativeLuaArchitecture(val machine: api.machine.Machine) extends Architectu
|
|||||||
override def isInitialized = kernelMemory > 0
|
override def isInitialized = kernelMemory > 0
|
||||||
|
|
||||||
override def recomputeMemory() = Option(lua) match {
|
override def recomputeMemory() = Option(lua) match {
|
||||||
case Some(l) =>
|
case Some(l) if Settings.get.limitMemory =>
|
||||||
l.setTotalMemory(Int.MaxValue)
|
l.setTotalMemory(Int.MaxValue)
|
||||||
l.gc(LuaState.GcAction.COLLECT, 0)
|
l.gc(LuaState.GcAction.COLLECT, 0)
|
||||||
if (kernelMemory > 0) {
|
if (kernelMemory > 0) {
|
||||||
@ -241,7 +241,9 @@ class NativeLuaArchitecture(val machine: api.machine.Machine) extends Architectu
|
|||||||
new ExecutionResult.Shutdown(false)
|
new ExecutionResult.Shutdown(false)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (Settings.get.limitMemory) {
|
||||||
lua.setTotalMemory(Int.MaxValue)
|
lua.setTotalMemory(Int.MaxValue)
|
||||||
|
}
|
||||||
val error =
|
val error =
|
||||||
if (lua.isJavaObjectRaw(3)) lua.toJavaObjectRaw(3).toString
|
if (lua.isJavaObjectRaw(3)) lua.toJavaObjectRaw(3).toString
|
||||||
else lua.toString(3)
|
else lua.toString(3)
|
||||||
@ -291,7 +293,9 @@ class NativeLuaArchitecture(val machine: api.machine.Machine) extends Architectu
|
|||||||
|
|
||||||
override def close() {
|
override def close() {
|
||||||
if (lua != null) {
|
if (lua != null) {
|
||||||
|
if (Settings.get.limitMemory) {
|
||||||
lua.setTotalMemory(Integer.MAX_VALUE)
|
lua.setTotalMemory(Integer.MAX_VALUE)
|
||||||
|
}
|
||||||
lua.close()
|
lua.close()
|
||||||
}
|
}
|
||||||
lua = null
|
lua = null
|
||||||
@ -310,7 +314,9 @@ class NativeLuaArchitecture(val machine: api.machine.Machine) extends Architectu
|
|||||||
bootAddress = nbt.getString("bootAddress")
|
bootAddress = nbt.getString("bootAddress")
|
||||||
|
|
||||||
// Unlimit memory use while unpersisting.
|
// Unlimit memory use while unpersisting.
|
||||||
|
if (Settings.get.limitMemory) {
|
||||||
lua.setTotalMemory(Integer.MAX_VALUE)
|
lua.setTotalMemory(Integer.MAX_VALUE)
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Try unpersisting Lua, because that's what all of the rest depends
|
// Try unpersisting Lua, because that's what all of the rest depends
|
||||||
@ -333,7 +339,7 @@ class NativeLuaArchitecture(val machine: api.machine.Machine) extends Architectu
|
|||||||
if (!lua.isThread(1)) {
|
if (!lua.isThread(1)) {
|
||||||
// This shouldn't really happen, but there's a chance it does if
|
// This shouldn't really happen, but there's a chance it does if
|
||||||
// the save was corrupt (maybe someone modified the Lua files).
|
// the save was corrupt (maybe someone modified the Lua files).
|
||||||
throw new IllegalArgumentException("Invalid kernel.")
|
throw new LuaRuntimeException("Invalid kernel.")
|
||||||
}
|
}
|
||||||
if (state.contains(Machine.State.SynchronizedCall) || state.contains(Machine.State.SynchronizedReturn)) {
|
if (state.contains(Machine.State.SynchronizedCall) || state.contains(Machine.State.SynchronizedReturn)) {
|
||||||
val stack =
|
val stack =
|
||||||
@ -343,15 +349,16 @@ class NativeLuaArchitecture(val machine: api.machine.Machine) extends Architectu
|
|||||||
if (!(if (state.contains(Machine.State.SynchronizedCall)) lua.isFunction(2) else lua.isTable(2))) {
|
if (!(if (state.contains(Machine.State.SynchronizedCall)) lua.isFunction(2) else lua.isTable(2))) {
|
||||||
// Same as with the above, should not really happen normally, but
|
// Same as with the above, should not really happen normally, but
|
||||||
// could for the same reasons.
|
// could for the same reasons.
|
||||||
throw new IllegalArgumentException("Invalid stack.")
|
throw new LuaRuntimeException("Invalid stack.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
kernelMemory = (nbt.getInteger("kernelMemory") * ramScale).toInt
|
kernelMemory = (nbt.getInteger("kernelMemory") * ramScale).toInt
|
||||||
} catch {
|
} catch {
|
||||||
case e: LuaRuntimeException =>
|
case e: LuaRuntimeException =>
|
||||||
OpenComputers.log.warning("Could not unpersist computer.\n" + e.toString + "\tat " + e.getLuaStackTrace.mkString("\n\tat "))
|
OpenComputers.log.warning("Could not unpersist computer.\n" + e.toString + (if (e.getLuaStackTrace.isEmpty) "" else "\tat " + e.getLuaStackTrace.mkString("\n\tat ")))
|
||||||
machine.stop()
|
machine.stop()
|
||||||
|
machine.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limit memory again.
|
// Limit memory again.
|
||||||
@ -364,7 +371,9 @@ class NativeLuaArchitecture(val machine: api.machine.Machine) extends Architectu
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unlimit memory while persisting.
|
// Unlimit memory while persisting.
|
||||||
|
if (Settings.get.limitMemory) {
|
||||||
lua.setTotalMemory(Integer.MAX_VALUE)
|
lua.setTotalMemory(Integer.MAX_VALUE)
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Try persisting Lua, because that's what all of the rest depends on.
|
// Try persisting Lua, because that's what all of the rest depends on.
|
||||||
|
@ -99,6 +99,7 @@ class PersistenceAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def persist(index: Int): Array[Byte] = {
|
def persist(index: Int): Array[Byte] = {
|
||||||
|
if (Settings.get.allowPersistence) {
|
||||||
configure()
|
configure()
|
||||||
lua.getGlobal("eris") // ... eris
|
lua.getGlobal("eris") // ... eris
|
||||||
lua.getField(-1, "persist") // ... eris persist
|
lua.getField(-1, "persist") // ... eris persist
|
||||||
@ -120,10 +121,12 @@ class PersistenceAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) {
|
|||||||
} // ... eris :(
|
} // ... eris :(
|
||||||
} // ... eris :(
|
} // ... eris :(
|
||||||
lua.pop(2) // ...
|
lua.pop(2) // ...
|
||||||
|
}
|
||||||
Array[Byte]()
|
Array[Byte]()
|
||||||
}
|
}
|
||||||
|
|
||||||
def unpersist(value: Array[Byte]): Boolean = {
|
def unpersist(value: Array[Byte]): Boolean = {
|
||||||
|
if (Settings.get.allowPersistence) {
|
||||||
configure()
|
configure()
|
||||||
lua.getGlobal("eris") // ... eris
|
lua.getGlobal("eris") // ... eris
|
||||||
lua.getField(-1, "unpersist") // ... eris unpersist
|
lua.getField(-1, "unpersist") // ... eris unpersist
|
||||||
@ -136,6 +139,7 @@ class PersistenceAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) {
|
|||||||
return true
|
return true
|
||||||
} // ... :(
|
} // ... :(
|
||||||
lua.pop(1)
|
lua.pop(1)
|
||||||
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ object AbstractBusCard extends Item {
|
|||||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("abstractBusCard"))
|
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("abstractBusCard"))
|
||||||
|
|
||||||
override def createEnvironment(stack: ItemStack, container: Container) = if (Mods.StargateTech2.isAvailable) container match {
|
override def createEnvironment(stack: ItemStack, container: Container) = if (Mods.StargateTech2.isAvailable) container match {
|
||||||
case device: IBusDevice => new component.AbstractBus(device)
|
case device: IBusDevice => new component.AbstractBusCard(device)
|
||||||
case _ => null
|
case _ => null
|
||||||
}
|
}
|
||||||
else null
|
else null
|
||||||
|
@ -158,7 +158,9 @@ object LuaStateFactory {
|
|||||||
if (!haveNativeLibrary) return None
|
if (!haveNativeLibrary) return None
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val state = new jnlua.LuaState(Int.MaxValue)
|
val state =
|
||||||
|
if (Settings.get.limitMemory) new jnlua.LuaState(Int.MaxValue)
|
||||||
|
else new jnlua.LuaState()
|
||||||
try {
|
try {
|
||||||
// Load all libraries.
|
// Load all libraries.
|
||||||
state.openLib(jnlua.LuaState.Library.BASE)
|
state.openLib(jnlua.LuaState.Library.BASE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user