From e92fa472d46283e219839ce037973a9978a4001a Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Fri, 2 Sep 2022 20:39:26 +0200 Subject: [PATCH 1/6] fix version check to support newer GitHub tag format --- src/main/scala/li/cil/oc/OpenComputers.scala | 2 ++ src/main/scala/li/cil/oc/util/UpdateCheck.scala | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/scala/li/cil/oc/OpenComputers.scala b/src/main/scala/li/cil/oc/OpenComputers.scala index d6e431185..fa57c1138 100644 --- a/src/main/scala/li/cil/oc/OpenComputers.scala +++ b/src/main/scala/li/cil/oc/OpenComputers.scala @@ -21,6 +21,8 @@ object OpenComputers { final val Name = "OpenComputers" + final val McVersion = "1.7.10-forge" + final val Version = "@VERSION@" def log = logger.getOrElse(LogManager.getLogger(Name)) diff --git a/src/main/scala/li/cil/oc/util/UpdateCheck.scala b/src/main/scala/li/cil/oc/util/UpdateCheck.scala index 8d6b1e670..4314470ec 100644 --- a/src/main/scala/li/cil/oc/util/UpdateCheck.scala +++ b/src/main/scala/li/cil/oc/util/UpdateCheck.scala @@ -2,7 +2,6 @@ package li.cil.oc.util import java.io.InputStreamReader import java.net.URL - import com.google.gson.Gson import com.google.gson.stream.JsonReader import cpw.mods.fml.common.Loader @@ -10,6 +9,7 @@ import cpw.mods.fml.common.versioning.ComparableVersion import li.cil.oc.OpenComputers import li.cil.oc.Settings +import java.util.Objects import scala.collection.mutable import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future @@ -32,7 +32,18 @@ object UpdateCheck { while (reader.hasNext) { val release: Release = new Gson().fromJson(reader, classOf[Release]) if (!release.prerelease) { - candidates += release + // Handle the newer version format: mcVersion/release + var versionMatch = true + if (release.tag_name.contains("/")) { + val tagNameParts = release.tag_name.split("/", 2) + if (tagNameParts.length >= 2) { + release.tag_name = tagNameParts(1) + versionMatch = Objects.equals(OpenComputers.McVersion, tagNameParts(0)) + } + } + if (versionMatch) { + candidates += release + } } } reader.endArray() From 3c0ee3c731da5715f42b6143b31322fab072c8a1 Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Fri, 2 Sep 2022 20:55:23 +0200 Subject: [PATCH 2/6] do not allow any domain through if a whitelisted domain fails to resolve - fix #2883 --- src/main/scala/li/cil/oc/Settings.scala | 10 +++++----- .../li/cil/oc/server/component/InternetCard.scala | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/scala/li/cil/oc/Settings.scala b/src/main/scala/li/cil/oc/Settings.scala index f0206da1f..5b4f25f47 100644 --- a/src/main/scala/li/cil/oc/Settings.scala +++ b/src/main/scala/li/cil/oc/Settings.scala @@ -601,25 +601,25 @@ object Settings { val cidrPattern = """(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?:/(\d{1,2}))""".r class AddressValidator(val value: String) { - val validator = try cidrPattern.findFirstIn(value) match { + val validator: (InetAddress, String) => Option[Boolean] = try cidrPattern.findFirstIn(value) match { case Some(cidrPattern(address, prefix)) => val addr = InetAddresses.coerceToInteger(InetAddresses.forString(address)) val mask = 0xFFFFFFFF << (32 - prefix.toInt) val min = addr & mask val max = min | ~mask - (inetAddress: InetAddress, host: String) => inetAddress match { + (inetAddress: InetAddress, host: String) => Some(inetAddress match { case v4: Inet4Address => val numeric = InetAddresses.coerceToInteger(v4) min <= numeric && numeric <= max case _ => true // Can't check IPv6 addresses so we pass them. - } + }) case _ => val address = InetAddress.getByName(value) - (inetAddress: InetAddress, host: String) => host == value || inetAddress == address + (inetAddress: InetAddress, host: String) => Some(host == value || inetAddress == address) } catch { case t: Throwable => OpenComputers.log.warn("Invalid entry in internet blacklist / whitelist: " + value, t) - (inetAddress: InetAddress, host: String) => true + (inetAddress: InetAddress, host: String) => None } def apply(inetAddress: InetAddress, host: String) = validator(inetAddress, host) diff --git a/src/main/scala/li/cil/oc/server/component/InternetCard.scala b/src/main/scala/li/cil/oc/server/component/InternetCard.scala index 5faac807a..3e8dd1fe4 100644 --- a/src/main/scala/li/cil/oc/server/component/InternetCard.scala +++ b/src/main/scala/li/cil/oc/server/component/InternetCard.scala @@ -356,10 +356,10 @@ object InternetCard { } def checkLists(inetAddress: InetAddress, host: String) { - if (Settings.get.httpHostWhitelist.length > 0 && !Settings.get.httpHostWhitelist.exists(_ (inetAddress, host))) { + if (Settings.get.httpHostWhitelist.length > 0 && !Settings.get.httpHostWhitelist.exists(i => i.apply(inetAddress, host).getOrElse(false))) { throw new FileNotFoundException("address is not whitelisted") } - if (Settings.get.httpHostBlacklist.length > 0 && Settings.get.httpHostBlacklist.exists(_ (inetAddress, host))) { + if (Settings.get.httpHostBlacklist.length > 0 && Settings.get.httpHostBlacklist.exists(i => i.apply(inetAddress, host).getOrElse(true))) { throw new FileNotFoundException("address is blacklisted") } } From 7b8172af0f4fa0742649aba76e1c39b051e0509c Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Sat, 3 Sep 2022 16:25:44 +0200 Subject: [PATCH 3/6] cache inflated color entries in PackedColor --- .../scala/li/cil/oc/util/PackedColor.scala | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/scala/li/cil/oc/util/PackedColor.scala b/src/main/scala/li/cil/oc/util/PackedColor.scala index 771498615..1a28d4175 100644 --- a/src/main/scala/li/cil/oc/util/PackedColor.scala +++ b/src/main/scala/li/cil/oc/util/PackedColor.scala @@ -119,6 +119,20 @@ object PackedColor { private val greens = 8 private val blues = 5 + private val staticPalette = new Array[Int](240) + + { + for (index <- staticPalette.indices) { + val idxB = index % blues + val idxG = (index / blues) % greens + val idxR = (index / blues / greens) % reds + val r = (idxR * 0xFF / (reds - 1.0) + 0.5).toInt + val g = (idxG * 0xFF / (greens - 1.0) + 0.5).toInt + val b = (idxB * 0xFF / (blues - 1.0) + 0.5).toInt + staticPalette(index) = (r << rShift32) | (g << gShift32) | (b << bShift32) + } + } + // Initialize palette to grayscale, excluding black and white, because // those are already contained in the normal color cube. for (i <- palette.indices) { @@ -130,16 +144,7 @@ object PackedColor { override def inflate(value: Int) = if (isFromPalette(value)) super.inflate(value) - else { - val index = value - palette.length - val idxB = index % blues - val idxG = (index / blues) % greens - val idxR = (index / blues / greens) % reds - val r = (idxR * 0xFF / (reds - 1.0) + 0.5).toInt - val g = (idxG * 0xFF / (greens - 1.0) + 0.5).toInt - val b = (idxB * 0xFF / (blues - 1.0) + 0.5).toInt - (r << rShift32) | (g << gShift32) | (b << bShift32) - } + else staticPalette((value - palette.length) % 240) override def deflate(value: Color) = { val paletteIndex = super.deflate(value) From 719d2f90d2f6e42475874599d862183a93ae012b Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Sat, 3 Sep 2022 20:47:45 +0200 Subject: [PATCH 4/6] fix artifact name for GitHub Packages --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 09934984c..8ac60e2d6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -rootProject.name = "OpenComputers" \ No newline at end of file +rootProject.name = "opencomputers-1.7.10-forge" From 912d93efb0d84425c896498b8944e7584e3b661d Mon Sep 17 00:00:00 2001 From: payonel Date: Sat, 3 Sep 2022 13:32:09 -0700 Subject: [PATCH 5/6] Revert support for /bin/sh command... as it causes various env issues. will not support #3196 at this time --- .../resources/assets/opencomputers/loot/openos/bin/sh.lua | 2 +- .../assets/opencomputers/loot/openos/lib/core/full_shell.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua b/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua index de7a7b1c4..d4e4dd9db 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/bin/sh.lua @@ -41,5 +41,5 @@ if #args == 0 then end else -- execute command. - return sh.execute(_ENV, ...) + return sh.execute(...) end diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_shell.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_shell.lua index 7c6701715..2576b07ee 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_shell.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/core/full_shell.lua @@ -10,8 +10,8 @@ function shell.execute(command, env, ...) if not sh then return false, reason end - local proc = process.load(sh, env, nil, command) - local result = table.pack(process.internal.continue(proc, command, ...)) + local proc = process.load(sh, nil, nil, command) + local result = table.pack(process.internal.continue(proc, env, command, ...)) if result.n == 0 then return true end return table.unpack(result, 1, result.n) end From 3d2bec9640509c5a907c1193e7202dc47975e9b1 Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Sat, 3 Sep 2022 22:50:58 +0200 Subject: [PATCH 6/6] bump version, update changelog --- build.properties | 2 +- changelog.md | 92 +++---------------- .../loot/openos/lib/core/boot.lua | 2 +- 3 files changed, 13 insertions(+), 83 deletions(-) diff --git a/build.properties b/build.properties index cf1420f9c..f6c7aaed7 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -oc.version=1.7.6 +oc.version=1.7.7 ae2.version=rv2-stable-10 bc.version=7.1.24 diff --git a/changelog.md b/changelog.md index f4646c918..2af5bbac1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,89 +1,19 @@ ## New Features/Support -* Added: Access to waypoint address UUIDs in the Navigation Upgrade. (hohserg1) -* Added: [#779] Graphics Card video RAM system. - - Graphics Cards now have multiple internal video RAM buffers, which can be allocated and freed. - - Reads and writes to Video RAM have zero costs. - - Writing to the text buffer outside of the viewport now has zero costs. -* Added: More complete Unicode support! - - Unscii has been upgraded to version 2.1 (with funscii patches). - - Unifont 14.0.04 can now be used to fill in missing glyphs, thanks to the license change. - - The above mean that OpenComputers now supports the near-complete Unicode Basic Multilingual Plane. -* Added: More Upgrades now have a descriptive tooltip. -* Added: New mod integrations: - - GregTech: Seismic Prospector data reading. (repo-alt) - - Thaumic Energistics: Distillation pattern aspect information. (repo-alt) -* Changed: Block 0.0.0.0/8 from internet card by default. (divergentdave) -* Changed: Game logs now contain the dimension when reporting a machine's position. (D-Cysteine, repo-alt) -* Changed: Make Lua BIOS take use tail call optimisation. (skyem123) -* Changed: [#3440] 'media()' is now implemented on Server disk drives. -* Changed: Motion Sensor now considers both feet and eyes when checking for the visibility of an entity. -* Changed: The default CPU architecture is now Lua 5.3. -* Changed: When creating a new Rack, the "Relay Mode" is now disabled by default. -* Misc: Updated the following translations: - - Chinese (Low-power) - - German (JakobDev) - - Portuguese (guilherme-puida) - - Russian (Fingercomp, Smollet777) -* (1.7.10) Fixed: AE2 filtering by keys which are not always present. -* Fixed: AE2 item stack sizes larger than 2^31-1. -* Fixed: Barcode Reader upgrade crash when scanning anything that is not a valid target. (AmandaCameron) -* Fixed: [#3509] ByteBufInputStream memory leak. -* Fixed: [#3187] Crash with CodeChickenLib and IC2 installed. -* Fixed: [#3247] Disassembler accepted whole stack via direct inventory access. -* Fixed: [#3254] Edge case issues with Hologram copy(). -* Fixed: [#2999, #3225] Edge case issues with deleting computer/robot persistence data. -* (1.12.2) Fixed: Ender IO/Project: Red wrench compatibility. -* Fixed: [#3159] Error when calling 'debug.sendToDebugCard()'. -* Fixed: [#3494] Errors when using block GUIs on larger/negative Y values (f.e. with Cubic Chunks). -* Fixed: [#3391] Generator upgrade destroys fuel containers. -* Fixed: Inconsistent 3D print item stacking (Quant1um). -* Fixed: [#2911] Inconsistent values used by getGameType() and setGameType() in Debug Card. -* (1.12.2) Fixed: [#3472] Incorrect 3D print lighting. -* Fixed: [#3226] Incorrect Hard Drive reported maximum stack size when formatted. -* Fixed: [#3084] Incorrect parsing of the 'maxSignalQueueSize' configuration option. -* Fixed: [#3184] Incorrect redstone card sides inside racks and computers. -* Fixed: [#3182] Incorrect reporting of entity inventory names in Transposer, plus other Transposer interaction issues. -* Fixed: Missing null check for Blood Magic integration. -* Fixed: [#3336] Missing null check for GregTech data stick NBTs. -* Fixed: [#3249] NullPointerException when remote terminal is missing. -* Fixed: Potential edge case crash with the Tank Controller Upgrade. -* Fixed: [#3401] 'rawSetForeground', 'rawSetBackground' not working correctly. -* Fixed: [#3265] Relay 'setStrength' unlimited upper bound. (JamesOrdner) -* (1.7.10) Fixed: [#3540] Server-side crash with Motion Sensor -* Fixed: [#1999] 'string.gsub' patterns now allow numbers. -* Fixed: [#3195] Tier 1 Wireless Cards not receiving messages. -* (1.7.10) Fixed: [#3239] Unnecessary/unwanted canEntityDestroy check in OpenComputers fake player. -* Fixed: Update issues in the Floppy Drive GUI. +* Fixed: Adjusted version check to support the newer GitHub tag format. +* Fixed: [#2883] Allowing any domain through if a whitelisted domain failed to resolve. +* (1.12.2) Fixed: Block/item color regression (introduced in OpenComputers 1.7.6). +* Fixed: [#3547] Character glyph regressions (introduced in OpenComputers 1.7.6). +* Fixed: [#3004] Incorrect damage/metadata values on Cable items. +* (1.12.2) Fixed: [#3546] Incorrect version number reported by mod. +* (1.12.2) Fixed: Reflection call regression (introduced in OpenComputers 1.7.6). +* (1.12.2) Fixed: [#2902] Thread race condition crash when rendering some blocks. ## OpenOS fixes/improvements -* Changed: Added binary support to 'text.internal.reader'. -* Changed: Errors are now passed back to 'shell.execute'. -* Changed: 'install' no longer clobbers '/etc/rc.cfg' nor '/home/.shrc'. -* Changed: If /home is read-only, a helpful message is displayed to tell the user to run 'install'. -* Changed: Removed '-i' from 'cp' alias. -* Changed: [#3320] VT ABCD should move 1 character by default. -* Changed: [#3305] 'wget' now passes a default user agent. -* Fixed: [#3423] Can't yield from an orphan coroutine. -* Fixed: Crash when calling 'tty.setViewport' without arguments. -* Fixed: [#3499] 'edit' crashing once clicking somewhere. -* Fixed: [#3196] Env pass in 'sh' command. -* Fixed: [#3201] 'io.input' implementation inconsistency. -* Fixed: [#1207] I/O buffer reading splitting UTF-8 sequences. -* Fixed: Minor issues in the OpenOS manpage for 'ls'. (avevad) -* Fixed: [#3308] Out of memory error isn't reported in the shell in certain conditions. -* Fixed: Shift+Backspace handling in '/bin/edit'. -* Numerous small improvements to the codebase. +* Fixed: /bin/edit not working on Lua 5.2 (introduced in OpenOS 1.7.6). +* Fixed: Reverted "[#3196] Env pass in 'sh' command." due to a regression. ## List of contributors -payonel, asie, -AmandaCameron, avevad, -D-Cysteine, -divergentdave, hohserg1, -JamesOrdner, repo-alt, -Fingercomp, guilherme-puida, -JakobDev, Low-power, -Quant1um, skyem123, -Smollet777 +payonel, asie diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/core/boot.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/core/boot.lua index 9209b8e32..b223b2e4e 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/core/boot.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/core/boot.lua @@ -1,7 +1,7 @@ -- called from /init.lua local raw_loadfile = ... -_G._OSVERSION = "OpenOS 1.7.6" +_G._OSVERSION = "OpenOS 1.7.7" -- luacheck: globals component computer unicode _OSVERSION local component = component