From f24c1ff1706062043933f8ff10d7a81de11adfdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Wed, 27 Aug 2014 19:04:13 +0200 Subject: [PATCH] Switched to extracting the native library into the game directory (instead of the temp directory), configurable. --- src/main/resources/application.conf | 8 ++++++++ src/main/scala/li/cil/oc/OpenComputers.scala | 7 +++++-- src/main/scala/li/cil/oc/Settings.scala | 1 + src/main/scala/li/cil/oc/util/LuaStateFactory.scala | 10 +++++++--- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index b5d0a5fbe..084100644 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -947,5 +947,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 468326ff7..6ec973c0c 100644 --- a/src/main/scala/li/cil/oc/OpenComputers.scala +++ b/src/main/scala/li/cil/oc/OpenComputers.scala @@ -28,7 +28,7 @@ object OpenComputers { final val Fingerprint = "@FINGERPRINT@" - val log = Logger.getLogger("OpenComputers") + var log = Logger.getLogger("OpenComputers") @SidedProxy(clientSide = "li.cil.oc.client.Proxy", serverSide = "li.cil.oc.server.Proxy") var proxy: Proxy = null @@ -39,7 +39,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 73de7fa35..cefd0ba88 100644 --- a/src/main/scala/li/cil/oc/Settings.scala +++ b/src/main/scala/li/cil/oc/Settings.scala @@ -240,6 +240,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 83c9f7dd1..82d4491ca 100644 --- a/src/main/scala/li/cil/oc/util/LuaStateFactory.scala +++ b/src/main/scala/li/cil/oc/util/LuaStateFactory.scala @@ -96,11 +96,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.