diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 1c8dbc843..1a6ffc0df 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -932,5 +932,13 @@ opencomputers { # Logs information about malformed glyphs (i.e. glyphs that deviate in # width from what wcwidth says). logUnifontErrors: false + + # Extract the native library with Lua into the system's temporary + # directory instead of the game directory (e.g. /tmp on Linux). The + # default is to extract into the game directory, to avoid issues when + # the temporary directory is mounted as noexec (meaning the lib cannot) + # be loaded. There is also less of a chance of conflicts when running + # multiple servers or server and client on the same machine. + nativeInTmpDir: false } } \ No newline at end of file diff --git a/src/main/scala/li/cil/oc/OpenComputers.scala b/src/main/scala/li/cil/oc/OpenComputers.scala index f440730e4..7dda2cdc1 100644 --- a/src/main/scala/li/cil/oc/OpenComputers.scala +++ b/src/main/scala/li/cil/oc/OpenComputers.scala @@ -20,7 +20,7 @@ object OpenComputers { final val Fingerprint = "@FINGERPRINT@" - val log = LogManager.getLogger("OpenComputers") + var log = LogManager.getLogger("OpenComputers") @SidedProxy(clientSide = "li.cil.oc.client.Proxy", serverSide = "li.cil.oc.server.Proxy") var proxy: Proxy = null @@ -33,7 +33,10 @@ object OpenComputers { // def invalidFingerprint(e: FMLFingerprintViolationEvent) = tampered = Some(e) @EventHandler - def preInit(e: FMLPreInitializationEvent) = proxy.preInit(e) + def preInit(e: FMLPreInitializationEvent) { + proxy.preInit(e) + log = e.getModLog + } @EventHandler def init(e: FMLInitializationEvent) = proxy.init(e) diff --git a/src/main/scala/li/cil/oc/Settings.scala b/src/main/scala/li/cil/oc/Settings.scala index c1c025ed9..00c570058 100644 --- a/src/main/scala/li/cil/oc/Settings.scala +++ b/src/main/scala/li/cil/oc/Settings.scala @@ -230,6 +230,7 @@ class Settings(config: Config) { val logUnifontErrors = config.getBoolean("debug.logUnifontErrors") val alwaysTryNative = config.getBoolean("debug.alwaysTryNative") val debugPersistence = config.getBoolean("debug.verbosePersistenceErrors") + val nativeInTmpDir = config.getBoolean("debug.nativeInTmpDir") } object Settings { diff --git a/src/main/scala/li/cil/oc/util/LuaStateFactory.scala b/src/main/scala/li/cil/oc/util/LuaStateFactory.scala index 7fae9d64f..d40cb9b58 100644 --- a/src/main/scala/li/cil/oc/util/LuaStateFactory.scala +++ b/src/main/scala/li/cil/oc/util/LuaStateFactory.scala @@ -95,11 +95,15 @@ object LuaStateFactory { return } - val tmpLibFile = new File({ + val tmpLibName = "OpenComputersMod-" + OpenComputers.Version + "-" + libraryName + val tmpBasePath = if (Settings.get.nativeInTmpDir) { val path = System.getProperty("java.io.tmpdir") - if (path.endsWith("/") || path.endsWith("\\")) path + if (path == null) "" + else if (path.endsWith("/") || path.endsWith("\\")) path else path + "/" - } + "OpenComputersMod-" + OpenComputers.Version + "-" + libraryName) + } + else "" + val tmpLibFile = new File(tmpBasePath + tmpLibName) // If the file, already exists, make sure it's the same we need, if it's // not disable use of the natives.