From b6dbef709554b9d123d48d5e5b2831f28958ee01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 20 Feb 2015 21:11:28 +0100 Subject: [PATCH 1/6] Wrap external NBT loading with try-catch to avoid corrupting block if external NBT data is corrupt. Closes #926. --- src/main/scala/li/cil/oc/common/SaveHandler.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/scala/li/cil/oc/common/SaveHandler.scala b/src/main/scala/li/cil/oc/common/SaveHandler.scala index b16a850d4..c7fb5b454 100644 --- a/src/main/scala/li/cil/oc/common/SaveHandler.scala +++ b/src/main/scala/li/cil/oc/common/SaveHandler.scala @@ -83,11 +83,16 @@ object SaveHandler { def loadNBT(nbt: NBTTagCompound, name: String): NBTTagCompound = { val data = load(nbt, name) - if (data.length > 0) { + if (data.length > 0) try { val bais = new ByteArrayInputStream(data) val dis = new DataInputStream(bais) CompressedStreamTools.read(dis) } + catch { + case t: Throwable => + OpenComputers.log.warn("There was an error trying to restore a block's state from external data. This indicates that data was somehow corrupted.", t) + new NBTTagCompound() + } else new NBTTagCompound() } From a24d31e1fad84275c452b9293543df833a1138bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 20 Feb 2015 21:11:46 +0100 Subject: [PATCH 2/6] Bump version. --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index 05b250f75..35511b616 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ minecraft.version=1.7.10 forge.version=10.13.2.1236 -oc.version=1.5.0 +oc.version=1.5.1 oc.subversion=dev ae2.version=rv1-stable-1 From e1fe1259890d98210730a4b743472a76fc747736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sat, 21 Feb 2015 16:05:41 +0100 Subject: [PATCH 3/6] Added fix I forgot to backport, fixes broken flight height computation. Closes #927. --- src/main/scala/li/cil/oc/common/event/RobotCommonHandler.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/li/cil/oc/common/event/RobotCommonHandler.scala b/src/main/scala/li/cil/oc/common/event/RobotCommonHandler.scala index 45a077fd2..e0f8771be 100644 --- a/src/main/scala/li/cil/oc/common/event/RobotCommonHandler.scala +++ b/src/main/scala/li/cil/oc/common/event/RobotCommonHandler.scala @@ -31,7 +31,7 @@ object RobotCommonHandler { val maxFlyingHeight = Settings.get.limitFlightHeight def isMovingDown = e.direction == ForgeDirection.DOWN def hasAdjacentBlock(pos: BlockPosition) = ForgeDirection.VALID_DIRECTIONS.exists(side => world.isSideSolid(pos.offset(side), side.getOpposite)) - def isWithinFlyingHeight(pos: BlockPosition) = (1 to maxFlyingHeight).exists(n => !world.isAirBlock(pos.offset(e.direction.getOpposite, n))) + def isWithinFlyingHeight(pos: BlockPosition) = (1 to maxFlyingHeight).exists(n => !world.isAirBlock(pos.offset(ForgeDirection.DOWN, n))) val startPos = BlockPosition(robot) val targetPos = startPos.offset(e.direction) // New movement rules as of 1.5: From 28aeaf4313d2e5734266cd0fe4fb7d5194abbd05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Mon, 23 Feb 2015 14:39:28 +0100 Subject: [PATCH 4/6] Fixed typos / information in manpages, closes #928. --- src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/df | 2 +- .../resources/assets/opencomputers/loot/OpenOS/usr/man/primary | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/df b/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/df index eb8a3b82d..5fc6e477f 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/df +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/df @@ -5,7 +5,7 @@ SYNOPSIS df [FILE]... DESCRIPTION - `cp` allows copying single files on a filesystem and across filesystems. + `df` outputs disk space information for the file systems containing the specified files. If no file names are given it returns the information for all currently mounted file systems. EXAMPLES df diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/primary b/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/primary index 6eedccd42..b868f738a 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/primary +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/usr/man/primary @@ -6,7 +6,7 @@ SYNOPSIS primary TYPE ADDRESS DESCRIPTION - This program allows reading the address of the current primary component of the specified type. It also allows chaning the current primary component for a specified type by providing the (abbreviated) address of the new primary component. + This program allows reading the address of the current primary component of the specified type. It also allows changing the current primary component for a specified type by providing the (abbreviated) address of the new primary component. EXAMPLES primary gpu From e83e572854f988216c6cd0a0f8876e9e0d7d242b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Mon, 23 Feb 2015 15:02:29 +0100 Subject: [PATCH 5/6] Force periodically sending power info if it changed at all to avoid incorrect values being displayed when 100% is hit when charging, e.g., closes #932. --- .../tileentity/traits/PowerInformation.scala | 16 +++++++++++++++- .../scala/li/cil/oc/server/PacketSender.scala | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/PowerInformation.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/PowerInformation.scala index 671032e37..653307475 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/traits/PowerInformation.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/traits/PowerInformation.scala @@ -2,12 +2,15 @@ package li.cil.oc.common.tileentity.traits import cpw.mods.fml.relauncher.Side import cpw.mods.fml.relauncher.SideOnly +import li.cil.oc.Settings import li.cil.oc.server.{PacketSender => ServerPacketSender} import net.minecraft.nbt.NBTTagCompound trait PowerInformation extends TileEntity { private var lastSentRatio = -1.0 + private var ticksUntilSync = 0 + def globalBuffer: Double def globalBuffer_=(value: Double): Unit @@ -18,12 +21,23 @@ trait PowerInformation extends TileEntity { protected def updatePowerInformation() { val ratio = if (globalBufferSize > 0) globalBuffer / globalBufferSize else 0 - if (lastSentRatio < 0 || math.abs(lastSentRatio - ratio) > (5.0 / 100.0)) { + if (shouldSync(ratio) || hasChangedSignificantly(ratio)) { lastSentRatio = ratio ServerPacketSender.sendPowerState(this) } } + private def hasChangedSignificantly(ratio: Double) = lastSentRatio < 0 || math.abs(lastSentRatio - ratio) > (5.0 / 100.0) + + private def shouldSync(ratio: Double) = { + ticksUntilSync -= 1 + if (ticksUntilSync <= 0) { + ticksUntilSync = (100 / Settings.get.tickFrequency).toInt max 1 + lastSentRatio != ratio + } + else false + } + @SideOnly(Side.CLIENT) override def readFromNBTForClient(nbt: NBTTagCompound) { super.readFromNBTForClient(nbt) diff --git a/src/main/scala/li/cil/oc/server/PacketSender.scala b/src/main/scala/li/cil/oc/server/PacketSender.scala index b7981467e..68e1df349 100644 --- a/src/main/scala/li/cil/oc/server/PacketSender.scala +++ b/src/main/scala/li/cil/oc/server/PacketSender.scala @@ -220,7 +220,7 @@ object PacketSender { val pb = new SimplePacketBuilder(PacketType.PowerState) pb.writeTileEntity(t) - pb.writeDouble(t.globalBuffer) + pb.writeDouble(math.round(t.globalBuffer)) pb.writeDouble(t.globalBufferSize) pb.sendToPlayersNearTileEntity(t) From e96348f66581bebe870855019f686f515cfbdb43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Mon, 23 Feb 2015 15:38:50 +0100 Subject: [PATCH 6/6] Added note wrt. tablets in chargers to charger tooltip. --- src/main/resources/assets/opencomputers/lang/de_DE.lang | 2 +- src/main/resources/assets/opencomputers/lang/en_US.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/opencomputers/lang/de_DE.lang b/src/main/resources/assets/opencomputers/lang/de_DE.lang index 7767f84d3..6e3375830 100644 --- a/src/main/resources/assets/opencomputers/lang/de_DE.lang +++ b/src/main/resources/assets/opencomputers/lang/de_DE.lang @@ -195,7 +195,7 @@ oc:tooltip.Cable=Ein billiger Weg, verschiedene Blöcke miteinander zu verbinden oc:tooltip.Capacitor=Speichert Energie für spätere Verwendung. Kann extrem schnell befüllt und entleert werden. oc:tooltip.CardBase=Wie der Name schon sagt, werden alle Erweiterungskarten hieraus hergestellt. oc:tooltip.Case=Das Computergehäuse ist der essentielle Grundbaustein für einen Computer. §fErweiterungskarten§7, §fRAM§7 und §fFestplatten§7 können in einem Gehäuse installiert werden.[nl] Slots: §f%s§7 -oc:tooltip.Charger=Lädt Roboter mit Energie aus Kondensatoren auf. Die Ladegeschwindigkeit hängt vom eingehenden §fRedstonesignal§7 ab, wobei kein Signal "nicht laden" und ein Signal mit maximaler Stärke "schnellstmöglich laden" heißt. +oc:tooltip.Charger=Lädt Roboter mit Energie aus Kondensatoren auf. Die Ladegeschwindigkeit hängt vom eingehenden §fRedstonesignal§7 ab, wobei kein Signal "nicht laden" und ein Signal mit maximaler Stärke "schnellstmöglich laden" heißt. Erlaubt es auch Tablets zu laden, und ermöglicht Zugriff auf Festplatten in Tablets. oc:tooltip.CircuitBoard=Mühsam ernährt sich das Eichhörnchen. Wenn es groß wird, wird es mal eine gedruckte Leiterplatte. oc:tooltip.ControlUnit=Klingt wichtig, ist es auch. Man baut daraus immerhin CPUs. Wie könnte es da nicht wichtig sein. oc:tooltip.ComponentBus=Diese Erweiterung erlaubt es es Servern, mit noch mehr Komponenten gleichzeitig zu kommunizieren, ähnlich wie CPUs.[nl] Supported components: §f%s§7 diff --git a/src/main/resources/assets/opencomputers/lang/en_US.lang b/src/main/resources/assets/opencomputers/lang/en_US.lang index f417561f8..8b1c56259 100644 --- a/src/main/resources/assets/opencomputers/lang/en_US.lang +++ b/src/main/resources/assets/opencomputers/lang/en_US.lang @@ -219,7 +219,7 @@ oc:tooltip.Cable=A cheap way of connecting blocks. oc:tooltip.Capacitor=Stores energy for later use. Can be filled and emptied very quickly. oc:tooltip.CardBase=As the name indicates, this is the basic building block for all expansion cards. oc:tooltip.Case=The Computer Case is the basic building block for computers and houses the computer's §fextension cards§7, §fRAM§7 and §fhard disks§7.[nl] Slots: §f%s§7 -oc:tooltip.Charger=Transfers energy from capacitors into adjacent robots and drones. The transfer rate depends on the incoming §fredstone signal§7, where no signal means don't charge devices, and maximum strength means charge at full speed. +oc:tooltip.Charger=Transfers energy from capacitors into adjacent robots and drones. The transfer rate depends on the incoming §fredstone signal§7, where no signal means don't charge devices, and maximum strength means charge at full speed. Can also be used to charge tablets and access hard drives in tablets. oc:tooltip.CircuitBoard=Now we're getting somewhere. Can be etched to obtain a printed circuit board. oc:tooltip.ControlUnit=This is the unit that... controls... stuff. You need it to build a CPU. So yeah, totally important. oc:tooltip.ComponentBus=This expansion allows servers to communicate with more components at the same time, similar to how CPUs do.[nl] Supported components: §f%s§7